Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question Creating hdrp-ready normal map at runtime

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

  1. benthecassidy


    Aug 17, 2022
    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


    Unity Technologies

    Oct 3, 2017
    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.