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:
i set its shadowMin to 0, so it would not clip, its on the demo and its working with the same settings, but its not working on my project. i tried to increase/decrease both of them with no luck
Hi,
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:
i read in the docs that pont lights use a cube map to generate the shadows. it looks like the bottom image of the cube map is not being draw. i may be wrong about that, but i got no other explanation
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