fix lightmap artifacts in self-shadowing bumpmapping?

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:

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:

If I instead use nearest filtering, the distortion is reduced to a 2 scanline high area, but it is still there:
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:

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:

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).]

I think you’re mixing up my and Tom’s versions. The latter one is my solution, which fixes the filter problem. I had the filter problem myself, and came up with that solution.

Anyway, shouldn’t your last line be
MUL Thorizon.z, fix.x, h_e.y;

Whoops you’re right, I switched the authors. Sorry! (I edited the post to correct the attribution.)

As for h_e.x or h_e.y, you’re using an RGB texture with R empty, heading in G and elevation in B. Tom and I are using an intensity_luminance texture to save texture space, so heading is in h_e.x. The results are correct, except for the annoying 2 pixel high artifact.

You don’t get the same result? What hardware? I am testing with a Radeon 9600…

No, works fine for me. Using a Radeon 9800pro. Do you get the same problem running mine or Toms demo on your hardware? Maybe your cubemap is too low res or something?

Since I also used ARB_fp, have you tried plugging my fragment program into your own code and copying my exact texture filter settings?

– Tom