Animating camera leads to unexpected results
Consider the following pbrt scene (modified off the example here), where the transformations for the camera at the start and end times are the same, and the x-axis is flipped using Scale:
# Camera transformations ------------
Scale -1 1 1
LookAt 3 4 1.5 # eye
.5 .5 0 # look at point
0 0 1 # up vector
ActiveTransform StartTime
Translate 1 0 0
ActiveTransform EndTime
Translate 1 0 0
ActiveTransform All
# End camera transformations ------
Camera "perspective" "float fov" 45
Sampler "halton" "integer pixelsamples" 4
Integrator "volpath"
Film "rgb" "string filename" "/tmp/testRender.png"
"integer xresolution" [400] "integer yresolution" [400]
WorldBegin
# uniform blue-ish illumination from all directions
LightSource "infinite" "rgb L" [ .4 .45 .5 ]
# approximate the sun
LightSource "distant" "point3 from" [ -30 40 100 ]
"blackbody L" 3000 "float scale" 1.5
AttributeBegin
Material "dielectric"
Shape "sphere" "float radius" 1
AttributeEnd
AttributeBegin
Texture "checks" "spectrum" "checkerboard"
"float uscale" [16] "float vscale" [16]
"rgb tex1" [.1 .1 .1] "rgb tex2" [.8 .8 .8]
Material "diffuse" "texture reflectance" "checks"
Translate 0 0 -1
Shape "bilinearmesh"
"point3 P" [ -20 -20 0 20 -20 0 -20 20 0 20 20 0 ]
"point2 uv" [ 0 0 1 0 1 1 0 1 ]
AttributeEnd
That produces this image:
Now, modify the start or end time transform slightly, and all of a sudden the camera flips unexpectedly. In this case I changed the end time from above by adding 0.1 to the x-axis:
ActiveTransform EndTime
Translate 1.1 0 0
With that adjustment, I get:
This oddity seems to only happen when any of the Scale axes are negative. If all the scale axes are positive, then the animated camera doesn't do the strange flip.
(My pbrt version is based off the most recent commit on master: 39e01e6)
@lijenicol I think the culprit is the 'Scale -1 1 1' statement in your scene.. try to remove and render again
@pbrt4bounty Yes that Scale -1 1 1 directive is part of the problem, and removing it "fixes" the render, but what remains a question is why the mixture of all the things I said above produces unexpected results.
Basically, I removed this in my Pbrt-v4 for Blender integration. 'Scale -1 1 1' is not anymore on the scenes created from this plugin. I don't know the reason why this is in the original pbrt scenes
It's in the original scenes because there was a bug in some of the camera code in pbrt-v1 (and maybe pbrt-v2?) that, when corrected, flipped images horizontally compared to before. So that got added to all of the scene files so renderings wouldn't change.
I agree that the behavior @lijenicol is seeing is a bug; there's no reason that shouldn't work. I haven't had a chance to dig into the code yet but hope do to so later in December.
Thanks @mmp, let us know what you find!
To be honest.. going through my code, I have found a single point where I am forced to use Scale -1 1 1: Spherical Camera
# fix for spherical camera
if cam.pbrt.camera_type == "spherical" and cam.pbrt.mapping_type == "equirectangular":
dat += ('Scale -1 1 1\n')
mtx = mtx @ Matrix.Rotation(math.radians(90.0), 4, 'Y')
Now I don't remember how much time I spent on this part of the code, but maybe there is another solution that doesn't need Scale -1 1 1