Hi, I am trying to integrate self-shadowing into mogumbo’s parallax bumpmapping . I am working from two sets of example code, Humus’ SelfShadowBump , and Tom Nuydens’ uberbump .
My problem is, there is an artifact visible in the shadowing due to interpolation or precision errors in the horizon map texture lookup.
This is easier to explain in pictures than words, so:
The first approach (Tom’s) creates a heading cubemap where the front face rotates from 0 to 1, which looks like this: http://homepage.mac.com/arekkusu/bugs/t/lightmap_edge.png
Now when the lightmap texture lookup happens, if I use linear filtering there is a discontinuity at that edge which causes a distortion artifact in the resulting shadow. The size of the distortion depends on the resolution of the cubemap, and it looks like this: http://homepage.mac.com/arekkusu/bugs/t/lightmap_edge_linear.png
If I instead use nearest filtering, the distortion is reduced to a 2 scanline high area, but it is still there: http://homepage.mac.com/arekkusu/bugs/t/lightmap_edge_nearest.png
And of course there is nasty pixelization visible due to the lack of filtering.
The second approach (Humus) creates the front face of the heading cubemap such that it rotates from 0, through 1, and back to 0. Now there is no discontinuity, and it looks like this: http://homepage.mac.com/arekkusu/bugs/t/lightmap_continuous.png
This approach needs to fix up the texture coordinate in the fragment program though, to get the same result. Humus’ original code looks like:
float4 ang = texCUBE(AngleMap, lightVec);
float e = 0.5 * sign(lightVec.y) * ang.y;
which I converted to ARB_fragment_program like so:
TEX h_e, light0, texture[4], CUBE;
MOV Thorizon, Toffset;
SLT fix, 0.0, light0.yyyy;
ADD fix, fix, -0.5;
MUL Thorizon.z, fix.x, h_e.x;
This comes out better since I can use linear filtering, but there is still a 2 scanline high artifact: http://homepage.mac.com/arekkusu/bugs/t/lightmap_continuous_linear.png
In both approaches the 2 scanline high artifact flickers in and out depending on the light and camera vectors. Is it due to a precision / rounding problem?
How do I get around this?
[This message has been edited by arekkusu (edited 02-02-2004).]