Soft Light by Photoshop's formula; stacks, coverage and adjustments in every mode proven (13.9a)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-01 17:47:52 -04:00
1 parent cb85b86d58
commit 06843364fe
6 files changed
+268 -7

No files matched your search

-2
View File
@@ -20,8 +20,6 @@ QPainter::CompositionMode compositionMode(LayerBlendMode mode)
return QPainter::CompositionMode_Screen;
case LayerBlendMode::overlay:
return QPainter::CompositionMode_Overlay;
case LayerBlendMode::softLight:
return QPainter::CompositionMode_SoftLight;
case LayerBlendMode::darken:
return QPainter::CompositionMode_Darken;
case LayerBlendMode::lighten:
+6
View File
@@ -1,5 +1,6 @@
#include "Rendering/SeparableBlend.h"
#include <algorithm>
#include <cmath>
#include <stdexcept>
namespace {
@@ -22,6 +23,7 @@ float dodge(float backdrop, float source)
bool SeparableBlend::needsSurface(LayerBlendMode mode)
{
switch (mode) {
case LayerBlendMode::softLight:
case LayerBlendMode::linearBurn:
case LayerBlendMode::linearDodge:
case LayerBlendMode::vividLight:
@@ -39,6 +41,10 @@ bool SeparableBlend::needsSurface(LayerBlendMode mode)
float SeparableBlend::channel(LayerBlendMode mode, float backdrop, float source)
{
switch (mode) {
case LayerBlendMode::softLight:
// Photoshop's, as Core Image's: the PDF's strays 17 levels.
return source <= 0.5f ? 2 * backdrop * source + backdrop * backdrop * (1 - 2 * source)
: 2 * backdrop * (1 - source) + std::sqrt(backdrop) * (2 * source - 1);
case LayerBlendMode::linearBurn:
return std::max(0.0f, backdrop + source - 1);
case LayerBlendMode::linearDodge:
+1 -1
View File
@@ -1,7 +1,7 @@
#pragma once
#include "Document/LayerAppearance.h"
// Swift's SeparableBlend: channel-by-channel modes QPainter lacks.
// Swift's SeparableBlend: channel-by-channel modes QPainter lacks or differs on.
namespace SeparableBlend {
// Blended by hand against a surface, Swift's `needsSurface`.
bool needsSurface(LayerBlendMode mode);