Search Unity

Diffuse buffer alpha channel unused...not anymore?

Discussion in 'General Graphics' started by grllle, Nov 1, 2016.

  1. grllle

    grllle

    Joined:
    May 4, 2015
    Posts:
    28
    Hey there!

    Until 5.2 the doc stated the diffuse buffer as
    RT0, ARGB32 format: Diffuse color (RGB), unused (A)

    I planed to use the alpha channel for project specific data just to realize that it is used for "occlusion" now. I would like to avoid additional passes or render textures so i want to ask what kind of occlusion is meant?
    I don't use occlusion culling, in this case i could rewrite the standard shader and (mis)use the alpha channel.
    Or will i f*ck up SSAO doing so?
     
  2. grllle

    grllle

    Joined:
    May 4, 2015
    Posts:
    28
    Or is it used for the occlusion map? But those existed before 5.2...
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
    The alpha of RT0 is used for storing the ambient occlusion from the material so it can be used later in the deferred pipeline in later versions of Unity 5. Generally ambient occlusion is only applied to ambient lighting and reflections, and in Unity 5.0 the ambient lighting and reflections were rendered out at the same time as the rest of the GBuffer, so the AO wasn't "needed" anymore. However Unity 5.2's per-pixel reflection probes (and later screen space reflections) do need it so it as those are applied later. However the documentation was not updated until 5.3.

    The only unused channel is the alpha of the normal map ... which only has 2 bits of precision. (It can be 0.0, 0.333, 0.667, or 1.0, and that's it.)

    It's possible to reuse other channels if you're okay with modifying internal Unity shaders & image effects, like you could reconstruct the world normal z value from the x and y DXT5nm style, and use that alpha as a positive / negative flip, or do some bit packing and reduce the roughness or occlusion to 4 bits and use the other 4 bits.
     
  4. grllle

    grllle

    Joined:
    May 4, 2015
    Posts:
    28
    Thank you very much for your detailed explanation!
    I want to use a bit mask within a command buffer, so i think i won't get away using an extra pass and render texture.