Hi, Sebastian

You can setup blend func in a way that will keep old rgb values and replace 
alpha with new value.
for second pass -> BlendFunc(osg::BlendFunc::ZERO, osg::BlendFunc::ONE, 
osg::BlendFunc::ONE, osg::BlendFunc::ZERO).
However if you reading from same texture attached to camera output this is not 
gonna work, unless you use NV_texture_barrier extension (and it have 
limitations too).

Cheers

22.09.2011, 11:46, "Sebastian Messerschmidt" <[email protected]>:
> Thanks to all replies but I was able to figure it out.
>
> My initial idea was to modify a color attachment created in the first
> pass in the second pass only where fragments were created(i.e. depth was
> written)
> I came up with the following solution:
>
> 1. Pass
> RTT-Cam1
>      - DEPTH, COLOR1, COLOR2, ...
>      - renders the scene
> 2. Pass
> RTT-Cam2
>      - DEPTH, COLOR1 (same attachments as in the first pass
>      - depth test to GREATER
>      - depth writes off
>      - disable color and depth clearing (which we want to reuse)
>      - bind the COLOR1-texture as uniform input
>      - render a full screen quad with camera in ABSOLUTE_RF and same
> viewport as first pass
>      - in the frag shader for instance do: gl_FragData[0]=
> vec4(texture2D(firstPassTexture,gl_TexCoord[0].st).rgb, 0.0)  +
> vec4(0.0,0.0,0.0, myNewTerm);
>
> This works, because the fullscreen quad rendered will pass depth test
> only if something was written there in the first pass. Using this sceme
> saves us a stencil test.
>
> There is a remaining question however:
> What I really wanted to do is to write the gl_FragData[0].rgb in the
> first and gl_FragData[0].a in the second pass.
> This gave me a blank result (with the alpha component set to 1)
> Do I have to enable blending or something? Or is it illegal to write
> uncomplete FragData?
>
>>  Hello,
>>
>>  I've have a question regarding RenderToTexture in a multipass setup.
>>  I have to RTT cameras, the first one has DEPTH and 3 color
>>  attachments, while the second has only one color attachment.
>>  I need to use the data from the first RTT-pass in the second camera,
>>  so the renderorder is set accordingly.
>>
>>  Basically my scene is organized like this:
>>
>>  root
>>      |
>>      RTTCamera_1
>>      |    |----Model
>>      RTTCamera_2
>>      |    |----Model
>>
>>  Booth cameras use the same geometry, viewport, transform. Yet the
>>  Model graph is culled twice.
>>  Is there any way to prevent the second cull traversal? I.e. reuse the
>>  batch collected in the first culling?
>>
>>  cheers
>>  Sebastian
>>  _______________________________________________
>>  osg-users mailing list
>>  [email protected]
>>  http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to