diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-09 18:05:37 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-09 18:05:37 +0400 |
commit | d236b4d60fb188fcd2bc0aba1ebdff58c8220f60 (patch) | |
tree | 1d2d20e3e5f36a99810df39f0511a940aeb98e5a /intern/cycles/kernel/svm | |
parent | d326d92b2f2aeb94396ddedc1221681c82e250d9 (diff) |
Cycles bump node: change the Strength value to work better, previously it would
give results that were either too weak or too strong, this makes it give more
predictable results. The downside is that it breaks backwards compatibility but
the previous behavior was almost broken.
Diffstat (limited to 'intern/cycles/kernel/svm')
-rw-r--r-- | intern/cycles/kernel/svm/svm_displace.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/intern/cycles/kernel/svm/svm_displace.h b/intern/cycles/kernel/svm/svm_displace.h index 92f23990ad1..5d0300c5855 100644 --- a/intern/cycles/kernel/svm/svm_displace.h +++ b/intern/cycles/kernel/svm/svm_displace.h @@ -31,8 +31,8 @@ __device void svm_node_set_bump(KernelGlobals *kg, ShaderData *sd, float *stack, float3 Ry = cross(normal_in, sd->dP.dx); /* get bump values */ - uint c_offset, x_offset, y_offset, intensity_offset; - decode_node_uchar4(node.z, &c_offset, &x_offset, &y_offset, &intensity_offset); + uint c_offset, x_offset, y_offset, strength_offset; + decode_node_uchar4(node.z, &c_offset, &x_offset, &y_offset, &strength_offset); float h_c = stack_load_float(stack, c_offset); float h_x = stack_load_float(stack, x_offset); @@ -41,14 +41,16 @@ __device void svm_node_set_bump(KernelGlobals *kg, ShaderData *sd, float *stack, /* compute surface gradient and determinant */ float det = dot(sd->dP.dx, Rx); float3 surfgrad = (h_x - h_c)*Rx + (h_y - h_c)*Ry; - float intensity = stack_load_float(stack, intensity_offset); - surfgrad *= intensity; float absdet = fabsf(det); + float strength = stack_load_float(stack, strength_offset); + strength = clamp(strength, 0.0f, 1.0f); + /* compute and output perturbed normal */ - float3 outN = normalize(absdet*normal_in - signf(det)*surfgrad); - stack_store_float3(stack, node.w, outN); + float3 normal_out = normalize(absdet*normal_in - signf(det)*surfgrad); + normal_out = normalize(strength*normal_out + (1.0f - strength)*normal_in); + stack_store_float3(stack, node.w, normal_out); #endif } |