Archived

This topic is now archived and is closed to further replies.

bakery2k1

Render to texture

Recommended Posts

bakery2k1    712
OK, I''ve now got my projective textures working, so would like to try shadow mapping. This involves first rendering the scene from the lights point of view to a smaller(eg 256x256 viewport), obtaining te depth values for each pixel and using these as a texture. How can I: a) Render my scene so that the depth buffer is automatically rendered to a 256x256 texture? OR: b) -Reduce the viewport size to 256x256 (without changing the window size) AND -Read back depth values from the resulting image? Thanks

Share this post


Link to post
Share on other sites
CrazedGenius    156
nVidia has a sample on their site that does exactly what you''re talking about.

a) Create a 256x256 texture and backbuffer. Set both when rendering your scene.

and

b) Call SetViewport()

See the nVidia sample about the depth buffer. Alternatively, you can use a vertex shader to write derived depth values to the color channel and use that for your shadow map.

Share this post


Link to post
Share on other sites