flickering trees

Hi,

In my scene there are trees which consists of
two intersecting quads with transparent textures.
I render them with alpha test so that the alpha
channel acts as a mask.

The problem with this standard approach is that
the edges of the trees flicker a lot.On a
monitor this is not much of a problem but when a
projector is used flickering edges are
unacceptably disturbing.

Using alpha blending instead of alpha test
increases the quality but since I have to draw
the polys in back-to-front order I can not
generate large batches of polys hence frame rate
goes down incredibly.

Does anybody have an idea about how to stop
flickering without the need of sorting polygons?

Are you using Mipmapping with your textures?

Yes I use mipmapping.

I tried seperating the mask and color by using
multitexturing and disabled mipmapping for the
mask texture.

By doing that i got rid of erroneous edges
that would come from unsorted rendering when
blending is enabled(actually they were there but
just a few texels wide) but since the blend region
is smaller when the trees are away from camera
they continued to flicker.

First draw with alpha test set at 0.75 and GEQUAL, depth write on, depth test on, no blending.

Then draw the same geometry again with alpha test set at 0.75 and LESS, depth write off, depth test on, alpha blending.

That’s about the best you can get without having to sort all of the polygons.

Of course, you can sort the polygon soup from something like 3-8 different view directions, and pick the sorting list that’s closest to the actual view direction to actually render. The additional memory is small, since “sorting” just means another index list.

This may be stupid, or irrelevant…

Are the parts of the tree that are passed by the Alpha Test more or lesss opaque? Meaning, is most of your Alpha texture either 0, or 1 (or 255, depending on how you look at it), with intermediate values only on the silhouette edges of the image?

If they aren’t, then I don’t understand the need for sorting - you need to do that (AFAIK), only when you have transparent pixels that pass the Alpha Test, and have disabled the Z buffer writes to allow drawing behind a transparent object - you could simply draw them blended, with Z buffer writes enabled.

This might solve the frame rate problem, I dunno about the flickering edges…

Charlie

Hi,

charliejay:
Without sorting you always get artifacts.
In my case,yes they are on the silhouette but
to prevent flickering I need to have a wide
region of transparency (I mean 0<alpha<1.You can
think that I have a very wide silhouette ) and
artifacts are very visible.

jwatte:
thanks for the suggestion.Your method
almost works :slight_smile: The scene is pretty complex
and it is not only the trees which have
transparency.Now,however,I don’t need to sort
single polygons of the trees, they are rendered
correctly (or at least artifacts are not
eye catching ).Less polys to sort and a smaller
number of batches. :slight_smile:

What amazes me is the number of commercial games that get away with this without it even being mentioned, like these horribly ugly trees from half life 2:

http://media.pc.gamespy.com/media/492/492830/img_2473378.html

And here’s what it should look like:

http://media.xbox.gamespy.com/media/482/482216/img_2104876.html

Rallisport uses trees that are presorted from a number of angles, like jwatte suggested. (The screenshot looks somewhat better than the actual game since it’s been taken at a higher resolution and then downsampled, the actual game still looks spectacular though)

You can’t say a game has cutting edge graphics if they haven’t solved these kind of problems.

/A.B.

HL2 doesn’t have “cutting” edge graphics all over the place. The only thing cutting edge I remember is some technique that borrows from radiosity rendering.

HL2’s fences also look bad. It’s just alpha testing.
I saw a fence in Doom3 at some point and it looked perfectly precise. I’m not sure if they actually used some geometry there. I stopped for a second and said “what the …???”

How many triangles do you think are in those Railsport trees? Those are amazing. I’d love to see a video of it in fine detail, so you can see (maybe) the temporal jumps as it switches sorting order.

bah those aint trees, u wanna see some real trees check this out :wink:
http://www.flipcode.com/cgi-bin/fcarticles.cgi?show=65237

check this out regarding vegetation:

http://www.sunflowers.de/shots.php?shot=paraworld_pw_002

How many triangles do you think are in those Railsport trees? Those are amazing. I’d love to see a video of it in fine detail, so you can see (maybe) the temporal jumps as it switches sorting order.
I think it’s somewhere between two and three hundred triangles. Most of the detail in the branches is done with textures. I think the trees are presorted from 8 angles which makes it pretty hard to find a viewpoint where the sorting is incorrect enough to be visible.

/A.B.

that dinosaur game looks amazing (perhaps the best ive ever seen), though i have a feeling itll look a lot less amazing in motion, ie billboards

I think you can use the alpha to coverage mechanism from the ARB_multisample extension. With a 4x AA it should gives you 16 transparency levels and you won’t need to sort your trees