After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 162395 - Soft Light and Overlay modes are identical
Soft Light and Overlay modes are identical
Status: RESOLVED OBSOLETE
Product: GIMP
Classification: Other
Component: General
git master
Other All
: Low normal
: 2.8
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2004-12-28 17:29 UTC by weskaggs
Modified: 2016-10-26 00:41 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description weskaggs 2004-12-28 17:29:06 UTC
I was experimenting with different compositing modes yesterday, trying to
understand how they work, and happened to notice that switching between Soft
Light and Overlay modes never altered the result, no matter what variations I
tried.  I then looked at the formulas for the two, in paint-funcs-generic.h, and
found that although they are written differently, they are algebraically equivalent.

ViewCVS indicates that neither of these formulas has been changed since
Guillermo Romero introduced Soft Light on 2002-11-5 (in a patch committed by Sven).

The question is what to do about it.
Comment 1 weskaggs 2004-12-30 17:01:11 UTC
After some discussion with UnNamed, and with reference to

 http://www.pegtop.net/delphi/blendmodes/

the story seems to be as follows:  GIMP soft light mode is about the same as the
soft light mode in the program XFader, and seems to be nearly the same as PS
soft light mode.  However, GIMP overlay mode is nothing like PS overlay mode,
which is actually identical to GIMP hard light mode with the top and and bottom
layers reversed.  Instead, GIMP overlay mode is simply identical to GIMP and PS
soft light mode, as stated above.  (GIMP hard light mode = PS hard light mode.)
 I hope this makes sense.
Comment 2 Albert Cahalan 2005-01-22 22:30:36 UTC
None of these mode names make any sense anyway, and there's your proof.
Perhaps they relate to archaic photochemical processes? In any case,
the huge list of meaningless names is unhelpful.

If the math expression isn't way too long, just display that.
Comment 3 weskaggs 2005-01-23 17:40:42 UTC
Congratulations, you have just taken the lead in the race for the Worst Idea of
the Year award.  But don't feel too bad, it's only January.

Seriously, you're right that it would be nice to do a better job of explaining
the modes.  But inflicting equations on people would be obnoxious.
Comment 4 Albert Cahalan 2005-01-23 20:01:47 UTC
Well, how about the equation in a tooltip or some such?
People come to the gimp from different backgrounds.

There may be a few (very rare!) people with a clue about
those old photochemical and printing press processes.

There will be a decent number of people coming from other
paint programs, PhotoShop being the prime example.

There will be a decent number of people like me, who come
to the gimp with a background that involves doing math
operations on pixel data. We will be utterly lost without
seeing the equations; provide the equations and all questions
have been answered.

