From e35845d37cd9ff9ab287eb8250476de687cca832 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 13 Jul 2014 12:06:31 +0200 Subject: Fix T40987: Distant Lamps have no influence on Volumes. Differential Revision: https://developer.blender.org/D639 --- intern/cycles/kernel/kernel_light.h | 26 ++++++-------------------- intern/cycles/kernel/kernel_path_surface.h | 8 ++++---- intern/cycles/kernel/kernel_path_volume.h | 23 ++++++++--------------- 3 files changed, 18 insertions(+), 39 deletions(-) (limited to 'intern/cycles') diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h index 0adf9ed4666..ac432d3fe04 100644 --- a/intern/cycles/kernel/kernel_light.h +++ b/intern/cycles/kernel/kernel_light.h @@ -208,8 +208,8 @@ ccl_device float lamp_light_pdf(KernelGlobals *kg, const float3 Ng, const float3 return t*t/cos_pi; } -ccl_device bool lamp_light_sample(KernelGlobals *kg, int lamp, - float randu, float randv, float3 P, LightSample *ls, bool for_volume) +ccl_device void lamp_light_sample(KernelGlobals *kg, int lamp, + float randu, float randv, float3 P, LightSample *ls) { float4 data0 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 0); float4 data1 = kernel_tex_fetch(__light_data, lamp*LIGHT_SIZE + 1); @@ -224,11 +224,6 @@ ccl_device bool lamp_light_sample(KernelGlobals *kg, int lamp, ls->v = randv; if(type == LIGHT_DISTANT) { -#ifdef __VOLUME__ - if(for_volume) - return false; -#endif - /* distant light */ float3 lightD = make_float3(data0.y, data0.z, data0.w); float3 D = lightD; @@ -249,11 +244,6 @@ ccl_device bool lamp_light_sample(KernelGlobals *kg, int lamp, } #ifdef __BACKGROUND_MIS__ else if(type == LIGHT_BACKGROUND) { -#ifdef __VOLUME__ - if(for_volume) - return false; -#endif - /* infinite area light (e.g. light dome or env light) */ float3 D = background_light_sample(kg, randu, randv, &ls->pdf); @@ -309,8 +299,6 @@ ccl_device bool lamp_light_sample(KernelGlobals *kg, int lamp, ls->eval_fac *= kernel_data.integrator.inv_pdf_lights; ls->pdf *= lamp_light_pdf(kg, ls->Ng, -ls->D, ls->t); } - - return true; } ccl_device bool lamp_light_eval(KernelGlobals *kg, int lamp, float3 P, float3 D, float t, LightSample *ls) @@ -526,7 +514,7 @@ ccl_device int light_distribution_sample(KernelGlobals *kg, float randt) /* Generic Light */ -ccl_device bool light_sample(KernelGlobals *kg, float randt, float randu, float randv, float time, float3 P, LightSample *ls, bool for_volume) +ccl_device void light_sample(KernelGlobals *kg, float randt, float randu, float randv, float time, float3 P, LightSample *ls) { /* sample index */ int index = light_distribution_sample(kg, randt); @@ -545,12 +533,10 @@ ccl_device bool light_sample(KernelGlobals *kg, float randt, float randu, float ls->D = normalize_len(ls->P - P, &ls->t); ls->pdf = triangle_light_pdf(kg, ls->Ng, -ls->D, ls->t); ls->shader |= shader_flag; - - return true; } else { int lamp = -prim-1; - return lamp_light_sample(kg, lamp, randu, randv, P, ls, for_volume); + lamp_light_sample(kg, lamp, randu, randv, P, ls); } } @@ -560,9 +546,9 @@ ccl_device int light_select_num_samples(KernelGlobals *kg, int index) return __float_as_int(data3.x); } -ccl_device bool light_select(KernelGlobals *kg, int index, float randu, float randv, float3 P, LightSample *ls, bool for_volume) +ccl_device void light_select(KernelGlobals *kg, int index, float randu, float randv, float3 P, LightSample *ls) { - return lamp_light_sample(kg, index, randu, randv, P, ls, for_volume); + lamp_light_sample(kg, index, randu, randv, P, ls); } ccl_device int lamp_light_eval_sample(KernelGlobals *kg, float randt) diff --git a/intern/cycles/kernel/kernel_path_surface.h b/intern/cycles/kernel/kernel_path_surface.h index 7700abfbdae..81526b0ba7a 100644 --- a/intern/cycles/kernel/kernel_path_surface.h +++ b/intern/cycles/kernel/kernel_path_surface.h @@ -50,7 +50,7 @@ ccl_device void kernel_branched_path_surface_connect_light(KernelGlobals *kg, RN path_branched_rng_2D(kg, &lamp_rng, state, j, num_samples, PRNG_LIGHT_U, &light_u, &light_v); LightSample ls; - light_select(kg, i, light_u, light_v, sd->P, &ls, false); + light_select(kg, i, light_u, light_v, sd->P, &ls); if(direct_emission(kg, sd, &ls, &light_ray, &L_light, &is_lamp, state->bounce, state->transparent_bounce)) { /* trace shadow ray */ @@ -82,7 +82,7 @@ ccl_device void kernel_branched_path_surface_connect_light(KernelGlobals *kg, RN light_t = 0.5f*light_t; LightSample ls; - light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls, false); + light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls); if(direct_emission(kg, sd, &ls, &light_ray, &L_light, &is_lamp, state->bounce, state->transparent_bounce)) { /* trace shadow ray */ @@ -103,7 +103,7 @@ ccl_device void kernel_branched_path_surface_connect_light(KernelGlobals *kg, RN path_state_rng_2D(kg, rng, state, PRNG_LIGHT_U, &light_u, &light_v); LightSample ls; - light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls, false); + light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls); /* sample random light */ if(direct_emission(kg, sd, &ls, &light_ray, &L_light, &is_lamp, state->bounce, state->transparent_bounce)) { @@ -200,7 +200,7 @@ ccl_device_inline void kernel_path_surface_connect_light(KernelGlobals *kg, RNG #endif LightSample ls; - light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls, false); + light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls); if(direct_emission(kg, sd, &ls, &light_ray, &L_light, &is_lamp, state->bounce, state->transparent_bounce)) { /* trace shadow ray */ diff --git a/intern/cycles/kernel/kernel_path_volume.h b/intern/cycles/kernel/kernel_path_volume.h index 8453b79de45..b4917f9a3ae 100644 --- a/intern/cycles/kernel/kernel_path_volume.h +++ b/intern/cycles/kernel/kernel_path_volume.h @@ -41,9 +41,8 @@ ccl_device void kernel_path_volume_connect_light(KernelGlobals *kg, RNG *rng, light_ray.time = sd->time; #endif - if(!light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls, true)) - return; - else if(ls.pdf == 0.0f) + light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls); + if(ls.pdf == 0.0f) return; if(direct_emission(kg, sd, &ls, &light_ray, &L_light, &is_lamp, state->bounce, state->transparent_bounce)) { @@ -135,8 +134,7 @@ ccl_device void kernel_branched_path_volume_connect_light(KernelGlobals *kg, RNG path_branched_rng_2D(kg, &lamp_rng, state, j, num_samples, PRNG_LIGHT_U, &light_u, &light_v); LightSample ls; - if(!light_select(kg, i, light_u, light_v, ray->P, &ls, true)) - continue; + light_select(kg, i, light_u, light_v, ray->P, &ls); float3 tp = throughput; @@ -152,8 +150,7 @@ ccl_device void kernel_branched_path_volume_connect_light(KernelGlobals *kg, RNG continue; /* todo: split up light_sample so we don't have to call it again with new position */ - if(!light_select(kg, i, light_u, light_v, sd->P, &ls, true)) - continue; + light_select(kg, i, light_u, light_v, sd->P, &ls); } if(ls.pdf == 0.0f) @@ -190,8 +187,7 @@ ccl_device void kernel_branched_path_volume_connect_light(KernelGlobals *kg, RNG light_t = 0.5f*light_t; LightSample ls; - if(!light_sample(kg, light_t, light_u, light_v, sd->time, ray->P, &ls, true)) - continue; + light_sample(kg, light_t, light_u, light_v, sd->time, ray->P, &ls); float3 tp = throughput; @@ -207,8 +203,7 @@ ccl_device void kernel_branched_path_volume_connect_light(KernelGlobals *kg, RNG continue; /* todo: split up light_sample so we don't have to call it again with new position */ - if(!light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls, true)) - continue; + light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls); } if(ls.pdf == 0.0f) @@ -233,8 +228,7 @@ ccl_device void kernel_branched_path_volume_connect_light(KernelGlobals *kg, RNG path_state_rng_2D(kg, rng, state, PRNG_LIGHT_U, &light_u, &light_v); LightSample ls; - if(!light_sample(kg, light_t, light_u, light_v, sd->time, ray->P, &ls, true)) - return; + light_sample(kg, light_t, light_u, light_v, sd->time, ray->P, &ls); float3 tp = throughput; @@ -250,8 +244,7 @@ ccl_device void kernel_branched_path_volume_connect_light(KernelGlobals *kg, RNG return; /* todo: split up light_sample so we don't have to call it again with new position */ - if(!light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls, true)) - return; + light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, &ls); } if(ls.pdf == 0.0f) -- cgit v1.2.3