From Wojciech Lewandowski, "I made a minor tweak in StandardShadowMap.cpp. As agreed with J-S I have added AlphaFunc/AlphaTest to shadow camera stateset to make sure transparent objects will not cast blocky solid shadows."

This commit is contained in:
Robert Osfield
2008-10-21 16:32:55 +00:00
parent 3b5f9f1e5d
commit fd5f9741d3

View File

@@ -21,6 +21,7 @@
#include <osg/Geode>
#include <osg/Geometry>
#include <osg/CullFace>
#include <osg/AlphaFunc>
#include <osg/Point>
#include <sstream>
@@ -526,6 +527,12 @@ void StandardShadowMap::ViewData::init( ThisClass *st, osgUtil::CullVisitor *cv
stateset->setRenderBinDetails( 0, "RenderBin",
osg::StateSet::OVERRIDE_RENDERBIN_DETAILS );
// Assure that AlphaTest/AlphaRef works when redirecting all drawables to single bin.
// If AlphaFunc/AlphaTest is off - transparent objects will cast solid blocky shadows.
// No override to allow users change this policy in the model if really want solid shadows.
stateset->setAttributeAndModes
( new osg::AlphaFunc( osg::AlphaFunc::GREATER, 0 ), osg::StateAttribute::ON );
// agressive optimization
stateset->setAttributeAndModes
( new osg::ColorMask( false, false, false, false ),
@@ -555,11 +562,6 @@ void StandardShadowMap::ViewData::init( ThisClass *st, osgUtil::CullVisitor *cv
stateset->setMode
( GL_BLEND, osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF );
#if 0
stateset->setMode
( GL_ALPHA_TEST, osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF );
#endif
#if 0 // fixed pipeline seems faster (at least on my 7800)
program->addShader( new osg::Shader( osg::Shader::FRAGMENT,
"uniform sampler2D texture; \n"