Time for action - achieving the translucent effect

We are going to implement a common translucent effect that treats a model as glass. Any other scene objects can be displayed through the glass object. This can be done with the OpenGL blending mechanism, but it is important to calculate the correct rendering order of scene objects in this case.

  1. Include the necessary headers:
    #include <osg/BlendFunc>
    #include <osg/Texture2D>
    #include <osg/Geometry>
    #include <osgDB/ReadFile>
    #include <osgViewer/Viewer>
    
  2. We will continue using the quad geometry with a predefined texture coordinate array. It should be treated as a translucent object and the blending attribute and modes should be applied later:
    osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array; ...

Get OpenSceneGraph 3.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.