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).
[EDIT]
Maybe we should have a look at what others do about this (like Unity).
[/EDIT]
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.
Yo @Evgeni_Popov or @sebavan any reason why the projected shadow texture would not render on a plane mesh.
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 ?
Yo @Evgeni_Popov / @sebavan … Did you get a chance to look into why a plane from a gltf vs crating a ground plane via code… The projection texture shadow does not show up on the gltf plane
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 ?
Turns out if you set a new spot light position, that cause the spot light _setPosition override to run which sets _projectionTextureViewLightDirty = true
But if you just update that value, the _setPosition does not run so you gotta manually mark dirty if you manually update the position vector directly. SO that i am only marking it dirty if the that last position is different
Ok @Evgeni_Popov … i got one for you… How would i rotate the spot light and/or its projected texture ?
Can you modify the playground and rotate/spin the projected texture around… since there is no light.rotation.y += 0.1 or something… How would you handle that one ?
because _projectionTextureViewLightDirty is a private property and we make no guarantee that this property will exist forever.
You can use the projectionTextureUpDirection property for that, which is used internally to build the view matrix corresponding to the projection matrix:
The problem is with mipmapping, which is not full white at the lowest level(s) but grey. You can either create the mipmap chain yourself and make sure the lowest level is a white pixel or simply disable mipmapping for the shadow texture:
Hello, don’t mean to raise a dead thread too much - this is the closest thing I could find searching for how to do a ‘fake’/forced shadow. I want to do something like the original request here, or look at old 8 bit games like Tornado Low Level.
Is there a sort of final / most recent concise explanation or example per chance? I am super new to BabylonJS and modern 3D apis unfortunately.
If you want to do the same thing than in TLL, then the easiest way is to simply draw an additional mesh a bit offseted from the main mesh. Else, you can use the latest PG from this thread (https://playground.babylonjs.com/#CQNGRK#512) or even use real shadows.