Depth Buffer to texture
Depth Buffer to texture
I swear this topic came up before, but I searched and can't seem to find it anywhere.
Is there any way to get access to the depth buffer and store it as a texture?
Is there any way to get access to the depth buffer and store it as a texture?
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
You need set render targed (floating point texture eg. ECF_R32F) and write linearized depth. After it, You will have ready depth texture.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
XEffects provides this feature.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Thanks, but right now I'm not interested in using an entire other project simply to get one feature that I need. I'm not trying to disrespect XEffects... it looks great, but I'm compiling on MSVC and I don't want to have to rebuild Irrlicht or become acquainted with a new API for just a singular feature. Could you point me in the direction of help or provide an example of how to do this?
depth texture writing
I def think this is possible with irrlicht. Its not a feature of the engine per-say but you can do it with custom shaders. Im using GLSL and I can share my work-in-progress with you. I don't have it done yet but I'm just sitting down to finish this today. The theory is simple enough, on the first pass you write the depth value to a color channel of a texture buffer and on the second pass you it to restore the depth value.
A quick search picks up this discussion of the topic (with shaders):
http://www.gamedev.net/community/forums ... _id=562668
-P
A quick search picks up this discussion of the topic (with shaders):
http://www.gamedev.net/community/forums ... _id=562668
-P
-
- Posts: 66
- Joined: Sat Sep 29, 2012 11:58 am
Re: Depth Buffer to texture
can any one explain how to Write Depth Values from Shaders to Frame Buffer in irrlicht ?
and Frame Buffer to Texture ? i'm in need for Depth Texture to do Shadow Mapping.
i'v gone through xeffects , as a beginner i could't grasp it.
and Frame Buffer to Texture ? i'm in need for Depth Texture to do Shadow Mapping.
i'v gone through xeffects , as a beginner i could't grasp it.
Re: Depth Buffer to texture
You should go back to XEffects. I know you think shadow mapping is a walk in the park and you are just missing the signpost, but no, it is a serious undertaking.
Set a render target
Render depth values using a light as the camera
Set a render target
Render the scene using the Phong model, but only for pixels that are closest to the light (no intervening object parts)
Repeat for the next light
Blindside has done this for you. I think XEffects does not do the next part in the best way (it drains colour out of the scene instead of adding each light to the scene), but he has got you this far for free. The next part is to somehow combine the render targets you get from rendering per light.
Set a render target
Render depth values using a light as the camera
Set a render target
Render the scene using the Phong model, but only for pixels that are closest to the light (no intervening object parts)
Repeat for the next light
Blindside has done this for you. I think XEffects does not do the next part in the best way (it drains colour out of the scene instead of adding each light to the scene), but he has got you this far for free. The next part is to somehow combine the render targets you get from rendering per light.
Re: Depth Buffer to texture
look up
"binding GL_DEPTH_COMPONENT texture to Frame Buffer" and you can bind the depth buffer as a texture to a GLSL shader
FOR FREE!!!
"binding GL_DEPTH_COMPONENT texture to Frame Buffer" and you can bind the depth buffer as a texture to a GLSL shader
FOR FREE!!!
Re: Depth Buffer to texture
Ha-ha. I see you are itching for a fight.
I'll just say that, in this context, it really doesn't save much work. Besides, Blindside has written *working* code, which is always of enormous help in shader work.
Have you thought of contributing to Irrlicht 2.0? I would have thought you'd have a lot to offer.
I'll just say that, in this context, it really doesn't save much work. Besides, Blindside has written *working* code, which is always of enormous help in shader work.
Have you thought of contributing to Irrlicht 2.0? I would have thought you'd have a lot to offer.
-
- Posts: 66
- Joined: Sat Sep 29, 2012 11:58 am
Re: Depth Buffer to texture
But devsh how can i use openGL codes like "GL DEPTH COMPONENT" etc in irrlicht ?
Presently i can see my Scene's Black And White image(depth values)through shader's 1st pass. But dono how to save Depth Values in the Buffer and get it as a texture for 2nd pass.
Presently i can see my Scene's Black And White image(depth values)through shader's 1st pass. But dono how to save Depth Values in the Buffer and get it as a texture for 2nd pass.
Re: Depth Buffer to texture
need to edit COpenGLTexture.cpp
depthFBO attachment cannot be render buffer, needs to be a texture
you attach color buffers (MRTs) and an optional depth buffer to a FBO which is the thing that you set render targets with
native OpenGL reading is required here
you need to modify the driver so you can setTexture(i,depthFBOattachment) properly
depthFBO attachment cannot be render buffer, needs to be a texture
you attach color buffers (MRTs) and an optional depth buffer to a FBO which is the thing that you set render targets with
native OpenGL reading is required here
you need to modify the driver so you can setTexture(i,depthFBOattachment) properly