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
diff options
context:
space:
mode:
authorThomas Dinges <blender@dingto.org>2013-08-01 00:30:37 +0400
committerThomas Dinges <blender@dingto.org>2013-08-01 00:30:37 +0400
commit3840e0b2347200ceb414f12deb3436b20d274c66 (patch)
treef61c6dc0087edc69b50acf29aae6dc4712d3aeb2 /intern/cycles/kernel/osl/osl_services.cpp
parentc15ae082bb3bcb379c343aa770601b49c0866583 (diff)
Cycles / Ray Depth:
* Added a Ray Depth output to the Light Path node, which gives the user access to the current bounce. This can be used to limit the maximum ray bounce on a per shader basis. Another use case is to restrict light influence with this, to have a lamp only contribute to the direct lighting. http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/More#Light_Path This is part of my GSoC 2013 project. SVN merge of r58091 and r58772 from soc-2013-dingto.
Diffstat (limited to 'intern/cycles/kernel/osl/osl_services.cpp')
-rw-r--r--intern/cycles/kernel/osl/osl_services.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp
index e1e43b117e7..f3b79da8894 100644
--- a/intern/cycles/kernel/osl/osl_services.cpp
+++ b/intern/cycles/kernel/osl/osl_services.cpp
@@ -84,6 +84,7 @@ ustring OSLRenderServices::u_curve_thickness("geom:curve_thickness");
ustring OSLRenderServices::u_curve_tangent_normal("geom:curve_tangent_normal");
#endif
ustring OSLRenderServices::u_path_ray_length("path:ray_length");
+ustring OSLRenderServices::u_path_ray_depth("path:ray_depth");
ustring OSLRenderServices::u_trace("trace");
ustring OSLRenderServices::u_hit("hit");
ustring OSLRenderServices::u_hitdist("hitdist");
@@ -660,6 +661,11 @@ bool OSLRenderServices::get_background_attribute(KernelGlobals *kg, ShaderData *
float f = sd->ray_length;
return set_attribute_float(f, type, derivatives, val);
}
+ else if (name == u_path_ray_depth) {
+ /* Ray Depth */
+ int f = sd->ray_depth;
+ return set_attribute_int(f, type, derivatives, val);
+ }
else if (name == u_ndc) {
/* NDC coordinates with special exception for otho */
OSLThreadData *tdata = kg->osl_tdata;
@@ -919,7 +925,10 @@ bool OSLRenderServices::getmessage(OSL::ShaderGlobals *sg, ustring source, ustri
if(!tracedata->setup) {
/* lazy shader data setup */
- shader_setup_from_ray(kg, sd, &tracedata->isect, &tracedata->ray);
+ ShaderData *original_sd = (ShaderData *)(sg->renderstate);
+ int bounce = original_sd->ray_depth + 1;
+
+ shader_setup_from_ray(kg, sd, &tracedata->isect, &tracedata->ray, bounce);
tracedata->setup = true;
}