Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Resolved How performance-heavy is Normal Reconstruct?

Discussion in 'Shader Graph' started by Horus_Sungod42, Jun 7, 2019.

  1. Horus_Sungod42

    Horus_Sungod42

    Joined:
    Oct 30, 2014
    Posts:
    75
    Hello, for a shader's detail texture, I'd want to use a single map for both the albedo and the normal map, and the result seems to work well.

    It use 1 channel an the albedo and 2 channels as the normal map, which are sent in the Reconstruct Normal node. This seems similar to what the HDRP's standard shader uses.

    Question is: is the calculation for the "Reconstruct Normal" performed every frame? If so, is it slow?
    If so, I imagine this is a fairly non-performant solution. Or maybe it is done every frame, but it is really light CPU/GPU-wise and is actually performant.

    (Without the ability to see a shader's number of operations, I'm a bit at a loss whether these texture-packing shenanigans are effective or not.)

    Thank you
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    7,253
    What user case you have, to need recalculate normals every frame?

    There isn't clear answer to your question, due to too many variables, and unknowns. Best bet is to profile and test for what you need.
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,363
    If you're referring to the Normal Reconstruct Z node, pretty much every normal mapped shader used in any non-mobile game made in the last 15+ years roughly uses the same math in that node.
     
  4. Horus_Sungod42

    Horus_Sungod42

    Joined:
    Oct 30, 2014
    Posts:
    75
    We moved away from that method with further testing, the normal maps created by this node seem bugged and lack volume.

    I'll just use a standard normal map for the detail texture, and another map for the albedo.

    Thank you
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,363
    If your packing both albedo and normals into one texture, your texture is presumably set to sRGB. Normal maps need to be linear to work properly.
     
unityunity