[Bf-blender-cvs] [fdb16b162e0] soc-2022-many-lights-sampling: implement initial bounding computations for point lights
Jebbly
noreply at git.blender.org
Fri Jun 10 16:32:59 CEST 2022
Commit: fdb16b162e0437d9ae4db8920077b4c6b73b89f9
Author: Jebbly
Date: Wed Jun 8 00:49:47 2022 -0400
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rBfdb16b162e0437d9ae4db8920077b4c6b73b89f9
implement initial bounding computations for point lights
===================================================================
M intern/cycles/scene/light_tree.cpp
M intern/cycles/scene/light_tree.h
===================================================================
diff --git a/intern/cycles/scene/light_tree.cpp b/intern/cycles/scene/light_tree.cpp
index 6340440b81b..dc713c229f9 100644
--- a/intern/cycles/scene/light_tree.cpp
+++ b/intern/cycles/scene/light_tree.cpp
@@ -53,6 +53,37 @@ OrientationBounds merge(const OrientationBounds& cone_a,
}
}
+/* to-do: right now, this is assuming that the primitive is a point light.
+/* The plan is to progressively add support for more primitives.
+/* Some of the logic is different from the past GSoC work, so
+/* will have to see which logic is more correct. */
+BoundBox LightTreePrimitive::calculate_bbox(Scene *scene) const
+{
+ BoundBox bbox = BoundBox::empty;
+ Light *lamp = scene->lights[lamp_id];
+ /* A point light should occupy no space, but the bounding box
+ /* should at least contain the position of the point. */
+ bbox.grow(lamp->get_co());
+ return bbox;
+}
+
+OrientationBounds LightTreePrimitive::calculate_bcone(Scene *scene) const
+{
+ OrientationBounds bcone;
+ Light *lamp = scene->lights[lamp_id];
+ bcone.axis = lamp->get_dir() / len(lamp->get_dir());
+ bcone.theta_o = M_PI_F;
+ bcone.theta_e = M_PI_2_F;
+ return bcone;
+}
+
+float LightTreePrimitive::calculate_energy(Scene *scene) const
+{
+ Light *lamp = scene->lights[lamp_id];
+ /* Past GSoC work also divides this by pi, but will need to test which is more accurate. */
+ return scene->shader_manager->linear_rgb_to_gray(lamp->get_strength());
+}
+
void LightTreeBuildNode::init_leaf(
uint offset, uint n, const BoundBox &b, const OrientationBounds &c, float e, float e_var)
{
diff --git a/intern/cycles/scene/light_tree.h b/intern/cycles/scene/light_tree.h
index 8c68eefe9af..25e3bfba318 100644
--- a/intern/cycles/scene/light_tree.h
+++ b/intern/cycles/scene/light_tree.h
@@ -4,6 +4,7 @@
#ifndef __LIGHT_TREE_H__
#define __LIGHT_TREE_H__
+#include "scene/light.h"
#include "scene/scene.h"
#include "util/boundbox.h"
More information about the Bf-blender-cvs
mailing list