summaryrefslogtreecommitdiffstats
path: root/libdimension/gl.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-05-20 18:59:18 -0600
committerTavian Barnes <tavianator@gmail.com>2011-05-20 18:59:18 -0600
commit18b89c6edc29a009b1419e6d34bc3eef2dd911b9 (patch)
tree02f36651220fbd0821c94d6c13848bd9beb59098 /libdimension/gl.c
parent250b980002419746fc099c7633b9600a15afb1c6 (diff)
downloaddimension-18b89c6edc29a009b1419e6d34bc3eef2dd911b9.tar.xz
Switch to Blender model of filtered transparency.
Diffstat (limited to 'libdimension/gl.c')
-rw-r--r--libdimension/gl.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/libdimension/gl.c b/libdimension/gl.c
index 587038f..7fd3cb9 100644
--- a/libdimension/gl.c
+++ b/libdimension/gl.c
@@ -110,13 +110,12 @@ dmnsn_gl_write_canvas(const dmnsn_canvas *canvas)
pixel[2] = color.B*UINT16_MAX;
}
- double alpha = dmnsn_color_intensity(color)*color.filter + color.trans;
- if (alpha <= 0.0) {
+ if (color.trans <= 0.0) {
pixel[3] = 0;
- } else if (alpha >= 1.0) {
+ } else if (color.trans >= 1.0) {
pixel[3] = UINT16_MAX;
} else {
- pixel[3] = alpha*UINT16_MAX;
+ pixel[3] = color.trans*UINT16_MAX;
}
}
}
@@ -152,8 +151,8 @@ dmnsn_gl_read_canvas(size_t x0, size_t y0,
dmnsn_color color = dmnsn_new_color5((double)pixel[0]/UINT16_MAX,
(double)pixel[1]/UINT16_MAX,
(double)pixel[2]/UINT16_MAX,
- 0.0,
- (double)pixel[3]/UINT16_MAX);
+ (double)pixel[3]/UINT16_MAX,
+ 0.0);
dmnsn_set_pixel(canvas, x, y, color);
}
}
@@ -196,12 +195,11 @@ dmnsn_gl_optimizer_fn(const dmnsn_canvas *canvas,
pixel[2] = color.B*UINT16_MAX;
}
- double alpha = dmnsn_color_intensity(color)*color.filter + color.trans;
- if (alpha <= 0.0) {
+ if (color.trans <= 0.0) {
pixel[3] = 0;
- } else if (alpha >= 1.0) {
+ } else if (color.trans >= 1.0) {
pixel[3] = UINT16_MAX;
} else {
- pixel[3] = alpha*UINT16_MAX;
+ pixel[3] = color.trans*UINT16_MAX;
}
}