diff options
author | Vito Caputo <vcaputo@gnugeneration.com> | 2017-02-14 00:24:32 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@gnugeneration.com> | 2017-02-14 00:46:17 -0800 |
commit | 8fc69c2b21dc101c04495c4689587e99a70cf875 (patch) | |
tree | eb05dae0e2a145d6cbb97ad5c66f0d9e441184b5 /src | |
parent | 2e300062591398269e27fe2b359ed28030bc788e (diff) |
ray: add highlight exponent to ray_surface_t
Was a constant at 20, this allows it to be specified per-object.
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/ray/ray.c | 5 | ||||
-rw-r--r-- | src/modules/ray/ray_scene.c | 6 | ||||
-rw-r--r-- | src/modules/ray/ray_surface.h | 1 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c index 6dc15a6..ad8a06b 100644 --- a/src/modules/ray/ray.c +++ b/src/modules/ray/ray.c @@ -24,6 +24,7 @@ static void ray(fb_fragment_t *fragment) .color = { .x = 0.6, .y = 0.3, .z = 0.8 }, .diffuse = 1.0f, .specular = 0.2f, + .highlight_exponent = 20.0f }, .normal = { .x = 0.0, .y = 1.0, .z = 0.0 }, .distance = 2.0f, @@ -35,6 +36,7 @@ static void ray(fb_fragment_t *fragment) .color = { .x = 1.0, .y = 0.0, .z = 0.0 }, .diffuse = 1.0f, .specular = 0.05f, + .highlight_exponent = 20.0f }, .center = { .x = 0.5, .y = 1.0, .z = 0.0 }, .radius = 1.2f, @@ -46,6 +48,7 @@ static void ray(fb_fragment_t *fragment) .color = { .x = 0.0, .y = 0.0, .z = 1.0 }, .diffuse = 0.9f, .specular = 0.4f, + .highlight_exponent = 20.0f }, .center = { .x = -2.0, .y = 1.0, .z = 0.0 }, .radius = 0.9f, @@ -57,6 +60,7 @@ static void ray(fb_fragment_t *fragment) .color = { .x = 0.0, .y = 1.0, .z = 1.0 }, .diffuse = 0.9f, .specular = 0.3f, + .highlight_exponent = 20.0f }, .center = { .x = 2.0, .y = -1.0, .z = 0.0 }, .radius = 1.0f, @@ -68,6 +72,7 @@ static void ray(fb_fragment_t *fragment) .color = { .x = 0.0, .y = 1.0, .z = 0.0 }, .diffuse = 0.95f, .specular = 0.85f, + .highlight_exponent = 20.0f }, .center = { .x = 0.2, .y = -1.25, .z = 0.0 }, .radius = 0.6f, diff --git a/src/modules/ray/ray_scene.c b/src/modules/ray/ray_scene.c index 496c447..b4cddad 100644 --- a/src/modules/ray/ray_scene.c +++ b/src/modules/ray/ray_scene.c @@ -83,10 +83,8 @@ static inline ray_color_t shade_ray(ray_scene_t *scene, ray_ray_t *ray, ray_obje diffuse = ray_3f_mult_scalar(&diffuse, surface.diffuse); color = ray_3f_add(&color, &diffuse); - /* FIXME: assumes light is a point for its color, and 20 is a constant "Phong exponent", - * which should really be object/surface-specific - */ - specular = ray_3f_mult_scalar(&scene->lights[i].light.emitter.point.surface.color, powf(rvec_lvec_dot, 20)); + /* FIXME: assumes light is a point for its color */ + specular = ray_3f_mult_scalar(&scene->lights[i].light.emitter.point.surface.color, powf(rvec_lvec_dot, surface.highlight_exponent)); specular = ray_3f_mult_scalar(&specular, surface.specular); color = ray_3f_add(&color, &specular); #else diff --git a/src/modules/ray/ray_surface.h b/src/modules/ray/ray_surface.h index b3e3c68..2e7544b 100644 --- a/src/modules/ray/ray_surface.h +++ b/src/modules/ray/ray_surface.h @@ -8,6 +8,7 @@ typedef struct ray_surface_t { ray_color_t color; float specular; + float highlight_exponent; float diffuse; } ray_surface_t; |