diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2017-08-08 09:42:30 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2017-08-15 16:46:40 -0700 |
commit | adb76b79d39a185be4659193baff0cb1fe043506 (patch) | |
tree | fdc51e2d986e7ef6bd22d0897bdbca10ed51f550 /src/modules/ray/ray.c | |
parent | 760112de102f36ba5aaf16d9e949d0bfa3623175 (diff) |
ray: misc computational fixups
ray:object intersection coordinates were incorrectly being computed
relative to the ray origin using a subtraction instead of addition, a
silly mistake with surprisingly acceptable results. Those results
were a result of other minor complementary mistakes compensating to
produce reasonable looking results.
In the course of experimenting with an acceleration data structure it
became very apparent that 3d space traversal vectors were not behaving
as intended, leading to review and correction of this code.
Diffstat (limited to 'src/modules/ray/ray.c')
-rw-r--r-- | src/modules/ray/ray.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c index 89d114c..ac00806 100644 --- a/src/modules/ray/ray.c +++ b/src/modules/ray/ray.c @@ -98,7 +98,7 @@ static ray_camera_t camera = { .order = RAY_EULER_ORDER_YPR, /* yaw,pitch,roll */ .yaw = RAY_EULER_DEGREES(0.0f), .pitch = RAY_EULER_DEGREES(0.0f), - .roll = RAY_EULER_DEGREES(180.0f), + .roll = RAY_EULER_DEGREES(0.0f), }, .focal_length = 700.0f, }; @@ -128,7 +128,7 @@ static void ray_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fra #if 1 /* animated point light source */ - r += .02; + r += -.02; scene.lights[0].light.emitter.point.center.x = cosf(r) * 4.5f; scene.lights[0].light.emitter.point.center.z = sinf(r * 3.0f) * 4.5f; @@ -141,10 +141,11 @@ static void ray_prepare_frame(void *context, unsigned n_cpus, fb_fragment_t *fra camera.position.y = cosf(r * 1.3f) * 4.0f + 2.08f; /* keep camera facing the origin */ - camera.orientation.yaw = r; + camera.orientation.yaw = r + RAY_EULER_DEGREES(180.0f); + /* 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; + camera.orientation.pitch = -(sinf((M_PI * 1.5f) + r * 1.3f) * .6f + -.35f); #endif ray_scene_prepare(&scene, &camera); } |