I have a strange bug rendering to shadow maps which only happens using
ATI cards (currently developing on a 4800 series, though it has
happened on other ones and doesn't happen on any Nvidia card).
I use one (very simple) fragment program to render non-alpha tested
objects (they don't need their associated textures bound) and another
(more complicated) one to render alpha tested objects. The non-alpha
tested objects are being rendered into the shadow map correctly but
the alpha tested ones are not.
This is where it gets a bit weird: I am using a texture where about
half the pixels have alpha < 0.5 and the other half > 0.5. If I set
the alpha test function to GL_GREATER and the ref to 0.5 (for
instance) none of the object gets rendered to the shadow map. If I set
the function to GL_EQUAL and the ref to 0.0 then the whole object gets
rendered.
Now it gets a bit weirder: The following fragment program exhibits the
above behaviour (my actual program is more complicated, but I checked
that the simple version does the same)
void main(void)
{
gl_FragColor = texture2D( u_color_texture0, v_uvs[ 0 ].xy );
}
change this to:
void main(void)
{
gl_FragColor = texture2D( u_color_texture0, v_uvs[ 0 ].xy );
// Overwrite the alpha channel.
gl_FragColor.a = 1.0;
}
or even
void main(void)
{
gl_FragColor = texture2D( u_color_texture0, v_uvs[ 0 ].xy );
// Overwrite the whole texture look-up result.
gl_FragColor = vec4( 1.0, 1.0, 1.0, 1.0 );
}
and it still happens, but change it to:
void main(void)
{
gl_FragColor = vec4( 1.0, 1.0, 1.0, 1.0 );
}
and the whole object appears (as expected).
It seemed to me to be a case of setting up an invalid state such as
having two samplers bound to the same texture stage, but it doesn't
seem to be. I call glValidateProgramARB() just before rendering my
object and nothing is amiss in the info log. I know this is a long
shot, but I wondered if anyone has seen anything similar to this or
has any ideas. Thanks for reading this far.
Guy
|
|
0
|
|
|
|
Reply
|
Guy
|
10/31/2008 11:36:53 AM |
|