Cycles: add Ray Length output to Light Path node. This gives the distance travelled

by the last light ray. One use case for this might be to do absorption.

Patch #31232 by Agustin benavidez, see this blog post for details:
http://agus3d.blogspot.com.ar/2012/05/blender-cycles-ray-length-node-output.html
This commit is contained in:
Brecht Van Lommel
2012-05-02 17:03:46 +00:00
parent 89f554fd24
commit d64661b507
7 changed files with 23 additions and 6 deletions

View File

@@ -1623,6 +1623,7 @@ LightPathNode::LightPathNode()
add_output("Is Singular Ray", SHADER_SOCKET_FLOAT);
add_output("Is Reflection Ray", SHADER_SOCKET_FLOAT);
add_output("Is Transmission Ray", SHADER_SOCKET_FLOAT);
add_output("Ray Length", SHADER_SOCKET_FLOAT);
}
void LightPathNode::compile(SVMCompiler& compiler)
@@ -1671,6 +1672,13 @@ void LightPathNode::compile(SVMCompiler& compiler)
compiler.stack_assign(out);
compiler.add_node(NODE_LIGHT_PATH, NODE_LP_transmission, out->stack_offset);
}
out = output("Ray Length");
if(!out->links.empty()) {
compiler.stack_assign(out);
compiler.add_node(NODE_LIGHT_PATH, NODE_LP_ray_length, out->stack_offset);
}
}
void LightPathNode::compile(OSLCompiler& compiler)