mitsuba-renderer / mitsuba2

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

[πŸ› bug report][❔ other question] Light cannot pass through the transparent object, creating an unreasonable shadow. #491

Closed Daiqy closed 3 years ago

Daiqy commented 3 years ago

Description

Hi, I am now using Mitsuba2 for my research. There are a bunny and a floor plane in the scene, with a camera (left) and a projector (right). I set the bunny as a transparent material ("Smooth dielectric material" ), and use a "Projection light source" to project an image to the scene. However, I found that the unreasonable shadow can be seen behind the glass bunny, which seems the light cannot pass through the object to reach the floor. But in fact, the object is transparent as shown in the rendered image. output I am wondering what may cause that. Is it a bug? If I want to generate a reasonable result (most lights pass through the transparent object, no all-black shadow), what should I do? Thanks and regards!

System configuration

Reproduce

Here is my scene XML:

<scene version="0.5.0" >

    <integrator type="path" >
        <integer name="maxDepth" value="64" />
    </integrator>

    <emitter type="projector">
        <texture name="irradiance" type="bitmap">
            <string name="filename" value="./mandrill.png"/>
            <boolean name="raw" value="true" />
        </texture>
        <float name="scale" value="1000000" />
        <float name="fov" value="58.13" />
        <transform name="to_world">
            <lookat origin="75, 300, 300" target="75, 50, 0" up="0, 1, 0"/>
        </transform>
    </emitter>

    <sensor type="perspective" >
        <float name="fov" value="58.13" />
        <transform name="toWorld" >
            <lookat origin="0, 300, 300" target="0, 50, 0" up="0, 1, 0"/>
        </transform>

        <sampler type="ldsampler" >
            <integer name="sampleCount" value="256" />
        </sampler>

        <film type="hdrfilm" >
            <integer name="width" value="640" />
            <integer name="height" value="480" />
            <string name="pixelFormat" value="rgb" />
            <boolean name="banner" value="false" />
            <rfilter type="tent" />
        </film>
    </sensor>

    <shape type="obj" >
        <string name="filename" value="./floor.obj" />
    </shape>

    <shape type="obj" >
        <string name="filename" value="./bunny.obj" />
        <bsdf type="dielectric">
            <float name="int_ior" value="1.51"/>
            <float name="ext_ior" value="1.0"/>
        </bsdf>
    </shape>
</scene>

All my code and other files (.obj model, image, etc.) are here: issue.zip

kontramind commented 3 years ago

I'm also getting issues as @Daiqy. Here is a scene with a checkerboard and a transparent bottle. The projector here is sending some stripes (ones that can be used in structured light). This does not look physically correct.

Please advise on what are we doing wrong.

projector_and_transparent_bottle

Some more experiments:

no ambient light - only pattern projection image

rough dielectric material image

thin dielectric material image

Daiqy commented 3 years ago

Description

Hi, I am now using Mitsuba2 for my research. There are a bunny and a floor plane in the scene, with a camera (left) and a projector (right). I set the bunny as a transparent material ("Smooth dielectric material" ), and use a "Projection light source" to project an image to the scene. However, I found that the unreasonable shadow can be seen behind the glass bunny, which seems the light cannot pass through the object to reach the floor. But in fact, the object is transparent as shown in the rendered image. output I am wondering what may cause that. Is it a bug? If I want to generate a reasonable result (most lights pass through the transparent object, no all-black shadow), what should I do? Thanks and regards!

System configuration

  • Platform: Ubuntu 18.04
  • Python version: Python 3.9
  • Mitsuba 2 version: 2.2.1
  • Compiled variants: 'scalar_rgb'

Reproduce

Here is my scene XML:

<scene version="0.5.0" >

  <integrator type="path" >
      <integer name="maxDepth" value="64" />
  </integrator>

  <emitter type="projector">
      <texture name="irradiance" type="bitmap">
          <string name="filename" value="./mandrill.png"/>
          <boolean name="raw" value="true" />
      </texture>
      <float name="scale" value="1000000" />
      <float name="fov" value="58.13" />
      <transform name="to_world">
          <lookat origin="75, 300, 300" target="75, 50, 0" up="0, 1, 0"/>
      </transform>
  </emitter>

  <sensor type="perspective" >
      <float name="fov" value="58.13" />
      <transform name="toWorld" >
          <lookat origin="0, 300, 300" target="0, 50, 0" up="0, 1, 0"/>
      </transform>

      <sampler type="ldsampler" >
          <integer name="sampleCount" value="256" />
      </sampler>

      <film type="hdrfilm" >
          <integer name="width" value="640" />
          <integer name="height" value="480" />
          <string name="pixelFormat" value="rgb" />
          <boolean name="banner" value="false" />
          <rfilter type="tent" />
      </film>
  </sensor>

  <shape type="obj" >
      <string name="filename" value="./floor.obj" />
  </shape>

  <shape type="obj" >
      <string name="filename" value="./bunny.obj" />
      <bsdf type="dielectric">
          <float name="int_ior" value="1.51"/>
          <float name="ext_ior" value="1.0"/>
      </bsdf>
  </shape>
</scene>

All my code and other files (.obj model, image, etc.) are here: issue.zip

Hi @wjakob @merlinND @Speierers, could any Mitsuba contributor give some advice about the question? Thanks again!

merlinND commented 3 years ago

Hello @Daiqy and @kontramind,

In my understanding, this is a limitation of the rendering algorithm (path tracing): your light source only occupies a single point in space, and the bunny object has a delta BSDF. This means that once your light path reached e.g. the diffuse floor plane, there's no way to create a connection back to the light source through the glass bunny with vanilla path tracing.

If you replace the projector by an area light source, you should see this is no longer a problem. Likewise, if you replace the bunny / bottle's BSDF by a non-delta one, like @kontramind did in his experiment above, these connections become possible (but still difficult to render if the roughness is low).

A light tracer integrator (tracing paths from the light source instead of from the camera) will be included in the next release of Mitsuba 2, but this technique also cannot make specular BSDF β†’ delta camera connections. Bidirectional path tracing would be able to render some of the missing paths, but it's a significantly heavier technique which is not on the roadmap for now.

kontramind commented 3 years ago

Hello @Daiqy and @kontramind,

In my understanding, this is a limitation of the rendering algorithm (path tracing): your light source only occupies a single point in space, and the bunny object has a delta BSDF. This means that once your light path reached e.g. the diffuse floor plane, there's no way to create a connection back to the light source through the glass bunny with vanilla path tracing.

If you replace the projector by an area light source, you should see this is no longer a problem. Likewise, if you replace the bunny / bottle's BSDF by a non-delta one, like @kontramind did in his experiment above, these connections become possible (but still difficult to render if the roughness is low).

Hi @merlinND

Many thanks for your answer. To "simulate" an projector one could instantiate a rectangular shape, attach a texture (image) and then add area light? How would one make sure that light is emitted only from one side of the rectangle; eg. tweaking normals?

Aleksandar[kontramind]

merlinND commented 3 years ago

By default, area lights emit only in the direction of the normal (see e.g. light source in the Cornell box), so that wouldn't be a problem.

One difference to the projector is that the light would be emitted in all directions of the hemisphere, so I don't believe you would get the sharp patterns you are looking for. You can already try without the glass object to see how it goes.

When adding back the glass object, you can still expect pretty significant noise since light paths need to hit the rectangular light source "by chance" after refracting through glass (specular interaction, can't sample the emitter directly to ensure it gets hit).

kontramind commented 3 years ago

@merlinND

Yes, I was afraid that getting sharp(focused) patterns with area light would not be viable. Then it seems that I cannot make my scene with mitsuba :). I'll try area light in any case.