Jump to content

Does each instance of a ShadowGenerator create a new Shadow Map?


Dinkelborg
 Share

Recommended Posts

Hi,
I am momentarily writing a report about BabylonJS and as I was analysing my scene I came up with the question
if any new instance of a ShadowGenerator would also create a new Texture for its shadow map ...

I guess (soly based on the constructor parameters) that each ShadowGenerator creates a Texture of the size specified in the constructor parameter and that the renderer (or a post processing entity) will combine all those shadow maps at the end.

Is that true or does it work in another fashion?

Thanks for the answers in advance,

Dinkelborg

Link to comment
Share on other sites

Oh and if somebody who can answer this question would be here already, I just came up with another question about the inner functionality of the prefab-objects:

If I change the "scaling" attribute of a cube, will this cause the cube to be scaled every frame as it would be in other frameworks or is there some internal optimisation for this?
Since in the constructor for a box for example there is only one size attribute, I assume that it internally generates a geometry object which is equilateral.

The only way I see to control the boxes outer appearance then is to change its scaling, in other frameworks this is something you normally want to avoid for performance reasons, and therefore you will rather create a new geometry for your mesh and change the appearance for that (because then the box will not be scaled every frame...)

Link to comment
Share on other sites

Hey,

 

this is perfectly true: each shadowgenerator generates a shadow map per light that standardmaterial uses to render meshes

 

Changing scaling, position or rotation change the worldMatrix of the mesh. This matrix is computed only when required. THere is a huge optimisation around matrices in order to reduce required computations per mesh. So once the scaling is change, it will trigger a worldMatrix update. during rendering the worldMatrix is then send to the shader and won't be update then

 

on every frame, the mesh is rendered using a shader with the given worldmatrix and because everything remains unchanged this is pretty well optimized :)

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