summaryrefslogtreecommitdiff
path: root/src/libs/ray/ray_camera.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2020-01-12 16:32:59 -0800
committerVito Caputo <vcaputo@pengaru.com>2020-01-12 16:43:57 -0800
commit179341f758ca86d0f8d820713cf35bd281f01755 (patch)
treeebce00ed744bca69754b0d04498e1f17d6d4c3d2 /src/libs/ray/ray_camera.h
parent14a6d7be88955affdfbdbb8293bf5bca191ee7ff (diff)
libs/ray: decouple film and frame dimensions
The existing code conflated the rendered frame dimensions with what's essentially the virtual camera's film dimensions. That resulted in a viewing frustum depending on the rendered frame dimensions. Smaller frames (like in the montage module) would show a smaller viewport into the same scene. Now the view into the scene always shows the same viewport in terms of the frustum dimensions for a given combination of focal_length and film_{width,height}. The rendered frame is essentially a sampling of the 2D plane (the virtual film) intersecting the frustum. Nothing is done to try enforce a specific aspect ratio or any such magic. The caller is expected to manage this for now, or just ignore it and let the output be stretched when the aspect ratio of the output doesn't match the virtual film's aspect ratio. In the future it might be interesting to support letter boxing or such things for preserving the film's aspect ratio. For now the ray module just lets things be stretched, with hard-coded film dimensions of something approximately consistent with the past viewport. The ray module could make some effort to fit the hard-coded film dimensions to the runtime aspect ratio for the frame to be rendered, tweaking things as needed but generally preserving the general hard-coded dimensions. Allowing the frustum to be minimally adjusted to fit the circumstances... that might also be worth shoving into libray. Something of a automatic fitting mode for the camera.
Diffstat (limited to 'src/libs/ray/ray_camera.h')
-rw-r--r--src/libs/ray/ray_camera.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/libs/ray/ray_camera.h b/src/libs/ray/ray_camera.h
index e393beb..0a8af2a 100644
--- a/src/libs/ray/ray_camera.h
+++ b/src/libs/ray/ray_camera.h
@@ -13,9 +13,19 @@
typedef struct ray_camera_t {
ray_3f_t position; /* position of camera, the origin of all its rays */
ray_euler_t orientation; /* orientation of the camera */
+
+ /* Units for focal_length, width, and height, are undefined in absolute terms or any
+ * kind of SI unit - they're the same units of the virtual scene shared
+ * with the objects.
+ */
float focal_length; /* controls the field of view */
- unsigned width; /* width of camera viewport in pixels */
- unsigned height; /* height of camera viewport in pixels */
+
+ /* XXX: Note these are not the same as the rendered frame width and height in pixels,
+ * these influence the frustum size and shape in the 3D world by controlling the 2D
+ * plane size and shape that frustum intersects.
+ */
+ float film_width; /* width of camera's virtual "film" */
+ float film_height; /* height of camera's virtual "film" */
} ray_camera_t;
@@ -38,7 +48,7 @@ typedef struct ray_camera_fragment_t {
} ray_camera_fragment_t;
-void ray_camera_frame_prepare(const ray_camera_t *camera, ray_camera_frame_t *res_frame);
+void ray_camera_frame_prepare(const ray_camera_t *camera, unsigned frame_width, unsigned frame_height, ray_camera_frame_t *res_frame);
void ray_camera_fragment_begin(ray_camera_frame_t *frame, fb_fragment_t *fb_fragment, ray_ray_t *res_ray, ray_camera_fragment_t *res_fragment);
© All Rights Reserved