Blender V4.3
light/common.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
8
10
11/* Light Sample Result */
12
13typedef struct LightSample {
14 float3 P; /* position on light, or direction for distant light */
15 packed_float3 Ng; /* normal on light */
16 float t; /* distance to light (FLT_MAX for distant light) */
17 float3 D; /* direction from shading point to light */
18 float u, v; /* parametric coordinate on primitive */
19 float pdf; /* pdf for selecting light and point on light */
20 float pdf_selection; /* pdf for selecting light */
21 float eval_fac; /* intensity multiplier */
22 int object; /* object id for triangle/curve lights */
23 int prim; /* primitive id for triangle/curve lights */
24 int shader; /* shader id */
25 int lamp; /* lamp id */
26 int group; /* lightgroup */
27 LightType type; /* type of light */
28 int emitter_id; /* index in the emitter array */
30
31/* Utilities */
32
34{
35 const float2 uv = sample_uniform_disk(rand);
36 return ru * uv.x + rv * uv.y;
37}
38
40{
41 return ru * (2.0f * rand.x - 1.0f) + rv * (2.0f * rand.y - 1.0f);
42}
43
45{
46 float3 ru, rv;
47
48 make_orthonormals(n, &ru, &rv);
49
50 return ellipse_sample(ru, rv, rand);
51}
52
54{
55 float cos_pi = dot(Ng, I);
56
57 if (cos_pi <= 0.0f)
58 return 0.0f;
59
60 return t * t / cos_pi;
61}
62
63/* Visibility flag om the light shader. */
64ccl_device_inline bool is_light_shader_visible_to_path(const int shader, const uint32_t path_flag)
65{
66 if ((shader & SHADER_EXCLUDE_ANY) == 0) {
67 return true;
68 }
69
70 if (((shader & SHADER_EXCLUDE_DIFFUSE) && (path_flag & PATH_RAY_DIFFUSE)) ||
71 ((shader & SHADER_EXCLUDE_GLOSSY) && ((path_flag & (PATH_RAY_GLOSSY | PATH_RAY_REFLECT)) ==
73 ((shader & SHADER_EXCLUDE_TRANSMIT) && (path_flag & PATH_RAY_TRANSMIT)) ||
74 ((shader & SHADER_EXCLUDE_CAMERA) && (path_flag & PATH_RAY_CAMERA)) ||
75 ((shader & SHADER_EXCLUDE_SCATTER) && (path_flag & PATH_RAY_VOLUME_SCATTER)))
76 {
77 return false;
78 }
79
80 return true;
81}
82
additional_info("compositor_sum_squared_difference_float_shared") .push_constant(Type output_img float dot(value.rgb, luminance_coefficients)") .define("LOAD(value)"
#define ccl_device
#define ccl_device_inline
#define CCL_NAMESPACE_END
@ PATH_RAY_REFLECT
@ PATH_RAY_TRANSMIT
@ PATH_RAY_VOLUME_SCATTER
@ PATH_RAY_GLOSSY
@ PATH_RAY_DIFFUSE
@ PATH_RAY_CAMERA
@ SHADER_EXCLUDE_CAMERA
@ SHADER_EXCLUDE_DIFFUSE
@ SHADER_EXCLUDE_ANY
@ SHADER_EXCLUDE_SCATTER
@ SHADER_EXCLUDE_GLOSSY
@ SHADER_EXCLUDE_TRANSMIT
LightType
ccl_device_inline float3 rectangle_sample(float3 ru, float3 rv, float2 rand)
ccl_device_inline float3 ellipse_sample(float3 ru, float3 rv, float2 rand)
ccl_device float3 disk_light_sample(float3 n, float2 rand)
CCL_NAMESPACE_BEGIN struct LightSample LightSample
ccl_device float light_pdf_area_to_solid_angle(const float3 Ng, const float3 I, float t)
ccl_device_inline bool is_light_shader_visible_to_path(const int shader, const uint32_t path_flag)
#define I
CCL_NAMESPACE_BEGIN ccl_device float2 sample_uniform_disk(const float2 rand)
unsigned int uint32_t
Definition stdint.h:80
packed_float3 Ng
LightType type
float pdf_selection
float x
float y
ccl_device_inline void make_orthonormals(const float3 N, ccl_private float3 *a, ccl_private float3 *b)
Definition util/math.h:593