Normal Node - Cycles

reviewed by Brecht, with help from Lukas.

Note: dot is reversed compared to Blender.
In Blender Normals point outside, while in Cycles they point inside.
If you use your own custom vector with the Normal Node you will see a difference.
If you feed it with object normals it should work just as good.
This commit is contained in:
Dalai Felinto
2011-12-16 18:15:07 +00:00
parent ce8f64d9f9
commit 3c8ab559a5
11 changed files with 137 additions and 3 deletions

View File

@@ -713,6 +713,41 @@ void MagicTextureNode::compile(OSLCompiler& compiler)
compiler.add(this, "node_magic_texture");
}
/* Normal */
NormalNode::NormalNode()
: ShaderNode("normal")
{
direction = make_float3(0.0f, 0.0f, 1.0f);
add_input("Normal", SHADER_SOCKET_NORMAL);
add_output("Normal", SHADER_SOCKET_NORMAL);
add_output("Dot", SHADER_SOCKET_FLOAT);
}
void NormalNode::compile(SVMCompiler& compiler)
{
ShaderInput *normal_in = input("Normal");
ShaderOutput *normal_out = output("Normal");
ShaderOutput *dot_out = output("Dot");
compiler.stack_assign(normal_in);
compiler.stack_assign(normal_out);
compiler.stack_assign(dot_out);
compiler.add_node(NODE_NORMAL, normal_in->stack_offset, normal_out->stack_offset, dot_out->stack_offset);
compiler.add_node(
__float_as_int(direction.x),
__float_as_int(direction.y),
__float_as_int(direction.z));
}
void NormalNode::compile(OSLCompiler& compiler)
{
compiler.parameter_vector("Direction", direction);
compiler.add(this, "node_normal");
}
/* Mapping */
MappingNode::MappingNode()