summaryrefslogtreecommitdiffstats
path: root/libdimension/raytrace.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-01-13 15:32:01 -0500
committerTavian Barnes <tavianator@gmail.com>2010-01-13 15:32:01 -0500
commitc552664a8371a55f2e082507998f78228308672c (patch)
tree93464a9820630ec2e63a2e53b8f7fab6ff6b28cd /libdimension/raytrace.c
parent6787a9219748575cd63aaadd483f49a4fd83b543 (diff)
downloaddimension-c552664a8371a55f2e082507998f78228308672c.tar.xz
Split finish_fn into diffuse_fn and specular_fn.
Diffstat (limited to 'libdimension/raytrace.c')
-rw-r--r--libdimension/raytrace.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/libdimension/raytrace.c b/libdimension/raytrace.c
index 9cfb904..0165870 100644
--- a/libdimension/raytrace.c
+++ b/libdimension/raytrace.c
@@ -413,7 +413,7 @@ dmnsn_raytrace_lighting(const dmnsn_raytrace_state *state)
dmnsn_color light_color;
if (dmnsn_raytrace_light_ray(state, light, &light_color)) {
if (state->scene->quality & DMNSN_RENDER_FINISH
- && finish && finish->finish_fn)
+ && finish && (finish->diffuse_fn || finish->specular_fn))
{
dmnsn_vector ray = dmnsn_vector_normalize(
dmnsn_vector_sub(light->x0, x0)
@@ -424,10 +424,19 @@ dmnsn_raytrace_lighting(const dmnsn_raytrace_state *state)
);
/* Get this light's color contribution to the object */
- dmnsn_color contrib = (*finish->finish_fn)(finish,
- light_color, state->pigment,
- ray, normal, viewer);
- illum = dmnsn_color_add(contrib, illum);
+ if (finish->diffuse_fn) {
+ dmnsn_color diffuse = (*finish->diffuse_fn)(finish, light_color,
+ state->pigment,
+ ray, normal);
+ illum = dmnsn_color_add(diffuse, illum);
+ }
+
+ if (finish->specular_fn) {
+ dmnsn_color specular = (*finish->specular_fn)(finish, light_color,
+ state->pigment,
+ ray, normal, viewer);
+ illum = dmnsn_color_add(specular, illum);
+ }
} else {
illum = state->pigment;
}