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:
Diffstat (limited to 'intern/cycles/kernel/svm/svm_displace.h')
-rw-r--r--intern/cycles/kernel/svm/svm_displace.h26
1 files changed, 19 insertions, 7 deletions
diff --git a/intern/cycles/kernel/svm/svm_displace.h b/intern/cycles/kernel/svm/svm_displace.h
index b1677f67eca..92f23990ad1 100644
--- a/intern/cycles/kernel/svm/svm_displace.h
+++ b/intern/cycles/kernel/svm/svm_displace.h
@@ -20,23 +20,35 @@ CCL_NAMESPACE_BEGIN
/* Bump Node */
-__device void svm_node_set_bump(ShaderData *sd, float *stack, uint c_offset, uint x_offset, uint y_offset)
+__device void svm_node_set_bump(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
{
#ifdef __RAY_DIFFERENTIALS__
+ /* get normal input */
+ float3 normal_in = stack_valid(node.y)? stack_load_float3(stack, node.y): sd->N;
+
+ /* get surface tangents from normal */
+ float3 Rx = cross(sd->dP.dy, normal_in);
+ 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);
+
float h_c = stack_load_float(stack, c_offset);
float h_x = stack_load_float(stack, x_offset);
float h_y = stack_load_float(stack, y_offset);
- float3 Rx = cross(sd->dP.dy, sd->N);
- float3 Ry = cross(sd->N, sd->dP.dx);
-
+ /* 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 *= 0.1f; /* todo: remove this factor */
-
+ surfgrad *= intensity;
float absdet = fabsf(det);
- sd->N = normalize(absdet*sd->N - signf(det)*surfgrad);
+
+ /* compute and output perturbed normal */
+ float3 outN = normalize(absdet*normal_in - signf(det)*surfgrad);
+ stack_store_float3(stack, node.w, outN);
#endif
}