From e8e25e82a9f2c336581f32eda8d70de42131a2b6 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 3 Oct 2011 15:25:16 +0000 Subject: [PATCH] From Jean-Sebastien Guay, changed the border colour for the shadow map to be 1 rather the 0 used for debugging so that areas outside the shadow map default to being unshadowed rather than shadowed. changed the shadow map texture assigment to StateSet so that it doesn't use OVERRIDE, enabling subgraphs to use the same texture unit for other textures if they so required. tidied up indentation. --- src/osgShadow/ViewDependentShadowMap.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/osgShadow/ViewDependentShadowMap.cpp b/src/osgShadow/ViewDependentShadowMap.cpp index 745f8c38e..c57b7c343 100644 --- a/src/osgShadow/ViewDependentShadowMap.cpp +++ b/src/osgShadow/ViewDependentShadowMap.cpp @@ -36,14 +36,14 @@ static const char fragmentShaderSource_withBaseTexture[] = #else static const char fragmentShaderSource_withBaseTexture[] = "uniform sampler2D baseTexture; \n" - "uniform int baseTextureUnit; \n" + "uniform int baseTextureUnit; \n" "uniform sampler2DShadow shadowTexture; \n" "uniform int shadowTextureUnit; \n" " \n" "void main(void) \n" "{ \n" " vec4 colorAmbientEmissive = gl_FrontLightModelProduct.sceneColor; \n" - " vec4 color = texture2D( baseTexture, gl_TexCoord[baseTextureUnit].xy ); \n" + " vec4 color = texture2D( baseTexture, gl_TexCoord[baseTextureUnit].xy ); \n" " color *= mix( colorAmbientEmissive, gl_Color, shadow2DProj( shadowTexture, gl_TexCoord[shadowTextureUnit] ).r ); \n" " gl_FragColor = color; \n" "} \n"; @@ -316,8 +316,8 @@ ViewDependentShadowMap::ShadowData::ShadowData(ViewDependentShadowMap::ViewDepen // the shadow comparison should fail if object is outside the texture _texture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::CLAMP_TO_BORDER); _texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP_TO_BORDER); - //_texture->setBorderColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); - _texture->setBorderColor(osg::Vec4(0.0f,0.0f,0.0f,0.0f)); + _texture->setBorderColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); + //_texture->setBorderColor(osg::Vec4(0.0f,0.0f,0.0f,0.0f)); // set up the camera _camera = new osg::Camera; @@ -1916,7 +1916,7 @@ osg::StateSet* ViewDependentShadowMap::selectStateSetForRenderingShadow(ViewDepe OSG_INFO<<" ShadowData for "<setTextureAttributeAndModes(sd._textureUnit, sd._texture.get(), osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); + stateset->setTextureAttributeAndModes(sd._textureUnit, sd._texture.get(), osg::StateAttribute::ON/* | osg::StateAttribute::OVERRIDE*/); stateset->setTextureMode(sd._textureUnit,GL_TEXTURE_GEN_S,osg::StateAttribute::ON); stateset->setTextureMode(sd._textureUnit,GL_TEXTURE_GEN_T,osg::StateAttribute::ON);