Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/films/specfilm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,12 @@ class SpecFilm final : public Film<Float, Spectrum> {
SurfaceInteraction3f si = dr::zeros<SurfaceInteraction3f>();
si.wavelengths = wavelengths;

// The SRF is not necessarily normalized, cancel out multiplicative factors
UnpolarizedSpectrum inv_spec = m_srf->eval(si);
inv_spec = dr::select(inv_spec != 0.f, dr::rcp(inv_spec), 1.f);
UnpolarizedSpectrum values = spec * inv_spec;

for (size_t j = 0; j < m_srfs.size(); ++j) {
UnpolarizedSpectrum weights = m_srfs[j]->eval(si);
aovs[j] = dr::zeros<Float>();

for (size_t i = 0; i<Spectrum::Size; ++i)
aovs[j] = dr::fmadd(weights[i], values[i], aovs[j]);
aovs[j] = dr::fmadd(weights[i], spec[i], aovs[j]);

aovs[j] *= 1.f / Spectrum::Size;
}
Expand Down
13 changes: 9 additions & 4 deletions src/render/sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,15 @@ Sensor<Float, Spectrum>::sample_wavelengths(const SurfaceInteraction3f& /*si*/,
Mask active) const {
if constexpr (is_spectral_v<Spectrum>) {
if (m_srf != nullptr) {
return m_srf->sample_spectrum(
dr::zeros<SurfaceInteraction3f>(),
math::sample_shifted<Wavelength>(sample),
active);
auto wavelengths = m_srf->sample_spectrum(
dr::zeros<SurfaceInteraction3f>(),
math::sample_shifted<Wavelength>(sample),
active).first;
SurfaceInteraction3f si;
si.wavelengths = wavelengths;
auto pdf = m_srf->pdf_spectrum(si, active);
auto weights = dr::select(pdf != 0.f, dr::rcp(pdf), 0.f);
return { wavelengths, weights };
}
} else {
DRJIT_MARK_USED(active);
Expand Down