Documentation:https://mitsuba2.readthedocs.io/en/latest/
如何評價Mitsuba2渲染器? - 閆令琪的回答 - 知乎
https://www.zhihu.com/question/376628212/answer/1120415596
下載代碼
git clone --recursive https://github.com/mitsuba-renderer/mitsuba2
Mitsuba2有很多變體,用以支持不同的功能,這些變體可以同時選擇多個。
- 后端計算方式:scalar, packet,gpu,gpu_autodiff。(這里我理解的不一定對,具體的請看文檔)
scalar:最簡單的數字計算
packet:使用SSE4.2, AVX, AVX2, and AVX512等CPU指令集加速
gpu:使用gpu加速
gpu_autodiff:在gpu的基礎上增加一些可導渲染計算的必要信息 - 色彩形式:mono,rgb,spectral
mono: 黑白,rgb那就是rgb吧,sepctral是使用光譜形式的計算 - 偏正光 polarization
- 浮點精度
32bit floating(default)或者64bit floating
設置mitsuba.conf
編譯之前先把resource/mitsuba.conf.template文件復制到mitsuba2的root路徑下面,rename為mitsuba.conf
cd <..mitsuba repository..>
cp resources/mitsuba.conf.template mitsuba.conf
找到里面這么一段
"enabled": [
# The "scalar_rgb" variant must be included at the moment.
"scalar_rgb",
"scalar_spectral"
],
在里面刪除或者添加自已要的功能。這里我只用了scalar_rgb和packet_rgb。
scalar_rgb是必須保留的,packet是官方推薦使用pythonapi的用戶添加的
1. 編譯
Linux和windows都能夠支持,這里只寫linux (WSL同樣適用)
安裝必要組件:
sudo apt install clang-9 libc++-9-dev libc++abi-9-dev cmake ninja-build
sudo apt install libz-dev libpng-dev libjpeg-dev libxrandr-dev libxinerama-dev libxcursor-dev
# 這里也可以使用conda來安裝python,記得要先激活要用到conda環境
sudo apt install python3-dev python3-distutils python3-setuptools
設置環境變量指定clang編譯器的版本
export CC=clang-9
export CXX=clang++-9
最后創建一個build文件夾,然后用cmake編譯就完事了。
# Create a directory where build products are stored
mkdir build
cd build
cmake -GNinja .. # 創建ninja編譯文件
ninja # 使用ninja編譯
編譯完了之后執行setpath,就可以使用了,setpath設置了環境變量PYTHONPATH和PATH
# On Linux / Mac OS
source setpath.sh
# On Windows
C:/.../mitsuba2> setpath
簡單測試一下:
mitsuba -m scalar_rgb scene.xml
compiling issue
這里我遇到報了個錯是
Could NOT find Sphinx (missing: SPHINX_EXECUTABLE)
conda install sphinx即可