Extract ShadowMap values

I looking to extract shadow map values of a scene using directional Light. I have a scene of couple of objects ( let say 2-3 polygons placed on a plane). When using directional light shadows are created on the ground (plane) as well as on the object. Now I need a way to extract the shadowMap values (could be an array of values denoting each pixel value: i guess) for certain use case.

Is there any possible way to do this? or is it something that happens at core webgl level which is not extractable?

If by sampling, you mean reading pixel values of the shadow map in JS / on the CPU - DirectionalLight.shadow.map.texture may be what you’re looking for :thinking: ?

I have checked this, but couldn’t find a way to get the values out of it.
Could help me out here?
Thanks!

https://threejs.org/docs/#api/en/renderers/WebGLRenderer.readRenderTargetPixels

2 Likes

yes this works, but there is one issue I’m facing. This returns me the pixel value of the entire scene. I want to get the value for a certain section, all the pixel value in the scene ie contained in the bounding box of the plane (ground). I tried to play around with the camera and renderer, but not able to find a solution.