mitsuba-renderer / mitsuba3

Mitsuba 3: A Retargetable Forward and Inverse Renderer
https://www.mitsuba-renderer.org/
Other
2.08k stars 243 forks source link

rendered polarized images with polarizer #827

Open wxw19990405 opened 1 year ago

wxw19990405 commented 1 year ago

Summary

Unexpect result with a rectangle with 'linear polarizer' material in front of the camera

System information:

Platform: windows 11 CPU: 12th Gen Intel(R) Core(TM) i7-12700H GPU: Intel(R) lris(R) Xe Graphics Python version: 3.9 Mitsuba version: 3.0 Variants compiled: "llvm_spectral_polarized"

Description

I tried to place a rectangle made of polarizer in front of my camera. In order to get the polarization Angle I wanted, I first rotated the rectangle around the z axis by 0°, 90°, 135° and 45°, and then converted it to the specified position in front of the camera with look at. In order to test whether my rotation method is effective, I put it far away in front of the camera for verification, but it turns out that there are two polarizers in the image and they are side by side in the image, but my code only defined a rectangle with a material of polarizer. The following code is an example of the rectangle rotated by 135°.

Steps to reproduce

sensor setting

'sensor':{
            'type':'perspective',
            # 'fov_axis':'larger',
            'focal_length':'12mm',
            "to_world": T.look_at(
                origin=T.rotate([0, 0, 1], 0).rotate([0, 1, 0], 90) @ mi.ScalarPoint3f([0, 0, 75]),
                target=[0, 0, 0],
                up=[0, 0, 1]),
            'sampler':{
                'type':'ref',
                'id':"sampler"
            },
            'film':{
                'type':'ref',
                'id':'film'
            }
        },

rectangle setting

        'shape2': {
            'type': 'rectangle',
            'bsdf': {
                'type': 'polarizer',
                'theta': {
                    'type': 'spectrum',
                    'value': 0
                }
            },
            'to_world': T.look_at(
                origin=T.rotate([0, 0, 1], 0).rotate([0, 1, 0], 90) @ mi.ScalarPoint3f([0, 0, 66.5]),
                target=[0, 0, 0],
                up=[0, 0, 1]).rotate([0,0,1],135),
        },

result 456

njroussel commented 1 year ago

Hi @wxw19990405

Please follow the issue template and provide us with a complete and minimal reproducer. For the scene, you can usually build up from the mi.cornell_box() for which every user already has all assets.

You can edit your current issue description.

wxw19990405 commented 1 year ago

Hi @njroussel

Sorry, I have revised my description of the problem, I don't know whether I have understood your meaning correctly

njroussel commented 1 year ago

When you create a new issue, there is some existing text in the form - our template - which we'd appreciate if you fully filled out. It saves us a lot of time. Among other minor points, what I'd really want is a script, as short as possible, with some instructions on how to run it, the expected result, an explanation as to why you would expect that result, and also the actual result.

wxw19990405 commented 1 year ago

Hi @njroussel Thanks for such a detailed explanation. I have modified my problem description according to your prompt. Is it OK now?

wxw19990405 commented 1 year ago

Hi! @njroussel When I was debugging, I found that when I set the r(orirgin=T.rotate([0, 0, 1], 0).rotate([0, 1, 0], 90) @ mi.ScalarPoint3f([0, 0, r]) )higher, the two polarizers looked like separation, and when the r was lower, the two polarizers looked like coincidence. Why is this happening? r=75 456 r = 5 ![Uploading 456.png…]()

njroussel commented 1 year ago

I'm unable to reproduce this. As I asked previously, please give me an entire script that I can run -- not a partial scene description.

wxw19990405 commented 1 year ago

@njroussel sorry!here is my entire script, you can directly run it with python

import mitsuba as mi
mi.set_variant("llvm_spectral_polarized")
from mitsuba import ScalarTransform4f as T

scene = mi.load_dict({
        'type':'scene',
        'intergrator':{
            'type':'stokes',
            'intergrator':{
                'type':'volpath',
                'max_depth':-1

            }
        },
        'sampler':{
            'type':'independent',
            'sample_count':512,
            'id': 'sampler',
        },
        'film':{
            'type':'hdrfilm',
            'width':700,
            'height':700,
            'pixel_format': 'rgb',
            'rfilter':{
                'type':'gaussian'
            },
            'id': 'film'
        },
        'sensor':{
            'type':'perspective',
            'focal_length':'12mm',
            "to_world": T.look_at(
                origin=T.rotate([0, 0, 1], 0).rotate([0, 1, 0], 45) @ mi.ScalarPoint3f([0, 0, 75]),
                target=[0, 0, 0],
                up=[0, 0, 1]),
            'sampler':{
                'type':'ref',
                'id':"sampler"
            },
            'film':{
                'type':'ref',
                'id':'film'
            }
        },
        'emitter':{
            'type': 'point',
            'id': 'emitter-envmap',
            'intensity': {
                'type': 'spectrum',
                'value': 4000.0,},
            "to_world": T.look_at(
                origin=T.rotate([0, 0, 1], 2).rotate([0, 1, 0], 45) @ mi.ScalarPoint3f([0, 0, 74.5]),
                target=[0, 0, 0],
                up=[0, 0, 1])

        },
        'texture':{
            'type': 'checkerboard',
            "color0": 0.06,
            'color1': 0.2,
            'to_uv': T.scale([50, 50, 0]),
            'id': "texture-checkerboard",
        },
        'shape1':{
            'type':'ply',
            'filename':"E:/Mitsuba/dragon/meshes/plane.ply",
            'to_world': T.rotate([1, 0, 0], 90).scale([10,10,10]),
            'bsdf':{
                'type':'diffuse',
                'reflectance':{
                    'type':'ref',
                    'id':'texture-checkerboard'
                }
            }
        },
        'shape2': {
            'type': 'rectangle',
            'bsdf': {
                'type': 'polarizer',
                'theta': {
                    'type': 'spectrum',
                    'value': 0
                }
            },
            'to_world': T.look_at(
                origin=T.rotate([0, 0, 1], 0).rotate([0, 1, 0], 45) @ mi.ScalarPoint3f([0, 0, 72]),
                target=[0, 0, 0],
                up = [0,0,1]),
        },
    })
image = mi.render(scene)
bitmap = mi.Bitmap(image, channel_names=['R', 'G', 'B'] + scene.integrator().aov_names())
channels = dict(bitmap.split())
mi.util.write_bitmap("root.png", channels['<root>'].convert(srgb_gamma=True))

the result 457 the meshes i used meshes.zip

merlinND commented 6 months ago

Hello @HuixianZhong,

Please open a new issue describing the problem that you are encountering (making sure to fill the issue template) rather than posting on unrelated Issues.