diff options
author | Thomas Dinges <blender@dingto.org> | 2013-11-09 17:14:00 +0400 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2013-11-09 17:14:00 +0400 |
commit | cc7b2a0b046f9eb0548b8a1e84c4deb5754487c1 (patch) | |
tree | 690d653011978ab63979d4f6886f3183c5a66e15 /intern/cycles/kernel/svm/svm_fresnel.h | |
parent | 396fb315c5f0267a0511eda87221c8a2836c6f21 (diff) |
Cycles / Fresnel Node:
* Add a "Normal" Input to the Fresnel node.
* Fix for the Fresnel GLSL code (normalize the Incoming vector).
Patch #37384 by Philipp Oeser (lichtwerk) , thanks!
Diffstat (limited to 'intern/cycles/kernel/svm/svm_fresnel.h')
-rw-r--r-- | intern/cycles/kernel/svm/svm_fresnel.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/intern/cycles/kernel/svm/svm_fresnel.h b/intern/cycles/kernel/svm/svm_fresnel.h index 549c0351d83..d97d6a3738f 100644 --- a/intern/cycles/kernel/svm/svm_fresnel.h +++ b/intern/cycles/kernel/svm/svm_fresnel.h @@ -18,13 +18,17 @@ CCL_NAMESPACE_BEGIN /* Fresnel Node */ -__device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset, uint ior_value, uint out_offset) +__device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset, uint ior_value, uint node) { + uint normal_offset, out_offset; + decode_node_uchar4(node, &normal_offset, &out_offset, NULL, NULL); float eta = (stack_valid(ior_offset))? stack_load_float(stack, ior_offset): __uint_as_float(ior_value); + float3 normal_in = stack_valid(normal_offset)? stack_load_float3(stack, normal_offset): sd->N; + eta = fmaxf(eta, 1.0f + 1e-5f); eta = (sd->flag & SD_BACKFACING)? 1.0f/eta: eta; - float f = fresnel_dielectric_cos(dot(sd->I, sd->N), eta); + float f = fresnel_dielectric_cos(dot(sd->I, normal_in), eta); stack_store_float(stack, out_offset, f); } |