I was thinking we would need a PR to add a new flag on lights to change the mode to only projection this could solve your issues ?
I see… I will make one after I get a better shadow texture with alpha or black for the non shadow parts
Yo @Evgeni_Popov … How is the scene being illuminated. Both the light and the spot light have an intensity = 0. WITHOUT a projectionTexture on the spot light the scene is completely black (Which is expected). But if i add projectionTexture to the one spot light … THE WHOLE SCENE gets illuminated, even if i make the ground 1000 x 1000 meters… the WHOLE GROUND is still illuminated… I would expect only the CONE SHAPE from the spot light should be illuminated on the ground… But it lights up the whole scene… Why is that ?
That’s because I have disabled the cone of the spot altogether: the final diffuse light color is simply the color read from the projection texture, the spot light itself does not come into play. It’s basically like having a simple texture projector, the feature of the spot light is not taken into account.
The spot light has a zero intensity because as explained above it is not used anymore: you can put whatever value you want, it won’t change anything.
The directional light however is used: try to raise the value, you will see things changing. The scene is “illuminated” even without lights because my changes multiply the values from the projection texture by the final diffuse color of the material (the ground texture) and you have some white pixels in your texture around the shadow. So you end up with the ground texture fully lit in those parts. Try to replace the white by black in your texture, you will see you need the directional light to light things up.
Yo @Evgeni_Popov … I made the Shadow Texture have a black background.
But now with the directional light… I dont see gray shadow.
My bad, the directional light is also added to the shadowed part of the terrain, so the surrounding color need to be lighter than the shadow color in the ShadowBlack.png file to see a contrast.
For eg, this will work:
Result when directional light intensity = 0:
Result when directional light intensity = 0.5:
I think there’s a better way to achieve this and closer to what we would do with a real projector which would not use a spot:
This simply sets the spot intensity to 0 and modulates the base color with the projection texture color. For this to work as expected you should use the first picture, the one with a white filling color.
Now do you think we can add this as a switch or boolean or something like a light.projectionTextureMode … So we dont have to hack the lightFragment…
But that looks like we want… to project a shadow without the expense of the shadow map…
This should looks beautiful underneath a car model in a driving game
Let me ask one question about performance… Since i am not using a shadow map on the spot light… How expensive is using the spot with a projection texture vs using an actual shadow map ?
Would it be feasible to put 4 (additional) spot lights with projection textures in a scene. That way i would have one spot light above each car on the track, projecting the fake shadow ?
It is way less expensive to use the projection and I guess it should just work fine with a few of them.
A new mode is definitely the way to go but disabling lighting completely sounds counter intuitive and in this case I think it should be a separate feature.
I guess either we replace the shadow value with the projection and keep it in the light (like a projectionShadowTexture) or if it completely disable lighting maybe we should find smthg else to modulate the output color with the projected shadow.
Yes, I think we should add a new feature here, something like a “projector”, that would simply modulate the baseColor / diffuseColor given a projection matrix and a texture and would be independent from lights: we are limited in the number of lights we can use (even if the limit can be raised). Also, we are not using any of the spot light attribute neither (angle, intensity, …).
In fact there is no shadow value because there is no shadow map (shadow=1 in the fragment code).
Maybe we should have a look at what others do about this (like Unity).
I like the idea of looking around for this one
Or do we wanna create a new class called Projector or something and handle it there ?
We were thinking to first look out how others do and else evaluating the cost in light vs in a new feature.
I did not found anything fully conclusive looking out, so the simplest would be to add new defines in the light code. It could be smthg like a new projectionOnly boolean + another one for projected shadows instead of light.
I simply replaced the create ground from heightmap to just be a simple plane, but the projected shadow does not show up. Is there a property on the mesh that needs to be setup for the projection to show up ?
For PBR materials, it’s
surfaceAlbedo that should be updated, not
Thank you very much
Yo @Evgeni_Popov … Quick question… Does this count against the 4 light max limit ???
Yes, each created light count to the limit. However, you can raise the 4 limit to a higher value (
Yo @Evgeni_Popov … is there something i have to do to refresh it when i move the spot light projector position… That projected shadow on the ground stays the same spot.
Should i be redrawing something when the spot light moves… My intent was to have the projector above a car racing on a track so the the shadow would be projected on to the track while driving ?