Discussion:
[Opensg-users] Stage access depth buffer to texture
Victor Haefner
2016-02-04 09:47:48 UTC
Permalink
Hi all,

I am trying to do metaballs with shaders:

- SimpleStage - Geometry (point cloud)
- Geometry (fullscreen quad)

I setup my stage as in the fbo example with the flag
Then I add a geometry with my points (SPH simulation)
I then set the result from the stage as texture of a quad which spans the
whole screen
My problem now is that the result is allwas on top of everything.
I tried to pass FragCoord.z through the texture but I need to use alpha
blending for my points,
wich screws up the Fragcoord.

Is there another way to pass the depth information from the stage rendering?
I tried:

dfboImg = Image::create();
dfboImg->set(Image::OSG_L_PF, 512, 512);
dfboTex = TextureObjChunk::create();
dfboTex->setImage(dfboImg);
TextureBufferRefPtr depthBuf = TextureBuffer::create();
depthBuf->setTexture(dfboTex);
fbo->setDepthAttachment(depthBuf);

but this is not valid.

I will try to use two stages and a visitor to render once the fragcoord to
texture and once the stuff i need for the metaballs. But this seams very
wrong :)

Maybe I am going a totally wrong way.. any Ideas how to do this better?
I want to avoid to extend OpenSG itself (writing my own stage), as I have
cluster environments.

best regards,
Victor

Loading...