Hi,
I posted a message a few weeks ago, at that time I was not able to test, now I am.
So my problem is :

    I have draw many virtual objects in my scene. But one is particular. I constructed its geometry in a normal way.
    And now I would like to use its geometry to update the depth buffer without drawing in the ColorBuffer. So that
    if I first update this Z-Buffer, then when I'll draw the others objects, if they are behind this object they would not appear.
    For instance if I have black background, a blue plane parrallel to the projection plane and my object in front of the plane (but without seeing the         object) , I want that it's silouette appear in black (the background) on the plane, that the part of the plane who is supposed to be behind the object
    is not drawn.

    For now my object is drawn, so virtual objects  are occluded.
    geo is the GeometryPtr of my object, I use a classical material :
      plainMat = SimpleMaterial::create();
      beginEditCP(plainMat);
      plainMat->setDiffuse(diffuse);
      plainMat->setSpecular(specular);
      plainMat->setShininess(shininess);
     endEditCP(plainMat);
     beginEditCP(geo);
     geo->setMaterial(plainMat);
     endEditCP(geo);
Last time Antonio proposed :
You can use a ColorMaskChunk in order to disable the
drawing into the colorbuffer, something like this:

occluderMat = ColorMaskChunk::create();
beginEditCP(occluderMat);
occluderMat->setMaskR( false );
occluderMat->setMaskG( false );
occluderMat->setMaskB( false );
occluderMat->setMaskA( false );
endEditCP(occluderMat);
You have to add this chunk to the material associated to
your "occluder" geometries. You'll most probably also have
to set the "sortKey" to ensure that the occluding geometries
are rendered first. Search for the "setSortKey" method.

So I tried like this :

  SimpleMaterialPtr occluderMat = SimpleMaterial::create();
  ColorMaskChunkPtr occluderChunk = ColorMaskChunk::create();
  beginEditCP(occluderChunk);
    occluderChunk->setMaskR( false );
    occluderChunk->setMaskG( false );
    occluderChunk->setMaskB( false );
    occluderChunk->setMaskA( false );
  endEditCP(occluderChunk);
  beginEditCP(occluderMat);
    occluderMat->setDiffuse(Color3f(0.42, 0.42, 0.52));
    occluderMat->addChunk(occluderChunk);
    occluderMat->setSortKey(Int32(10));  }
  endEditCP(occluderMat);
  beginEditCP(geo);
    geo->setMaterial(occluderMat);
  endEditCP(geo);
But it don't work. My object is not visible, it's ok, but it doesn't occlude the object behind him (the plane is totally blue, as if
my object was not here).
I'm I using corectly the ColorMaskChunk?

Dirk proposed :
If you have it as an image you can draw that instead of the geometry.
You can use a manual glDrawPixels() and a DepthClearBackground, or you
put it in a texture and use the PolygonBackground. You will need a
shader to change the depth of the fragments you're drawing, drawing
directly into the depth buffer doesn't work.
Could you be a little more precise? :)
I don't know where to start....

Thanks a lot
Regards

Adrien





-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to