Search Unity

Question Creating hdrp-ready normal map at runtime

Discussion in 'High Definition Render Pipeline' started by benthecassidy, Jan 29, 2023.

  1. benthecassidy

    benthecassidy

    Joined:
    Aug 17, 2022
    Posts:
    2
    Hi, I want to:
    • Generate a RenderTexture containing a normal map made from a height map, in a compute shader.
    • Use this normal map with the HDRP Lit shader
    So far: I've run into these issues:
    • The shader needs it in a weird format (DXT5 or something)
    • I can't find a way to produce the normal map in this format
    • I can't see an easy way to alter the shader to allow a normal map of a basic format
    Passing in an ARGB32 makes the normals wonky, and passing in an ARGBFloat seems to crash the renderer (the whole scene turns all black)

    Anyone have any ideas? Seems like something that really should be doable.
     
  2. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
    The normal map for the HDRP/Lit shader is no different than other normal maps in Unity or even any game engine.
    It stores the (usually tangent space) normal map packed in RGB normalized (0 to 1) texture.
    The math to convert from a 3D normal value to RGB is : color = 0.5 + 0.5 * normal.

    There is no specific texture compression format requirement if you meet this data layout.