Horde3D

Next-Generation Graphics Engine
It is currently 14.05.2024, 20:23

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: 04.08.2008, 11:39 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
I'm trying to write a real-time glow shader (based on the forward pipeline).

After the geometry stage, I've added a new stage that renders out the glow geometry to a render-target (which will be blurred and then added to the main target buffer).

My problem is that I need to preserve the depth buffer from the geometry stage, so that glow geometry isn't drawn in places where it should be hidden. I haven't looked at the code yet, but it seems that if my temporary glow RenderTarget has depthBuf set to true, then it will use it's own depth buffer, and if it is set to false then it won't use any depth buffer.
Is this correct? And is there a way to use the main depth buffer when rendering to my RenderTarget?
Or perhaps it is sharing the depth buffer, but I require a way to set the depth test to "less or equal" instead of just "less"?


Top
 Profile  
Reply with quote  
PostPosted: 04.08.2008, 15:45 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
I wanted to to do the same for my atmosphere shaders, so I have been experimenting a bit. At this point, I am not sure it is actually possible using OpenGL. I was able to share a depth texture between 2 FBOs, but I wasn't able to use the main depth buffer with an FBO. Perhaps someone more familiar with the FBO extension can give us some suggestions.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 05.08.2008, 01:15 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
Thanks for the info swift.

The only reason I want to keep the depth buffer is so that I only have to render "glow geometry" in the second stage.

...but I could easily change things so that non-glowing geometry also gets rendered in this stage and simply outputs black pixels. I guess I'll go with that for now.


Top
 Profile  
Reply with quote  
PostPosted: 05.08.2008, 21:04 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
DarkAngel wrote:
My problem is that I need to preserve the depth buffer from the geometry stage, so that glow geometry isn't drawn in places where it should be hidden. I haven't looked at the code yet, but it seems that if my temporary glow RenderTarget has depthBuf set to true, then it will use it's own depth buffer, and if it is set to false then it won't use any depth buffer.
Is this correct? And is there a way to use the main depth buffer when rendering to my RenderTarget?

Funnily I was thinking about a similar issue very recently. It would make sense in several scenarios to share a depth buffer between render targets. Currently that is not possible with the pipelines. From GL side I also don't think that it works to share the main framebuffer depth data with a FBO. But as swift states it should be possible to share depth attachments between several FBOs. We just would need a nice way of exposing that feature to the pipeline (call for proposals :) )

A workaround for your problem could be to bind the depth texture of your temporary render target and draw a fullscreen quad to the main buffer that copies over the depth values by setting gl_FragDepth in a very small fragment shader.


Top
 Profile  
Reply with quote  
PostPosted: 06.08.2008, 07:48 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
Yes, it seems the spec says that when an FBO is bound, you can't access the default depth-buffer.
Quote:
Additionally, when rendering to or reading from an application
created-framebuffer object,
...
- The only depth buffer bitplanes are the ones defined by the
framebuffer attachment point DEPTH_ATTACHMENT_EXT.


I'll have a think about the nicest way to share depth attachments between RenderTargets. Perhaps we could implement a generic technique so that colour attachments could be shared as well?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group