diff options
author | Thomas Dinges <blender@dingto.org> | 2016-01-07 01:38:13 +0300 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2016-01-07 01:43:29 +0300 |
commit | 83e73a2100688655f0eb2df5cbfac2ca1f051fff (patch) | |
tree | 76f1cd502187544777b61fa55f5695b2503993a8 /intern/cycles/kernel/osl/osl_services.cpp | |
parent | be28706bacfb95e7c3c1b58b183acda0e35977f8 (diff) |
Cycles: Refactor how we pass bounce info to light path node.
This commit changes the way how we pass bounce information to the Light
Path node. Instead of manualy copying the bounces into ShaderData, we now
directly pass PathState. This reduces the arguments that we need to pass
around and also makes it easier to extend the feature.
This commit also exposes the Transmission Bounce Depth to the Light Path
node. It works similar to the Transparent Depth Output: Replace a
Transmission lightpath after X bounces with another shader, e.g a Diffuse
one. This can be used to avoid black surfaces, due to low amount of max
bounces.
Reviewed by Sergey and Brecht, thanks for some hlp with this.
I tested compilation and usage on CPU (SVM and OSL), CUDA, OpenCL Split
and Mega kernel. Hopefully this covers all devices. :)
Diffstat (limited to 'intern/cycles/kernel/osl/osl_services.cpp')
-rw-r--r-- | intern/cycles/kernel/osl/osl_services.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp index 8838c28ca13..0595282af64 100644 --- a/intern/cycles/kernel/osl/osl_services.cpp +++ b/intern/cycles/kernel/osl/osl_services.cpp @@ -101,6 +101,7 @@ ustring OSLRenderServices::u_curve_tangent_normal("geom:curve_tangent_normal"); ustring OSLRenderServices::u_path_ray_length("path:ray_length"); ustring OSLRenderServices::u_path_ray_depth("path:ray_depth"); ustring OSLRenderServices::u_path_transparent_depth("path:transparent_depth"); +ustring OSLRenderServices::u_path_transmission_depth("path:transmission_depth"); ustring OSLRenderServices::u_trace("trace"); ustring OSLRenderServices::u_hit("hit"); ustring OSLRenderServices::u_hitdist("hitdist"); @@ -726,12 +727,20 @@ bool OSLRenderServices::get_background_attribute(KernelGlobals *kg, ShaderData * } else if(name == u_path_ray_depth) { /* Ray Depth */ - int f = sd->ray_depth; + PathState *state = sd->osl_path_state; + int f = state->bounce; return set_attribute_int(f, type, derivatives, val); } else if(name == u_path_transparent_depth) { /* Transparent Ray Depth */ - int f = sd->transparent_depth; + PathState *state = sd->osl_path_state; + int f = state->transparent_bounce; + return set_attribute_int(f, type, derivatives, val); + } + else if(name == u_path_transmission_depth) { + /* Transmission Ray Depth */ + PathState *state = sd->osl_path_state; + int f = state->transmission_bounce; return set_attribute_int(f, type, derivatives, val); } else if(name == u_ndc) { @@ -1257,11 +1266,7 @@ bool OSLRenderServices::getmessage(OSL::ShaderGlobals *sg, ustring source, ustri if(!tracedata->setup) { /* lazy shader data setup */ - ShaderData *original_sd = (ShaderData *)(sg->renderstate); - int bounce = original_sd->ray_depth + 1; - int transparent_bounce = original_sd->transparent_depth; - - shader_setup_from_ray(kg, sd, &tracedata->isect, &tracedata->ray, bounce, transparent_bounce); + shader_setup_from_ray(kg, sd, &tracedata->isect, &tracedata->ray); tracedata->setup = true; } |