Re: [osg-users] Basic transparency pb (?)

From: Brian R Hill <bhill22_at_csc.com>
Date: Tue Jan 25 2005 - 10:28:22 PST

Jerome,

This is what I did:

osg::Group * root = new osg::Group;
osg::Node * node = osgDB::readNodeFile("c:/temp/scene_tester2.osg");
root->addChild(node);

osg::CullFace * cf = new osg::CullFace;
cf->setMode(osg::CullFace::BACK);
root->getOrCreateStateSet()->setAttributeAndModes(cf);
root->getOrCreateStateSet()->setAttributeAndModes(new osg::BlendFunc);

osgDB::writeNodeFile(*root,"c:/temp/scene_tester3.osg");

Brian

----------------------------------------------------------------------------------------
This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery. NOTE: Regardless of content, this e-mail shall not operate to
bind CSC to any order or other contract unless pursuant to explicit
written agreement or government initiative expressly permitting the use of
e-mail for such purpose.
----------------------------------------------------------------------------------------

Jérôme Schmid <jerome.schmid
@free.fr>
Sent by: osg-users-bounces
01/24/2005 08:36 PM
Please respond to osg users

 
        To: osg users <osg-users@openscenegraph.net>
        cc:
        Subject: Re: [osg-users] Basic transparency pb (?)

Hi Brian,

>
> Jerome,
>
> You are seeing an artifact of the sphere geometry.
>
> I just set face culling on.
>
> osg::CullFace * cf = new osg::CullFace;
> cf->setMode(osg::CullFace::BACK);
> geode->getOrCreateStateSet()->setAttributeAndModes(cf);

That means that you succeed in having correct results ? Before you
applied the back face culling did you see the artefacts? Or you give me
a classic tip that is often used in transparency ?

