Unexpected Perspective Camera Rays and Grey Image

37 views
Skip to first unread message

AaronMK

unread,
Apr 27, 2009, 2:22:21 AM4/27/09
to pbrt
I am attempting to use a GUI to feed scenes into the PBRT engine, and
the output is a completely gray exr image. Stepping through the
program, I suspect it to be a result of some bad rays being generated
by the camera. I am using the following function to create a
perspective camera for rendering:

--- QPerspectiveCamera.cpp (line 82) -----
PBRT::Camera* QPerspectiveCamera::getPBRTCamera()
{
QSize FilmSize = m_Film->getResolution();
float Screen[4] = {0, 0, FilmSize.width(), FilmSize.height()};

PBRT::Transform WorldToCam = PBRT::LookAt(
PBRT::Point(m_Eye[X], m_Eye[Y], m_Eye[Z]),
PBRT::Point(m_Center[X], m_Center[Y], m_Center[Z]),
PBRT::Vector(m_Up[X], m_Up[Y], m_Up[Z]));

return new PBRT::PerspectiveCamera(
WorldToCam, Screen, m_Near, m_Far, 0.0f, 1.0f, 2.0f, 10.f,
m_FOV, m_Film->getPbrtFilm());
}
-----------------------------------------------------------

The rays generated by the camera do not seem to be within the view
frustum. For example a camera with Eye<0, 1, 0>, Lookat <0, 1, -1>,
Up <0,1,0>, and FOV 35deg is generating a ray of Origin <-0.8, 192.1,
-1> and Direction <0.0005, 1.0, -0.005>. Note the large Y value for
the origin. Is there an obvious mistake I am making that might be
causing this?

Besides putting in hooks for status output to the GUI, moving PBRT
into a separate namespace, some documentation for my benefit, and
fixing the Lookat function to generate Up and Right instead of down
and left vectors (although I was getting bad camera rays before making
that change as well), I have not made many changes to the PBRT source
tree.

FYI, my current full source tree with the VS2008 Project is at
https://sourceforge.net/projects/phyzray/

Thanks for any assistance!

Matt Pharr

unread,
Jun 1, 2009, 7:53:42 PM6/1/09
to pb...@googlegroups.com
I think your error is that you're setting the screen window based on
the film size. Check out the CreateCamera() function in cameras/
perspective.cpp to see how that's usually computed in pbrt. (I think
why that is the way it is is explained in the camera chapter of the
book, but I don't have it with me right now so can't confirm for sure.)

Thanks,
-matt

AaronMK

unread,
Jun 22, 2009, 5:02:41 PM6/22/09
to pbrt
Matt,

Thank you for catching this. Camera rays are now closer to what I
expect.

Now onto other things.

- Aaron
Reply all
Reply to author
Forward
0 new messages