diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2018-02-28 20:24:30 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2018-02-28 20:24:30 -0800 |
commit | 3b9a4861d6937a66b03791b5b497e47c52189a7d (patch) | |
tree | 213f698873293d87e38ce47f90937469db077bc0 /src | |
parent | 0aa9efd5c69a956d88adc25abd154289ecfbede7 (diff) |
ray: implement distance-based light brightness
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/ray/ray.c | 2 | ||||
-rw-r--r-- | src/modules/ray/ray_render.c | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/modules/ray/ray.c b/src/modules/ray/ray.c index bb9c042..1e58f3b 100644 --- a/src/modules/ray/ray.c +++ b/src/modules/ray/ray.c @@ -83,7 +83,7 @@ static ray_object_t lights[] = { { .light = { .type = RAY_OBJECT_TYPE_LIGHT, - .brightness = 1.0, + .brightness = 15.0f, .emitter = { .point.type = RAY_LIGHT_EMITTER_TYPE_POINT, .point.center = { .x = 3.0f, .y = 3.0f, .z = 3.0f }, diff --git a/src/modules/ray/ray_render.c b/src/modules/ray/ray_render.c index 4ca168f..8b930f6 100644 --- a/src/modules/ray/ray_render.c +++ b/src/modules/ray/ray_render.c @@ -88,6 +88,7 @@ static inline ray_color_t shade_intersection(ray_render_t *render, ray_render_ob if (lvec_normal_dot > 0) { #if 1 float rvec_lvec_dot = ray_3f_dot(&ray->direction, &lvec); + float intensity = light->light.brightness * (1.0 / (ldist * ldist)); ray_color_t diffuse; diffuse = ray_3f_mult_scalar(&surface.color, lvec_normal_dot); @@ -102,6 +103,8 @@ static inline ray_color_t shade_intersection(ray_render_t *render, ray_render_ob specular = ray_3f_mult_scalar(&specular, surface.specular); color = ray_3f_add(&color, &specular); } + + color = ray_3f_mult_scalar(&color, intensity); #else ray_color_t diffuse; |