Fix T54107: bevel shader + normal map gives wrong result.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Tue, 20 Feb 2018 19:24:40 +0000 (20:24 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 21 Feb 2018 16:56:26 +0000 (17:56 +0100)
intern/cycles/kernel/shaders/node_bevel.osl
intern/cycles/kernel/svm/svm_bevel.h

index a5b185b6b4c8d80aa8459e46bd11adb4d575801e..9c4ca15be1738a94637c59b75bed5a4487e8de70 100644 (file)
@@ -23,9 +23,9 @@ shader node_bevel(
        output normal NormalOut = N)
 {
        /* Abuse texture call with special @bevel token. */
-       NormalOut = (normal)(color)texture("@bevel", samples, Radius);
+       vector bevel_N = (normal)(color)texture("@bevel", samples, Radius);
 
        /* Preserve input normal. */
-       NormalOut = normalize(N + (NormalOut - NormalIn));
+       NormalOut = normalize(NormalIn + (bevel_N - N));
 }
 
index dcfe4ad71b8b9e56885fb7282404bba553e15c27..6d5a10db98fa7124d761c5c4c4e994fc84feaacb 100644 (file)
@@ -216,7 +216,7 @@ ccl_device void svm_node_bevel(
        if(stack_valid(normal_offset)) {
                /* Preserve input normal. */
                float3 ref_N = stack_load_float3(stack, normal_offset);
-               bevel_N = normalize(sd->N + (bevel_N - ref_N));
+               bevel_N = normalize(ref_N + (bevel_N - sd->N));;
        }
 
        stack_store_float3(stack, out_offset, bevel_N);