Hi Dirk,

could you please first have a look at my opensg code, just to be sure, that the basic geometry settings are ok.

Here is my code (without begin / endEditCP, that would be to long):

First the material, the polygon background (with the shader) and the viewport with the texture.

// texture unit 0 to 4 are input data textures, texture 5 is for the particle positions
_cmMaterial = ChunkMaterial::create();
_cmMaterial->addChunk(_shlChunk);     // shader chunk
_cmMaterial->addChunk(_tcInData[0]);  // tex unit 1
_cmMaterial->addChunk(_tcInData[1]);  // tex unit 2
_cmMaterial->addChunk(_tcInGrHeight); // tex unit 3
_cmMaterial->addChunk(_tcInOffset);   // tex unit 4
_cmMaterial->addChunk(_tcInPart);     // tex unit 5

// the polygon background (with data textures and the shader)
_polyBkgnd = PolygonBackground::create();
_polyBkgnd->setMaterial(_cmMaterial);
_polyBkgnd->getMFPositions()->push_back(Pnt2f(0.0, 0.0));
_polyBkgnd->getMFPositions()->push_back(Pnt2f(1.0, 0.0));
_polyBkgnd->getMFPositions()->push_back(Pnt2f(1.0, 1.0));
_polyBkgnd->getMFPositions()->push_back(Pnt2f(0.0, 1.0));
_polyBkgnd->getMFTexCoords()->push_back(Vec3f(0.0, 0.0, 0.0));
_polyBkgnd->getMFTexCoords()->push_back(Vec3f(1.0, 0.0, 0.0));
_polyBkgnd->getMFTexCoords()->push_back(Vec3f(1.0, 1.0, 0.0));
_polyBkgnd->getMFTexCoords()->push_back(Vec3f(0.0, 1.0, 0.0));

// the float image
int vpsize = 512;

_imOutFBO = Image::create();
_imOutFBO->set(Image::OSG_RGBA_PF, vpsize/2, vpsize/2, 1, 1, 1, 0, NULL, Image::OSG_FLOAT32_IMAGEDATA);

// texture for the fboviewport
_tcOutFBO = TextureChunk::create();
_tcOutFBO->setImage(_imOutFBO);
_tcOutFBO->setEnvMode(GL_REPLACE);
_tcOutFBO->setMinFilter(GL_NEAREST);
_tcOutFBO->setMagFilter(GL_NEAREST);
_tcOutFBO->setWrapS(GL_CLAMP);
_tcOutFBO->setWrapT(GL_CLAMP);
_tcOutFBO->setInternalFormat(GL_RGBA32F_ARB);

// and the fboviewport

_fboVp = FBOViewport::create();
_fboVp->setBackground(_polyBkgnd);
_fboVp->setCamera(cam);
_fboVp->setRoot(makeCoredNode<Group>());
_fboVp->setSize(0, 0, (vpsize/2)-1, (vpsize/2)-1);
_fboVp->setStorageWidth(vpsize/2);
_fboVp->setStorageHeight(vpsize/2);
_fboVp->getTextures().push_back(_tcOutFBO);

// I don't know, if this is important (took it from the test program)
_fboVp->setFboOn(false);

// -----

this was for init, now for the rendering

// -----

// first I set the particle positions to the first input texture (as floats)
_fInPartData = new float[vpsize*vpsize*4];
int count = 0;
for (i=0; i<_iInPartLength; i+=4) {
   // store x, y, z values at  r, g, b components of the float texture
   _fInPartData[i]   = pvec[count].x();
   _fInPartData[i+1] = pvec[count].y();
   _fInPartData[i+2] = pvec[count].z();
   _fInPartData[i+3] = 0.0f;
   count ++;
}

_imInPart->setData(reinterpret_cast<UInt8*>(_fInPartData));

beginEditCP (_tcInPart, TextureChunk::ImageFieldMask); {
   _tcInPart->setImage(_imInPart);
   _tcInPart->imageContentChanged();
} endEditCP (_tcInPart, TextureChunk::ImageFieldMask);

// -----

Then, after the first render pass, the output texture (which should store the new positions) is the input for the shader (change textures)

// -----

beginEditCP (_cmMaterial, ChunkMaterial::ChunksFieldMask); {
   if (_cmMaterial->getChunks(5) == _tcInPart) {
_cmMaterial->subChunk(_tcInPart); // removes texture unit 5 (old input position) _cmMaterial->addChunk(_tcOutFBO); // add texture unit 5 (new fbo stored position)
   }
} endEditCP (_cmMaterial, ChunkMaterial::ChunksFieldMask);

// -----

And now, every frame the same. Read within the shader the position from the texture, compute new position and write to the same texture.

Is that ok until now, especially the texture formats?

bye
Oliver




Dirk Reiners schrieb:

        Hi Oliver,

On Fri, 2005-10-07 at 17:16 +0200, Oliver Kutter wrote:
Hi,

I've got another idea, could it be, that the fboviewport, which yvonne send to and which is of opensg 2.0a, does not work correctly. Could that be the reason?

I'm not sure how that could be the reason. Unless it's not actually
floating point, it should work just fine. That said, there might be
things that I don't see. If you could try to simplify the problem (like
1 particle only and trivial geometry) and create a new, smaller OpenGl
log I could try taking a look.

Yours

        Dirk




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to