I ask you because it doesn't change nothing...sigh. I try other kind of
culling ( one tries anything when something doesn't work ^_^) but it
doesn't change the pb.

If you can have a beautiful shading with transparency by running
osgviewer with my .osg supplied it will mean that that's a driver or
card pb. Else it means that my scene grpah is not correctly set up and
it is case I will be pleased if somebody can provide to me a *very*
simple .osg file with simple geometry that illustrates transparency. In
that I will chech if it is a driver/hardware pb.

I translated a sphere in order to have the intersection of spheres
blended with transparency and I notice that it depends on eye viewpoint
relativelly to scene: sometimes artefacts appear, sometimes not; a flip
effect is there also: a part of sphere disapear depending on
viewpoint...I repost the .osg if somebody saw same odd effects please
told me.

What the hell? ^_^

Regards,

Jerome
>
> Brian
>
>
>
----------------------------------------------------------------------------------------
> This is a PRIVATE message. If you are not the intended recipient, please

> delete without copying and kindly advise us by e-mail of the mistake in
> delivery. NOTE: Regardless of content, this e-mail shall not operate to
> bind CSC to any order or other contract unless pursuant to explicit
> written agreement or government initiative expressly permitting the use
> of e-mail for such purpose.
>
----------------------------------------------------------------------------------------
>
>
>
> *Jérôme Schmid <jerome.schmid
> @free.fr>*
> Sent by: osg-users-bounces
>
> 01/24/2005 08:43 AM
> Please respond to osg users
>
>
> To: osg users <osg-users@openscenegraph.net>
> cc:
> Subject: [osg-users] Basic transparency pb (?)
>
>
>
>
> Hi,
>
> I have a pb for transparency in case of a *very* simple scene: one
> sphere radius 2 into another radius 3.
>
> The scene looks like
>
> Group->MatrixTransform->Geode->ShapeDrawable( sphere1 )
> |
> -->MatrixTransform->Geode->ShapeDrawable( sphere2 )
>
>
> In each matrixTransform I set something like:
>
> osg::StateSet* stateset = mNode->getOrCreateStateSet();
> stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
> stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
>
> // Blending Function
> osg::BlendFunc *trans = new osg::BlendFunc();
> trans->setFunction(osg::BlendFunc::SRC_ALPHA
> ,osg::BlendFunc::ONE_MINUS_SRC_ALPHA);
> stateset->setAttributeAndModes(trans);
>
> I have browsed the mail archives ( I cannot access easilly web and
> especially www.openscenegraph.org so mail archive is my best weapon )
> and read threads regarding transparency setup and it seems that my code
> looks correct.
>
> However the result can be seen in attached pics: some odd effects appear
> on sphere surfaces ( easier to see it in no light version ). I dump my
> tree on an osg file ( attached ) and run it into osgviewer in order to
> see if my app works incorrectly. Nothing better.
>
> I tried to force DEPTH_TEST, to move stateset params to the geodes (
> maybe inherittence from matrixTransform node didn't work correctly ),
> user tesselation hints, force normals on, change alpha func,use
> material....T_T nope.
>
> Maybe my approach is not good and there is something that I really do
> not understand on transparency. I profit of this mail to ask a simple
> question then: Is there a magic way to pick up an osg node and apply
> something on it to be *sure* that it will be transparent? The knowledge
> of the rest of the tree must be known ( side effects coming from other
> nodes in tree perturbing transparency )???
>
> For me transparency works like this:
> - Render opaque object - no blending
> - Render transparent objects in the sorted way ( back to front )-
> blending on - zbuffer read only.
>
> Am I right? With TRANSPARENT_BIN the depth sorting is enabled, no?
>
> *Sorry* for so long mail but I am frustated to succeed in doing
> transparency in openGL pure code but not in osg...! But as I noticed in
> mailing archive some newbies( or not? ) encountered also troubles in
> correct transparency setup.
>
> Thank you!!!
>
> Regards,
>
> Jerome
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@openscenegraph.net
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
> << Attachment Removed : trans_pb.zip >>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> osg-users mailing list
> osg-users@openscenegraph.net
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
>
>
> ------------------------------------------------------------------------
>
> Internal Virus Database is out-of-date.
> Checked by AVG Anti-Virus.
> Version: 7.0.300 / Virus Database: 265.7.0 - Release Date: 17/01/2005
Group {
  UniqueID Group_0
  DataVariance DYNAMIC
  nodeMask 0xffffffff
  cullingActive TRUE
  num_children 2
  MatrixTransform {
    UniqueID MatrixTransform_1
    DataVariance DYNAMIC
    nodeMask 0xffffffff
    cullingActive TRUE
    StateSet {
      DataVariance STATIC
      rendering_hint TRANSPARENT_BIN
      renderBinMode USE
      binNumber 10
      binName DepthSortedBin
      0xba1 ON
      GL_BLEND ON
      BlendFunc {
        DataVariance STATIC
        source SRC_ALPHA
        destination ONE_MINUS_SRC_ALPHA
      }
    }
    UpdateCallbacks {
      NodeCallback {
        DataVariance DYNAMIC
      }
    }
    referenceFrame RELATIVE
    Matrix {
      1 0 0 0
      0 1 0 0
      0 0 1 0
      0 0 0 1
    }
    num_children 1
    Geode {
      UniqueID Geode_2
      DataVariance DYNAMIC
      nodeMask 0xffffffff
      cullingActive TRUE
      StateSet {
        DataVariance STATIC
        rendering_hint DEFAULT_BIN
        renderBinMode INHERIT
        GL_CULL_FACE ON
        CullFace {
          DataVariance STATIC
          mode BACK
        }
      }
      num_drawables 1
      ShapeDrawable {
        UniqueID ShapeDrawable_3
        DataVariance DYNAMIC
        StateSet {
          DataVariance STATIC
          rendering_hint DEFAULT_BIN
          renderBinMode INHERIT
        }
        Sphere {
          UniqueID Sphere_4
          DataVariance DYNAMIC
          Center 2 0 0
          Radius 2
        }
        useDisplayList TRUE
        useVertexBufferObjects FALSE
        color 1 0 0 0.5
      }
    }
  }
  MatrixTransform {
    UniqueID MatrixTransform_5
    DataVariance DYNAMIC
    nodeMask 0xffffffff
    cullingActive TRUE
    StateSet {
      DataVariance STATIC
      rendering_hint TRANSPARENT_BIN
      renderBinMode USE
      binNumber 10
      binName DepthSortedBin
      0xba1 ON
      GL_BLEND ON
      BlendFunc {
        DataVariance STATIC
        source SRC_ALPHA
        destination ONE_MINUS_SRC_ALPHA
      }
    }
    UpdateCallbacks {
      NodeCallback {
        DataVariance DYNAMIC
      }
    }
    referenceFrame RELATIVE
    Matrix {
      1 0 0 0
      0 1 0 0
      0 0 1 0
      0 0 0 1
    }
    num_children 1
    Geode {
      UniqueID Geode_6
      DataVariance DYNAMIC
      nodeMask 0xffffffff
      cullingActive TRUE
      StateSet {
        DataVariance STATIC
        rendering_hint DEFAULT_BIN
        renderBinMode INHERIT
        GL_CULL_FACE ON
        CullFace {
          DataVariance STATIC
          mode BACK
        }
      }
      num_drawables 1
      ShapeDrawable {
        UniqueID ShapeDrawable_7
        DataVariance DYNAMIC
        StateSet {
          DataVariance STATIC
          rendering_hint DEFAULT_BIN
          renderBinMode INHERIT
        }
        Sphere {
          UniqueID Sphere_8
          DataVariance DYNAMIC
          Center 0 0 0
          Radius 3
        }
        useDisplayList TRUE
        useVertexBufferObjects FALSE
        color 1 1 0 0.5
      }
    }
  }
}
_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Received on Tue Jan 25 10:30:34 2005

This archive was generated by hypermail 2.1.8 : Tue Jan 25 2005 - 10:30:35 PST