Ray-Tracing: Generating Camera Rays

raster space 光栅空间
(the point coordinates are expressed in pixels with coordinates(0,0) being the top-left corder of the frame)
is a two-dimensional pixel location on the screen bounded by (0, 0) in the lower left corner of the image, and the rendered image resolution.
The center of the pixel in the lower left corner of raster space has the coordinates (0.5, 0.5).

NDC space
in ray-tracing (0,0) top-left range(0, 1) is different than NDC space in the rasterization world where it generally maps to the range [-1,1])

screen space 屏幕空间
is defined such that (-1, -1/a) is in the lower left corner of the screen and (1, 1/a) is in the upper right, where a is the aspect ratio of the screen (the relation between its width and height).

world space 世界空间
(is basically the space in which all objects of the scene, the geometry, the lights and the cameras have their coordinates expressed into)

we know:
1. the image plane is located exactly one unit away from the world origin and aligned along the negative z axis.
2. the image is square therefore the portion of the image plane on which the image is projected is also necessarily square( the dimension of this projection area is 2 by 2 units )

find a relation between
the coordinates of these pixels in raster space
and
the coordinates of the same pixels but expressed in world space.

steps:
1.normalize this pixel position using the frame's dimensions(raster space --> NDC space)
(NDC space in ray-tracing is different than NDC space in the rasterization world where it generally maps to the range [-1,1])
2.NDC --> screen space(consider ImageAspectRatio)
3.account for the field of view.

Figure 5: converting the coordinate of a point in the middle of a pixel to world coordinates requires a few steps. The coordinates of this point are first expressed in raster space (the pixels coordinate plus an offset of 0.5), then converted to NDC space (the coordinates are remapped to the range [0,1]) then converted to screen space (the NDC coordinates are remapped to the [-1,1]). Applying the final camera-to-world transformation 4x4 matrix transform the coordinates in screen space to world space.

参考链接:https://www.scratchapixel.com/lessons/3d-basic-rendering/ray-tracing-generating-camera-rays/generating-camera-rays

你可能感兴趣的:(Ray-Tracing: Generating Camera Rays)