PDA

View Full Version : glitches using fract



vince
05-02-2005, 01:07 PM
I'm using the following fragment shader. It is quite simple, just supposed to apply the texture on a polygon, but clamping the texture coordinates. It is very bizzare I get a line where my incoming texture coordinates are a multiple of 1. It's not something in my texture itself because I then clamp the texture coordinates before I pass them to the texture lookup. Seems like something is weird using "fract". I tried recoding the fract using mod or floor, but I always get the same artifact on my FX 6800 (tried multiple drivers)

Any idea?

uniform sampler2D nTextIdx0;
void main(void)
{
vec2 texCoord = fract(gl_TexCoord[0].xy);
texCoord = clamp(texCoord, 0.15,0.45);
gl_FragColor = texture2D(nTextIdx0, texCoord);
}

kingjosh
05-02-2005, 01:58 PM
I've seen this issue as well, it occurs when you create a discontinuity by using the fract() function, and then indexing into the texture. The easiest way to fix this is the either use an LOD bias in your fragment shader to turn off mip mapping, or turn it off in your application.