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.
- Include the necessary headers:
#include <osg/BlendFunc> #include <osg/Texture2D> #include <osg/Geometry> #include <osgDB/ReadFile> #include <osgViewer/Viewer>
- 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; ...