summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/dimension/scene.h1
-rw-r--r--libdimension/raytrace.c4
-rw-r--r--libdimension/scene.c2
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;