summaryrefslogtreecommitdiff
path: root/src/modules
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/modules
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/modules')
-rw-r--r--src/modules/ray/ray.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c
index dd33b19..a9d78c4 100644
--- a/src/modules/ray/ray.c
+++ b/src/modules/ray/ray.c
@@ -106,6 +106,12 @@ static ray_camera_t camera = {
.roll = RAY_EULER_DEGREES(0.0f),
},
.focal_length = 700.0f,
+
+ /* TODO: these should probably be adjusted @ runtime to at least fit the aspect ratio
+ * of the frame being rendered.
+ */
+ .film_width = 1000.f,
+ .film_height = 900.f,
};
static ray_scene_t scene = {
@@ -148,10 +154,6 @@ static void ray_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fra
ray_context_t *ctxt = context;
*res_fragmenter = ray_fragmenter;
-
- /* TODO: the camera doesn't need the width and height anymore, the fragment has the frame_width/frame_height */
- camera.width = fragment->frame_width,
- camera.height = fragment->frame_height,
#if 1
/* animated point light source */
@@ -174,7 +176,7 @@ static void ray_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fra
/* tilt camera pitch in time with up and down movements, phase shifted appreciably */
camera.orientation.pitch = -(sinf((M_PI * 1.5f) + r * 1.3f) * .6f + -.35f);
#endif
- ctxt->render = ray_render_new(&scene, &camera);
+ ctxt->render = ray_render_new(&scene, &camera, fragment->frame_width, fragment->frame_height);
}
© All Rights Reserved