Hi everyone, I’m new for babylonjs. I’m tring the shadow feature, but it seems doesn’t work properly with direction light. I found some answers said GridMaterial doesn’t support shadow, so I use StandardMaterial, the problem is still there. Can anyone tell me how to fix it?
that’s good learning. Obviously, placing a light within an opaque object actually does not cast light outside of it… so this thingy actually does work
Edit: @yarpee Welcome to the Forum (and no pun intended with my comment). Dealing with light and shadows is clearly not just something simple. I struggled my way around it for quite some time I’m pretty sure you’ll get a grasp on it faster than I did
Yes. Indeed. It’s kind of a specificity of BJS. You can see in the properties that the dir light actually has a position (the source). Although, this source does not necessarly have an influence on how the shadow appears. Like if you push the light at 100 position on the y.axis, it’s not gonna change anything. However, there are some other properties you can set, where the position will also take part in the calculation. Using IE contact hardening shadows will calculate a distance from the light to set the min and max Z. So, in the end, it sort of does make sense. It’s also more open and more versatile than what you can find in some other engines. Eventually, you’ll get used to it. Eventually, you’re going to value and leverage this versatility.
Thank you for the warm welcome! I appreciate your understanding. It’s reassuring to know that I’m not alone in finding light and shadows challenging. I’ll do my best to learn quickly!
Yes, @yarpee, you’re right, the directional light is related only to the direction but in your example, the light is INSIDE the opaque sphere so it is not able to create the shadow of the sphere.
@mawa is right, dealing with the lights is not so easy when you’re a newbie…