Results 1 to 6 of 6

Thread: render order + alpha blending

  1. #1

    render order + alpha blending

    Hi all.

    I have implemented billboarding in my engine and now i want to test it by creating a small piece of land with grass billboards on it.
    But this wasn't as easy as i thought.

    As Usual i'll provide a picture:



    Most of the texture used for this billboard is transparent.
    When rendered, the transparent pixel Z coords are written to the zbuffer. so when an billboard is rendered behind this one, a whole corner is cut away by the alpha-ed part of another billboard.

    Can i prevent alpha-ed pixels from being added to the zbuffer??
    Or is there an other sollution? :?

    Does anyone have better grass/tree billboard textures because this one sucks. A good tutorial might be even better.

    Thanx in advance.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  2. #2

    render order + alpha blending

    You could use alpha test to kill pixels that should not be rendered at all. But probably this will not solve your problem as non-transparent parts still put their Z-coordinates (which is constant as I understand) in Z-buffer. It will be more correctly to render background first and when your flower/grass decals with Z-test enabled and Z-write disabled (and probably with alpha test still enabled).
    There are only 10 types of people in this world; those who understand binary and those who don't.

  3. #3

    render order + alpha blending

    The solution is what you put as the topic of this thread: to order your billboards by depth. Just sort them by their z value and draw from back to front. This will only work for billboards that are oriented towards the camera though.

  4. #4

    render order + alpha blending

    I had the same problems when working on my grassengine.

    Ordering by Z-Buffer would help here, but the more grass-billboards you have, the more CPU-Power you need to order the billboards (you have to order every frame!). So if its just <100 then no problem, but with thousands it will decrease your performance a lot!

    I "solved" this problem just by setting Alpharef to 254 befor rendering the grass and resetting Alpharef to 1 after rendering.

    This of course can cause other artifacts, but for my needs it was ok.
    <a href="http://www.greatgamesexperiment.com/game/Valgard/?utm_source=gge&amp;utm_medium=badge_game"><img border="0" alt="GGE" title="GGE" src="http://static.greatgamesexperiment.com/badge/game/valgard/gge400x56.png"></a>

  5. #5

    render order + alpha blending

    Thanks for the alphatesting tip. that's what i was looking for

    I've read on MSDN that from back-to-front rendering is computational expensive, because of the many zbuffer/framebuffer manipulations required, so i'm not very keen on fixing it that way.

    But i still have crappy looking billboards. When i set alpharef to 255 and the comparison function to greaterequal then my billboards look more like heads of lettuce.

    Does anyone know how to make good billboards/textures??
    I like to know some good texture resources but tutorials are probably better if anyone knows one. :?
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  6. #6

    render order + alpha blending

    I've read on MSDN that from back-to-front rendering is computational expensive, because of the many zbuffer/framebuffer manipulations required, so i'm not very keen on fixing it that way.
    Drawing back-to-front with the zbuffer enabled has no sense coz the pixel rejection will never happen; so if you are going to sort the traingles your self then dissable the zbuffer.

    You only need to sort the visible alphablended triangles, and draw them after the opaques ones.

    I think people at some point need to sort triangles by texture or by stages anyway, so including the alphablend attrib in the sorting criteria is not big deal.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •