mitsuba-renderer / mitsuba2

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

Including external XML files; and using Shape primitives with gpu variants. #54

Closed abhinavvs closed 4 years ago

abhinavvs commented 4 years ago

I have 2 questions which I list below. Any help with either one of the issues will be much appreciated. Thanks in advance!

Q1) I realize that instantiating geometry using shapegroup and instance plugins aren't available for Mitsuba2 yet. Hence I wanted to split my scene into multiple pieces for better readability. However, I get a Runtime error (like the one shown below) when I try that.

RuntimeError: ​[xml.cpp:1078] Error while loading "hallway/corridorA.xml" (near line 36, col 10):
unreferenced property ["toWorld"] in shape plugin of type "rectangle"

The external file has the following structure:

<scene>
      <!-- Define all the Shapes and bsdfs  -->
</scene>

However, if I copy-paste the contents of the external file into the main scene file, things seem to work. Could someone share a simple working example of how this needs to be done?

Q2) On a slightly unrelated note, my scene is mainly composed of the Mitsuba primitive shapes (sphere and rectangle), but I want to run some applications involving differentiable rendering, i.e. in the gpu_autodiff mode. What's the best way of doing that? Can I somehow convert the Mitsuba shape plugins to .obj or .ply files which I can then load into Mitusba2?

Speierers commented 4 years ago

Hi @abhinavvs ,

Q1: Mitsuba 2 uses the underscore_case naming convention, so toWorld should become to_world. For compability with Mitsuba 1 scenes, the Mitsuba 2 parser is able to do the name conversion itself if a scene version is provided. In your case, this should fix it:

<scene version="0.1.0">
      <!-- Define all the Shapes and bsdfs  -->
</scene>

Q2: Currently, only triangular meshes are supported in the gpu_* modes. You can easily generate .obj meshes for rectangle and sphere with Blender, or use the ones in resources/data/docs/scenes/meshes/.

abhinavvs commented 4 years ago

Thanks, @Speierers - I used the version tag for the older (Mitsuba 1) scene file as mentioned by you, but still got the same error.

Also, I have the following bsdf definition from Mitusba 1 format (this is not part of the external scene file above)

<!-- White paint definition -->
    <bsdf type="twosided" id="white-paint">
        <bsdf type="roughplastic">
            <!-- The BEHR Premium paint is documented as having an RGB color
                 of (247, 248, 244) = #f7f8f4. This is used, although the
                 semi-gloss/eggshell sheen effects this too. -->
            <srgb name="diffuseReflectance" value="#f7f8f4" />
            <string name="distribution" value="ggx" />
            <float name="alpha" value="0.08" />
            <!-- BEHR paint has an acrylic finish, this is an approximate match. -->
            <string name="intIOR" value="acrylic glass" />
            <boolean name="nonlinear" value="true" />
        </bsdf>
    </bsdf>

How can I convert the diffuseReflectance value from <srgb> to <spectrum> or <rgb>? Could you tell me what would be the equivalent BSDF definition for the above material in Mitsuba2?

Also, I see that there are new commits to the repository all the time. For staying up-to-date with the latest version of Mitusba, is it sufficient to simply do a git pullall as mentioned in the docs, or should we build and compile the software again as well?


Update: Looks like the automatic name conversion from Mitsuba 1 to Mitsuba 2 doesn't seem to work for loading external files. I changed the syntax on the external xml file to Mitusba 2 format and things work fine.

Speierers commented 4 years ago

@abhinavvs this is now fixed (77a8024)

Thanks for reporting this!