39 const int size = width * height;
40 const int num_channels = 3;
53 for (
int y = 0;
y < height;
y++) {
54 for (
int x = 0;
x < width;
x++) {
55 float const u = (
x + 0.5f) / width;
56 float const v = (
y + 0.5f) / height;
64 d_input_data[
x +
y * width] =
in;
72 float *d_output_data = d_output.data();
74 for (
int y = 0;
y < height;
y++) {
75 for (
int x = 0;
x < width;
x++) {
76 pixels[
y * width +
x].x = d_output_data[(
y * width +
x) * num_channels + 0];
77 pixels[
y * width +
x].y = d_output_data[(
y * width +
x) * num_channels + 1];
78 pixels[
y * width +
x].z = d_output_data[(
y * width +
x) * num_channels + 2];
118 "pointlight", create,
NodeType::NONE, Light::get_node_base_type());
135 return (
area == 0.0f) ? 4.0f :
area;
140 const Object *
object)
const
142 const float invarea =
normalize ? 1.0f /
area(object->get_tfm()) : 1.0f;
145 const float eval_fac = invarea *
M_1_PI_F;
147 uint shader_flags = 0;
148 if (use_mis && radius > 0.0f) {
153 klight->spot.radius = radius;
154 klight->spot.eval_fac = eval_fac;
155 klight->spot.is_sphere = is_sphere && radius != 0.0f;
177 const float cos_half_spot_angle =
cosf(
angle * 0.5f);
178 const float spot_smooth = 1.0f / ((1.0f - cos_half_spot_angle) *
smooth);
179 const float tan_half_spot_angle =
tanf(
angle * 0.5f);
185 const float tan_sq =
sqr(tan_half_spot_angle);
188 klight->spot.cos_half_spot_angle = cos_half_spot_angle;
189 klight->spot.half_cot_half_spot_angle = 0.5f / tan_half_spot_angle;
190 klight->spot.spot_smooth = spot_smooth;
192 klight->spot.cos_half_larger_spread =
inversesqrtf(1.0f + tan_sq *
fmaxf(len_u_sq, len_v_sq) /
195 klight->spot.ray_segment_dp = radius *
196 sqrtf(1.0f + len_w_sq / (tan_sq *
fminf(len_u_sq, len_v_sq)));
224 const float area =
len(axisu * sizeu) *
len(axisv * sizev);
237 const float area_ =
area(object->get_tfm());
238 float invarea = ((
normalize || is_portal) && area_ != 0.0f) ? 1.0f / area_ : 1.0f;
246 klight->area.axis_u = axis_u;
247 klight->area.len_u = len_u;
248 klight->area.axis_v = axis_v;
249 klight->area.len_v = len_v;
250 klight->area.invarea = invarea;
258 const float half_spread = 0.5f *
fmaxf(spread, 0.0f);
264 const float normalize_spread = (half_spread > 0.0f) ?
265 (half_spread > 0.05f ?
266 1.0f / (tan_half_spread - half_spread) :
267 3.0f /
powf(half_spread, 3.0f)) :
270 uint shader_flags = 0;
271 if (use_mis && area_ != 0.0f && spread > 0.0f) {
275 klight->area.tan_half_spread = tan_half_spread;
276 klight->area.normalize_spread = normalize_spread;
303 uint shader_flags = 0;
304 const float half_angle =
angle / 2.0f;
305 if (use_mis && half_angle > 0.0f) {
309 const float one_minus_cosangle = 2.0f *
sqr(
sinf(0.5f * half_angle));
310 const float pdf = (half_angle > 0.0f) ? (
M_1_2PI_F / one_minus_cosangle) : 1.0f;
313 klight->sun.angle = half_angle;
314 klight->sun.one_minus_cosangle = one_minus_cosangle;
315 klight->sun.pdf = pdf;
316 klight->sun.eval_fac =
normalize ? 1.0f /
area(object->get_tfm()) : 1.0f;
317 klight->sun.half_inv_sin_half_angle = (half_angle == 0.0f) ? 0.0f :
318 0.5f /
sinf(0.5f * half_angle);
326 "backgroundlight", create,
NodeType::NONE, Light::get_node_base_type());
328 SOCKET_INT(map_resolution,
"Map Resolution", 0);
329 SOCKET_FLOAT(average_radiance,
"Average Radiance", 0.0f);
346 const Object *
object)
const
348 const uint visibility = scene->
background->get_visibility();
373 for (
const Node *
node : get_used_shaders()) {
374 if (
node->is_modified()) {
398 if ((light->get_sizeu() * light->get_sizev() == 0.0f) ||
413 return (used_shaders.empty()) ? nullptr :
static_cast<Shader *
>(used_shaders[0]);
438 const uint visibility =
object->get_visibility();
439 uint visibility_flag = 0;
456 if (!(object->get_is_shadow_catcher())) {
460 return visibility_flag;
466 const uint shader_flags)
const
468 klight->
type = light_type;
479 klight->
shader_id = shader_id | shader_flags;
499 if (!object->get_geometry()->is_light()) {
503 Light *light =
static_cast<Light *
>(
object->get_geometry());
518 size_t num_lights = 0;
519 bool has_portal =
false;
521 if (!object->get_geometry()->is_light()) {
525 Light *light =
static_cast<Light *
>(
object->get_geometry());
533 num_lights += light->is_enabled;
536 LOG_INFO <<
"Total " << num_lights <<
" lights.";
538 bool background_enabled =
false;
539 int background_resolution = 0;
541 if (!background_lights.empty()) {
549 if (light->is_enabled) {
550 background_enabled =
true;
551 background_resolution = light->get_map_resolution();
555 if (!background_enabled) {
556 LOG_INFO <<
"Background MIS has been disabled.";
574 KernelIntegrator *kintegrator = &dscene->
data.integrator;
575 if (kintegrator->use_light_tree) {
581 progress.
set_status(
"Updating Lights",
"Computing distribution");
584 size_t num_triangles = 0;
586 const int num_lights = kintegrator->num_lights;
587 const size_t max_num_triangles = std::numeric_limits<int>::max() - 1 - kintegrator->num_lights;
598 Mesh *mesh =
static_cast<Mesh *
>(
object->get_geometry());
599 const int mesh_num_triangles =
static_cast<int>(mesh->
num_triangles());
601 for (
int i = 0; i < mesh_num_triangles; i++) {
602 const int shader_index = mesh->get_shader()[i];
603 Shader *shader = (shader_index < mesh->get_used_shaders().size()) ?
604 static_cast<Shader *
>(mesh->get_used_shaders()[shader_index]) :
612 if (num_triangles > max_num_triangles) {
614 "Number of emissive triangles exceeds the limit, consider using Light Tree or disabling "
615 "Emission Sampling on some emissive materials");
619 const size_t num_distribution = num_triangles + num_lights;
622 kintegrator->num_distribution = num_distribution;
624 LOG_INFO <<
"Use light distribution with " << num_distribution <<
" emitters.";
628 float totarea = 0.0f;
642 Mesh *mesh =
static_cast<Mesh *
>(
object->get_geometry());
649 for (
size_t i = 0; i < mesh_num_triangles; i++) {
650 const int shader_index = mesh->get_shader()[i];
651 Shader *shader = (shader_index < mesh->get_used_shaders().size()) ?
652 static_cast<Shader *
>(mesh->get_used_shaders()[shader_index]) :
656 distribution[offset].
totarea = totarea;
659 distribution[offset].
object_id =
object->index;
663 if (!t.
valid(mesh_positions)) {
666 float3 p1 = mesh_positions[t.
v[0]];
667 float3 p2 = mesh_positions[t.
v[1]];
668 float3 p3 = mesh_positions[t.
v[2]];
670 if (!transform_applied) {
681 const float trianglearea = totarea;
686 if (num_lights > 0) {
687 const float lightarea = (totarea > 0.0f) ? totarea / num_lights : 1.0f;
689 if (!object->get_geometry()->is_light()) {
693 Light *light =
static_cast<Light *
>(
object->get_geometry());
694 if (!light->is_enabled) {
698 distribution[offset].
totarea = totarea;
699 distribution[offset].
prim = ~light_index;
700 distribution[offset].
object_id =
object->index;
702 totarea += lightarea;
710 distribution[num_distribution].
totarea = totarea;
711 distribution[num_distribution].
prim = 0;
715 if (totarea > 0.0f) {
716 for (
size_t i = 0; i < num_distribution; i++) {
717 distribution[i].
totarea /= totarea;
719 distribution[num_distribution].
totarea = 1.0f;
727 kintegrator->use_direct_light = (totarea > 0.0f);
731 kintegrator->distribution_pdf_triangles = 0.0f;
732 kintegrator->distribution_pdf_lights = 0.0f;
734 if (trianglearea > 0.0f) {
735 kintegrator->distribution_pdf_triangles = 1.0f / trianglearea;
737 kintegrator->distribution_pdf_triangles *= 0.5f;
742 kintegrator->distribution_pdf_lights = 1.0f / num_lights;
743 if (trianglearea > 0.0f) {
744 kintegrator->distribution_pdf_lights *= 0.5f;
766 const int left_child,
767 const int right_child)
783 if (
node.is_leaf() ||
node.is_distant()) {
785 knode.leaf.first_emitter =
node.get_leaf().first_emitter_index;
787 else if (
node.is_inner()) {
789 knode.inner.left_child = left_child;
790 knode.inner.right_child = right_child;
798 int &next_node_index);
804 int &next_node_index)
807 for (
int i = 0; i <
node.get_leaf().num_emitters; i++) {
808 const int emitter_index = i +
node.get_leaf().first_emitter_index;
819 Mesh *mesh =
static_cast<Mesh *
>(
object->get_geometry());
821 mesh->get_used_shaders()[mesh->get_shader()[emitter.
prim_id]]);
832 kemitter.light.id = emitter.
prim_id;
850 auto map_it = flatten.
instances.find(reference_node);
852 if (instance_node != reference_node) {
855 std::swap(instance_node->
type, reference_node->
type);
862 flatten, instance_node, knodes, kemitters, next_node_index);
868 kinstance_node.instance.reference = map_it->second;
871 flatten.
instances[reference_node] = kemitter.mesh.node_id;
882 int &next_node_index)
885 const int node_index = next_node_index++;
887 int right_child = -1;
889 if (
node->is_leaf() ||
node->is_distant()) {
892 else if (
node->is_inner()) {
918 int &next_node_index)
921 if (
node->is_leaf() ||
node->is_distant()) {
946 int &next_node_index,
947 bool can_share =
true)
954 int right_child = -1;
958 if (depth == 0 && !(
node->light_link.set_membership & light_link_mask)) {
960 node_index = next_node_index++;
963 else if (can_share &&
node->light_link.shareable &&
node->light_link.shared_node_index != -1) {
965 return std::make_pair(
node->light_link.shared_node_index,
node->measure);
967 else if (
node->is_leaf() ||
node->is_distant()) {
969 node_index = next_node_index++;
970 int first_emitter = -1;
971 int num_emitters = 0;
973 for (
int i = 0; i <
node->get_leaf().num_emitters; i++) {
977 if (first_emitter == -1) {
978 first_emitter =
node->get_leaf().first_emitter_index + i;
985 assert(first_emitter != -1);
989 if (
node->is_leaf()) {
990 new_node.
make_leaf(first_emitter, num_emitters);
1009 only_node = right_node;
1012 only_node = left_node;
1019 flatten, only_node, light_link_mask, depth + 1, knodes, next_node_index,
false);
1021 assert(only_index != -1);
1022 knodes[only_index].bit_skip++;
1023 return std::make_pair(only_index, only_measure);
1027 node_index = next_node_index++;
1030 flatten, left_node, light_link_mask, depth + 1, knodes, next_node_index);
1032 flatten, right_node, light_link_mask, depth + 1, knodes, next_node_index);
1034 new_node.
measure = left_measure;
1037 left_child = left_index;
1038 right_child = right_index;
1042 if (knodes.size() <= node_index) {
1043 knodes.resize(node_index + 1);
1047 if (
node->light_link.shareable) {
1048 node->light_link.shared_node_index = node_index;
1051 return std::make_pair(node_index, new_node.
measure);
1059 KernelIntegrator *kintegrator = &dscene->
data.integrator;
1061 if (!kintegrator->use_light_tree) {
1066 progress.
set_status(
"Updating Lights",
"Computing tree");
1070 LightTree light_tree(scene, dscene, progress, 8);
1078 flatten.
scene = scene;
1091 kintegrator->use_direct_light = num_emitters > 0;
1096 memset(klight_link_sets, 0,
sizeof(dscene->
data.light_link_sets));
1098 LOG_INFO <<
"Use light tree with " << num_emitters <<
" emitters and " << light_tree.
num_nodes
1101 if (!use_light_linking) {
1106 int next_node_index = 0;
1111 int next_node_index = 0;
1119 light_link_nodes.resize(light_tree.
num_nodes);
1121 flatten, root, light_link_nodes.data(), kemitters, next_node_index);
1122 light_link_nodes.resize(next_node_index);
1133 klight_link_sets[tree_index].light_tree_root =
1135 flatten, root, tree_mask, 0, light_link_nodes, next_node_index)
1142 memcpy(knodes, light_link_nodes.data(), light_link_nodes.size() *
sizeof(*knodes));
1144 LOG_INFO <<
"Specialized light tree for light linking, with "
1145 << light_link_nodes.size() - light_tree.
num_nodes <<
" additional nodes.";
1163 const int cdf_width = res_x + 1;
1165 for (
int i = start; i < end; i++) {
1167 float3 env_color = (*pixels)[i * res_x];
1170 cond_cdf[i * cdf_width].
x = ave_luminance *
sin_theta;
1171 cond_cdf[i * cdf_width].
y = 0.0f;
1173 for (
int j = 1; j < res_x; j++) {
1174 env_color = (*pixels)[i * res_x + j];
1177 cond_cdf[i * cdf_width + j].
x = ave_luminance *
sin_theta;
1178 cond_cdf[i * cdf_width + j].
y = cond_cdf[i * cdf_width + j - 1].
y +
1179 cond_cdf[i * cdf_width + j - 1].
x / res_x;
1182 const float cdf_total = cond_cdf[i * cdf_width + res_x - 1].
y +
1183 cond_cdf[i * cdf_width + res_x - 1].
x / res_x;
1187 cond_cdf[i * cdf_width + res_x].
x = cdf_total;
1189 if (cdf_total > 0.0f) {
1190 const float cdf_total_inv = 1.0f / cdf_total;
1191 for (
int j = 1; j < res_x; j++) {
1192 cond_cdf[i * cdf_width + j].
y *= cdf_total_inv;
1196 cond_cdf[i * cdf_width + res_x].
y = 1.0f;
1205 KernelIntegrator *kintegrator = &dscene->
data.integrator;
1206 KernelBackground *kbackground = &dscene->
data.background;
1209 bool background_mis =
false;
1213 if (!object->get_geometry()->is_light()) {
1217 Light *light =
static_cast<Light *
>(
object->get_geometry());
1220 background_mis |= light->use_mis;
1224 kbackground->portal_weight = kintegrator->num_portals > 0 ? 1.0f : 0.0f;
1225 kbackground->map_weight = background_mis ? 1.0f : 0.0f;
1226 kbackground->sun_weight = 0.0f;
1229 if (!background_light || !background_light->is_enabled) {
1230 kbackground->map_res_x = 0;
1231 kbackground->map_res_y = 0;
1232 kbackground->map_dD =
FLT_MAX;
1233 kbackground->use_mis = (kbackground->portal_weight > 0.0f);
1237 progress.
set_status(
"Updating Lights",
"Importance map");
1242 float sun_average_radiance = 0.0f;
1244 if (
node->type == EnvironmentTextureNode::get_node_type()) {
1248 environment_res.
x =
max(environment_res.
x, (
int)metadata.
width);
1249 environment_res.
y =
max(environment_res.
y, (
int)metadata.
height);
1252 if (
node->type == SkyTextureNode::get_node_type()) {
1254 if (sky->get_sun_disc()) {
1261 if ((vec_src->
type != TextureCoordinateNode::get_node_type()) ||
1262 (vec_in->
link != vec_src->
output(
"Generated")))
1264 environment_res.
x =
max(environment_res.
x, 4096);
1265 environment_res.
y =
max(environment_res.
y, 2048);
1271 const float latitude = sky->get_sun_elevation();
1272 const float longitude = sky->get_sun_rotation() +
M_PI_2_F;
1283 kbackground->sun_weight = 4.0f;
1285 environment_res.
x =
max(environment_res.
x, 512);
1286 environment_res.
y =
max(environment_res.
y, 256);
1293 kbackground->use_sun_guiding = (num_suns == 1);
1294 if (!kbackground->use_sun_guiding) {
1295 kbackground->sun_weight = 0.0f;
1296 environment_res.
x =
max(environment_res.
x, 4096);
1297 environment_res.
y =
max(environment_res.
y, 2048);
1301 kbackground->use_mis = (kbackground->portal_weight + kbackground->map_weight +
1302 kbackground->sun_weight) > 0.0f;
1305 int2 res =
make_int2(background_light->get_map_resolution(),
1306 background_light->get_map_resolution() / 2);
1309 res = environment_res;
1310 if (res.
x > 0 && res.
y > 0) {
1311 LOG_INFO <<
"Automatically set World MIS resolution to " << res.
x <<
" by " << res.
y;
1315 if (res.
x == 0 || res.
y == 0) {
1317 LOG_INFO <<
"Setting World MIS resolution to default";
1319 kbackground->map_res_x = res.
x;
1320 kbackground->map_res_y = res.
y;
1325 kbackground->map_dD = (kbackground->map_weight > 0.0f && res.
x > 0 && res.
y > 0) ?
1337 const int cdf_width = res.
x + 1;
1341 const double time_start =
time_dt();
1344 const int rows_per_task =
divide_up(10240, res.
x);
1345 parallel_for(blocked_range<size_t>(0, res.
y, rows_per_task),
1346 [&](
const blocked_range<size_t> &r) {
1347 background_cdf(r.begin(), r.end(), res.x, res.y, &pixels, cond_cdf);
1351 marg_cdf[0].
x = cond_cdf[res.
x].
x;
1352 marg_cdf[0].
y = 0.0f;
1354 for (
int i = 1; i < res.
y; i++) {
1355 marg_cdf[i].
x = cond_cdf[i * cdf_width + res.
x].
x;
1356 marg_cdf[i].
y = marg_cdf[i - 1].
y + marg_cdf[i - 1].
x / res.
y;
1359 const float cdf_total = marg_cdf[res.
y - 1].
y + marg_cdf[res.
y - 1].
x / res.
y;
1360 marg_cdf[res.
y].
x = cdf_total;
1362 const float map_average_radiance = cdf_total *
M_PI_2_F;
1363 if (sun_average_radiance > 0.0f) {
1368 background_light->set_average_radiance(0.8f * map_average_radiance +
1369 0.2f * sun_average_radiance);
1372 background_light->set_average_radiance(map_average_radiance);
1375 if (cdf_total > 0.0f) {
1376 for (
int i = 1; i < res.
y; i++) {
1377 marg_cdf[i].
y /= cdf_total;
1381 marg_cdf[res.
y].
y = 1.0f;
1392 size_t num_lights = 0;
1393 size_t num_portals = 0;
1394 size_t num_background_lights = 0;
1395 size_t num_distant_lights = 0;
1398 if (!object->get_geometry()->is_light()) {
1402 const Light *light =
static_cast<const Light *
>(
object->get_geometry());
1403 if (light->is_enabled) {
1412 kintegrator->num_lights = num_lights;
1413 kintegrator->num_distant_lights = num_distant_lights;
1414 kintegrator->num_background_lights = num_background_lights;
1415 kintegrator->num_portals = num_portals;
1416 kintegrator->portal_offset = num_lights;
1421 KernelIntegrator *kintegrator = &dscene->
data.integrator;
1422 kintegrator->use_light_tree = scene->
integrator->get_use_light_tree();
1429 int light_index = 0;
1430 int portal_index = kintegrator->num_lights;
1433 if (!object->get_geometry()->is_light()) {
1437 const Light *light =
static_cast<const Light *
>(
object->get_geometry());
1442 else if (light->is_enabled) {
1448 LOG_INFO <<
"Number of lights sent to the device: " << kintegrator->num_lights;
1464 scene->
update_stats->light.times.add_entry({
"device_update", time});
1506 const bool free_background)
1516 if (free_background) {
1536 bool log_parsing_error =
true;
1538 if (!filename.empty()) {
1540 LOG_ERROR <<
"Could not read IES file from " << filename;
1541 log_parsing_error =
false;
1545 log_parsing_error =
false;
1548 return add_ies(content, log_parsing_error);
1553 const uint
hash = hash_string(content.c_str());
1559 for (slot = 0; slot <
ies_slots.size(); slot++) {
1567 for (slot = 0; slot <
ies_slots.size(); slot++) {
1575 ies_slots.push_back(make_unique<IESSlot>());
1578 const bool valid_ies =
ies_slots[slot]->ies.load(content);
1579 if (!valid_ies && log_parsing_error) {
1580 LOG_ERROR <<
"Could not parse IES file, invalid content";
1596 if (slot < 0 || slot >=
ies_slots.size()) {
1615 if (slot->users == 0) {
1623 for (slot_end =
ies_slots.size(); slot_end; slot_end--) {
1624 if (
ies_slots[slot_end - 1]->users > 0) {
1632 int packed_size = 0;
1634 packed_size += slot->ies.packed_size();
1643 for (
int i = 0; i <
ies_slots.size(); i++) {
1644 const int size =
ies_slots[i]->ies.packed_size();
ccl_device_inline float sin_theta(const float3 w)
unsigned long long int uint64_t
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
float area(const Transform &tfm) const override
void copy_to_kernel(KernelLight *klight, const Scene *scene, const Object *object) const override
float area(const Transform &tfm) const override
void copy_to_kernel(KernelLight *klight, const Scene *scene, const Object *object) const override
Shader * get_shader(const Scene *scene)
device_vector< KernelLightTreeEmitter > light_tree_emitters
device_vector< KernelLightTreeNode > light_tree_nodes
device_vector< float2 > light_background_marginal_cdf
device_vector< uint > object_lookup_offset
device_vector< float > ies_lights
device_vector< float2 > light_background_conditional_cdf
device_vector< KernelLightDistribution > light_distribution
device_vector< uint > triangle_to_tree
device_vector< uint > light_to_tree
device_vector< KernelLight > lights
virtual void const_copy_to(const char *name, void *host, const size_t size)=0
const packed_float3 * get_position() const
Geometry(const NodeType *node_type, const Type type)
ImageMetaData metadata(Progress &progress)
void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress)
void count_lights(KernelIntegrator *kintegrator, const Scene *scene)
void device_update_ies(DeviceScene *dscene)
void device_update_tree(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress)
vector< unique_ptr< IESSlot > > ies_slots
int add_ies_from_file(const string &filename)
void device_update_lights(DeviceScene *dscene, Scene *scene)
void test_enabled_lights(Scene *scene)
void device_free(Device *device, DeviceScene *dscene, const bool free_background=true)
void remove_ies(const int slot)
void device_update_distribution(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress)
bool need_update_background
int add_ies(const string &content, const bool log_parsing_error)
void tag_update(Scene *scene, const uint32_t flag)
void device_update_background(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress)
int last_background_resolution
bool has_background_light(Scene *scene)
bool last_background_enabled
std::atomic< int > num_nodes
const LightTreeEmitter * get_emitters() const
uint64_t light_link_receiver_used
LightTreeNode * build(Scene *scene, DeviceScene *dscene)
size_t num_emitters() const
bool has_contribution(const Scene *scene, const Object *object)
bool is_distant_light() const
Light(const NodeType *node_type, const Geometry::Type type)
bool is_spot_light() const
void tag_update(Scene *scene)
void get_uv_tiles(ustring map, unordered_set< int > &tiles) override
bool is_sun_light() const
void copy_to_kernel(KernelLight *klight, const Scene *scene, const Object *object, const uint shader_flags) const
void compute_bounds() override
virtual bool is_portal_light() const
void apply_transform(const Transform &tfm, const bool apply_to_motion) override
PrimitiveType primitive_type() const override
Shader * get_shader() const
bool is_background_light() const
bool is_point_light() const
bool is_area_light() const
size_t num_triangles() const
Triangle get_triangle(const size_t i) const
bool usable_as_light() const
void copy_to_kernel(KernelLight *klight, const Scene *scene, const Object *object) const override
float area(const Transform &tfm) const override
void set_status(const string &status_, const string &substatus_="")
void set_error(const string &error_message_)
unique_ptr< LightManager > light_manager
unique_ptr< SceneUpdateStats > update_stats
unique_ptr< ShaderManager > shader_manager
bool use_light_mis() const
unique_ptr_vector< Object > objects
bool eval(const ShaderEvalType type, const int max_num_inputs, const int num_channels, const std::function< int(device_vector< KernelShaderEvalInput > &)> &fill_input, const std::function< void(device_vector< float > &)> &read_output)
ShaderInput * input(const char *name)
ShaderOutput * output(const char *name)
bool has_surface_spatial_varying
EmissionSampling emission_sampling
NODE_DECLARE unique_ptr< ShaderGraph > graph
float get_sun_average_radiance()
void copy_to_kernel(KernelLight *klight, const Scene *scene, const Object *object) const override
float area(const Transform &tfm) const override
void copy_to_kernel(KernelLight *klight, const Scene *scene, const Object *object) const override
Transform compute_transform()
TextureMapping tex_mapping
T * alloc(const size_t width, const size_t height=0)
#define LIGHT_LINK_SET_MAX
#define CCL_NAMESPACE_END
#define assert(assertion)
VecBase< float, D > normalize(VecOp< float, D >) RET
VecT safe_normalize(VecT vector)
@ PATH_RAY_VISIBILITY_VOLUME_SCATTER
@ PATH_RAY_VISIBILITY_CAMERA
@ PATH_RAY_VISIBILITY_TRANSMIT
@ PATH_RAY_VISIBILITY_DIFFUSE
@ PATH_RAY_VISIBILITY_GLOSSY
@ SHADER_EXCLUDE_SHADOW_CATCHER
@ SHADER_EXCLUDE_TRANSMIT
ccl_device_inline float inversesqrtf(const float f)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
ccl_device_inline dual1 len_squared(const ccl_private dual< T > &a)
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
ccl_device_inline float2 normalize_len(const float2 a, ccl_private float *t)
ccl_device_inline void copy_v3_v3(ccl_private float *r, const float3 val)
ccl_device_inline float3 one_float3()
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
ccl_device_inline float triangle_area(const ccl_private float3 &v1, const ccl_private float3 &v2, const ccl_private float3 &v3)
#define SOCKET_FLOAT(name, ui_name, default_value,...)
#define SOCKET_INT(name, ui_name, default_value,...)
#define NODE_DEFINE(structname)
#define SOCKET_COLOR(name, ui_name, default_value,...)
#define SOCKET_BOOLEAN(name, ui_name, default_value,...)
#define NODE_ABSTRACT_DEFINE(structname)
#define SOCKET_ENUM(name, ui_name, values, default_value,...)
bool path_read_text(const string &path, string &text)
static void light_tree_emitters_copy_and_flatten(LightTreeFlatten &flatten, const LightTreeNode *node, KernelLightTreeNode *knodes, KernelLightTreeEmitter *kemitters, int &next_node_index)
static CCL_NAMESPACE_BEGIN void shade_background_pixels(Device *device, DeviceScene *dscene, const int width, const int height, vector< float3 > &pixels, Progress &progress)
static int light_tree_flatten(LightTreeFlatten &flatten, const LightTreeNode *node, KernelLightTreeNode *knodes, KernelLightTreeEmitter *kemitters, int &next_node_index)
static void light_tree_leaf_emitters_copy_and_flatten(LightTreeFlatten &flatten, const LightTreeNode &node, KernelLightTreeNode *knodes, KernelLightTreeEmitter *kemitters, int &next_node_index)
static uint light_object_visibility_flags(const Object *object)
static void light_tree_node_copy_to_device(KernelLightTreeNode &knode, const LightTreeNode &node, const int left_child, const int right_child)
static void background_cdf(int start, const int end, const int res_x, const int res_y, const vector< float3 > *pixels, float2 *cond_cdf)
static std::pair< int, LightTreeMeasure > light_tree_specialize_nodes_flatten(const LightTreeFlatten &flatten, LightTreeNode *node, const uint64_t light_link_mask, const int depth, vector< KernelLightTreeNode > &knodes, int &next_node_index, bool can_share=true)
float3 sun_direction(float sun_cos_theta)
__forceinline bool is_mesh() const
__forceinline bool is_triangle() const
unique_ptr< LightTreeNode > root
uint64_t light_set_membership
__forceinline bool is_light() const
const uint * object_lookup_offset
const LightTreeEmitter * emitters
std::unordered_map< LightTreeNode *, int > instances
__forceinline void add(const LightTreeMeasure &measure)
void make_leaf(const int first_emitter_index, const int num_emitters)
LightTreeNode * get_reference()
std::variant< Leaf, Inner, Instance > variant_type
void make_distant(const int first_emitter_index, const int num_emitters)
__forceinline bool is_inner() const
LightTreeLightLink light_link
bool valid(const packed_float3 *verts) const
void insert(const char *x, const int y)
static NodeType * add(const char *name, CreateFunc create, Type type=NONE, const NodeType *base=nullptr)
Node(const NodeType *type, ustring name=ustring())
std::unique_lock< std::mutex > thread_scoped_lock
CCL_NAMESPACE_BEGIN double time_dt()
ccl_device_inline size_t divide_up(const size_t x, const size_t y)