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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2014-05-01 21:18:42 +0400
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2014-05-01 21:25:13 +0400
commitc806a8ce96d93c739675f8444427be575b67a788 (patch)
tree80178fd0be9c8988ea62152fd9e4b0ae4e082234 /intern/cycles/kernel/kernel_emission.h
parent95b93b5d46b7fb8b98295a1368bc44a3f63fe8c7 (diff)
Cycles: MIS for lamps now loops over all lamps instead of picking one.
Probably will not be noticed in most scenes. This helps reduce noise when you have multiple lamps with MIS enabled, at the cost of some performance, but from testing some scenes this seems better.
Diffstat (limited to 'intern/cycles/kernel/kernel_emission.h')
-rw-r--r--intern/cycles/kernel/kernel_emission.h48
1 files changed, 26 insertions, 22 deletions
diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h
index 8812bbb36ce..44899e0bf97 100644
--- a/intern/cycles/kernel/kernel_emission.h
+++ b/intern/cycles/kernel/kernel_emission.h
@@ -183,38 +183,42 @@ 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, float randt, float3 *emission)
+ccl_device_noinline bool indirect_lamp_emission(KernelGlobals *kg, PathState *state, Ray *ray, float3 *emission)
{
- LightSample ls;
- int lamp = lamp_light_eval_sample(kg, randt);
+ bool hit_lamp = false;
- if(lamp == LAMP_NONE)
- return false;
+ *emission = make_float3(0.0f, 0.0f, 0.0f);
- if(!lamp_light_eval(kg, lamp, ray->P, ray->D, ray->t, &ls))
- return false;
+ for(int lamp = 0; lamp < kernel_data.integrator.num_all_lights; lamp++) {
+ LightSample ls;
+
+ if(!lamp_light_eval(kg, lamp, ray->P, ray->D, ray->t, &ls))
+ continue;
#ifdef __PASSES__
- /* use visibility flag to skip lights */
- if(ls.shader & SHADER_EXCLUDE_ANY) {
- if(((ls.shader & SHADER_EXCLUDE_DIFFUSE) && (state->flag & PATH_RAY_DIFFUSE)) ||
- ((ls.shader & SHADER_EXCLUDE_GLOSSY) && (state->flag & PATH_RAY_GLOSSY)) ||
- ((ls.shader & SHADER_EXCLUDE_TRANSMIT) && (state->flag & PATH_RAY_TRANSMIT)))
- return false;
- }
+ /* use visibility flag to skip lights */
+ if(ls.shader & SHADER_EXCLUDE_ANY) {
+ if(((ls.shader & SHADER_EXCLUDE_DIFFUSE) && (state->flag & PATH_RAY_DIFFUSE)) ||
+ ((ls.shader & SHADER_EXCLUDE_GLOSSY) && (state->flag & PATH_RAY_GLOSSY)) ||
+ ((ls.shader & SHADER_EXCLUDE_TRANSMIT) && (state->flag & PATH_RAY_TRANSMIT)))
+ continue;
+ }
#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, -ray->D, ray->dD, ls.t, ray->time, state->bounce, state->transparent_bounce);
- if(!(state->flag & PATH_RAY_MIS_SKIP)) {
- /* multiple importance sampling, get regular light pdf,
- * and compute weight with respect to BSDF pdf */
- float mis_weight = power_heuristic(state->ray_pdf, ls.pdf);
- L *= mis_weight;
+ if(!(state->flag & PATH_RAY_MIS_SKIP)) {
+ /* multiple importance sampling, get regular light pdf,
+ * and compute weight with respect to BSDF pdf */
+ float mis_weight = power_heuristic(state->ray_pdf, ls.pdf);
+ L *= mis_weight;
+ }
+
+ *emission += L;
+ hit_lamp = true;
}
- *emission = L;
- return true;
+ return hit_lamp;
}
/* Indirect Background */