Blender V5.0
emissive.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009-2010 Sony Pictures Imageworks Inc., et al. All Rights Reserved.
2 * SPDX-FileCopyrightText: 2011-2022 Blender Foundation
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 * Adapted code from Open Shading Language. */
7
8#pragma once
9
10#include "kernel/types.h"
11
13
14/* BACKGROUND CLOSURE */
15
16ccl_device void background_setup(ccl_private ShaderData *sd, const Spectrum weight)
17{
18 if (sd->flag & SD_EMISSION) {
19 sd->closure_emission_background += weight;
20 }
21 else {
22 sd->flag |= SD_EMISSION;
23 sd->closure_emission_background = weight;
24 }
25}
26
27/* EMISSION CLOSURE */
28
29ccl_device void emission_setup(ccl_private ShaderData *sd, const Spectrum weight)
30{
31 if (sd->flag & SD_EMISSION) {
32 sd->closure_emission_background += weight;
33 }
34 else {
35 sd->flag |= SD_EMISSION;
36 sd->closure_emission_background = weight;
37 }
38}
39
40/* return the probability distribution function in the direction wi,
41 * given the parameters and the light's surface normal. This MUST match
42 * the PDF computed by sample(). */
43ccl_device float emissive_pdf(const float3 Ng, const float3 wi)
44{
45 const float cosNI = fabsf(dot(Ng, wi));
46 return (cosNI > 0.0f) ? 1.0f : 0.0f;
47}
48
50 const float /*randu*/,
51 const float /*randv*/,
52 ccl_private float3 * /*wi*/,
53 ccl_private float * /*pdf*/)
54{
55 /* todo: not implemented and used yet */
56}
57
59{
60 const float res = emissive_pdf(Ng, wi);
61
62 return make_spectrum(res);
63}
64
dot(value.rgb, luminance_coefficients)") DEFINE_VALUE("REDUCE(lhs
#define make_spectrum(f)
#define ccl_private
#define CCL_NAMESPACE_END
ccl_device Spectrum emissive_simple_eval(const float3 Ng, const float3 wi)
Definition emissive.h:58
ccl_device void emissive_sample(const float3, const float, const float, ccl_private float3 *, ccl_private float *)
Definition emissive.h:49
ccl_device void emission_setup(ccl_private ShaderData *sd, const Spectrum weight)
Definition emissive.h:29
CCL_NAMESPACE_BEGIN ccl_device void background_setup(ccl_private ShaderData *sd, const Spectrum weight)
Definition emissive.h:16
ccl_device float emissive_pdf(const float3 Ng, const float3 wi)
Definition emissive.h:43
@ SD_EMISSION
#define fabsf
#define ccl_device
float3 Spectrum