Hey! I’ve been struggling with a problem: I’m trying to get cubes to cast shadows on each other. However, when I enable ‘cube.receiveShadows’, they not only shadow each other but also themselves in an unrealistic way. The cubes become overly dark and their edges look odd. I can’t figure out how to fix this. Could you please offer some advice?
Here’s an example: https://playground.babylonjs.com/#ICTTIY#1
To be honest, I don’t see self-shadowing in your PG. In any case, may be you want to try the contact hardening shadow option which I found is sometimes a good way to cast shadow on objects and self.
The set-up might be a bit tricky since its depending on the min and max. So, when objects have very different sizes, it’s not always the best option. It also requires quite a bit of fiddling with the bias and normal bias to set it up to your liking. Thought I would share anyways… might give you some ideas, hopefully Else, have a great sunday
Wow, I wasn’t expecting such a quick answer! Sundays with Babylon are always great .
By saying ‘self-shadowing,’ I meant that the cubes became dark after adding ‘.useBlurExponentialShadowMap’ It looked as though each cube was shadowed by its own shape. Changing the bias did nothing.
Good idea with the contact hardening shadow! It looks great, yet it’s slow and, as you said, tricky.
Another possibility is using Poisson Sampling (https://playground.babylonjs.com/#ICTTIY#3). It doesn’t make the cubes dark, but it also doesn’t look as good as the Blur Exponential Shadow Map. So if possible, I would use it as it makes nicely blurred shadows. Do you guys have any other ideas about what’s wrong with ‘.useBlurExponentialShadowMap’?
There’s nothing ‘wrong’ with it. The sampling and blur work ‘as expected’. The point is, the smaller the scale, the trickier it is to put in the right numbers (for the bias and normal bias). The scaling of the scene and setting the directional light higher from the scene (scaling up everything) can help. Else, you might sometimes want to play with a lot of decimals (and yes, it’s a pain).
I’ve spent some time adjusting the decimals, which only softened the dark areas, but the they still appear incorrect/ unrealistic. Achieving nicely looking results requires probably even more tweaking than I’m capable of rn.
Just discovered another workaround/ alternative solution: switching to ‘usePercentageCloserFiltering’. From what I understand, it’s a WebGL2 solution. It actually looks really good.
I’ll stick with it or with the contact hardening shadows. Thanks for your help! <3
yes, this filtering method is also the one I tend the use. But then, the filtering method only changes the aspect of the shadow; It also eventually makes the shadow lighter or darker but this is just a ‘side-effect’ from the rendering method. In essence, the type of shadow and its darkness is defined through the other parameters. And I agree that achieving shadows the way you want them in your scene can be very time consuming