Jump to content

How can I render the shadow mapping texture only once?


BlackMojito
 Share

Recommended Posts

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;
Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...