mitsuba-renderer / mitsuba2

Mitsuba 2: A Retargetable Forward and Inverse Renderer
Other
2.05k stars 267 forks source link

[🔨 compilation issue] `Spectrum<Float, 36>` fails #547

Closed joeftiger closed 2 years ago

joeftiger commented 2 years ago

Summary

Compiling mitsuba with Spectrum<Float, 36> inside mitsuba.conf fails due to an ambiguous overloaded operator.

System configuration

Description

I am trying to compile mitsuba with a spectrum size of 36. As far as I understood, I have to change the value iniside mitsuba.conf from Spectrum<Float, 4> to Spectrum<Float, 36>. I didn't find any documentation about this value and searched the source code definition of Spectrum to try and understand it.

The compilation then fails with

mitsuba2/ext/enoki/include/enoki/array_masked.h:28:85: error: use of overloaded operator '=' is ambiguous (with operand types 'enoki::Array<float, 36>' and 'const mitsuba::Spectrum<float, 36>')
    template <typename T2> ENOKI_INLINE void operator =(const T2 &value) { if (m) d = value; }
                                                                                  ~ ^ ~~~~~
mitsuba2/src/integrators/volpathmis.cpp:459:45: note: in instantiation of function template specialization 'enoki::detail::MaskedValue<enoki::Array<float, 36>>::operator=<mitsuba::Spectrum<float, 36>>' requested here
                masked(p_over_f[i], active) = select(neq(ratio, ratio), 0.f, ratio);
                                            ^
mitsuba2/src/integrators/volpathmis.cpp:140:13: note: in instantiation of member function 'mitsuba::VolpathMisIntegratorImpl<float, mitsuba::Spectrum<float, 36>, true>::update_weights' requested here
            update_weights(p_over_f, detach(q), 1.0f, channel, perform_rr);
            ^
mitsuba2/src/integrators/volpathmis.cpp:72:5: note: in instantiation of member function 'mitsuba::VolpathMisIntegratorImpl<float, mitsuba::Spectrum<float, 36>, true>::sample' requested here
    VolpathMisIntegratorImpl(const Properties &props) : Base(props) {}
    ^
mitsuba2/src/integrators/volpathmis.cpp:48:37: note: in instantiation of member function 'mitsuba::VolpathMisIntegratorImpl<float, mitsuba::Spectrum<float, 36>, true>::VolpathMisIntegratorImpl' requested here
            result = (Object *) new Impl<true>(m_props);
                                    ^
mitsuba2/ext/enoki/include/enoki/array_recursive.h:30:5: note: candidate function
    ENOKI_ARRAY_IMPORT_BASIC(Base, StaticArrayImpl)
    ^
mitsuba2/ext/enoki/include/enoki/array_generic.h:129:5: note: expanded from macro 'ENOKI_ARRAY_IMPORT_BASIC'
    ENOKI_ARRAY_DEFAULTS(Array)                                                \
    ^
mitsuba2/ext/enoki/include/enoki/array_generic.h:125:12: note: expanded from macro 'ENOKI_ARRAY_DEFAULTS'
    Array &operator=(Array &&) = default;
           ^
mitsuba2/ext/enoki/include/enoki/array.h:83:5: note: candidate function
    ENOKI_ARRAY_IMPORT(Base, Array)
    ^
mitsuba2/ext/enoki/include/enoki/array_generic.h:138:5: note: expanded from macro 'ENOKI_ARRAY_IMPORT'
    ENOKI_ARRAY_IMPORT_BASIC(Base, Array)                                      \
    ^
mitsuba2/ext/enoki/include/enoki/array_generic.h:129:5: note: expanded from macro 'ENOKI_ARRAY_IMPORT_BASIC'
    ENOKI_ARRAY_DEFAULTS(Array)                                                \
    ^
mitsuba2/ext/enoki/include/enoki/array_generic.h:125:12: note: expanded from macro 'ENOKI_ARRAY_DEFAULTS'
    Array &operator=(Array &&) = default;
           ^
1 warning and 1 error generated.
ninja: build stopped: subcommand failed.

Is 36 somehow a magic number that is disallowed? I am trying to compare Mitsuba2 to my bachelor thesis program which uses a spectrum size of 36.

Steps to reproduce

  1. git clone --recursive https://github.com/mitsuba-renderer/mitsuba2.git
  2. cd mitsuba2
  3. git checkout 4e7628c6eed365904ca2ba536b795d1b03410344
  4. cp resources/mitsuba.conf.template mitsuba.conf
  5. Edit mitsuba.conf to replace/include
    "enabled": [
            # The "scalar_rgb" variant *must* be included at the moment.
            "scalar_rgb",
            "scalar_spectral"
    ],
    "default": "scalar_spectral",
    "scalar_spectral": {
        "float": "float",
        "spectrum": "Spectrum<Float, 36>"
    },
  6. mkdir build && cd build
  7. cmake -GNinja ..
  8. ninja
  9. See error
wjakob commented 2 years ago

I'm curious: could you explain why you are compiling Mitsuba with a whoppping 36 spectral samples? Mitsuba uses stochastic sampling to cover the full continuous wavelength domain. (By setting the spectral samples to 36 you will not be getting data with a spectral discretization into 36 separate bins.)

wjakob commented 2 years ago

Aha, indeed -- I saw now in your description that you're trying to do what I mentioned above. This is unfortunately not possible with Mitsuba 2, but you could try PBRTv3 or Mitsuba 1.