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
path: root/intern
diff options
context:
space:
mode:
authorThomas Dinges <blender@dingto.org>2013-11-09 17:14:00 +0400
committerThomas Dinges <blender@dingto.org>2013-11-09 17:14:00 +0400
commitcc7b2a0b046f9eb0548b8a1e84c4deb5754487c1 (patch)
tree690d653011978ab63979d4f6886f3183c5a66e15 /intern
parent396fb315c5f0267a0511eda87221c8a2836c6f21 (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')
-rw-r--r--intern/cycles/kernel/svm/svm_fresnel.h8
-rw-r--r--intern/cycles/render/nodes.cpp7
2 files changed, 12 insertions, 3 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);
}
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 5352840d2cb..4919222e81c 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -3166,12 +3166,17 @@ FresnelNode::FresnelNode()
void FresnelNode::compile(SVMCompiler& compiler)
{
+ ShaderInput *normal_in = input("Normal");
ShaderInput *ior_in = input("IOR");
ShaderOutput *fac_out = output("Fac");
compiler.stack_assign(ior_in);
compiler.stack_assign(fac_out);
- compiler.add_node(NODE_FRESNEL, ior_in->stack_offset, __float_as_int(ior_in->value.x), fac_out->stack_offset);
+
+ if(normal_in->link)
+ compiler.stack_assign(normal_in);
+
+ compiler.add_node(NODE_FRESNEL, ior_in->stack_offset, __float_as_int(ior_in->value.x), compiler.encode_uchar4(normal_in->stack_offset, fac_out->stack_offset));
}
void FresnelNode::compile(OSLCompiler& compiler)