Home Unreal Engine

Getting the most out of channels

Gestalt
polycounter lvl 11
Offline / Send Message
Gestalt polycounter lvl 11
I've read that a 1bit alpha channel can be stored in a DXT1 texture. Does anyone have experience doing this and could explain how to go about it? Would using the alpha of the diffuse in this way work well for transparency, masking, and the performance of those two?

I'd also like to use the blue channel of my normal maps for other things whenever possible. The first thing that comes to mind is for a height map, but I'm not sure I would generate a height map for everything.

Is there some type of map or method that could add crispness to the normal details? Normal details tend to average out and smooth, and while a specular map can be used to indicate that there are still details and surface variation, does anyone have a method of preserving the "sharpness" that I could use the blue channel for? I don't mean using a tiling texture to add noise; I mean making up for the detail shortcomings of normal maps.

Replies

  • LoTekK
    Options
    Offline / Send Message
    LoTekK polycounter lvl 17
    Gestalt wrote: »
    I've read that a 1bit alpha channel can be stored in a DXT1 texture. Does anyone have experience doing this and could explain how to go about it? Would using the alpha of the diffuse in this way work well for transparency, masking, and the performance of those two?
    Go to the texture viewer, and change the Texture Compression dropdown to TC_OneBitAlpha. 1 bit is obviously cheaper than using 8-bit alpha, but whether it's actually appropriate depends on the asset, really.
    I'd also like to use the blue channel of my normal maps for other things whenever possible. The first thing that comes to mind is for a height map, but I'm not sure I would generate a height map for everything.
    Do you mean for something like parallax occlusion mapping? In any case, if you're using your blue channel for something else, you'll need to make sure your shader is only looking at the RG channels and recalculating the blue component.
  • Gestalt
    Options
    Offline / Send Message
    Gestalt polycounter lvl 11
    Thanks! Any idea how the memory compares as opposed to using a DXT5? I found charts that compare the memory of DXT1 and DXT5 but I don't believe DXT1 with a 1bit alpha.
    Do you mean for something like parallax occlusion mapping? In any case, if you're using your blue channel for something else, you'll need to make sure your shader is only looking at the RG channels and recalculating the blue component.

    I'm really asking for suggestions here. Using a heightmap for parallax is what I've thought of so far, but I wasn't sure if there were other uses that people had for the space. I was curious if anyone had a method of preserving details (maybe with some type of greyscale bump? I really don't know). Just looking for ideas.
  • LoTekK
    Options
    Offline / Send Message
    LoTekK polycounter lvl 17
    DXT1 w/Alpha simply sacrifices 1 of the color bits to stick in the alpha channel, so RGB565 becomes RGBA5551 instead. In other words, it's exactly the same on-disk cost. DXT5 is double that, though you're still paying the same run-time memory cost for all formats.

    I'll have to defer to someone else for the second bit, though.
  • PointlessReboot
    DXT1 compression uses 2 bits per pixel giving 3 colours, now only two colours are stored the other two are generated. The colours are stored in 565 format. The other two colours are generated from the stored two colours C0 and C1. usually C0 is > C1. For textures with alpha C0 can be < C1 in this case you only have C2 as C3 is transparent black.

    So there is no difference in the quality of the of the colours stored, but you will see a loss in the number of colours that can be generated for a given 4x4 block when a zero alpha is required.
  • PointlessReboot
    For the maths geeks, the colours are calculated as follows

    If C0 > C1 then we have 4 colours in a 4x4 block
    C0 = Stored 565
    C1 = Stored 565
    C2 = 2/3 C0 + 1/3 C1
    C3 = 1/3 C0 + 2/3 C1

    When Zero alpha is needed in the 4x4 block then the following is used

    if C0 < C1 then we have 3 colours in a 4x4 block and 0
    C0 = Stored 565
    C1 = Stored 565
    C2 = 1/2 C0 + 1/2 C1
    C3 = 0

    Hope this helps, for more info you can read here
  • PointlessReboot
    Also to answer the question on textures memory used, I will list some of the common texture formats and the memory they consume

    R8G8B8A8 - 1:1 no compression
    - 2048 x 2048 = 16.0MB
    - 1024 x 1024 = 4.0MB
    - 512 x 512 = 1.000MB

    DXT1 - 8:1 compression (optional 1 bit alpha)
    - 2048 x 2048 = 2.0MB
    - 1024 x 1024 = 0.5MB
    - 512 x 512 = 0.125MB

    DXT5 - 4:1 compression (8 bit interpolated alpha)
    - 2048 x 2048 = 4.0MB
    - 1024 x 1024 = 1.0MB
    - 512 x 512 = 0.250MB

    G8 - 1:1 no compression, single channel
    - 2048 x 2048 = 4.0MB
    - 1024 x 1024 = 1.0MB
    - 512 x 512 = 0.250MB
  • imbueFX
    Options
    Offline / Send Message
    imbueFX polycounter lvl 5
    So does this mean when using DXT1, the green channel holds better detail than red and blue? We had this talk at our last studio, but I could never find a real answer. We just knew that some channels held less than others.
  • Butthair
    Options
    Offline / Send Message
    Butthair polycounter lvl 11
    http://udn.epicgames.com/Three/TextureOptimizationTechniques.html
    One useful note about channel packing textures, the compression format we use is DXT1, which, through a quirk in the compression scheme, stores an extra bit of data in the green channel of the texture. Thus, if you have an emissive that deserves some higher frequency detail or is delicate, put it in the green channel for the highest quality.

    I've also found from various places that the blue channel gets altered a bit, creating possible artefacts. I've noticed this myself when trying to use the blue channel of a normal map for something else (for instance a specular map). (Importing as default rather than NormalMap reduced this.)
  • imbueFX
    Options
    Offline / Send Message
    imbueFX polycounter lvl 5
    Awesome! Thanks for the link as well.
Sign In or Register to comment.