diff options
Diffstat (limited to 'intern/cycles/kernel/light')
-rw-r--r-- | intern/cycles/kernel/light/background.h | 4 | ||||
-rw-r--r-- | intern/cycles/kernel/light/light.h | 10 | ||||
-rw-r--r-- | intern/cycles/kernel/light/sample.h | 22 |
3 files changed, 14 insertions, 22 deletions
diff --git a/intern/cycles/kernel/light/background.h b/intern/cycles/kernel/light/background.h index 2a97d43c9ce..951620ff1cb 100644 --- a/intern/cycles/kernel/light/background.h +++ b/intern/cycles/kernel/light/background.h @@ -9,8 +9,6 @@ CCL_NAMESPACE_BEGIN /* Background Light */ -#ifdef __BACKGROUND_MIS__ - ccl_device float3 background_map_sample(KernelGlobals kg, float randu, float randv, @@ -435,6 +433,4 @@ ccl_device float background_light_pdf(KernelGlobals kg, float3 P, float3 directi return pdf * kernel_data.integrator.pdf_lights; } -#endif - CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/light/light.h b/intern/cycles/kernel/light/light.h index b939489bb18..12a6f21b58d 100644 --- a/intern/cycles/kernel/light/light.h +++ b/intern/cycles/kernel/light/light.h @@ -86,7 +86,6 @@ ccl_device_inline bool light_sample(KernelGlobals kg, ls->pdf = invarea / (costheta * costheta * costheta); ls->eval_fac = ls->pdf; } -#ifdef __BACKGROUND_MIS__ else if (type == LIGHT_BACKGROUND) { /* infinite area light (e.g. light dome or env light) */ float3 D = -background_light_sample(kg, P, randu, randv, &ls->pdf); @@ -97,7 +96,6 @@ ccl_device_inline bool light_sample(KernelGlobals kg, ls->t = FLT_MAX; ls->eval_fac = 1.0f; } -#endif else { ls->P = make_float3(klight->co[0], klight->co[1], klight->co[2]); @@ -202,8 +200,12 @@ ccl_device_inline bool light_sample(KernelGlobals kg, inplane = ls->P - inplane; } - ls->u = dot(inplane, axisu) * (1.0f / dot(axisu, axisu)) + 0.5f; - ls->v = dot(inplane, axisv) * (1.0f / dot(axisv, axisv)) + 0.5f; + const float light_u = dot(inplane, axisu) * (1.0f / dot(axisu, axisu)); + const float light_v = dot(inplane, axisv) * (1.0f / dot(axisv, axisv)); + + /* NOTE: Return barycentric coordinates in the same notation as Embree and OptiX. */ + ls->u = light_v + 0.5f; + ls->v = -light_u - light_v; ls->Ng = Ng; ls->D = normalize_len(ls->P - P, &ls->t); diff --git a/intern/cycles/kernel/light/sample.h b/intern/cycles/kernel/light/sample.h index 4195675dd13..e0d4f221bef 100644 --- a/intern/cycles/kernel/light/sample.h +++ b/intern/cycles/kernel/light/sample.h @@ -4,7 +4,7 @@ #pragma once #include "kernel/integrator/path_state.h" -#include "kernel/integrator/shader_eval.h" +#include "kernel/integrator/surface_shader.h" #include "kernel/light/light.h" @@ -24,22 +24,19 @@ light_sample_shader_eval(KernelGlobals kg, /* setup shading at emitter */ Spectrum eval = zero_spectrum(); - if (shader_constant_emission_eval(kg, ls->shader, &eval)) { + if (surface_shader_constant_emission(kg, ls->shader, &eval)) { if ((ls->prim != PRIM_NONE) && dot(ls->Ng, ls->D) > 0.0f) { ls->Ng = -ls->Ng; } } else { - /* Setup shader data and call shader_eval_surface once, better + /* Setup shader data and call surface_shader_eval once, better * for GPU coherence and compile times. */ PROFILING_INIT_FOR_SHADER(kg, PROFILING_SHADE_LIGHT_SETUP); -#ifdef __BACKGROUND_MIS__ if (ls->type == LIGHT_BACKGROUND) { shader_setup_from_background(kg, emission_sd, ls->P, ls->D, time); } - else -#endif - { + else { shader_setup_from_sample(kg, emission_sd, ls->P, @@ -63,18 +60,15 @@ light_sample_shader_eval(KernelGlobals kg, /* No proper path flag, we're evaluating this for all closures. that's * weak but we'd have to do multiple evaluations otherwise. */ - shader_eval_surface<KERNEL_FEATURE_NODE_MASK_SURFACE_LIGHT>( + surface_shader_eval<KERNEL_FEATURE_NODE_MASK_SURFACE_LIGHT>( kg, state, emission_sd, NULL, PATH_RAY_EMISSION); /* Evaluate closures. */ -#ifdef __BACKGROUND_MIS__ if (ls->type == LIGHT_BACKGROUND) { - eval = shader_background_eval(emission_sd); + eval = surface_shader_background(emission_sd); } - else -#endif - { - eval = shader_emissive_eval(emission_sd); + else { + eval = surface_shader_emission(emission_sd); } } |