Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Analog polarization camera? #832

Open
wxw19990405 opened this issue Jul 28, 2023 · 1 comment
Open

How to Analog polarization camera? #832

wxw19990405 opened this issue Jul 28, 2023 · 1 comment

Comments

@wxw19990405
Copy link

wxw19990405 commented Jul 28, 2023

Summary

The result of the rendered stokes vector is not as expected (there is a rectangle with "linearly polarized" material in front of the camera)

System configuration

System information:

OS: windows 11
Python version: 3.9
Mitsuba version: 3.0
Variants compiled: "llvm_spectral_polarized"

Description

I try to put a polarizer in front of the camera (polarizer is defined by the rectangle of the polarizer through the material) to simulate the polarizer camera. I convert the positions of the polarizer and camera according to my understanding. Because this is the first time I have contact with and learn to apply mitsuba3 rendering, there may be errors in the position transformation. If I understand correctly the polaroid should be 0.5 in front of the camera.

The angle of the polarizer is 0 degree, according to my knowledge, S0 should equal to S1 and S2=0, but the result display S1=0, S2!=0

the code and result are display as following(really need help, thank you very much!)

meshes that i used in the code
meshes.zip

Steps to reproduce

  1. sence setting
scene1 = mi.load_dict({
        'type':'scene',
        'bsdf':{
            'type':'pplastic',
            'diffuse_reflectance':{
                'type':'rgb',
                'value':[0.2, 0.25, 0.7],
            },
            'alpha':0.1,
            'id': 'bsdf-measured'
        },
        'intergrator':{
            'type':'stokes',
            'intergrator':{
                'type':'volpath',
                'max_depth':-1
            }
        },
        'sensor':{
            'type':'perspective',
            # 'fov_axis':'larger',
            'focal_length':'12mm',
            'to_world':T.rotate([0,1,0],90).translate([0,0,75]).rotate([0,0,1],90).rotate([0,1,0],180),
            'sampler':{
                'type':'ref',
                'id':"sampler"
            },
            'film':{
                'type':'ref',
                'id':'film'
            }
        },
        'emitter':{
            'type': 'point',
            'id': 'emitter-envmap',
            'intensity': {
                'type': 'spectrum',
                'value': 5000.0,},
            'to_world': T.rotate([0, 0, 1], 10).rotate([0, 1, 0], 90).translate([0,0,74]),
        },
        },
        'shape1': {
            'type': 'ply',
            'filename': "E:/Mitsuba/dragon/meshes/dragon.ply",
            'bsdf': {
                'type': 'ref',
                'id': 'bsdf-measured'
                },
            'to_world':T.translate([0,0,-30]).scale([100,100,100]).rotate([0,0,1],6).rotate([1,0,0],90)
        },
        'shape2': {
            'type': 'rectangle',
            'bsdf': {
                'type': 'polarizer',
                'theta': {
                    'type': 'spectrum',
                    'value': 0
                }
            },
            'to_world':T.rotate([0, 1, 0], 90).translate([0,0,74.5]).rotate([0,0,1],0),
        },
        'shape3':{
            'type':'ply',
            'filename':"E:/Mitsuba/dragon/meshes/plane.ply",
            'to_world': T.translate([0,0,-30]).rotate([1, 0, 0], 90).scale([10,10,10]).rotate([0,0,1],180),
            'bsdf':{
                'type':'diffuse',
                'reflectance':{
                    'type':'ref',
                    'id':'texture-checkerboard'
                }
            }
        },
    })
  1. sensor transform
    'to_world':T.rotate([0,1,0],90).translate([0,0,75]).rotate([0,0,1],90).rotate([0,1,0],180),
  2. polarizer transform
    'to_world':T.rotate([0, 1, 0], 90).translate([0,0,74.5]).rotate([0,0,1],0),
  3. result(from top to end is S0, S1, S2)
    0degree

1degree

2degree

@wxw19990405 wxw19990405 changed the title Analog polarization camera How to Analog polarization camera? Jul 29, 2023
@wxw19990405
Copy link
Author

I discovered another problem while trying to solve the above problem. This time I directly define the Angle of the polarizer instead of the rotation of the rectangle, when the rotation Angle is 45°, then S1 should be equal to 0, but the result is this
1

the code attachs as following(the configration is same):

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

scene = mi.load_dict({
        'type':'scene',
        'bsdf': {
            'type': 'pplastic',
            'diffuse_reflectance': {
                'type': 'rgb',
                'value': [0.2, 0.25, 0.7],
            },
        'alpha': 0.1,
        'id': 'bsdf-measured'},
        '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], 90) @ 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': 'constant',
            'radiance': {
                'type': 'spectrum',
                'value': 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.translate([0, 0, -30]).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': 45
                }
            },
            'to_world': T.look_at(
                origin=T.rotate([0, 0, 1], 0).rotate([0, 1, 0], 90) @ mi.ScalarPoint3f([0, 0, 74.5]),
                target=[0, 0, 0],
                up = [0,0,1]),
        },
        'shape3': {
            'type': 'ply',
            'filename': "E:/Mitsuba/dragon/meshes/dragon.ply",
            'bsdf': {
                'type': 'ref',
                'id': 'bsdf-measured'
            },
            'to_world': T.translate([0, 0, -30]).scale([100, 100, 100]).rotate([0, 0, 1], 6).rotate([1, 0, 0], 90)
        }
    })
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("2.png", channels['S1'].convert(srgb_gamma=True))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant