Strange problem in Relief Mapping (triangle edges visible)

tamat

Newcomer
Hi:

I'm experiencing a weird problem with my relief mapping shader. The algorithm works fine, Im just applying an offset to every uv per pixel in my pixel shader.

But somehow the edges of the poligons are visible. I don't know why but if you check the screenshots you will see the mesh wireframe, and thats not intentional.

It looks like it is doing some distintion between the inner pixels of the triangles and the border.

I tested it in other computers and it doesnt happens, so it has to be something related to the configuration of my Nvidia 8800 Card.

Does anybody know why?

Thanks a lot

error_relief.jpg

error_relief2.jpg
 
I'd say you're getting some kind of discontinuity in the texture coordinates. Try disabling mipmapping. If the artifacts go away then that's most likely what's happening. Basically when you have a discontinuity what will happen is that it'll go straight for the 1x1 mipmap, resulting in uniformly colored artifacts, usually kinda grayish since it's the average of the whole image. Why that is happening is hard to know without seeing the shader. Make sure you're not sampling from something like frac(texCoord) or anything else that could cause a discontinuity. If you really need that kind of discontinuity, you need to use tex2Dgrad().

Are you using any MSAA? If so, you may also want to play around with centroid sampling.
 
Thanks Humus.

Indeed my shader doesnt do anything strange, just to use in GLSL the texture2D without any trick to get mipmaps.

On the other hand I've tryed disabling most of the features in my graphics card but I will test with the mipmaps and let you know if that solves something.

Thanks again.
 
Also, make sure you're not doing any standard texture2D() calls inside any dynamic branch (if-statements, loops etc.) unless you're using an interpolated texture coordinate directly. For lookups inside a dynamic branch you need to use either texture2DGrad() or texture2DLod(). Otherwise the gradients (which are implicit in texture2D()) become undefined.
 
sergi.gonzalez and I had been working on the problem.

As you said, Humus, it look like there is a problem with the mipmaps, it is taking a low mipmap on the edges. My idea is that the mipmap gradient calculation is done at the pixel we are drawing but we are reading the texture with the bias from relief mapping, that works in the inside pixel but not in the edges.

Setting all to GL_NEAREST the problem dissapears but we are loosing texture quality, so we will work around the problem.

Thanks again.
 
Like Humus said, this looks very much like a dynamic branching gradient problem. Mips are fetched according to the LOD calculated from the gradient (in 2x2 blocks). Disabling mips fixes this problem, but is not what you really want to do. Check all the texture fetches inside your branches, and replace the tex2D calls with appropriate branch safe sampling functions.
 
Back
Top