summaryrefslogtreecommitdiff
path: root/src/modules/ray/ray_camera.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2018-03-19 21:39:09 -0700
committerVito Caputo <vcaputo@pengaru.com>2018-03-19 22:02:08 -0700
commitb5bc962e834992eeba2abdd10f6e37ee2ba20295 (patch)
tree11bf58a64208806817c0fcab481588086297ce6c /src/modules/ray/ray_camera.h
parent3b9a4861d6937a66b03791b5b497e47c52189a7d (diff)
ray: libize raytracer core, introduces src/libs
This is the first step of breaking out all the core rendering stuffs into reusable libraries and making modules purely compositional, consumers of various included rendering/effects libraries. Expect multiple modules leveraging libray for a variety of scenes and such. Also expect compositions mixing the various libraries for more interesting visuals.
Diffstat (limited to 'src/modules/ray/ray_camera.h')
-rw-r--r--src/modules/ray/ray_camera.h84
1 files changed, 0 insertions, 84 deletions
diff --git a/src/modules/ray/ray_camera.h b/src/modules/ray/ray_camera.h
deleted file mode 100644
index e393beb..0000000
--- a/src/modules/ray/ray_camera.h
+++ /dev/null
@@ -1,84 +0,0 @@
-#ifndef _RAY_CAMERA_H
-#define _RAY_CAMERA_H
-
-#include <math.h>
-
-#include "fb.h"
-
-#include "ray_3f.h"
-#include "ray_euler.h"
-#include "ray_ray.h"
-
-
-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 */
- float focal_length; /* controls the field of view */
- unsigned width; /* width of camera viewport in pixels */
- unsigned height; /* height of camera viewport in pixels */
-} ray_camera_t;
-
-
-typedef struct ray_camera_frame_t {
- const ray_camera_t *camera; /* the camera supplied to frame_begin() */
-
- ray_3f_t nw, ne, sw, se; /* directions pointing through the corners of the frame fragment */
- float x_delta, y_delta; /* interpolation step delta along the x and y axis */
-} ray_camera_frame_t;
-
-
-typedef struct ray_camera_fragment_t {
- ray_camera_frame_t *frame; /* the frame supplied to fragment_begin() */
- fb_fragment_t *fb_fragment; /* the fragment supplied to fragment_begin() */
- ray_ray_t *ray; /* the ray supplied to frame_begin(), which gets updated as we step through the frame. */
-
- ray_3f_t cur_w, cur_e; /* current row's west and east ends */
- float x_alpha, y_alpha; /* interpolation position along the x and y axis */
- unsigned x, y; /* integral position within frame fragment */
-} ray_camera_fragment_t;
-
-
-void ray_camera_frame_prepare(const ray_camera_t *camera, 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);
-
-
-/* Step the ray through the fragment on the x axis, returns 1 when rays remain on this axis, 0 at the end. */
-/* When 1 is returned, fragment->ray is left pointing through the new coordinate. */
-static inline int ray_camera_fragment_x_step(ray_camera_fragment_t *fragment)
-{
- fragment->x++;
-
- if (fragment->x >= fragment->fb_fragment->width) {
- fragment->x = 0;
- fragment->x_alpha = fragment->frame->x_delta * (float)fragment->fb_fragment->x;
- return 0;
- }
-
- fragment->x_alpha += fragment->frame->x_delta;
- fragment->ray->direction = ray_3f_nlerp(&fragment->cur_w, &fragment->cur_e, fragment->x_alpha);
-
- return 1;
-}
-
-
-/* Step the ray through the fragment on the y axis, returns 1 when rays remain on this axis, 0 at the end. */
-/* When 1 is returned, fragment->ray is left pointing through the new coordinate. */
-static inline int ray_camera_fragment_y_step(ray_camera_fragment_t *fragment)
-{
- fragment->y++;
-
- if (fragment->y >= fragment->fb_fragment->height) {
- fragment->y = 0;
- fragment->y_alpha = fragment->frame->y_delta * (float)fragment->fb_fragment->y;
- return 0;
- }
-
- fragment->y_alpha += fragment->frame->y_delta;
- fragment->cur_w = ray_3f_lerp(&fragment->frame->nw, &fragment->frame->sw, fragment->y_alpha);
- fragment->cur_e = ray_3f_lerp(&fragment->frame->ne, &fragment->frame->se, fragment->y_alpha);
- fragment->ray->direction = ray_3f_nlerp(&fragment->cur_w, &fragment->cur_e, fragment->x_alpha);
-
- return 1;
-}
-
-#endif
© All Rights Reserved