I just started working on a ray tracing project. And here is one very basic question: I have the camera position in the world coordinate. How do I determine the position of the view plane? To make it clear: the camera information has already been provided: my camera is at (0,1,10) pointing to (0,0,-1) with a up direction of (0,1,0). For the perspective view: gluPerspective(45,1.0,0.1,100). I'm confused if the camera position is used as the view plane or the view point. Thanks.

有帮助吗?

解决方案

You want a 45 fov and 1 aspect ratio this means that the focal length f is

f = (w/2) / tan(45/2) = (h/2) / tan(45/2)

where w and h are the width and height of your film plane.

If your plane is normalized (in [-1,1]^2) f is simply:

f = 1/tan(45/2)

In a right handed coordinate system your ray origin will be (0,0,f).

The camera is independent from the focal length. You can transform your ray in world space by the camera transformation or transform your world in camera space with the inverse of the camera.

其他提示

I would advice you to look at this lesson from scratchapixel which is a repository for CG programming techniques:

http://scratchapixel.com/lessons/3d-basic-lessons/lesson-6-rays-cameras-and-images/

also:

http://scratchapixel.com/lessons/3d-advanced-lessons/cameras-advanced-techniques/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top