From 6d8fbc2953c6ae29ee5162ca04920d6cef85d0ce Mon Sep 17 00:00:00 2001 From: rodri Date: Thu, 4 Jul 2024 14:57:00 +0000 Subject: rough color space conversion implementation. colors are now properly processed in linear RGB space for lighting, shading and blending. sRGB is assumed for any texture sampled and the destination framebuffer. it's not perfect, but it does the job for now. --- texture.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'texture.c') diff --git a/texture.c b/texture.c index 158bcb6..d51076e 100644 --- a/texture.c +++ b/texture.c @@ -28,18 +28,6 @@ uv2tp(Point2 uv, Memimage *i) return Pt(uv.x*Dx(i->r), (1 - uv.y)*Dy(i->r)); } -static Color -ul2col(ulong l) -{ - Color c; - - c.a = (l & 0xff)/255.0; - c.b = (l>>8 & 0xff)/255.0; - c.g = (l>>16 & 0xff)/255.0; - c.r = (l>>24 & 0xff)/255.0; - return c; -} - static Color cbuf2col(uchar b[4]) { @@ -72,7 +60,11 @@ _memreadcolor(Memimage *i, Point sp) break; } - return cbuf2col(cbuf); + /* TODO + * not all textures require color space conversion. implement a better + * interface to let the user decide. + */ + return srgb2linear(cbuf2col(cbuf)); } /* -- cgit v1.2.3