mmp / pbrt-v3

Source code for pbrt, the renderer described in the third edition of "Physically Based Rendering: From Theory To Implementation", by Matt Pharr, Wenzel Jakob, and Greg Humphreys.
http://pbrt.org
BSD 2-Clause "Simplified" License
4.87k stars 1.18k forks source link

Projection light source maps a mirrored texture #230

Closed mshafiei closed 4 years ago

mshafiei commented 5 years ago

I have made a very simple scene containing a projection light source and a plane in front of it. I expect pbrt to render an image very similar to the texture image given to the projection light source but the projected image is mirrored and rotated despite the fact that I assigned the same transformation to the light source as that assigned to the camera. Below is the pbrt scene description and the materials necessary for rendering are attached, pbrt.zip

LookAt 0 -1 0 # eye 0 0 0 # look at point 1 0 0 # up vector Camera "perspective" "float fov" 90

Sampler "halton" "integer pixelsamples" 128 Integrator "path" Film "image" "string filename" "simple.png" "integer xresolution" [512] "integer yresolution" [512]

WorldBegin

LightSource "projection" "color I" [10 10 10] "string mapname" ["./Image2.png"] "float fov" 90 LookAt 0 -1 0 # eye 0 0 0 # look at point 1 0 0 # up vector AttributeBegin Texture "checks" "spectrum" "checkerboard" "float uscale" [8] "float vscale" [8] "rgb tex1" [.1 .1 .1] "rgb tex2" [.8 .8 .8] Material "matte" "texture Kd" [1 1 1] Translate 0 0 0 Shape "trianglemesh" "integer indices" [0 1 2 0 2 3] "point P" [ -60 0 -60 60 0 -60 60 0 60 -60 0 60 ] "float st" [ 0 0 1 0 1 1 0 1 ] AttributeEnd

WorldEnd

fab65 commented 4 years ago

I am dealing with the same problem. Did you have any luck figuring this out, somehow the original defined viewpoint before WorldBegin seems no longer valid when working with Projection lighting, no problem with point light sources though. Could this be a bug, I am running on OSX myself.

mshafiei commented 4 years ago

I found scene description file in PBRT very confusing. I used mitsuba instead for this case.

fab65 commented 4 years ago

Thank you Mohammad, I will give it a try anyway but maybe switch to mitsuba later if unsuccessful.

fab65 commented 4 years ago

It turns out that there is a google group discussion where this is solved. So when you want to project from the camera viewpoint you just use CoordSysTransform "camera" before specifying the LightSource "projection" ... Wrap the whole thing with AttributeBegin ... End and things are ok. See here and search for "problem rendering projection light"

varun19299 commented 3 years ago

Somehow:

LookAt <camera pos> <camera point> <up direction>

isn't the same as CoordSysTransform "camera".

Why is this the case?