美文网首页
Mitsuba2 编译记录 2020-06-06

Mitsuba2 编译记录 2020-06-06

作者: 笨蛋白熊 | 来源:发表于2020-06-06 19:18 被阅读0次

    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即可

    相关文章

      网友评论

          本文标题:Mitsuba2 编译记录 2020-06-06

          本文链接:https://www.haomeiwen.com/subject/ptxxtktx.html