Skip to content

Commit

Permalink
Fix constant to be opaque
Browse files Browse the repository at this point in the history
  • Loading branch information
njroussel committed May 27, 2024
1 parent c9e881b commit deebe4c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/emitters/constant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ConstantBackgroundEmitter final : public Emitter<Float, Spectrum> {
ConstantBackgroundEmitter(const Properties &props) : Base(props) {
/* Until `set_scene` is called, we have no information
about the scene and default to the unit bounding sphere. */
m_bsphere = ScalarBoundingSphere3f(ScalarPoint3f(0.f), 1.f);
m_bsphere = BoundingSphere3f(ScalarPoint3f(0.f), 1.f);
m_surface_area = 4.f * dr::Pi<ScalarFloat>;

m_radiance = props.texture_d65<Texture>("radiance", 1.f);
Expand All @@ -74,16 +74,22 @@ class ConstantBackgroundEmitter final : public Emitter<Float, Spectrum> {

void set_scene(const Scene *scene) override {
if (scene->bbox().valid()) {
m_bsphere = scene->bbox().bounding_sphere();
ScalarBoundingSphere3f scene_sphere =
scene->bbox().bounding_sphere();
m_bsphere = BoundingSphere3f(scene_sphere.center, scene_sphere.radius);
m_bsphere.radius =
dr::maximum(math::RayEpsilon<Float>,
m_bsphere.radius * (1.f + math::RayEpsilon<Float>));
} else {
m_bsphere = ScalarBoundingSphere3f(ScalarPoint3f(0.f), 1.f);
m_bsphere.center = 0.f;
m_bsphere.radius = math::RayEpsilon<Float>;
}
m_surface_area = 4.f * dr::Pi<ScalarFloat> * dr::sqr(m_bsphere.radius);

dr::make_opaque(m_bsphere.center, m_bsphere.radius, m_surface_area);
}


Spectrum eval(const SurfaceInteraction3f &si, Mask active) const override {
MI_MASKED_FUNCTION(ProfilerPhase::EndpointEvaluate, active);

Expand Down Expand Up @@ -195,10 +201,10 @@ class ConstantBackgroundEmitter final : public Emitter<Float, Spectrum> {
MI_DECLARE_CLASS()
protected:
ref<Texture> m_radiance;
ScalarBoundingSphere3f m_bsphere;
BoundingSphere3f m_bsphere;

/// Surface area of the bounding sphere
ScalarFloat m_surface_area;
Float m_surface_area;
};

MI_IMPLEMENT_CLASS_VARIANT(ConstantBackgroundEmitter, Emitter)
Expand Down

0 comments on commit deebe4c

Please sign in to comment.