21 light->
name = b_light.name().c_str();
24 switch (b_light.type()) {
25 case BL::Light::type_POINT: {
26 BL::PointLight b_point_light(b_light);
27 light->set_size(b_point_light.shadow_soft_size());
29 light->set_is_sphere(!b_point_light.use_soft_falloff());
32 case BL::Light::type_SPOT: {
33 BL::SpotLight b_spot_light(b_light);
34 light->set_size(b_spot_light.shadow_soft_size());
36 light->set_spot_angle(b_spot_light.spot_size());
37 light->set_spot_smooth(b_spot_light.spot_blend());
38 light->set_is_sphere(!b_spot_light.use_soft_falloff());
47 case BL::Light::type_SUN: {
48 BL::SunLight b_sun_light(b_light);
49 light->set_angle(b_sun_light.angle());
53 case BL::Light::type_AREA: {
54 BL::AreaLight b_area_light(b_light);
55 light->set_size(1.0f);
56 light->set_sizeu(b_area_light.size());
57 light->set_spread(b_area_light.spread());
58 switch (b_area_light.shape()) {
59 case BL::AreaLight::shape_SQUARE:
60 light->set_sizev(light->get_sizeu());
61 light->set_ellipse(
false);
63 case BL::AreaLight::shape_RECTANGLE:
64 light->set_sizev(b_area_light.size_y());
65 light->set_ellipse(
false);
67 case BL::AreaLight::shape_DISK:
68 light->set_sizev(light->get_sizeu());
69 light->set_ellipse(
true);
71 case BL::AreaLight::shape_ELLIPSE:
72 light->set_sizev(b_area_light.size_y());
73 light->set_ellipse(
true);
83 if (b_light.use_temperature()) {
84 light_color *=
get_float3(b_light.temperature_color());
87 const float3 strength = light_color * BL::PointLight(b_light).energy() *
88 exp2f(b_light.exposure());
89 light->set_strength(strength);
92 light->set_normalize(b_light.normalize());
96 light->set_cast_shadow(b_light.use_shadow());
97 light->set_use_mis(
get_boolean(clight,
"use_multiple_importance_sampling"));
100 light->set_use_caustics(
get_boolean(clight,
"is_caustics_light"));
102 light->set_max_bounces(
get_int(clight,
"max_bounces"));
105 light->set_is_portal(
get_boolean(clight,
"is_portal"));
108 light->set_is_portal(
false);
115void BlenderSync::sync_background_light(BL::SpaceView3D &b_v3d)
117 BL::World b_world = view_layer.world_override ? view_layer.world_override : b_scene.world();
122 enum SamplingMethod { SAMPLING_NONE = 0, SAMPLING_AUTOMATIC, SAMPLING_MANUAL, SAMPLING_NUM };
123 const int sampling_method =
get_enum(
124 cworld,
"sampling_method", SAMPLING_NUM, SAMPLING_AUTOMATIC);
125 const bool sample_as_light = (sampling_method != SAMPLING_NONE);
129 const ObjectKey object_key(b_world,
nullptr, b_world,
false);
130 bool update = object_map.add_or_update(&
object, b_world, b_world, object_key);
133 object->set_is_shadow_catcher(
true);
134 object->set_lightgroup(ustring(b_world ? b_world.lightgroup() :
""));
137 object->set_asset_name(ustring(b_world.name()));
141 Geometry *geom = geometry_map.find(geom_key);
143 update |= geometry_map.update(geom, b_world);
146 geom = scene->create_node<
Light>();
147 geometry_map.add(geom_key, geom);
148 object->set_geometry(geom);
152 if (
update || world_recalc || b_world.ptr.data != world_map) {
156 array<Node *> used_shaders;
158 light->set_used_shaders(used_shaders);
162 if (sampling_method == SAMPLING_MANUAL) {
163 light->set_map_resolution(
get_int(cworld,
"sample_map_resolution"));
166 light->set_map_resolution(0);
169 light->set_use_mis(sample_as_light);
170 light->set_max_bounces(
get_int(cworld,
"max_bounces"));
173 light->set_use_caustics(
get_boolean(cworld,
"is_caustics_light"));
177 geometry_map.set_recalc(b_world);
181 world_map = b_world.ptr.data;
182 world_recalc =
false;
183 viewport_parameters = BlenderViewportParameters(b_v3d, use_developer_ui);
void push_back_slow(const T &t)
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
VecBase< float, 3 > float3
static void update(bNodeTree *ntree)
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
void tag_update(Scene *scene)