Hi,

I have played around a bit with the FragmentShader for ShadowMap.cpp

Instead of using a predefined bias I wanted the shadow to appear exactly 
in the currents materials ambient color.

That's what I did:

static const char fragmentShaderSource_withBaseTexture[] =
        "uniform sampler2D osgShadow_baseTexture; \n"
        "uniform sampler2DShadow osgShadow_shadowTexture; \n"
        "uniform vec2 osgShadow_ambientBias; \n"
        "\n"
        "void main(void) \n"
        "{ \n"
        "    if (!shadow2DProj(osgShadow_shadowTexture, 
gl_TexCoord[1])[0] ) { \n"
        "        gl_FragColor = gl_FrontLightProduct[0].ambient * 
texture2D( osgShadow_baseTexture, gl_TexCoord[0].xy ); \n"
        "   } else { \n"
        "        gl_FragColor = gl_Color * texture2D( 
osgShadow_baseTexture, gl_TexCoord[0].xy ); \n"
        "    } \n"
        "}\n";

This works, and the result is quite good when looking at the object from 
the same direction as the light-source.

If I look at it from the other side then at the places where the shadow 
is (which is invisible here, as it uses the ambient color) the object is 
slightly transparent.

Any clues on this?

Regards,

Andreas
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to