Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ray Tracer Camera - Orthographic to Perspective Projection

I am implementing a ray tracer and it currently has an orthographic projection. I want to make it into a perspective projection. I know in orthographic you send out a ray from every pixel and check for intersections. In perspective projection, the starting position of the ray is constant rather than starting from every pixel.

So I assume that in perspective projection the ray's starting position should be the camera's position. The problem is that I don't think I ever explicitly placed a camera, so I do not know what to change my ray's starting position to.

How can I determine where my camera is placed? I tried (0,0,0), but that just leaves me with a blank image so I don't think it is right.

like image 750
Ben Reilly Avatar asked Oct 15 '25 03:10

Ben Reilly


1 Answers

In orthographic projection, the rays through each pixel would have the same direction, as if the rays originated from a camera behind the screen placed at infinite distance.

For perspective projection, the camera has to be placed at a finite distance behind the screen. Each ray should originate from the camera and go through each pixel of the screen. The distance between the screen and camera depends on the viewing angle.

like image 138
Sufian Latif Avatar answered Oct 16 '25 20:10

Sufian Latif