mitsuba-renderer / mitsuba3

Mitsuba 3: A Retargetable Forward and Inverse Renderer
https://www.mitsuba-renderer.org/
Other
1.95k stars 228 forks source link

[🐛 bug report] Intersection issues when rays are very long? #61

Closed leroyvn closed 2 years ago

leroyvn commented 2 years ago

Summary

There seems to have intersection issues when rays are very long.

System configuration

Default configuration (in particular, I'm using Embree).

Description

The test scene use consists of a rectangle ("surface") above which an assembly of small disks ("canopy") is floating. For simplicity, all disks have the same orientation. Optionally, a participating medium ("atmosphere") can be added to the scene. I'm using a volumetric path tracer. This setup is defined in a notebook attached to this issue.

canopy_atmosphere.ipynb.zip

Steps to reproduce

Let's first try with an atmosphere-free setup. If I position the camera relatively close to the surface (distance d), I get an image like this (I'm using a monochrome film):

no_atmosphere_dist_0

Setting the distance to 100d and reducing 100-fold the FOV:

no_atmosphere_dist_2

To 10^5d:

no_atmosphere_dist_5

Dark spots appear here, maybe due to intersection points falling behind some disks?

If I add an atmosphere with low extinction coefficient (almost transparent), things look correct (camera at 10^5d):

atmosphere_dist_5

Any idea how we could fix that reliably? I can try scaling scene units that if you think it's interesting.

wjakob commented 2 years ago

A quick question Vincent: is this a new issue specific to mitsuba2-next?

leroyvn commented 2 years ago

All the examples I posted are produced using mitsuba2-next. I made a bunch of similar tests with the old code: would you like me to run exactly the same examples?

leroyvn commented 2 years ago

I forgot to mention: I also tried using a unit disk and positioning the camera further and further away while reducing the FOV, and things were also correct.

wjakob commented 2 years ago

Same question as in #62: can you try compiling with -DMTS_ENABLE_EMBREE=OFF? Embree does not have support for double precision ray tracing. Ditto for OptiX/CUDA.

leroyvn commented 2 years ago

Thanks for the suggestion @wjakob (I actually vividly remember you telling us about k-d tree-related updates for double-precision variants, my bad).

I tried compiling Mitsuba without Embree but build failed due to an unfound enoki-thread header. Relevant information:

Error message:

FAILED: src/librender/python/CMakeFiles/render_scalar_rgb_ext.dir/film_v.cpp.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DENOKI_UNROLL=" " -DLITTLE_ENDIAN -DMTS_ENABLE_LLVM=1 -DMTS_ENABLE_PROFILER=1 -DMTS_VARIANT_FLOAT=float -DMTS_VARIANT_NAME=scalar_rgb -DMTS_VARIANT_SPECTRUM="Color<float, 3>" -Drender_scalar_rgb_ext_EXPORTS -I/Users/leroyv/Documents/src/thirdparty/mitsuba2-next/include -I/Users/leroyv/Documents/src/thirdparty/mitsuba2-next/ext/tinyformat -I/Users/leroyv/Documents/src/thirdparty/mitsuba2-next/build/include -I/Users/leroyv/Documents/src/thirdparty/mitsuba2-next/ext/rgb2spec -I/Users/leroyv/Documents/src/thirdparty/mitsuba2-next/ext/enoki/include -I/Users/leroyv/Documents/src/thirdparty/mitsuba2-next/ext/enoki/ext/enoki-jit/include -isystem /Users/leroyv/miniforge3/envs/mitsuba2-next/include/python3.8 -isystem /Users/leroyv/Documents/src/thirdparty/mitsuba2-next/ext/pybind11/include -stdlib=libc++ -D_LIBCPP_VERSION -fcolor-diagnostics -O3 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk -fPIC -fvisibility=hidden   -fno-math-errno -ffp-contract=fast -fno-trapping-math -march=native -Wall -Wextra -Wno-unused-local-typedefs -Wdouble-promotion -flto=thin -Os -std=gnu++17 -MD -MT src/librender/python/CMakeFiles/render_scalar_rgb_ext.dir/film_v.cpp.o -MF src/librender/python/CMakeFiles/render_scalar_rgb_ext.dir/film_v.cpp.o.d -o src/librender/python/CMakeFiles/render_scalar_rgb_ext.dir/film_v.cpp.o -c /Users/leroyv/Documents/src/thirdparty/mitsuba2-next/src/librender/python/film_v.cpp
In file included from /Users/leroyv/Documents/src/thirdparty/mitsuba2-next/src/librender/python/film_v.cpp:6:
In file included from /Users/leroyv/Documents/src/thirdparty/mitsuba2-next/include/mitsuba/render/scene.h:5:
In file included from /Users/leroyv/Documents/src/thirdparty/mitsuba2-next/include/mitsuba/render/shapegroup.h:8:
/Users/leroyv/Documents/src/thirdparty/mitsuba2-next/include/mitsuba/render/kdtree.h:6:10: fatal error: 'enoki-thread/thread.h' file not found
#include <enoki-thread/thread.h>
         ^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Speierers commented 2 years ago

Looking into this one as well.

Speierers commented 2 years ago

Using LLVM + kdtree should be fixed now: edf8cba

wjakob commented 2 years ago

Thanks @Speierers !

Speierers commented 2 years ago

Actually I am seeing some issues with llvm_ad_rgb_double + kdtree. Still investigating.

Speierers commented 2 years ago

Okay now it should work: 5317787 Sorry for that!

leroyvn commented 2 years ago

Thanks @Speierers! I built Mitsuba without Embree and got correct images with very large distances (I got something correct up to 10^9d, which is 5e6 km in my test case, i.e. way more than the Earth-Moon distance). I guess this closes the issue!

Speierers commented 2 years ago

Great!