Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-05-10 20:57:17 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-05-10 20:57:17 +0400
commiteaa6479ae3482b643e6e5d553f09b1a1100b48ee (patch)
treea7fcb0702a4b463df1777f395575b4b5d0d9386d /intern/cycles/kernel/svm/svm_displace.h
parent2f9f3dd5903eeec514640de05a45cfd21d168397 (diff)
Cycles: bump node changes to add a Distance input that controls the overall displacement
distance, and an Invert option to invert the bump effect.
Diffstat (limited to 'intern/cycles/kernel/svm/svm_displace.h')
-rw-r--r--intern/cycles/kernel/svm/svm_displace.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/intern/cycles/kernel/svm/svm_displace.h b/intern/cycles/kernel/svm/svm_displace.h
index 5d0300c5855..ee3c0c6fd21 100644
--- a/intern/cycles/kernel/svm/svm_displace.h
+++ b/intern/cycles/kernel/svm/svm_displace.h
@@ -24,7 +24,10 @@ __device void svm_node_set_bump(KernelGlobals *kg, ShaderData *sd, float *stack,
{
#ifdef __RAY_DIFFERENTIALS__
/* get normal input */
- float3 normal_in = stack_valid(node.y)? stack_load_float3(stack, node.y): sd->N;
+ uint normal_offset, distance_offset, invert;
+ decode_node_uchar4(node.y, &normal_offset, &distance_offset, &invert, NULL);
+
+ float3 normal_in = stack_valid(normal_offset)? stack_load_float3(stack, normal_offset): sd->N;
/* get surface tangents from normal */
float3 Rx = cross(sd->dP.dy, normal_in);
@@ -45,10 +48,15 @@ __device void svm_node_set_bump(KernelGlobals *kg, ShaderData *sd, float *stack,
float absdet = fabsf(det);
float strength = stack_load_float(stack, strength_offset);
- strength = clamp(strength, 0.0f, 1.0f);
+ float distance = stack_load_float(stack, distance_offset);
+
+ if(invert)
+ distance *= -1.0f;
+
+ strength = max(strength, 0.0f);
/* compute and output perturbed normal */
- float3 normal_out = normalize(absdet*normal_in - signf(det)*surfgrad);
+ float3 normal_out = normalize(absdet*normal_in - distance*signf(det)*surfgrad);
normal_out = normalize(strength*normal_out + (1.0f - strength)*normal_in);
stack_store_float3(stack, node.w, normal_out);
#endif