Home Technical Talk

An explanation on alpha maps? flippering

polycounter lvl 14
Offline / Send Message
NAIMA polycounter lvl 14
Hi I was wondering for a problem , in Second life I have seen that most of the alpha texture have a problem due to the alpha sorting level meaning that when two transparent textures overlap they flip somehow on the view , this I read was due to not using alpha textures that are just like 1 bit black or white but also using shades of gray that then cause the problem , tough tI have seen that in the game crysis the palm textures in dds format do use a shaded alpha of severall gray levels but do not have this weird flippering effect ingame why is that happening in SL ?

Replies

  • Eric Chadwick
    Options
    Offline / Send Message
    IIRC Crysis uses alpha test for its foliage, which avoids alpha sorting problems... but it only gives you a hard edge, no soft transparency. Alpha test means each screen pixel is tested by the shader to tell if it should be on or off, using some threshold value. Alpha pixels darker than the threshold are clipped out, brighter pixels are left alone.

    Even though it's only on vs. off, if you use a smooth grayscale alpha you get a smoother result when it's clipped. If you use an alpha that's only black vs. white you tend to get large stairsteps when it is alpha tested.

    The other common method for alpha transparency is alpha blend, which gives you soft-edged transparency and translucency, but also usually has alpha sorting problems as well. The renderer has to figure out what's behind each pixel, but it usually just compares the centers of each object to figure out what's in front vs. behind, instead of each pixel.

    Been meaning to get some of this into the wiki with purdy pictures to explain it. It's pretty easy to understand once someone explains it well, which I'm probably not. :)
  • Eric Chadwick
    Options
    Offline / Send Message
    OK, updated the wiki. Need to add pics though.
  • NAIMA
    Options
    Offline / Send Message
    NAIMA polycounter lvl 14
    Thanks a lot for the explanation tough but I still not very clear why in Crysis the alpha maps with not hard edged borders on the images do not look so hard edged in game .... or am I wrong?
  • Eric Chadwick
    Options
    Offline / Send Message
    The original CryEngine (Crysis) seemed to use a combo of alpha test and alpha blend. A shot from the demo.

    CryEngine 2 (Crysis Warhead, Crysis Wars) uses a deferred renderer, which allows them to smooth out the edges after they're alpha-tested.
    16fig07.jpg
    Here's an explanation along with lots of other cool info about their vegetation:
    GPU Gems 3: Vegetation Procedural Animation and Shading in Crysis

    More discussion about alpha in this thread.
    Transparencies, sorting and intersecting
  • achillesian
    Options
    Offline / Send Message
    i've decided that alpha test sounds better because of the stupid sorting problems i'm having with trees im making for scenes in unity, now whether a plane is alpha test or alpha blend is that dependent on the file type (image) or the program displaying maya/unity
  • achillesian
    Options
    Offline / Send Message
    i think i actually found the feature for unity, in the description they never actually call it alpha test, probably because it has the cool slider thing

    http://unity3d.com/support/documentation/Components/shader-TransCutDiffuse.html
  • Eric Chadwick
    Options
    Offline / Send Message
    Alpha test is controlled by the shader, not by the texture. A shader can be designed to have a toggle for alpha test, and a toggle for alpha blend, so you could choose either or both depending on what you wanted.

    The cool slider thing is the same thing as the "threshold" I mentioned. You can see what this does to your alpha if in Photoshop you go to the Image menu and choose Adjustments: Threshold and move the slider.

    The cool thing about alpha test is it cuts off the edge at the screen pixel level, so the edge appears to get rounder as you get closer to it, rather than just being the same resolution as your original texture.

    Edit... yeah sorting can be a pain in the ass! :)
Sign In or Register to comment.