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>2016-01-07 01:38:13 +0300
committerThomas Dinges <blender@dingto.org>2016-01-07 01:43:29 +0300
commit83e73a2100688655f0eb2df5cbfac2ca1f051fff (patch)
tree76f1cd502187544777b61fa55f5695b2503993a8 /intern/cycles/kernel/kernel_emission.h
parentbe28706bacfb95e7c3c1b58b183acda0e35977f8 (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/kernel_emission.h')
-rw-r--r--intern/cycles/kernel/kernel_emission.h41
1 files changed, 23 insertions, 18 deletions
diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h
index 3863cf221c5..47d357215cf 100644
--- a/intern/cycles/kernel/kernel_emission.h
+++ b/intern/cycles/kernel/kernel_emission.h
@@ -18,7 +18,7 @@ CCL_NAMESPACE_BEGIN
/* Direction Emission */
ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg,
- LightSample *ls, float3 I, differential3 dI, float t, float time, int bounce, int transparent_bounce
+ LightSample *ls, ccl_addr_space PathState *state, float3 I, differential3 dI, float t, float time
#ifdef __SPLIT_KERNEL__
,ShaderData *sd_input
#endif
@@ -45,19 +45,24 @@ ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg,
ray.dP = differential3_zero();
ray.dD = dI;
- shader_setup_from_background(kg, sd, &ray, bounce+1, transparent_bounce);
- eval = shader_eval_background(kg, sd, 0, SHADER_CONTEXT_EMISSION);
+ shader_setup_from_background(kg, sd, &ray);
+
+ path_state_modify_bounce(state, true);
+ eval = shader_eval_background(kg, sd, state, 0, SHADER_CONTEXT_EMISSION);
+ path_state_modify_bounce(state, false);
}
else
#endif
{
- shader_setup_from_sample(kg, sd, ls->P, ls->Ng, I, ls->shader, ls->object, ls->prim, ls->u, ls->v, t, time, bounce+1, transparent_bounce);
+ shader_setup_from_sample(kg, sd, ls->P, ls->Ng, I, ls->shader, ls->object, ls->prim, ls->u, ls->v, t, time);
ls->Ng = ccl_fetch(sd, Ng);
/* no path flag, we're evaluating this for all closures. that's weak but
* we'd have to do multiple evaluations otherwise */
- shader_eval_surface(kg, sd, 0.0f, 0, SHADER_CONTEXT_EMISSION);
+ path_state_modify_bounce(state, true);
+ shader_eval_surface(kg, sd, state, 0.0f, 0, SHADER_CONTEXT_EMISSION);
+ path_state_modify_bounce(state, false);
/* evaluate emissive closure */
if(ccl_fetch(sd, flag) & SD_EMISSION)
@@ -72,8 +77,7 @@ ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg,
}
ccl_device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd,
- LightSample *ls, Ray *ray, BsdfEval *eval, bool *is_lamp,
- int bounce, int transparent_bounce
+ LightSample *ls, ccl_addr_space PathState *state, Ray *ray, BsdfEval *eval, bool *is_lamp
#ifdef __SPLIT_KERNEL__
, ShaderData *sd_DL
#endif
@@ -87,9 +91,7 @@ ccl_device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd,
/* evaluate closure */
- float3 light_eval = direct_emissive_eval(kg, ls, -ls->D, dD, ls->t, ccl_fetch(sd, time),
- bounce,
- transparent_bounce
+ float3 light_eval = direct_emissive_eval(kg, ls, state, -ls->D, dD, ls->t, ccl_fetch(sd, time)
#ifdef __SPLIT_KERNEL__
,sd_DL
#endif
@@ -191,7 +193,7 @@ ccl_device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, Shader
/* Indirect Lamp Emission */
-ccl_device_noinline bool indirect_lamp_emission(KernelGlobals *kg, PathState *state, Ray *ray, float3 *emission
+ccl_device_noinline bool indirect_lamp_emission(KernelGlobals *kg, ccl_addr_space PathState *state, Ray *ray, float3 *emission
#ifdef __SPLIT_KERNEL__
,ShaderData *sd
#endif
@@ -219,9 +221,7 @@ ccl_device_noinline bool indirect_lamp_emission(KernelGlobals *kg, PathState *st
}
#endif
- float3 L = direct_emissive_eval(kg, &ls, -ray->D, ray->dD, ls.t, ray->time,
- state->bounce,
- state->transparent_bounce
+ float3 L = direct_emissive_eval(kg, &ls, state, -ray->D, ray->dD, ls.t, ray->time
#ifdef __SPLIT_KERNEL__
,sd
#endif
@@ -277,13 +277,18 @@ ccl_device_noinline float3 indirect_background(KernelGlobals *kg, ccl_addr_space
#ifdef __SPLIT_KERNEL__
/* evaluate background closure */
Ray priv_ray = *ray;
- shader_setup_from_background(kg, sd_global, &priv_ray, state->bounce+1, state->transparent_bounce);
- float3 L = shader_eval_background(kg, sd_global, state->flag, SHADER_CONTEXT_EMISSION);
+ shader_setup_from_background(kg, sd_global, &priv_ray);
+
+ path_state_modify_bounce(state, true);
+ float3 L = shader_eval_background(kg, sd_global, state, state->flag, SHADER_CONTEXT_EMISSION);
+ path_state_modify_bounce(state, false);
#else
ShaderData sd;
- shader_setup_from_background(kg, &sd, ray, state->bounce+1, state->transparent_bounce);
+ shader_setup_from_background(kg, &sd, ray);
- float3 L = shader_eval_background(kg, &sd, state->flag, SHADER_CONTEXT_EMISSION);
+ path_state_modify_bounce(state, true);
+ float3 L = shader_eval_background(kg, &sd, state, state->flag, SHADER_CONTEXT_EMISSION);
+ path_state_modify_bounce(state, false);
#endif
#ifdef __BACKGROUND_MIS__