Search Unity

Feedback Error in Normal Strength node -- results not normalized?

Discussion in 'Shader Graph' started by abovenyquist, Jul 27, 2019.

  1. abovenyquist

    abovenyquist

    Joined:
    Feb 13, 2014
    Posts:
    14
    The Shader Graph docs list this as a possible implementation of the Normal Strength node:

    https://docs.unity3d.com/Packages/com.unity.shadergraph@5.3/manual/Normal-Strength-Node.html

    Out = {precision}3(In.rg * Strength, lerp(1, In.b, saturate(Strength)));

    Indeed, this matched the associated C# code that generates the HLSL strings.

    The problem with this is that the result is not a unit-length vector, except in rare and particular circumstances.

    Compare and contrast this with a line in the old built-in pipeline UnpackScaleNormal function, which guarantees a unit length normal.

    normal.z = sqrt(1.0 - saturate(dot(normal.xy, normal.xy)));

    Is the expectation that the user of the "Normal Strength" node is expected to pass the result to a normalize node, which could potentially be skipped to gain performance at the expense of accuracy? If so, I think it would be good for instructions to explicitly say so. Maybe there could be a Normal Strength Accurate node that's different than the Normal Strength node, which could be renamed Normal Strength Approximate?
     
    bgolus likes this.