Mitsuba2 編譯記錄 2020-06-06

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有很多變體,用以支持不同的功能,這些變體可以同時選擇多個。

  1. 后端計算方式:scalar, packet,gpu,gpu_autodiff。(這里我理解的不一定對,具體的請看文檔)
    scalar:最簡單的數字計算
    packet:使用SSE4.2, AVX, AVX2, and AVX512等CPU指令集加速
    gpu:使用gpu加速
    gpu_autodiff:在gpu的基礎上增加一些可導渲染計算的必要信息
  2. 色彩形式:mono,rgb,spectral
    mono: 黑白,rgb那就是rgb吧,sepctral是使用光譜形式的計算
  3. 偏正光 polarization
  4. 浮點精度
    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即可

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。