Skip to content

Commit

Permalink
Spectral mode: fix accidental conversion to double
Browse files Browse the repository at this point in the history
The multiplication with a double-typed constant lead to a float -> double -> float round-trip, which breaks the AD graph.
It was only triggered in spectral modes.
  • Loading branch information
merlinND committed Dec 7, 2022
1 parent 9bd47c7 commit f3ac81b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/mitsuba/core/spectrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ Color<Float, 3> spectrum_to_xyz(const Spectrum<Float, Size> &value,
Color<Float, 3> res = { dr::mean(XYZ.x() * value),
dr::mean(XYZ.y() * value),
dr::mean(XYZ.z() * value) };
return res * MI_CIE_Y_NORMALIZATION;
return res * (dr::scalar_t<Float>) MI_CIE_Y_NORMALIZATION;
}

/**
Expand All @@ -388,7 +388,7 @@ Color<Float, 3> spectrum_to_srgb(const Spectrum<Float, Size> &value,
Color<Float, 3> res = { dr::mean(rgb.x() * value),
dr::mean(rgb.y() * value),
dr::mean(rgb.z() * value) };
return res * MI_CIE_Y_NORMALIZATION;
return res * (dr::scalar_t<Float>) MI_CIE_Y_NORMALIZATION;
}

/// Convert ITU-R Rec. BT.709 linear RGB to XYZ tristimulus values
Expand Down

0 comments on commit f3ac81b

Please sign in to comment.