[Bf-blender-cvs] [11955d178a5] soc-2020-production-ready-light-tree: Fixed light tree construction.
Sam Kottler
noreply at git.blender.org
Wed Jul 15 20:56:57 CEST 2020
Commit: 11955d178a522ba327538dd9c9e547033590008d
Author: Sam Kottler
Date: Wed Jul 15 12:52:23 2020 -0600
Branches: soc-2020-production-ready-light-tree
https://developer.blender.org/rB11955d178a522ba327538dd9c9e547033590008d
Fixed light tree construction.
There was a bug in the light tree construction that caused mesh lights
to appear as brighter than other lamp lights.
===================================================================
M intern/cycles/kernel/kernel_path_surface.h
M intern/cycles/render/light.cpp
M intern/cycles/render/light_tree.cpp
===================================================================
diff --git a/intern/cycles/kernel/kernel_path_surface.h b/intern/cycles/kernel/kernel_path_surface.h
index c783305d99f..e3746f69da5 100644
--- a/intern/cycles/kernel/kernel_path_surface.h
+++ b/intern/cycles/kernel/kernel_path_surface.h
@@ -113,7 +113,7 @@ ccl_device void accum_light_tree_contribution(KernelGlobals *kg,
float cdf_L = 0.0f;
float cdf_R = 0.0f;
float prob = 0.0f;
- int light;
+ int light = num_emitters - 1;
for (int i = 1; i < num_emitters + 1; ++i) {
prob = calc_light_importance(kg, P, N, offset, i - 1) * sum_inv;
cdf_R = cdf_L + prob;
@@ -167,6 +167,7 @@ ccl_device void accum_light_tree_contribution(KernelGlobals *kg,
scale_factor);
--stack_idx;
+ can_split = true;
continue;
}
else { // Interior node, choose which child(ren) to go down
@@ -220,6 +221,7 @@ ccl_device void accum_light_tree_contribution(KernelGlobals *kg,
}
//++stack_idx;
+ can_split = false;
randu_stack[stack_idx] = randu;
randv_stack[stack_idx] = randv;
offset_stack[stack_idx] = offset;
diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index 0a7eb493c36..ab556d40900 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -507,6 +507,7 @@ void LightManager::device_update_distribution(Device *device,
/* todo: is there a better way than recalcing this? */
/* have getters for the light tree that just accesses build_data? */
+
BoundBox bbox = light_tree.compute_bbox(emissive_prims[j]);
Orientation bcone = light_tree.compute_bcone(emissive_prims[j]);
float energy = light_tree.compute_energy(emissive_prims[j]);
diff --git a/intern/cycles/render/light_tree.cpp b/intern/cycles/render/light_tree.cpp
index 8f60b9097ab..4523e01b953 100644
--- a/intern/cycles/render/light_tree.cpp
+++ b/intern/cycles/render/light_tree.cpp
@@ -269,37 +269,21 @@ float LightTree::compute_energy(const Primitive &prim)
const Transform &tfm = scene->objects[prim.object_id]->tfm;
float area = mesh->compute_triangle_area(triangle_id, tfm);
- emission *= area * M_PI_F;
+ emission *= area * 4;
}
else {
const Light *light = scene->lights[prim.lamp_id];
- /* get emission from shader */
- shader = light->shader;
- bool is_constant_emission = shader->is_constant_emission(&emission);
- if (!is_constant_emission) {
- emission = make_float3(1.0f);
- }
+ emission = light->strength;
- /* calculate the total emission by integrating the emission over the
- * the entire sphere of directions. */
+ /* calculate the max emission in a single direction. */
if (light->type == LIGHT_POINT) {
- emission *= M_4PI_F;
+ emission /= M_PI_F;
}
else if (light->type == LIGHT_SPOT) {
- /* The emission is only non-zero within the cone and if spot_smooth
- * is non-zero there will be a falloff. In this case, approximate
- * the integral by considering a smaller cone without falloff. */
- float spot_angle = light->spot_angle * 0.5f;
- float spot_falloff_angle = spot_angle * (1.0f - light->spot_smooth);
- float spot_middle_angle = (spot_angle + spot_falloff_angle) * 0.5f;
- emission *= M_2PI_F * (1.0f - cosf(spot_middle_angle));
+ emission /= M_PI_F;
}
else if (light->type == LIGHT_AREA) {
- float3 axisu = light->axisu * (light->sizeu * light->size);
- float3 axisv = light->axisv * (light->sizev * light->size);
- float area = len(axisu) * len(axisv);
- emission *= area * M_PI_F;
}
else {
/* LIGHT_DISTANT and LIGHT_BACKGROUND are handled separately */
More information about the Bf-blender-cvs
mailing list