summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/raytrace.c7
-rw-r--r--libdimension/solid_pigment.c20
2 files changed, 24 insertions, 3 deletions
diff --git a/libdimension/raytrace.c b/libdimension/raytrace.c
index 89908fa..2d93c86 100644
--- a/libdimension/raytrace.c
+++ b/libdimension/raytrace.c
@@ -258,10 +258,11 @@ dmnsn_raytrace_scene_impl(dmnsn_progress *progress, dmnsn_scene *scene,
static void
dmnsn_raytrace_pigment(dmnsn_raytrace_state *state)
{
- state->pigment = TEXTURE_PROPERTY(state, pigment, quick_color, dmnsn_black);
if (state->scene->quality & DMNSN_RENDER_PIGMENT) {
- state->pigment = TEXTURE_CALLBACK(state, pigment, pigment_fn,
- state->pigment, state->r);
+ state->pigment = TEXTURE_CALLBACK(state, pigment, pigment_fn, dmnsn_black,
+ state->r);
+ } else {
+ state->pigment = TEXTURE_PROPERTY(state, pigment, quick_color, dmnsn_black);
}
state->diffuse = state->pigment;
}
diff --git a/libdimension/solid_pigment.c b/libdimension/solid_pigment.c
index 15ea86f..2b878c7 100644
--- a/libdimension/solid_pigment.c
+++ b/libdimension/solid_pigment.c
@@ -21,11 +21,31 @@
#include "dimension.h"
#include <stdlib.h>
+/* Solid color pigment callback */
+static dmnsn_color dmnsn_solid_pigment_fn(const dmnsn_pigment *pigment,
+ dmnsn_vector v);
+
/* Create a solid color */
dmnsn_pigment *
dmnsn_new_solid_pigment(dmnsn_color color)
{
dmnsn_pigment *pigment = dmnsn_new_pigment();
+
+ dmnsn_color *solid = dmnsn_malloc(sizeof(dmnsn_color));
+ *solid = color;
+
+ pigment->pigment_fn = &dmnsn_solid_pigment_fn;
+ pigment->free_fn = &dmnsn_free;
pigment->quick_color = color;
+ pigment->ptr = solid;
+
return pigment;
}
+
+/* Solid color callback */
+static dmnsn_color
+dmnsn_solid_pigment_fn(const dmnsn_pigment *pigment, dmnsn_vector v)
+{
+ dmnsn_color *color = pigment->ptr;
+ return *color;
+}