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. :)
This commit is contained in:
@@ -107,11 +107,14 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *
|
||||
|
||||
/* setup shader data at surface */
|
||||
ShaderData sd;
|
||||
shader_setup_from_ray(kg, &sd, isect, ray, state->bounce+1, bounce);
|
||||
shader_setup_from_ray(kg, &sd, isect, ray);
|
||||
|
||||
/* attenuation from transparent surface */
|
||||
if(!(sd.flag & SD_HAS_ONLY_VOLUME)) {
|
||||
shader_eval_surface(kg, &sd, 0.0f, PATH_RAY_SHADOW, SHADER_CONTEXT_SHADOW);
|
||||
path_state_modify_bounce(state, true);
|
||||
shader_eval_surface(kg, &sd, state, 0.0f, PATH_RAY_SHADOW, SHADER_CONTEXT_SHADOW);
|
||||
path_state_modify_bounce(state, false);
|
||||
|
||||
throughput *= shader_bsdf_transparency(kg, &sd);
|
||||
}
|
||||
|
||||
@@ -253,11 +256,14 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, ccl_addr_space PathStat
|
||||
ShaderData sd_object;
|
||||
ShaderData *sd = &sd_object;
|
||||
#endif
|
||||
shader_setup_from_ray(kg, sd, isect, ray, state->bounce+1, bounce);
|
||||
shader_setup_from_ray(kg, sd, isect, ray);
|
||||
|
||||
/* attenuation from transparent surface */
|
||||
if(!(ccl_fetch(sd, flag) & SD_HAS_ONLY_VOLUME)) {
|
||||
shader_eval_surface(kg, sd, 0.0f, PATH_RAY_SHADOW, SHADER_CONTEXT_SHADOW);
|
||||
path_state_modify_bounce(state, true);
|
||||
shader_eval_surface(kg, sd, state, 0.0f, PATH_RAY_SHADOW, SHADER_CONTEXT_SHADOW);
|
||||
path_state_modify_bounce(state, false);
|
||||
|
||||
throughput *= shader_bsdf_transparency(kg, sd);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user