Search Unity

Official Normal map compositing using the surface gradient framework in Shader Graph

Discussion in 'Shader Graph' started by mortenm, Nov 21, 2019.

  1. mortenm

    mortenm

    Unity Technologies

    Joined:
    Nov 6, 2015
    Posts:
    15
    Trying to correctly combine/blend two or more normal maps in a shader has historically been a difficult and frustrating problem. Particularly for bump maps of different forms such as tangent space, object space, triplanar projection, parallel projection (decals) or 3D texture.
    Traditionally real-time graphics has only supported tangent space normal mapping on UV0 since it is customary to compute one tangent space per vertex based on UV0.
    The surface gradient based framework defines a new approach which makes doing correct blends easy/intuitive to both technical artists and graphics engineers even in advanced scenarios where multiple sets of texture coordinates are used (procedural texure coordinates too) and different forms of bump maps as described above.
    Read more in this blog post.

    Morten
     
  2. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    So I have implemented this into a number of large shader frameworks now, and maybe I'm missing something or doing something wrong, but I find the visual difference very hard to spot in most cases.

    For instance, toggling between regular tangent space normal maps and surface gradients on a basic terrain shader with height blending is visually identical. I suspect this is because the blend areas are small between textures due to the height blending. However, even when doing a linear blend it's not noticable.

    Adding triplanar to the mix, the difference is again visually identical, which is surprising to me.

    The one place I do see a difference is when layering normal maps - like detail texturing, or using macro normal maps to break up tiling. Here, the normal direction is a bit more muted and doesn't blow out as easy, but again I find the difference relatively minor.

    In all of these cases, I'm converting from a tangent space normal map into a surface gradient using the interpolated TBN matrix, rather than say storing derivative maps directly, and I'm curious if this is causing my results to be generally the same?
     
  4. MaxRoetzler

    MaxRoetzler

    Joined:
    Jan 3, 2010
    Posts:
    136
    I've been playing around with the surface gradient framework and the photoshop action from the Doing More With Less Unity blog post. If I convert the cliff normal map texture using the photoshop action the results look the same as using a tangent space normal map in a standard shader. However, when doing the same with spherical normals instead, the results are wrong.

    If I use the original tangent space normal map of the sphere and convert it to derivatives in the shader, the result looks as expected. Is this an issue with the photoshop action?
     

    Attached Files:

  5. MaxRoetzler

    MaxRoetzler

    Joined:
    Jan 3, 2010
    Posts:
    136
    Never mind, doing the normal map conversion in a shader and saving the result gives the same issues. So it seems to be due to the lack of texture precision. After observing the example image in the 'Doing More With Less' blog post, similar issues are noticeable there as well.
    SurfaceGradients2.jpg