summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2017-05-26 23:46:41 -0700
committerVito Caputo <vcaputo@pengaru.com>2017-05-26 23:46:41 -0700
commit28d8022265a12e5032ddb54077f90af9f1bcb4f5 (patch)
treec1fe2707eac86a15be4929e567ecb418ce9ccb33
parentb8338217569a871cee6e91e3fd07766191667663 (diff)
ray: s/nlerp/lerp/ where normalize is unnecessary
It's only necessary to normalize the direction stored vector in x_step(), the rest can simply be linearly interpolated which saves some divides.
-rw-r--r--src/modules/ray/ray_camera.c4
-rw-r--r--src/modules/ray/ray_camera.h4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/modules/ray/ray_camera.c b/src/modules/ray/ray_camera.c
index 0703c2e..5910094 100644
--- a/src/modules/ray/ray_camera.c
+++ b/src/modules/ray/ray_camera.c
@@ -77,8 +77,8 @@ void ray_camera_frame_begin(ray_camera_t *camera, fb_fragment_t *fragment, ray_r
frame->x_alpha = frame->x_delta * (float)fragment->x;
frame->y_alpha = frame->y_delta * (float)fragment->y;
- frame->cur_w = ray_3f_nlerp(&frame->nw, &frame->sw, frame->y_alpha);
- frame->cur_e = ray_3f_nlerp(&frame->ne, &frame->se, frame->y_alpha);
+ frame->cur_w = ray_3f_lerp(&frame->nw, &frame->sw, frame->y_alpha);
+ frame->cur_e = ray_3f_lerp(&frame->ne, &frame->se, frame->y_alpha);
ray->origin = camera->position;
ray->direction = frame->cur_w;
diff --git a/src/modules/ray/ray_camera.h b/src/modules/ray/ray_camera.h
index 387f8c5..6e48839 100644
--- a/src/modules/ray/ray_camera.h
+++ b/src/modules/ray/ray_camera.h
@@ -67,8 +67,8 @@ static inline int ray_camera_frame_y_step(ray_camera_frame_t *frame)
}
frame->y_alpha += frame->y_delta;
- frame->cur_w = ray_3f_nlerp(&frame->nw, &frame->sw, frame->y_alpha);
- frame->cur_e = ray_3f_nlerp(&frame->ne, &frame->se, frame->y_alpha);
+ frame->cur_w = ray_3f_lerp(&frame->nw, &frame->sw, frame->y_alpha);
+ frame->cur_e = ray_3f_lerp(&frame->ne, &frame->se, frame->y_alpha);
frame->ray->direction = frame->cur_w;
return 1;
© All Rights Reserved