Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/integrator/shade_background.h
| /* SPDX-License-Identifier: Apache-2.0 | /* SPDX-License-Identifier: Apache-2.0 | |||||||||||
| * Copyright 2011-2022 Blender Foundation */ | * Copyright 2011-2022 Blender Foundation */ | |||||||||||
| #pragma once | #pragma once | |||||||||||
| #include "kernel/film/light_passes.h" | #include "kernel/film/light_passes.h" | |||||||||||
| #include "kernel/integrator/surface_shader.h" | #include "kernel/integrator/surface_shader.h" | |||||||||||
| #include "kernel/light/light.h" | #include "kernel/light/light.h" | |||||||||||
| #include "kernel/light/light_tree.h" | ||||||||||||
| #include "kernel/light/sample.h" | #include "kernel/light/sample.h" | |||||||||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | |||||||||||
| ccl_device Spectrum integrator_eval_background_shader(KernelGlobals kg, | ccl_device Spectrum integrator_eval_background_shader(KernelGlobals kg, | |||||||||||
| IntegratorState state, | IntegratorState state, | |||||||||||
| ccl_global float *ccl_restrict render_buffer) | ccl_global float *ccl_restrict render_buffer) | |||||||||||
| { | { | |||||||||||
| ▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | if (eval_background) { | |||||||||||
| if (!(INTEGRATOR_STATE(state, path, flag) & PATH_RAY_MIS_SKIP) && | if (!(INTEGRATOR_STATE(state, path, flag) & PATH_RAY_MIS_SKIP) && | |||||||||||
| kernel_data.background.use_mis) { | kernel_data.background.use_mis) { | |||||||||||
| const float3 ray_P = INTEGRATOR_STATE(state, ray, P); | const float3 ray_P = INTEGRATOR_STATE(state, ray, P); | |||||||||||
| const float3 ray_D = INTEGRATOR_STATE(state, ray, D); | const float3 ray_D = INTEGRATOR_STATE(state, ray, D); | |||||||||||
| const float mis_ray_pdf = INTEGRATOR_STATE(state, path, mis_ray_pdf); | const float mis_ray_pdf = INTEGRATOR_STATE(state, path, mis_ray_pdf); | |||||||||||
| /* multiple importance sampling, get background light pdf for ray | /* multiple importance sampling, get background light pdf for ray | |||||||||||
| * direction, and compute weight with respect to BSDF pdf */ | * direction, and compute weight with respect to BSDF pdf */ | |||||||||||
| const float pdf = background_light_pdf(kg, ray_P, ray_D); | float pdf = background_light_pdf(kg, ray_P, ray_D); | |||||||||||
| if (kernel_data.integrator.use_light_tree) { | ||||||||||||
| const float3 N = INTEGRATOR_STATE(state, path, mis_origin_n); | ||||||||||||
| pdf *= distant_lights_pdf(kg, ray_P, N, kernel_data.background.light_index); | ||||||||||||
| } | ||||||||||||
| mis_weight = light_sample_mis_weight_forward(kg, mis_ray_pdf, pdf); | mis_weight = light_sample_mis_weight_forward(kg, mis_ray_pdf, pdf); | |||||||||||
| } | } | |||||||||||
| L *= mis_weight; | L *= mis_weight; | |||||||||||
| } | } | |||||||||||
| /* Write to render buffer. */ | /* Write to render buffer. */ | |||||||||||
| film_write_background(kg, state, L, transparent, is_transparent_background_ray, render_buffer); | film_write_background(kg, state, L, transparent, is_transparent_background_ray, render_buffer); | |||||||||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | #endif /* __MNEE__ */ | |||||||||||
| } | } | |||||||||||
| /* MIS weighting. */ | /* MIS weighting. */ | |||||||||||
| float mis_weight = 1.0f; | float mis_weight = 1.0f; | |||||||||||
| if (!(path_flag & PATH_RAY_MIS_SKIP)) { | if (!(path_flag & PATH_RAY_MIS_SKIP)) { | |||||||||||
| /* multiple importance sampling, get regular light pdf, | /* multiple importance sampling, get regular light pdf, | |||||||||||
| * and compute weight with respect to BSDF pdf */ | * and compute weight with respect to BSDF pdf */ | |||||||||||
| const float mis_ray_pdf = INTEGRATOR_STATE(state, path, mis_ray_pdf); | const float mis_ray_pdf = INTEGRATOR_STATE(state, path, mis_ray_pdf); | |||||||||||
| mis_weight = light_sample_mis_weight_forward(kg, mis_ray_pdf, ls.pdf); | if (kernel_data.integrator.use_light_tree) { | |||||||||||
| const float3 ray_P = INTEGRATOR_STATE(state, ray, P); | ||||||||||||
| const float3 N = INTEGRATOR_STATE(state, path, mis_origin_n); | ||||||||||||
| ls.pdf *= distant_lights_pdf(kg, ray_P, N, lamp); | ||||||||||||
| } | ||||||||||||
| const float mis_weight = light_sample_mis_weight_forward(kg, mis_ray_pdf, ls.pdf); | ||||||||||||
AlaskaUnsubmitted Not Done Inline Actions
Alaska: | ||||||||||||
| } | } | |||||||||||
| /* Write to render buffer. */ | /* Write to render buffer. */ | |||||||||||
| film_write_surface_emission( | film_write_surface_emission( | |||||||||||
| kg, state, light_eval, mis_weight, render_buffer, kernel_data.background.lightgroup); | kg, state, light_eval, mis_weight, render_buffer, kernel_data.background.lightgroup); | |||||||||||
| } | } | |||||||||||
| } | } | |||||||||||
| } | } | |||||||||||
| Show All 26 Lines | ||||||||||||