Most people will be just plain clueless in any case. :-(
Comment 5 Sven Neumann 2005-01-23 20:28:26 UTC
The equations belong into the user manual if at all. People with a mathematical
background are usually rather good in reading. It should also be easy for
someone with a mathematical background to have a look at the source and to
contribute the equations to the gimp-docs team working on the user manual.
Comment 6 Raphaël Quinet 2005-01-24 10:34:58 UTC
Back to the original bug report: it looks like the Overlay mode should be changed.
Does anyone have a description of what it should be replaced with?  In the GIMP
distribution, there are only three scripts using the Overlay mode (they were
written before Soft Light was introduced) and it should not be a big deal to
update them.  As for third-party plug-ins, scripts and tutorials, this is another
issue but we could limit the breakage by announcing clearly that the Overlay mode
is going to be changed.
Comment 7 weskaggs 2005-01-24 17:17:08 UTC
I'm afraid you missed the most important part: saved xcf files.  If Overlay mode
changes, any saved images that use it will change their appearance.  I, at
least, have used Overlay mode quite a bit, and I don't think that's acceptable.
 The only way around it would be an increment to the xcf version, combined with
some kind of hack that changes Overlay mode to Soft Light mode when xcf files
with earlier versions are loaded.
Comment 8 Raphaël Quinet 2005-01-24 17:36:28 UTC
Yes, I looked at the XCF code and we should of course not break the old files.
Basically, the old code for GIMP_OVERLAY_MODE (5) should be kept and probably
renamed GIMP_OLD_OVERLAY_MODE or something similar in the enum.  It would be
handled in the same way as Soft Light.  A new value for GIMP_OVERLAY_MODE would
have to be added at the end of the GimpLayerModeEffects enum so that plug-ins
such as psd.c and psp.c give the expected results when loading files generated
by other programs.
Comment 9 Raphaël Quinet 2005-01-24 17:39:14 UTC
To avoid misunderstandings, s/the old code/the old value/.
Comment 10 weskaggs 2005-01-25 00:37:54 UTC
Regarding what it should be replaced with, if it is done at all, the site
referenced in comment #1 suggests that Overlay mode should be the same as Hard
Light mode with the top and bottom layers switched.  So that should be very easy.
Comment 11 Raphaël Quinet 2005-01-25 10:28:48 UTC
I think that I looked at all relevant parts of the code and this change seems to
be doable.  However, I am a bit afraid of touching the MMX and SSE compositing
code as I am not familiar with these extended asm instructions.

I still have one question: assuming that the we rename the current enum value to
GIMP_OLD_OVERLAY_MODE (5) in order to be able to load old XCF files and interact
with old scripts or plug-ins, what is the best place to substitute this value
with GIMP_SOFTLIGHT_MODE (19)?  It should probably be done in xcf-load.c, but
should it also be done somewhere in the PDB?

By the way, while investigating this I found that gimp-composite-generic.c has
a bug in its documentation.  It says that the formula for Overlay is:
  D =  A * (B + (2 * B) * (255 - A))
while it is actually:
  D =  A * (A + (2 * B) * (255 - A))
which is algebraically equivalent to Soft Light.  I will commit this minor fix
this evening.
Comment 12 Martin Nordholts 2008-11-01 13:00:22 UTC
We have a perfect opportunity now to address as we port the layer modes to GEGL.
Comment 13 Martin Nordholts 2008-11-03 23:11:01 UTC
When using GEGL for the projection, blending with Overlay uses the blending formula in the SVG 1.2 draft. This is the same formula Photoshop uses as well and it has the properties compared to Hard light as described earlier in this bug report.

GEGL Soft light behaves as legacy Soft light (i.e. also as legacy Overlay). Relevant commit, rev 27541:

2008-11-03  Martin Nordholts  <martinn@svn.gnome.org>

	* app/gegl/gimpoperationpointlayermode.c
	(gimp_operation_point_layer_mode_process): Reuse the blending
	formula from the legacy Soft light. (Actually the formula comes
	from legacy Overlay but legacy Overlay and Soft light blends
	pixels exactly the same.) I hereby declare the porting of the
	layer modes to this GEGL operation complete. Summary:

	Completely works the same:

	  Normal, Dissolve, Behind, Color Erase, Erase, Anti Erase

	Works the same for 100% opaque layers:

	  Lighten only, Screen, Dodge, Addition, Darken only, Multiply,
	  Dodge, Soft light, Hard light, Difference, Subtract, Grain
	  extract, Grain merge, Divide, Hue, Saturation, Color, Value

	Works different but similar:

	  Overlay now uses the SVG 1.2 overlay formula which is different
	  but similar to legacy Overlay

	  Replace needs to be externally masked to not replace too much,
	  but that is outside the scope of the layer mode porting.



Since making sure old xcfs renders correctly also when using GEGL for the projection is a general problem and not specific to this bug report, I am closing this as OBSOLETE.
Comment 14 paul_geraskin 2012-11-12 10:53:01 UTC
Martin, I did a fix for Gimp 2.9 Overlay Mode. Can you check it?

https://bugzilla.gnome.org/show_bug.cgi?id=673501 - issue
https://bugzilla.gnome.org/attachment.cgi?id=228551 - my patch

The Overlay mode fully compatible with Krita, Photoshop, ORA, Painter.

The formula was taken from here: http://en.wikipedia.org/wiki/Blend_modes

Mitch said that it's possible to set "New Overlay" and remain "Legecy Overlay".
Comment 15 Michael Natterer 2012-11-12 11:03:42 UTC
Paul, adding comments to closed bug has no effect, please stick to the open
bug :)
Comment 16 David Gowers 2014-02-12 06:44:50 UTC
This needs to be reopened. In GIMP 2.9, Overlay Mode and Soft Light mode are exactly equivalent in every case ((RGB|Greyscale), (8bit int|16bit int|32bit int|16bit float|32bit float) (gamma|linear))