From fd5f9741d333c03256d73c50ed42444d9d5ea7ae Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 21 Oct 2008 16:32:55 +0000 Subject: [PATCH] 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." --- src/osgShadow/StandardShadowMap.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/osgShadow/StandardShadowMap.cpp b/src/osgShadow/StandardShadowMap.cpp index ad27b0cfe..387aca1f7 100644 --- a/src/osgShadow/StandardShadowMap.cpp +++ b/src/osgShadow/StandardShadowMap.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -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"