View Full Version : strange "depth fighting" artifacts after shadowing...

03-03-2003, 09:06 AM
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. http://www.bloodyaxes.com/artifacts.jpg 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... http://www.bloodyaxes.com/shadows3.jpg

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.

03-03-2003, 11:07 AM
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..


03-03-2003, 12:01 PM
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....

03-03-2003, 07:24 PM
This sort of problem can happen if you mix vertex programs with fixed function on some nVidia cards.

03-03-2003, 10:48 PM
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.

03-04-2003, 02:23 PM
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).]

03-04-2003, 02:37 PM
Use a glDepthFunc of GL_LESS when rendering the volumes to stencil, and see how that goes for you.

03-04-2003, 04:26 PM
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: http://www.bloodyaxes.com/coolartifact.jpg

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.

03-04-2003, 07:24 PM
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. http://www.opengl.org/discussion_boards/ubb/wink.gif

03-05-2003, 03:33 AM
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.

03-05-2003, 05:25 PM
Rofl http://www.opengl.org/discussion_boards/ubb/biggrin.gif