I’m making 3d model viewer using babylon.js and I want to ensure high quality graphics that runs smoothly even on low end devices. So what I was trying to do was to set shadow map options heavy, then I update whenever I should update. I searched this for a while, and I found there is no method to force update the shadowmap. So I made this code like below.
var shadowGenerator = new …(4096,light);
shadowGenerator.getShadowMap().refreshRate = …RENDER_ONCE;
function update(){
//do things
scene.render();
shadowGenerator.getShadowMap().refreshRate = …RENDER_ONCE;
}
engine.runRenderLoop(update);
function UPDATESHADOWMAP(){
shadowGenerator.getShadowMap().refreshRate = …RENDER_ONEVERYFRAME;
}
And this caused to update shadowmap every frame and doesnt stop updating.
Hi SoHardToNameMyself!
Apologies but I’m not entirely sure what you’re trying to achieve with this? Is it to add meshes to the shadow map when they’re added to your scene?
Ahh, then I’m afraid this is a bit out of my wheelhouse, have you tried both steps in this section? Perhaps the light.autoUpdateExtends property can be changed for the desired effect? Failing that, have you considered using something like Poisson Sampling instead of such a large shadow resolution?
I tested some cases and realized that shadowGenerator.getShadowMap().refreshRate = 0;
didnt worked. even only with render once option, it rendered shadowmap every frame.
And I didnt tell you that light was moving not the object.(if this helps you understanding)
This PG shows the depth map as generated by the shadow generator.
If you click “Render once”, you will see the depth map stops being updated and the last rendered one is used for all subsequent rendering, leading to wrong shadows when the light is rotating.
Click on the other buttons to see a refresh rate of “every frame”, “every 2 frames” and “every 10 frames”.
When you click on “Render once”, the shadow stops moving (the ground is now lit with a static light) but the light is still rotating (you can see this on the sphere).
Click on any other button to make the shadow rotates again.