Andreas Goebel schrieb:
> 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?
>
I have pondered a bit about this, and I think I will need a
vertex-shader, too. There I will have to determine if light shines on
the surface or not.
In the pixel shader stage I will have to
- draw pixels that no light shines on in ambient color
- draw pixels that lights shine on but are in shadow in ambient color
- draw pixels that lights shine on but are not in shadow in the "normal"
color.
Here is an example of phong-shading:
http://www.opengl.org/sdk/docs/tutorials/ClockworkCoders/lighting.php
which will probably be a good reference for me to see how vertex shaders
work and can interact with a pixel shader.
Maybe someone can tell me if I am on the right track or not.
Regards,
Andreas
> Regards,
>
> Andreas
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org