28 void BlenderSync::sync_light(
BL::Object &b_parent,
38 ObjectKey key(b_parent, persistent_id, b_ob_instance,
false);
45 if (light->get_is_portal())
52 switch (b_light.type()) {
53 case BL::Light::type_POINT: {
54 BL::PointLight b_point_light(b_light);
55 light->set_size(b_point_light.shadow_soft_size());
59 case BL::Light::type_SPOT: {
60 BL::SpotLight b_spot_light(b_light);
61 light->set_size(b_spot_light.shadow_soft_size());
63 light->set_spot_angle(b_spot_light.spot_size());
64 light->set_spot_smooth(b_spot_light.spot_blend());
73 case BL::Light::type_SUN: {
74 BL::SunLight b_sun_light(b_light);
75 light->set_angle(b_sun_light.angle());
79 case BL::Light::type_AREA: {
80 BL::AreaLight b_area_light(b_light);
81 light->set_size(1.0f);
84 light->set_sizeu(b_area_light.size());
85 light->set_spread(b_area_light.spread());
86 switch (b_area_light.shape()) {
87 case BL::AreaLight::shape_SQUARE:
88 light->set_sizev(light->get_sizeu());
89 light->set_round(
false);
91 case BL::AreaLight::shape_RECTANGLE:
92 light->set_sizev(b_area_light.size_y());
93 light->set_round(
false);
95 case BL::AreaLight::shape_DISK:
96 light->set_sizev(light->get_sizeu());
97 light->set_round(
true);
99 case BL::AreaLight::shape_ELLIPSE:
100 light->set_sizev(b_area_light.size_y());
101 light->set_round(
true);
110 float3 strength =
get_float3(b_light.color()) * BL::PointLight(b_light).energy();
111 light->set_strength(strength);
121 light->set_shader(
static_cast<Shader *
>(used_shaders[0]));
126 light->set_cast_shadow(
get_boolean(clight,
"cast_shadow"));
127 light->set_use_mis(
get_boolean(clight,
"use_multiple_importance_sampling"));
129 int samples =
get_int(clight,
"samples");
131 light->set_samples(samples * samples);
133 light->set_samples(samples);
135 light->set_max_bounces(
get_int(clight,
"max_bounces"));
137 if (b_ob != b_ob_instance) {
138 light->set_random_id(random_id);
145 light->set_is_portal(
get_boolean(clight,
"is_portal"));
147 light->set_is_portal(
false);
149 if (light->get_is_portal())
163 void BlenderSync::sync_background_light(BL::SpaceView3D &b_v3d,
bool use_portal)
171 enum SamplingMethod { SAMPLING_NONE = 0, SAMPLING_AUTOMATIC, SAMPLING_MANUAL, SAMPLING_NUM };
172 int sampling_method =
get_enum(cworld,
"sampling_method", SAMPLING_NUM, SAMPLING_AUTOMATIC);
173 bool sample_as_light = (sampling_method != SAMPLING_NONE);
175 if (sample_as_light || use_portal) {
178 ObjectKey key(b_world, 0, b_world,
false);
180 if (light_map.
add_or_update(&light, b_world, b_world, key) || world_recalc ||
181 b_world.ptr.data != world_map) {
183 if (sampling_method == SAMPLING_MANUAL) {
184 light->set_map_resolution(
get_int(cworld,
"sample_map_resolution"));
187 light->set_map_resolution(0);
190 light->set_use_mis(sample_as_light);
191 light->set_max_bounces(
get_int(cworld,
"max_bounces"));
194 light->set_is_enabled(
true);
196 int samples =
get_int(cworld,
"samples");
198 light->set_samples(samples * samples);
200 light->set_samples(samples);
208 world_map = b_world.ptr.data;
209 world_recalc =
false;
@ OBJECT_PERSISTENT_ID_SIZE
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)
bool add_or_update(T **r_data, const BL::ID &id)
void set_recalc(const BL::ID &id)
#define CCL_NAMESPACE_END
void KERNEL_FUNCTION_FULL_NAME() shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int filter, int i, int offset, int sample)
@ PATH_RAY_VOLUME_SCATTER
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
void tag_update(Scene *scene)
Shader * default_background
static uint hash_string(const char *str)
ccl_device_inline uint hash_uint2(uint kx, uint ky)