Extract shadows and light info

Hi,

Straight to the goal: what is the cleanest way to extract shadows and light (maps, separate) from a scene?
I need to process that data in a different environment (to prepare better effect on the current BJS scene).

Thanks!

I’m not sure to understand what you mean by “extracting shadows and light”…

You can get the shadow map by doing yourShadowGenerator.getShadowMap() if that’s what you are after.

Thanks Evgeni,
Do we have something similar for the lights?

:+1: :+1:

Edit: to clarify:
I would like to have the maps on the different mesh where light and shadows hits.

The post process I make is to automatically modulate my lighting to make sure about the ambiance.

So, having grayscales enables me to understand better the lighting structure of my scene.

For shadows:
I can tell immediately, without struggling with mesh colors how I would modify the mesh position for example to have the shadow hit another region (that’s my code).

for lights:
Having a greyscale enables me to modify the post process effect to play with lights effects, while still being correct as far as light rays are involved.
I can derivate the light vectors and add ponderations depending on the importance it has on the mesh and do plenty of stuff with that.

All that happening offline

It seems you want to export the meshes as they are rendered to textures and reuse those textures on other meshes afterwards?

In that case that’s something (baking the rendering into textures) we don’t support in Babylon.js. DCC tools like Blender can do it, however.

Basically what I need is this:

https://en.wikipedia.org/wiki/Shadow_mapping#/media/File:2shadowmap.png

this is from https://en.wikipedia.org/wiki/Shadow_mapping

Back to shadowmap, do you make a projection first or is the mesh grayscale? (Actually, don’t bother to answer that question, I will check this afternoon)

Is my precision welcome Evgeni? :+1:

Yes, so the shadow map is what you need indeed.

It is a rendering of the depth of the meshes from the point of view of the light. It is stored as a linear value between 0 and 1: 0 corresponds to the points closest to the light and 1 to the points furthest away.

1 Like

Thanks Evgeni,

Thanks a lot :fist_right: :fist_left: