BlackMojito Posted April 4, 2018 Share Posted April 4, 2018 Hi guys, I have a static scene with fixed meshes and a fixed spot light for shadow mapping. So theoretically I can render the shadow map only once. How can I do it in Babylon? Quote Link to comment Share on other sites More sharing options...
Amarth2Estel Posted April 4, 2018 Share Posted April 4, 2018 Hello BlackMojito ! I copy-paste below a part of : https://doc.babylonjs.com/babylon101/shadows This is a very interesting page where you can find almost all the possibilities about shadows. Freezing shadows in static world In case you have a static game world (objects which cast shadows) - there is no need to do the same shadow calculations 60 times per second. It could be enough to create and place a shadowMap only once. This greatly improves performance, allowing higher values of shadowMap's resolution. Shadow generators can be frozen with: shadowGenerator.getShadowMap().refreshRate = BABYLON.RenderTargetTexture.REFRESHRATE_RENDER_ONCE; Ask the light to not recompute shadow position with: light.autoUpdateExtends = false; Quote Link to comment Share on other sites More sharing options...
BlackMojito Posted April 4, 2018 Author Share Posted April 4, 2018 30 minutes ago, Amarth2Estel said: Hello BlackMojito ! I copy-paste below a part of : https://doc.babylonjs.com/babylon101/shadows This is a very interesting page where you can find almost all the possibilities about shadows. Freezing shadows in static world In case you have a static game world (objects which cast shadows) - there is no need to do the same shadow calculations 60 times per second. It could be enough to create and place a shadowMap only once. This greatly improves performance, allowing higher values of shadowMap's resolution. Shadow generators can be frozen with: shadowGenerator.getShadowMap().refreshRate = BABYLON.RenderTargetTexture.REFRESHRATE_RENDER_ONCE; Ask the light to not recompute shadow position with: light.autoUpdateExtends = false; I tried. But in my case, I can encounter the fact that my meshes/materials are not ready (isReady return false) yet when the first time the shadoow RenderTargetTexture._shouldRender() returns true. And...as you know it will never return true again... Quote Link to comment Share on other sites More sharing options...
BlackMojito Posted April 4, 2018 Author Share Posted April 4, 2018 The case is that my model is downloaded from the server When the mesh creation stuff is completed (added to their parent node, materials assigned, etc.), I get a message. At that moment I create the shadow generator and set the refresh rate to be ONCE. But then I get meshes which are not ready... Quote Link to comment Share on other sites More sharing options...
BlackMojito Posted April 4, 2018 Author Share Posted April 4, 2018 Oh I am sorry, I forgot to call addShadowCaster before the first call of _shouldRender(). Sorry for the noise... GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.