Reputation: 4501
I have a seamlessly tilable texture.
In the fragmentshader i calculate the texturecoordinates UVproc procedurally using a function that jumps from 1.0 to 0.0 at some point (here the texture should repeat nicely).
the problem is that at this seam, the lookup seems to return pixelvalues from the smallest mipmap level.
If i debugoutput
out = vec4(dFdx(UVproc.x), dFdy(UVproc.y),0,1);
then i can see that at those pixels the finite differences of these texturecoordinates are very high and therefore a small mipmap level is accessed (makes sense - as there is a jump from 1 to 0 at those pixels, the finite differences will be big).
If i manually just access mipmaplevel 0 using textureLod() then i don't have this problem, but i also loose mipmapping and everything gets grainy.
so the question is:
How can I avoid visible mipmap related seams if texturecoordinates (in the range 0-1) are procedurally calculated in the fragment shader?
Upvotes: 2
Views: 880
Reputation: 1645
You should use gradient texture sampling, manually setting the derivatives. Here's a function for it:
gvec textureGrad(gsampler sampler, vec texCoord, gradvec dTdx, gradvec dTdy);
Upvotes: 2