15void BlenderSync::sync_light(BL::Object &b_parent,
30 const bool tfm_updated = (light && light->get_tfm() != tfm);
36 if (light->get_is_portal()) {
43 light->
name = b_light.name().c_str();
46 switch (b_light.type()) {
47 case BL::Light::type_POINT: {
48 BL::PointLight b_point_light(b_light);
49 light->set_size(b_point_light.shadow_soft_size());
51 light->set_is_sphere(!b_point_light.use_soft_falloff());
54 case BL::Light::type_SPOT: {
55 BL::SpotLight b_spot_light(b_light);
56 light->set_size(b_spot_light.shadow_soft_size());
58 light->set_spot_angle(b_spot_light.spot_size());
59 light->set_spot_smooth(b_spot_light.spot_blend());
60 light->set_is_sphere(!b_spot_light.use_soft_falloff());
69 case BL::Light::type_SUN: {
70 BL::SunLight b_sun_light(b_light);
71 light->set_angle(b_sun_light.angle());
75 case BL::Light::type_AREA: {
76 BL::AreaLight b_area_light(b_light);
77 light->set_size(1.0f);
78 light->set_sizeu(b_area_light.size());
79 light->set_spread(b_area_light.spread());
80 switch (b_area_light.shape()) {
81 case BL::AreaLight::shape_SQUARE:
82 light->set_sizev(light->get_sizeu());
83 light->set_ellipse(
false);
85 case BL::AreaLight::shape_RECTANGLE:
86 light->set_sizev(b_area_light.size_y());
87 light->set_ellipse(
false);
89 case BL::AreaLight::shape_DISK:
90 light->set_sizev(light->get_sizeu());
91 light->set_ellipse(
true);
93 case BL::AreaLight::shape_ELLIPSE:
94 light->set_sizev(b_area_light.size_y());
95 light->set_ellipse(
true);
104 float3 strength =
get_float3(b_light.color()) * BL::PointLight(b_light).energy();
105 light->set_strength(strength);
112 find_shader(b_light, used_shaders, scene->default_light);
113 light->set_shader(
static_cast<Shader *
>(used_shaders[0]));
117 light->set_cast_shadow(b_light.use_shadow());
118 light->set_use_mis(
get_boolean(clight,
"use_multiple_importance_sampling"));
121 light->set_use_caustics(
get_boolean(clight,
"is_caustics_light"));
123 light->set_max_bounces(
get_int(clight,
"max_bounces"));
126 light->set_random_id(random_id);
133 light->set_is_portal(
get_boolean(clight,
"is_portal"));
136 light->set_is_portal(
false);
139 if (light->get_is_portal()) {
150 light->set_is_shadow_catcher(b_ob_info.
real_object.is_shadow_catcher());
153 string lightgroup = b_ob_info.
real_object.lightgroup();
154 if (lightgroup.empty()) {
155 lightgroup = b_parent.lightgroup();
157 light->set_lightgroup(ustring(lightgroup));
158 light->set_light_set_membership(
160 light->set_shadow_set_membership(
164 light->tag_update(scene);
167void BlenderSync::sync_background_light(BL::SpaceView3D &b_v3d,
bool use_portal)
169 BL::World b_world = view_layer.world_override ? view_layer.world_override : b_scene.world();
174 enum SamplingMethod { SAMPLING_NONE = 0, SAMPLING_AUTOMATIC, SAMPLING_MANUAL, SAMPLING_NUM };
175 int sampling_method =
get_enum(cworld,
"sampling_method", SAMPLING_NUM, SAMPLING_AUTOMATIC);
176 bool sample_as_light = (sampling_method != SAMPLING_NONE);
178 if (sample_as_light || use_portal) {
181 ObjectKey key(b_world, 0, b_world,
false);
183 if (light_map.
add_or_update(&light, b_world, b_world, key) || world_recalc ||
184 b_world.ptr.data != world_map)
187 if (sampling_method == SAMPLING_MANUAL) {
188 light->set_map_resolution(
get_int(cworld,
"sample_map_resolution"));
191 light->set_map_resolution(0);
193 light->set_shader(scene->default_background);
194 light->set_use_mis(sample_as_light);
195 light->set_max_bounces(
get_int(cworld,
"max_bounces"));
198 light->set_is_enabled(
true);
201 light->set_use_caustics(
get_boolean(cworld,
"is_caustics_light"));
203 light->tag_update(scene);
209 world_map = b_world.ptr.data;
210 world_recalc =
false;
constexpr PointerRNA PointerRNA_NULL
static uint64_t get_shadow_set_membership(const BL::Object &parent, const BL::Object &object)
static uint64_t get_light_set_membership(const BL::Object &parent, const BL::Object &object)
bool add_or_update(T **r_data, const BL::ID &id)
void set_recalc(const BL::ID &id)
T * find(const BL::ID &id)
static uint object_ray_visibility(BL::Object &b_ob)
static bool get_boolean(PointerRNA &ptr, const char *name)
static int get_int(PointerRNA &ptr, const char *name)
static float3 get_float3(const BL::Array< float, 2 > &array)
static int get_enum(PointerRNA &ptr, const char *name, int num_values=-1, int default_value=-1)
#define CCL_NAMESPACE_END
static uint hash_string(const char *str)
ccl_device_inline uint hash_uint2(uint kx, uint ky)
@ OBJECT_PERSISTENT_ID_SIZE
@ PATH_RAY_VOLUME_SCATTER
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)