strange "depth fighting" artifacts after shadowing...

I just got done cleaning up all the odd little shadowing problems, I decided to use Carmack’s reverse, since it was a lot easier to cap both ends, slam it to a display list and forget about it (unless something changes, like light or mesh position).

Anyways, since the beginning of my programming the shadows in, I have had this strange shimmering artifact, almost like it’s depth fighting. Usually it’s only apparent when the camera is moving, but sometimes I can convince it to stick its ugly head out so I can get a screenshot. That’s a pretty ugly pic of the artifact, it actually took quite a long time to “find” one this bad. Usually its pretty clean looking…

Now a little background. I am doing an initial draw with the color buffer disabled, drawing to the depth buffer. Then I do each light, first clearing the stencil buffer, then drawing shadows, then drawing in the scene, lit from the one light. Then I move to the next light, and repeat the process. Like I said earlier, Im using Carmack’s Reverse to do the shadows, that way I dont have to deal with near plane, and it makes the shadow fit nicely into a display list.

I suppose this is a depth fighting artifact. Im wondering if there is a clean solution to this type of problem.

Yeah, definately looks like a Z-fighting problem. I think you can fix it with polygon offset, but i, for one, just extrude the vertices by a small amount.

I’m using a vertex shader so it’s easier. To extrude the shadow volume vertices, i use a weight. Ideally it’d be 0 for the near capping and 1 for the far capping; but i use 0.001 for the near weight instead, and i got ride of the problems. To be honnest, this was to fight against ugly “edges” with bump-mapping on curved surfaces, but it should work for your pb too…


You think mebbe if I jittered the cam backwards about 0.001 for the inital (depth fill) draw, it would work?

Im working on something else right now, and dont want to try this yet…

This sort of problem can happen if you mix vertex programs with fixed function on some nVidia cards.

Most likely you have a depth comparison function set wrong. Check them first as I have not needed any zbias in my shadows. I’m doing finite zfail shadows with d3d, though gl should work the same I would think.

OK, Im not using any vertex shaders. I have glDepthFunc(GL_LEQUAL) set, and I do not modify it anywhere else. I dunno about any other depth functions that I can/have set… I dont recall any.

I’m using infinite shadows, but I have seen this problem since before I implemented infinitude. I used to have my far plane set at 1000, so there’s a chance that I was close enuf to infinity to cause problems.

[This message has been edited by 147-2 (edited 03-04-2003).]

Use a glDepthFunc of GL_LESS when rendering the volumes to stencil, and see how that goes for you.

Hmm… didnt work so well, no noticeable change. Oh, here, take a look at my most recent amusing little artifact. I know what’s going on here, but I thot it would be amusing for you to see. I like this pic because of the geometric symmetry visible, and how the artifact adds to the artistic effect. See it here:

This is what happens when you use Carmack’s Reverse to do meshes, and the standard method for shadows to do portals and so forth. I was actually quite amused by it.

I wouldn’t worry about the artifacts if I were you, the splinter cell demo had HEAPS of them and they expect people to pay $100 for it. If your proggy’s good enough then people will pay for the artifacts.

LOL Thats about the funniest thing Ive read all day. Actually, I could prolly see if I can get the Vatican to buy it. They’re always looking for good artifacts.