diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-11-19 14:30:41 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-11-19 14:30:41 -0500 |
commit | 6137aed0179476eaa626660885f01ea3f04f988a (patch) | |
tree | e23b07cac6c9b8df58d9700e8a2fa2c719cf965b /libdimension | |
parent | 30cb9cb572cf8fa942faff7384580e5e2a06a7b3 (diff) | |
download | dimension-6137aed0179476eaa626660885f01ea3f04f988a.tar.xz |
Support global ambient_light.
Diffstat (limited to 'libdimension')
-rw-r--r-- | libdimension/dimension/scene.h | 1 | ||||
-rw-r--r-- | libdimension/raytrace.c | 4 | ||||
-rw-r--r-- | libdimension/scene.c | 2 |
3 files changed, 6 insertions, 1 deletions
diff --git a/libdimension/dimension/scene.h b/libdimension/dimension/scene.h index 57ef32b..489e4e5 100644 --- a/libdimension/dimension/scene.h +++ b/libdimension/dimension/scene.h @@ -44,6 +44,7 @@ typedef unsigned int dmnsn_quality; typedef struct dmnsn_scene { /* World attributes */ dmnsn_color background; /**< Background color. */ + dmnsn_color ambient; /**< Global ambient color. */ dmnsn_texture *default_texture; /**< Default object texture. */ /** Camera. */ diff --git a/libdimension/raytrace.c b/libdimension/raytrace.c index 74f4557..e6596e4 100644 --- a/libdimension/raytrace.c +++ b/libdimension/raytrace.c @@ -337,9 +337,11 @@ dmnsn_raytrace_light_ray(const dmnsn_raytrace_state *state, static void dmnsn_raytrace_lighting(dmnsn_raytrace_state *state) { - /* The illuminated color */ + /* The ambient color */ state->diffuse = TEXTURE_CALLBACK(state, finish, ambient_fn, dmnsn_black, state->pigment); + state->diffuse = dmnsn_color_illuminate(state->scene->ambient, + state->diffuse); if (!TEXTURE_HAS_CALLBACK(state, finish, diffuse_fn) && !TEXTURE_HAS_CALLBACK(state, finish, specular_fn)) diff --git a/libdimension/scene.c b/libdimension/scene.c index fc5bb92..9eca7b7 100644 --- a/libdimension/scene.c +++ b/libdimension/scene.c @@ -32,6 +32,8 @@ dmnsn_new_scene() { dmnsn_scene *scene = dmnsn_malloc(sizeof(dmnsn_scene)); + scene->background = dmnsn_black; + scene->ambient = dmnsn_white; scene->default_texture = dmnsn_new_texture(); scene->camera = NULL; scene->canvas = NULL; |