Blender V4.3
scene/light.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#ifndef __LIGHT_H__
6#define __LIGHT_H__
7
8#include "kernel/types.h"
9
10#include "graph/node.h"
11
12/* included as Light::set_shader defined through NODE_SOCKET_API does not select
13 * the right Node::set overload as it does not know that Shader is a Node */
14#include "scene/shader.h"
15
16#include "util/ies.h"
17#include "util/thread.h"
18#include "util/types.h"
19#include "util/vector.h"
20
22
23class Device;
24class DeviceScene;
25class Progress;
26class Scene;
27class Shader;
28
29class Light : public Node {
30 public:
32
33 Light();
34
35 NODE_SOCKET_API(LightType, light_type)
36 NODE_SOCKET_API(float3, strength)
37
38 NODE_SOCKET_API(float, size)
39 NODE_SOCKET_API(float, angle)
40
41 NODE_SOCKET_API(float, sizeu)
42 NODE_SOCKET_API(float, sizev)
43 NODE_SOCKET_API(bool, ellipse)
44 NODE_SOCKET_API(float, spread)
45
47
48 NODE_SOCKET_API(int, map_resolution)
49 NODE_SOCKET_API(float, average_radiance)
50
51 NODE_SOCKET_API(bool, is_sphere)
52
53 NODE_SOCKET_API(float, spot_angle)
54 NODE_SOCKET_API(float, spot_smooth)
55
56 NODE_SOCKET_API(bool, cast_shadow)
57 NODE_SOCKET_API(bool, use_mis)
58 NODE_SOCKET_API(bool, use_camera)
59 NODE_SOCKET_API(bool, use_diffuse)
60 NODE_SOCKET_API(bool, use_glossy)
61 NODE_SOCKET_API(bool, use_transmission)
62 NODE_SOCKET_API(bool, use_scatter)
63 NODE_SOCKET_API(bool, use_caustics)
64
65 NODE_SOCKET_API(bool, is_shadow_catcher)
66 NODE_SOCKET_API(bool, is_portal)
67 NODE_SOCKET_API(bool, is_enabled)
68
69 NODE_SOCKET_API(Shader *, shader)
70 NODE_SOCKET_API(int, max_bounces)
71 NODE_SOCKET_API(uint, random_id)
72
73 NODE_SOCKET_API(ustring, lightgroup)
74 NODE_SOCKET_API(uint64_t, light_set_membership);
75 NODE_SOCKET_API(uint64_t, shadow_set_membership);
76
77 /* Normalize power by the surface area of the light. */
79
80 void tag_update(Scene *scene);
81
82 /* Check whether the light has contribution the scene. */
83 bool has_contribution(Scene *scene);
84
85 /* Check whether this light participates in light or shadow linking. */
86 bool has_light_linking() const;
87 bool has_shadow_linking() const;
88
89 /* Convenience access to transform. */
90 float3 get_co() const;
91 float3 get_dir() const;
92 float3 get_axisu() const;
93 float3 get_axisv() const;
94
95 friend class LightManager;
96 friend class LightTree;
97};
98
100 public:
101 enum : uint32_t {
102 MESH_NEED_REBUILD = (1 << 0),
103 EMISSIVE_MESH_MODIFIED = (1 << 1),
104 LIGHT_MODIFIED = (1 << 2),
105 LIGHT_ADDED = (1 << 3),
106 LIGHT_REMOVED = (1 << 4),
107 OBJECT_MANAGER = (1 << 5),
108 SHADER_COMPILED = (1 << 6),
109 SHADER_MODIFIED = (1 << 7),
110
111 /* tag everything in the manager for an update */
112 UPDATE_ALL = ~0u,
113
114 UPDATE_NONE = 0u,
115 };
116
117 /* Need to update background (including multiple importance map) */
119
120 LightManager();
122
123 /* IES texture management */
124 int add_ies(const string &ies);
125 int add_ies_from_file(const string &filename);
126 void remove_ies(int slot);
127
128 void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress);
129 void device_free(Device *device, DeviceScene *dscene, const bool free_background = true);
130
131 void tag_update(Scene *scene, uint32_t flag);
132
133 bool need_update() const;
134
135 /* Check whether there is a background light. */
136 bool has_background_light(Scene *scene);
137
138 protected:
139 /* Optimization: disable light which is either unsupported or
140 * which doesn't contribute to the scene or which is only used for MIS
141 * and scene doesn't need MIS.
142 */
143 void test_enabled_lights(Scene *scene);
144
145 void device_update_lights(DeviceScene *dscene, Scene *scene);
146 void device_update_distribution(Device *device,
147 DeviceScene *dscene,
148 Scene *scene,
149 Progress &progress);
150 void device_update_tree(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress);
151 void device_update_background(Device *device,
152 DeviceScene *dscene,
153 Scene *scene,
154 Progress &progress);
155 void device_update_ies(DeviceScene *dscene);
156
162
165
168
170};
171
173
174#endif /* __LIGHT_H__ */
unsigned int uint
SIMD_FORCE_INLINE btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
Definition btVector3.h:303
vector< IESSlot * > ies_slots
uint32_t update_flags
bool need_update_background
int last_background_resolution
thread_mutex ies_mutex
bool last_background_enabled
#define CCL_NAMESPACE_END
#define NODE_SOCKET_API(type_, name)
Definition graph/node.h:55
LightType
unsigned int uint32_t
Definition stdint.h:80
unsigned __int64 uint64_t
Definition stdint.h:90
float3 get_axisv() const
float3 get_axisu() const
bool has_shadow_linking() const
void tag_update(Scene *scene)
float3 get_dir() const
float3 get_co() const
bool has_light_linking() const
bool has_contribution(Scene *scene)
friend class LightManager
Definition scene/light.h:95
short flag
CCL_NAMESPACE_BEGIN typedef std::mutex thread_mutex
Definition thread.h:29