PDA

View Full Version : Manual bilinear PCF seams on AMD

Sunray
01-30-2012, 10:06 AM
I did a bilinear filter for shadow maps, which I've also done quite a few times before over the years. But this time around I got some weird seams. Is there someone who has a sensible explanation for this?

I've tested with a simple color texture. I've tried using texture() with manual offseting and no explicit loding. No gain there.

Hardware is a AMD HD 4850 with the latest drivers. I've also tested on a NVIDIA Quadro 5000 and it worked perfectly (no seams). Seems like every time I try to do something with OpenGL on an AMD card I get problems, quite unfortunate since I've used AMD/ATI cards the past 10 years. :)

Screenshot 0 (http://rgba.se/dump/amd_seams0.png)
Screenshot 1 (http://rgba.se/dump/amd_seams1.png)

float textureBilinear(in sampler2DShadow Sampler, in vec4 TexCoordProj, in vec2 Dimensions)
{
vec3 TexCoord = TexCoordProj.xyz / TexCoordProj.w - vec3(0.5 / Dimensions, 0.0);
vec2 Fraction = fract(Dimensions * TexCoord.xy);

float Sample00 = textureLodOffset(Sampler, TexCoord, 0, ivec2(0, 0));
float Sample10 = textureLodOffset(Sampler, TexCoord, 0, ivec2(1, 0));
float Sample01 = textureLodOffset(Sampler, TexCoord, 0, ivec2(0, 1));
float Sample11 = textureLodOffset(Sampler, TexCoord, 0, ivec2(1, 1));

float SampleX0 = mix(Sample00, Sample10, Fraction.x);
float SampleX1 = mix(Sample01, Sample11, Fraction.x);
float SampleXY = mix(SampleX0, SampleX1, Fraction.y);

return SampleXY;
}

Sunray
01-31-2012, 11:46 AM
Solved by snapping to integer coordinates. Apparently, you can't trust GL_NEAREST.

...
vec2 Fraction = fract(Dimensions * TexCoord.xy);

TexCoord.xy -= Fraction / Dimensions; // <--
...