문제

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