Author Topic: Shadows and Depth Buffers  (Read 290 times)

Devansh Gupta   «   on: August 14, 2012, 02:12:53 PM »
Hi,

I am trying to create a shadow map for my scene. I have tried a lot to find how to create and render to a depth buffer. Can anyone tell me how to access and render to the depth buffer or generally how can we shadow maps?

Thanks,
Devansh

Jonas Volger   «   Reply #1 on: August 19, 2012, 06:49:48 AM »
Hey you,

actually I am not sure if it is possible with Stage3D to render the depth buffer directly. I briefly searched for it myself, but didnt come up with any answers. Maybe Jason Huang can help you with it. He already did this.
But there is a workaround that may help you. You can write a simple shader, which calculates the distance between the camera and the fragment(pixel) and outputs this as a grey value. This shader must be applied to all objects in the scene.
Now you would have to find a way to somehow "assign" this material to a second camera. I dont know if it is possible to render the scene with two cameras with different materials on the objects.
But if its possible you could render that camera to texture and - voila! - you have your shadow map ;)
Hope this helps.

Regards