RSS/Atom feed Twitter
Site is read-only, email is disabled

porting the DIVIDE blend mode in GLSL

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

2 of 2 messages available
Toggle history

Please log in to manage your subscriptions.

porting the DIVIDE blend mode in GLSL Marcelo Barbudas 02 Aug 08:23
  porting the DIVIDE blend mode in GLSL yahvuu 02 Aug 17:48
Marcelo Barbudas
2012-08-02 08:23:04 UTC (over 12 years ago)

porting the DIVIDE blend mode in GLSL

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.

yahvuu
2012-08-02 17:48:35 UTC (over 12 years ago)

porting the DIVIDE blend mode in GLSL

Hi Marcelo,

Am 02.08.2012 10:23, schrieb Marcelo Barbudas:

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.

GIMP divide is dodge with inverted top layer.

Also, are you aware of: http://mouaif.wordpress.com/2009/01/05/photoshop-math-with-glsl-shaders/ (not sure about the license, though)

best regards, yahvuu