Hello there I am experiencing weird problem with mesh that casts and also recieves shadows.
It is “humanoid orc” mesh without any special shapes.
When it casts shadows, it somehow casts it onto itself even on the side that points to the source of light and it seems somehow buggy :-/ Some ideas how to solve it ?
Note: Source of light is above head of “my character”, I have tried lot of diferent shadow caster settings but none seems to be working.
I can achieve best results when I turn “recieve shadows” to false - then orcs are lit nicely and they still cast shadow onto the ground. They are just not shadowed by corners of walls but it is still relatively ok. I can live with that but it still seems to be weird.
When shadow casting is on - shadow is nicely casted to the ground but mesh itself is almost not enlighted.
When shadow casting is off, mesh is lit by “my character” as it is meant to be
Hello, I believe that you mean “decrease bias” right ? Because the lower the number is, the lower bias is. I have tried to set the value to “0” and it remains the same My shadow generator is set like this
this.shadow = new BABYLON.ShadowGenerator(1024, this.light);
this.shadow.bias = 0;
this.shadow.setDarkness(0.25);
Ohh my gosh, I need talk to text. There is too much to explain with one hand to explain what’s going on and some fixes. If nobody helps by tomorrow, ill see if I can.
Thanx for some insight ! Sadly it only helps in this simple playground scene. In real application when I set bias high enough to prevent self-shadowing, then it corrupts shadows from another objects and vice-versa. There seems to be no exact bias value that would work for all objects at all distances. I have tried another options from shadow troubleshooting section but none seems to help.
I would love to have possibility to just somehow prevent mesh from self-shadowing at all (but still being shadowed by another meshes). Curently the best option for me is not to recieve shadows at smaller objects.
I could theoretically create several shadowGeneratos with different biases and somehow move objects between them but I am afraid that it would have tremendous impact on performance and probably I would not be able to guess correct bias value at all.
But your plane is quite big compared to the mesh (decreasing its size will improve the shadows), so it’s hard to get a detailed shadow map in these conditions (you can also raise the shadow generator size).
New shadow technics are planned for 4.2, I think, which will help in this case.
i think you need use ambient light + directiona llight + IBL with PBR material but i dont know about performance of this combination
In any case, stage lighting is never limited to a single light source, since in reality there is always reflected light called global lighting, and if we cannot calculate it directly, we need to simulate it using ambient lighting and environmental maps, for example. In reality, objects almost never happen without reflections, so something needs to be reflected from the material, and this is an environment map. otherwise you will get a picture with dark shadows and cognitive dissonance if you are trying to achieve some kind of photorealism.
and final solution https://playground.babylonjs.com/#MCNF1Y#7
self shadows, cast and recive shadows work fine with scene IBL and direct light.
if you try off scene IBL you get dark self shadows so use scene IBL and be happy)
Hello I have tried really hard to find correct shadow settings but always something was wrong.
I need actually 3 things to be shadowCasters:
My own character
Monsters
Cave walls
I couldnot find setting that works for all 3 so I tried to think a little bit outside of the box and I came up with possible solution, but I am afraid of performance issues.
What about split that 1 light into 3 lights ?
Light will only enlight monsters and create their shadows
Light will only enlight my own character and create my shadow
Light will enlight everything (except monsters and my own character) and create shadow for cave walls.
What do you think about it ? I am afraid that 2 more lights will have tremendous performance impact, on the other hand they will all enlight different objects (not 2 lights will lit the same object) and also each light will cause shadows for one object - theoretically it will create the same set of enlighted and shadowed objects as one light - but still it will be 3.
What would you think about it ? As a side effect it will allow me to controll each light separately (different position and ranges) whis is also benefical. And I believe that this way I will be able to find correct shadow setting for each light.
try cascade shadow map Cascaded Shadow Maps (CSM) are now in! or documentation says for large scenes use closeBlurExponental type of shadows and in any way you need directional light