hey guts, got another shadow problem
when using point light with a shadowGenerator, the bottom part of the shadow is not being cast. it looks like the bottom part of the cube map is not being set, or something like that
it looks like there is a invisible plane on the bottom like the image:
Did you check on the values you have in your demo compared to the PG?
Is your ground at zero? Your light further or closer to the mesh (torus in PG)?
Here is a rough repro of your ‘bug’. This is what I can get when I set a ‘wrong’ maxZ and minZ not accounting correctly the height of the mesh, position of the ground and/or light.
incorrect. You would need to decrease one and increase the other depending on your light position. Also I would advise to use directional light to cast shadows since point light casts lights in all directions.
the values are exactly the same as the PG i sent
its the same code, just the scene creation that is being created somewhere else
trying to figure out whats happening
but its not the minZ and maxZ
tried a lot of different combinations, with no success
Do you also have this torus with the same size? Isn’t it another mesh and size?
Did you try change it to a directional light and set a direction? Are you sure you don’t have any other code that could explain this? or another light source? another ground? Did you try with my version to see if you get the same result?
in my project i have enabled gizmos to move it aorund, it looks like there’s a ‘‘box’’ on the bottom of the light, that prevent the shadows being cast, but there is no other mesh in the scene, and no other object being sent to the shadow generator
if i put the light closer to the torus, so it would completely cover the ground with shadows, you can see that there is a empty square:
its exactly the code in the demo. no change in the meshes, positions or sizes
this only happens with spot light. i’m trying to find the code that is causing this, but its a complex project, and I have no idea of may cause this. i’m trying to remove everything from the project to see if i can find the answer, but so far no luck.
it doesn’t have any other light source. i tried with other lights in the scene too, but got the same results
with your version i got no shadow at all. thats because that ‘‘invisible block’’ ins completly on the way of the shadow:
Well, as I told you, a point light is not really the best to cast and master shadows. Using a directional light, you can cast shadows even from below the ground (so you would have no light from this light, just the shadow) and it should make it through your box you mentioned or whatever it is. With a directional light, it really is a matter of correctly setting the limits calculated from the light position and all through the size of the mesh you want to use as a shadow caster. To be honest, it’s hard for me to tell you more without a repro. But using a point light placed at origin zero, while the ground is at zero doesn’t sound like a good idea to me. In fact, I don’t even know why it seems to work in the PG!!!
Edit: Just opened your PG again and checked the nodes. Can you tell me what’s this name you have given to the light for (“this.name”)? Depending on how you would use that in your script, this can certainly create issues.
Together with the topic-starter we figured out what is the matter.
With the help of Spector.js comparing what we have in our app and in the PG we found out that the shadow cubemap view matrix for -Y and +Y was wrong. That was because we overrode the Vector3.normalizeFromLength method to prevent some floating point errors. That caused the wrong values in these 2 view matrices.
Further investigation has show that in BJS there is a hack in the shadowGenerator.ts module to avoid lights perfectly perpendicual to the UP vector. I think that is not exactly correct and different UP vectors should be used for -Y, +Y cube shadow sides.
Thanks for sharing. No way we could have detected that from the above reading, I’m afraid.
Will transmit to the people taking care of this part with their hard and dedicated work @Evgeni_Popov but I feel that calling this a ‘hack’ straight out like that feels a bit ‘rough’ (personal opinion, if I can allow myself). I’m pretty sure there’s a reason for it. In any case, we sure do appreciate to receive such detailed and expert feedback so thanks for that already.
Else, I’m glad yours found the solution to your problem and I shall wish you Both a great day
Sorry if that sounds rude. No offense meant of course . I consider realtime 3D graphics to be one big hack in general. We can call it a trick or whatever but it can be made safer I believe.
I’m speaking about this part specifically:
Yes, please do that and forgive me for saying your intervention was a bit ‘rude’. Point is with this messaging thing, you cannot see about how people ‘feel’. Also, I agree that 3D is ‘a hack’. Actually I often use this term even for when I see something in code that is simply not consistent with the structure.
If your solution is the one or even part of it or any good to consider, trust me when I say that it will be considered here and next implemented. And we shall thank you for your time and contribution Meanwhile, have a great day