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-22 03:33:28 +0400
committerThomas Dinges <blender@dingto.org>2013-11-22 03:33:28 +0400
commitbd5da19d86e5c490e4945bb4befc50b6eac48a86 (patch)
tree7ec0c54ccfb020f96d0625bb8dd3d4eb796dfd31 /intern
parenta08750addf764c8d02552b03f09b732b1cf76507 (diff)
Cycles: Add a "Normal" input socket to the Layer Weight node + GLSL drawing code.
Patch by lichtwerk (Philipp Oeser). Differential Revision: http://developer.blender.org/D28
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/kernel/svm/svm_fresnel.h12
-rw-r--r--intern/cycles/render/nodes.cpp8
2 files changed, 13 insertions, 7 deletions
diff --git a/intern/cycles/kernel/svm/svm_fresnel.h b/intern/cycles/kernel/svm/svm_fresnel.h
index bb70a3faa2a..0a3d576cfe1 100644
--- a/intern/cycles/kernel/svm/svm_fresnel.h
+++ b/intern/cycles/kernel/svm/svm_fresnel.h
@@ -39,10 +39,12 @@ ccl_device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node)
{
uint blend_offset = node.y;
uint blend_value = node.z;
- float blend = (stack_valid(blend_offset))? stack_load_float(stack, blend_offset): __uint_as_float(blend_value);
- uint type, out_offset;
- decode_node_uchar4(node.w, &type, &out_offset, NULL, NULL);
+ uint type, normal_offset, out_offset;
+ decode_node_uchar4(node.w, &type, &normal_offset, &out_offset, NULL);
+
+ float blend = (stack_valid(blend_offset))? stack_load_float(stack, blend_offset): __uint_as_float(blend_value);
+ float3 normal_in = (stack_valid(normal_offset))? stack_load_float3(stack, normal_offset): sd->N;
float f;
@@ -50,10 +52,10 @@ ccl_device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node)
float eta = fmaxf(1.0f - blend, 1e-5f);
eta = (sd->flag & SD_BACKFACING)? eta: 1.0f/eta;
- f = fresnel_dielectric_cos(dot(sd->I, sd->N), eta);
+ f = fresnel_dielectric_cos(dot(sd->I, normal_in), eta);
}
else {
- f = fabsf(dot(sd->I, sd->N));
+ f = fabsf(dot(sd->I, normal_in));
if(blend != 0.5f) {
blend = clamp(blend, 0.0f, 1.0f-1e-5f);
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 4919222e81c..daf75c81396 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -3198,8 +3198,12 @@ LayerWeightNode::LayerWeightNode()
void LayerWeightNode::compile(SVMCompiler& compiler)
{
+ ShaderInput *normal_in = input("Normal");
ShaderInput *blend_in = input("Blend");
+ if(normal_in->link)
+ compiler.stack_assign(normal_in);
+
if(blend_in->link)
compiler.stack_assign(blend_in);
@@ -3207,14 +3211,14 @@ void LayerWeightNode::compile(SVMCompiler& compiler)
if(!fresnel_out->links.empty()) {
compiler.stack_assign(fresnel_out);
compiler.add_node(NODE_LAYER_WEIGHT, blend_in->stack_offset, __float_as_int(blend_in->value.x),
- compiler.encode_uchar4(NODE_LAYER_WEIGHT_FRESNEL, fresnel_out->stack_offset));
+ compiler.encode_uchar4(NODE_LAYER_WEIGHT_FRESNEL, normal_in->stack_offset, fresnel_out->stack_offset));
}
ShaderOutput *facing_out = output("Facing");
if(!facing_out->links.empty()) {
compiler.stack_assign(facing_out);
compiler.add_node(NODE_LAYER_WEIGHT, blend_in->stack_offset, __float_as_int(blend_in->value.x),
- compiler.encode_uchar4(NODE_LAYER_WEIGHT_FACING, facing_out->stack_offset));
+ compiler.encode_uchar4(NODE_LAYER_WEIGHT_FACING, normal_in->stack_offset, facing_out->stack_offset));
}
}