18 blender::Light &b_light = *blender::id_cast<blender::Light *>(b_ob_info.
object_data);
20 light->
name = b_light.id.name + 2;
22 if (PointLight *point_light =
dynamic_cast<PointLight *
>(light)) {
23 point_light->set_radius(b_light.radius);
26 else if (AreaLight *area_light =
dynamic_cast<AreaLight *
>(light)) {
27 area_light->set_sizeu(b_light.area_size);
28 area_light->set_spread(b_light.area_spread);
32 area_light->set_sizev(area_light->get_sizeu());
35 area_light->set_sizev(b_light.area_sizey);
40 else if (SunLight *sun_light =
dynamic_cast<SunLight *
>(light)) {
41 sun_light->set_angle(b_light.sun_angle);
43 if (SpotLight *spot_light =
dynamic_cast<SpotLight *
>(light)) {
44 spot_light->set_angle(b_light.spotsize);
45 spot_light->set_smooth(b_light.spotblend);
55 light_color *=
make_float3(color[0], color[1], color[2]);
58 const float3 strength = light_color * b_light.energy * exp2f(b_light.exposure);
59 light->set_strength(strength);
67 light->set_use_mis(get_boolean(clight,
"use_multiple_importance_sampling"));
70 light->set_use_caustics(get_boolean(clight,
"is_caustics_light"));
72 light->set_max_bounces(get_int(clight,
"max_bounces"));
74 if (AreaLight *area_light =
dynamic_cast<AreaLight *
>(light)) {
75 area_light->set_is_portal(get_boolean(clight,
"is_portal"));
84 blender::World *b_world = view_layer.world_override ? view_layer.world_override : b_scene->world;
90 enum SamplingMethod { SAMPLING_NONE = 0, SAMPLING_AUTOMATIC, SAMPLING_MANUAL, SAMPLING_NUM };
91 const int sampling_method = get_enum(
92 cworld,
"sampling_method", SAMPLING_NUM, SAMPLING_AUTOMATIC);
93 const bool sample_as_light = (sampling_method != SAMPLING_NONE);
97 const ObjectKey object_key(b_world,
nullptr, b_world,
false);
98 bool update = object_map.add_or_update(&
object, &b_world->id, &b_world->id, object_key);
101 object->set_is_shadow_catcher(
true);
104 object->set_lightgroup(
105 ustring((b_world && b_world->lightgroup) ? b_world->lightgroup->name :
""));
106 object->set_asset_name(ustring(b_world->id.name + 2));
110 Geometry *geom = geometry_map.find(geom_key);
112 update |= geometry_map.update(geom, &b_world->id);
115 geom = scene->create_light_node<BackgroundLight>();
116 geometry_map.add(geom_key, geom);
117 object->set_geometry(geom);
121 if (update || world_recalc || b_world != world_map) {
123 BackgroundLight *light =
static_cast<BackgroundLight *
>(geom);
125 array<Node *> used_shaders;
127 light->set_used_shaders(used_shaders);
129 if (sampling_method == SAMPLING_MANUAL) {
130 light->set_map_resolution(get_int(cworld,
"sample_map_resolution"));
133 light->set_map_resolution(0);
136 light->set_use_mis(sample_as_light);
137 light->set_max_bounces(get_int(cworld,
"max_bounces"));
140 light->set_use_caustics(get_boolean(cworld,
"is_caustics_light"));
142 light->set_cast_shadow(get_boolean(cworld,
"use_shadows"));
146 geometry_map.set_recalc(b_world);
151 world_recalc =
false;
BlenderViewportParameters()
void tag_update(Scene *scene)
void push_back_slow(const T &t)
#define CCL_NAMESPACE_END
VecBase< float, 3 > float3
PointerRNA RNA_id_pointer_create(ID *id)
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
blender::ID * object_data