[Solved] [1.9] How to bind depth buffer to a shadow texture

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
Flynd
Gnoblar
Posts: 17
Joined: Wed Jan 21, 2015 11:21 am
Location: Strasbourg
Contact:

[Solved] [1.9] How to bind depth buffer to a shadow texture

Post by Flynd »

Hi everyone,
Is there a way to bind the previous depth buffer to a shadow texture ?
For example :
Into a compositor :
1st render pass : classical render scene (depth buffer filled)
2nd render pass : render scene (or render quad) using 1st render's depth buffer bound to a shadow texture (and readable using something like sample2Dshadow through fragment pass)
I wanna use something like this to achieve some depth tests into my shader...
How can I achieve this ?
Thank you for reading (and maybe answering). :wink:
Last edited by Flynd on Mon Jun 01, 2015 9:38 am, edited 1 time in total.
User avatar
Flynd
Gnoblar
Posts: 17
Joined: Wed Jan 21, 2015 11:21 am
Location: Strasbourg
Contact:

Re: [1.9] How to bind depth buffer to a shadow texture

Post by Flynd »

So, there is no way to bind depth buffer to texture in Ogre 1.9 ? Or must I try to call some OpenGL functions ? By the way, I don't really know how to achieve this, between two compositor's renders...
I don't want to have to store depth into a color buffer. :(
Is there any solution for this purpose in Ogre 2.1 ?
Thank you every one !
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [1.9] How to bind depth buffer to a shadow texture

Post by dark_sylinc »

Hi!

In Ogre 1.9 & 2.0:
Can't be done. There is no access to the depth buffer for a lot of reasons, mostly historical and the fact that depth buffers aren't textures but can be treated like one (which puts a lot of subtle problems). There has been discussions; but that's all.
The always-suggested solution was to render to a PF_FLOAT32_R colour render target, and still remains so.

Ogre 2.1
Support for depth buffers was added 2 weeks ago.
The ShadowMapDebugging sample shows how to use them for shadow mapping (just render to an RTT with format PF_D32_FLOAT). I have yet to write a sample that shows how to read an existing depth buffer from an RTT (e.g. read the depth buffer that was used with a deferred renderer's G-Buffer) although the manual in Docs/2.0 folder already does explain how to do it.
I still have to test whether the DepthBufferCopy pass runs ok in OpenGL (which is useful to avoid decompressing depth buffers if you still want to render to a depth buffer)

Cheers
Matias
User avatar
Flynd
Gnoblar
Posts: 17
Joined: Wed Jan 21, 2015 11:21 am
Location: Strasbourg
Contact:

Re: [1.9] How to bind depth buffer to a shadow texture

Post by Flynd »

Hi dark_sylinc,
Thank you for your answer and efforts.
So, for now, I figure I will continue to use PF_FLOAT32_R. :roll:
I will have a look to Ogre 2.1 too...
Post Reply