[Gimp-developer] porting the DIVIDE blend mode in GLSL
- From: Marcelo Barbudas <nostef gmail com>
- To: gimp-developer-list gnome org
- Subject: [Gimp-developer] porting the DIVIDE blend mode in GLSL
- Date: Thu, 2 Aug 2012 11:23:04 +0300
Hi.
I'm trying to port the GIMP divide blend filter code to GLSL. I've
been able to do this for various other blend modes, but for some
reason this is just not working. I know this is offtopic but since
I've been fighting with this for a while I hoped you might point me in
the right direction.
This is the C based GIMP code I'm using:
if (layA == 0.0 || inCa / layCa > inA / layA)
outCa = layA * inA + layCa * (1 - inA) + inCa * (1 - layA);
else
outCa = inCa * layA * layA / layCa + layCa * (1 - inA) + inCa * (1 - layA));
(from gimpoperationpointlayermode.c)
and this is the ported code, I do this for each channel and then merge
the result:
mediump float r;
if (overlay.a == 0.0 || base.r / overlay.r > base.a / overlay.a)
r = overlay.a * base.a + overlay.r * (1.0 - base.a) + base.r * (1.0
- overlay.a);
else
r = base.r * overlay.a * overlay.a / overlay.r + overlay.r * (1.0 -
base.a) + base.r * (1.0 - overlay.a);
How it looks like: http://i.imgur.com/EjPhz.jpg How it should look
like: http://i.imgur.com/bqbFT.png
In GLSL the color values are between 0 and 1.
-M.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]