Render Depth to Texture for Use in DOF and Shadow Mapping

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
TheSamurai
Posts: 1
Joined: Wed Feb 18, 2015 9:32 pm

Render Depth to Texture for Use in DOF and Shadow Mapping

Post by TheSamurai »

I have recently began to use Irrlicht as it is much easier to use than OpenGL by itself but have been unable to implement Rendering depth to a texture. In OpenGL I was able to accomplish this and I have read many forum posts but none have been able give an answer. Currently I am able to render to a texture and then apply a shader to it but I have been unable to render depth to it.

This code creates the texture.

Code: Select all

 
rt = Driver->addRenderTargetTexture(core::dimension2d<u32>(Driver->getScreenSize().Width,Driver->getScreenSize().Height),"RTT1");
 
This code currently draws the scene to the texture.

Code: Select all

        
Driver->setRenderTarget(rt,true,true,video::SColor(0,0,0,0));
Smgr->drawAll();
 
I am looking for any help to provide/point me in the direction of solving this. I believe I am correct in saying that the setup is what needs the changes to get depth.
Any help would be greatly appreciated
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Render Depth to Texture for Use in DOF and Shadow Mappin

Post by hendu »

You render depth by outputting depth in your shader. gl_FragColor = vec4(gl_FragCoord.z)
Post Reply