[osg-users] depth and stencil buffers in multi-pass rtt

147 views
Skip to first unread message

Brian ...

unread,
Jan 9, 2011, 6:02:24 PM1/9/11
to OpenSceneGraph Users
folks,

i'm trying to create 2 render to texture cameras that share the same depth and stencil buffer.

i want to render color, depth, and stencil values with the first rtt camera and then use the resulting depth and stencil with the second rtt camera.

this is what i'm doing:

create color texture1
create depth texture
create stencil texture

create rtt camera 1
attach color texture 1
attach depth texture
attach stencil texture

create color texture2

create rtt camera 2
attach color texture 2
attach depth texture
attach stencil texture

here's the scene graph

root
        rtt camera 1
                scene group 1
        rtt camera 2
                scene group 2

the color, depth, and stencil textures look ok coming out of camera 1, but the depth and stencil textures after camera 2 are blank (all zero).

is this the right way to do this?

thanks,

brian

J.P. Delport

unread,
Jan 10, 2011, 2:05:35 AM1/10/11
to OpenSceneGraph Users
Hi,

what is your clearmask set to for the 2nd camera? Are the projections
the same for the 2 cameras? How about depth range?

Only other thing I can recommend is have a look at
osgUtil/RenderStage.cpp and check for search for "depthAttached". You'll
find the code and osg bitmasks you can set for controlling depth/stencil
for FBO.

jp

> _______________________________________________
> osg-users mailing list
> osg-...@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

--
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard.
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner,
and is believed to be clean. MailScanner thanks Transtec Computers for their support.

_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Brian R Hill

unread,
Jan 10, 2011, 11:09:58 AM1/10/11
to OpenSceneGraph Users, OpenSceneGraph Users
jp,

thanks for responding. i haven't tried this before so my initial concern was that this was the correct approach. i'm assuming from your response that it should work but that i'm missing some detail. i'll start digging deeper to see if i can figure out what i'm doing wrong.

clear masks
rtt camera 1 is color, depth, stencil
rtt camera 2 is color only

projections
both cameras have the same projection

depth range
not doing anything with depth range

i'll look through the renderstage code.

brian

This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery.
NOTE: Regardless of content, this e-mail shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose.
-----osg-user...@lists.openscenegraph.org wrote: -----

To: OpenSceneGraph Users <osg-...@lists.openscenegraph.org>
From: "J.P. Delport" <jpde...@csir.co.za>
Sent by: osg-user...@lists.openscenegraph.org
Date: 01/10/2011 02:05AM
Subject: Re: [osg-users] depth and stencil buffers in multi-pass rtt

J.P. Delport

unread,
Jan 12, 2011, 2:13:49 AM1/12/11
to OpenSceneGraph Users
Hi,

On 10/01/11 18:09, Brian R Hill wrote:
> jp,
>
> thanks for responding. i haven't tried this before so my initial
> concern was that this was the correct approach. i'm assuming from
> your response that it should work but that i'm missing some detail.
> i'll start digging deeper to see if i can figure out what i'm doing
> wrong.

I think it should work :)

>
> clear masks rtt camera 1 is color, depth, stencil rtt camera 2 is
> color only
>
> projections both cameras have the same projection
>
> depth range not doing anything with depth range

A problem can occur where OSG auto computes the depth range (near/far)
for your 2 cameras and it differs. Then it obviously does not make sense
to reuse the depth buffer, because the depth range would not match.

See this thread:
http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/63891
It's not RTT but also uses multiple cameras.

jp

Reply all
Reply to author
Forward
0 new messages