I have a boulevard walkthrough with trees at the sides of the boulevard. The trees consist very small leaves on their branches.

I want to create a movie of the boulevard, but far tree leaves flicker very frequeny!
Using mipmaps is out of the question to me, because it creates a halo around the leaf texture (because the trasparent texels are blended with the leaf texels).
In addition the mipmaps magnify the leaves size when looking from not near distance.

The reason for the flickering is the z-buffer, which has 24 bits (This is the maximum I have succeeded to get).

In order to solve the problem I have decided to render my scene as follows:

I splitted my frustum into very small sub frustums and rendered to each one of the frustums from back to front and accumulated the color buffer.

no matter how small how make my sub frustums the tree leaves don't stop to flicker.

How can I stop the flickering without using mipmaps???
(about sorting the leaves from back to front, it seems hard to me http://www.opengl.org/discussion_boards/ubb/frown.gif, as each tree consists dozens of thousands of leaves)

Thanks,

Mikkel Gjoel

01-18-2004, 12:11 PM

Maybe the solution is to use mipmaps, but remove the artifacts due to mipmapping. A way to do this is the use the euclidian distance transform (if you don't know it, look it up, it's rather simple) - to preprocess the textures for use with mipmapping.

If you're sure about the problem being the z-buffer, mipmaps won't help. Are you using a "linear" or "nearest" min-filter? Linear is better.

JanHH

01-18-2004, 02:53 PM

I render trees the same way and far away trees do not flicker, no tree is flickering at all http://www.opengl.org/discussion_boards/ubb/wink.gif So you must be doing something wrong.

Do you use alpha test? This could remove the "halo".

Jan

jwatte

01-18-2004, 04:53 PM

The problem is likely that the tree leaves sit on a texture surrounded by non-leaf color, which causes halos when filtering. Make all of the texture greenish (leaf color), even where it is transparent, and MIP mapping will work fine.

rpbarbati

02-03-2012, 08:03 PM

Perhaps you should consider "baking" the tree leaves - i.e. pre-render them into a new bitmap and use that for your animation.

Using the pre-baked image with mipmapping may produce a better result for far trees also.

remdul

02-06-2012, 02:53 AM

Assuming the flicker you see is actually 'shimmer' (or 'jitter') of the tree leaf textures, the proper way to solve this is to enable mipmapping. At any rate, it has little to do with z-buffer (and z-fighting as you suggested).

Enabling anisotropic filtering should reduce the 'halo' effect with mipmapping you describingd. See http://www.opengl.org/wiki/Texture#Anisotropic_filtering .

Also ensure that the leaf textures have clean alpha-edges, and if possible non-tiling (change GL_WRAP to GL_CLAMP_TO_EDGE). Mipmapping can sometimes cause pixels outside the polygon boundaries to spill inwards, producing the halo you describe. Typically, try to keep at ~8 pixels clear of the image borders.

Play with the alpha-test reference value (glAlphaFunc) to see if that prevents the leafs from becoming invisible or, conversely, to thick.

Balancing out the average alpha value of the texture may also work for you (i.e. if you scale down the image in PhotoShop down to 1x1 pixels, the alpha channel value should be '127', mid-gray).

Also, what Jon Watte mentioned above. If you use color-keying to produce the alpha channel, certainly replace the mask color. The average of the color channel (minus mask color of course) should be sufficient in most cases. Avoid pre-multiplied alpha.

Also, as Mikkel Gjoel suggested, distance textures may produce cleaner alpha-tested edges (see: http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf ). I tried this for vegetation, and the improvement wasn't as noticable as I expected. It seems to work better with more refined shapes such as glyphs. So YMMV.

I've had much luck with alpha-to-coverage transparancy. This requires enabling multisampling however, though will as side effect also improve your image quality in other areas. See http://www.opengl.org/wiki/Multisampling . Tip: with alpha-to-coverage transparancy you may need to scale the alpha 2x. You can do that in your GLSL shader, or if you use FFP, tweak the alpha test reference value (glAlphaFunc).