I'm trying to implement relief mapping based on http://www.inf.ufrgs.br/~oliveira/pu...M_I3D_2005.pdf this paper, and the sample shader code in the appendix.

What I have works fine except for this strange artifact I'm getting:

http://i.imgur.com/wXaOZ.png

It's as if the ray's slope is greater than it should be and that that it's intersecting parts of the image that it shouldn't be able to reach. However, changing the slope doesn't seem to do all that much. This artifact occurs wherever the angle between two faces is greater then 180.

Is anyone here experienced with this technique?

Here's my ray cast function:

Code :vec2 castRay(in sampler2D rm, in vec2 tc, in vec2 delta) { const int nLinearSteps = 50; const int nBinarySteps = 15; float rayDepth = 0.0; float stepSize = 1.0/float(nLinearSteps); float texelDepth = texture(rm, tc).a; float intersect = 0.0; //linear test for(int i = 0; i < nLinearSteps; i++) { intersect = 1.0; if(texelDepth > rayDepth) { rayDepth += stepSize; texelDepth = texture(rm, tc + (delta * rayDepth)).a; intersect = 0.0; } } if(intersect < 0.9) discard; //"Rewind" to the point before the intersection, but only if there is an intersection rayDepth -= (stepSize * intersect); //binary search for(int i = 0; i < nBinarySteps; i++) { stepSize *= 0.5; rayDepth += stepSize; texelDepth = texture(rm, tc + (delta * rayDepth)).a; if(texelDepth <= rayDepth) { stepSize *= 2.0; rayDepth -= stepSize; stepSize *= 0.5; } } return (tc + (delta * rayDepth * intersect)); }

In the main function, I have

Code :vec2 delta = fReliefScale * -normTanView.xy/normTanView.z;

“normTanView” is the normalized tangent-space view vector and “fReliefScale” is what modifies the slope of the ray.

I'm using mikktspace to get the tangent and bitangent vectors.