Search Unity

How to access RGMB cubemap data... are HDRs still stored in RGBM?

Discussion in 'Scripting' started by DrDecipher, Sep 15, 2017.

  1. DrDecipher

    DrDecipher

    Joined:
    Dec 5, 2012
    Posts:
    54
    Question:
    How do I access the RGBM data of an HDR cubemap.
    or
    What new format are these stored in?

    Several of the RGBM options have been removed from the TextureImporter. I need to get to the RGBM textures stored in a cube map if they still exist.

    Process:
    Load HDR to CubeMap in editor manually(This used to convolute the map and store it in RGBM)
    In an editor script I am accessing each side of the cubemap and it's mip levels and saving them as pngs.

    Code (CSharp):
    1.  int width = cubemap.width;
    2.             int height = cubemap.height;
    3.             Debug.Log(cubemap.format);
    4.             //Debug.Log(Application.dataPath + "/" +cubemap.name +"_PositiveX.png");
    5.             Texture2D tex0 = new Texture2D(width, height, TextureFormat.ARGB32, false);
    6.             Debug.Log( (cubemap.GetPixels(CubemapFace.PositiveX, 0)).Length );
    7.             tex0.SetPixels(cubemap.GetPixels(CubemapFace.PositiveX, 0 ));  
    8.             bytes = tex0.EncodeToPNG();    
    9.             File.WriteAllBytes(Application.dataPath + "/"  + cubemap.name +"_PositiveX0.png", bytes);
    The results are a 24bit RGB PNG with no alpha. I would have expected to get an RGBM (png with alpha) out of the process.

    I've looked at this through the shader as well and there is nothing in the alpha channel of a cubemap, yet it is rendering in HDR with range.

    Thanks,
    Tharyn