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