Hello guys,
it’s time to continue improving my babylon projects.
Since I want to improve the performance of my scene as much as I can without loosing quality I try to get rid of unnecessary computation. In a recent post I was tought to set the refreshRate of my shadowGenerator to 0. My plan is to change the value to 1 every time the scene is changing.
-
Unfortunately it didn’t work but I found out that the reason was that I set useBlurExponentialShadowMap = true. Why am I not able to render the shadow only once if my shadow is blurred? Is there a more efficient way to create a blurry shadow?
-
Besides that is it possible to render the shadow manually on demand? Right now my approach is to set the refreshRate = 0 and before my scene changes I set the refreshRate = 1. After that again to 0. it would be much more convenient to keep it on 0 and call refreshShadow directly after my scene changed.
-
I try the same thing with autoUpdateExtends for my lights. It’s only necessary to update for the time my scene changes.
Thank you very much for your advise
Best
EDIT:
Okay, I don’t know what the problem was with blurred shadow but it works. My function looks like this:
export async function toggleLightUpdate(props) {
props.lights.forEach(light => light.autoUpdateExtends = props.state)
}
export async function toggleShadowRender(props) {
props.shadowGenerators.forEach(sg => {
sg.getShadowMap().refreshRate = props.state ? 1 : 0
})
}
const updateLightAndShadow = async () => {
await Promise.all([
toggleLightUpdate({ state: true, lights: props.lights }),
toggleShadowRender({ state: true, shadowGenerators: props.shadowGenerators })
])
setTimeout(async () => {
await Promise.all([
toggleLightUpdate({ state: false, lights: props.lights }),
toggleShadowRender({ state: false, shadowGenerators: props.shadowGenerators })
])
}, 10)
}
As you can see I wait 10ms until I set the values to its initial state. Is there a way to specify that in 1 render frame or something? Or what would be the best practice in general?