Sunday, May 18, 2008

Flimsy Edges or Z-Fighting

Sorry about not posting the past week but I had to do a lot of other things. We'll I hope this extra fat post will make you happy =).

First of all, here's the new Applet. (uses z-buffering)

My Z-buffering implementation is almost perfect but there are still some problems:

- Speed optimizations (I'll do this after finishing my 3d engine)
- Flimsy Edges / Z-Fighting

Here's a picture of what I mean by "flimsy edges":

This happens because of Z-fighting. Z-fighting is when two triangles fight for a place on the screen because they are both about the same depth. Here it is only edges which fight as only they have equal depth. The above edge (circled in red and magnified) has light gray shaded pixels from the triangle on the other side on it. In the applet it is a lot easier to see what I mean so take a look.

I'm not quite sure yet about how I should fix this, a few (bad) ideas which come to mind are:

- Don't make the edges equal, translate one edge by 0.000001. I really don't want to do this since it's annoying to do for big models and my engine should be able to fix this some other way. This would be the answer for when I'm desperate, which I'm not yet...

- Draw a line around each side of the triangle after I'm done drawing it eliminating pixels from other triangle around the edges no matter what depth they are. This would of course mean that the triangles would have to be drawn in the correct order which they are not.

- Do some research, which is what I'm going to pick for now.

Apart from fixing this Z-Fighting issue I plan to go over the previous and future posts with spell check. My posts don't have any labels/keywords so I'll add some. Also my title is all text and I think it would be nice to add a picture behind it, I'm just going to experiment a little with my blog layout and settings.

My geocities page which hosts the applets is all white except for the applet and doesn't have a proper menu. I'll try to make it look a little better. Also geocities is probably not the best choice so I'll look around for something without advertisements.

No comments: