Hi Gerrit,

I attached the sourcenode in an email before (that was unanswered). Here again:

// ---------------

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 input 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 material)
_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);

// ---------------

bye
Oliver


Gerrit Voss schrieb:

Hi,

On Mon, 2005-10-10 at 13:25 +0200, Oliver Kutter wrote:
Hi,

I found something and with it some new warnings / errors.
I set the fbo viewport to false with this call:

_fboVp->setFboOn(false);

And I think, that is why my fbo viewport does not work correctly. Now I set it on and I get some warnings:

WARNING: 8cd7: framebuffer FRAMEBUFFER_MISSING_ATTACHMENT
WARNING: OpenGL Error: invalid enumerant!

These errors came from the OSGFBOViewport.cpp in the source, when the FBO Status is checked. What could that be and how can I get this correct?

sounds a little bit like nothing is attached or that while attaching you
to the invalid enum error . What do you attach to the FBO ? Anything
custom ? or can I look at the original code ?


regards,
 gerrit




-------------------------------------------------------
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