Skip to content

Commit

Permalink
blend: fix over/mask inversion
Browse files Browse the repository at this point in the history
  • Loading branch information
hanatos committed Feb 2, 2024
1 parent 97f3af2 commit 1ed5467
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bin/data/presets/burn-guided.pst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ connect:blend:burn:output:blend:dodge:back
connect:blend:dodge:output:colour:01:input
param:blend:burn:opacity:1
param:blend:burn:mode:0
param:blend:burn:mask:2
param:blend:burn:mask:1
param:exposure:burn:exposure:2
param:draw:burn:opacity:5
param:draw:burn:hardness:1
2 changes: 1 addition & 1 deletion bin/data/presets/burn.pst
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ connect:blend:burn:output:blend:dodge:back
connect:blend:dodge:output:colour:01:input
param:blend:burn:opacity:1
param:blend:burn:mode:0
param:blend:burn:mask:2
param:blend:burn:mask:1
param:exposure:burn:exposure:2
2 changes: 1 addition & 1 deletion bin/data/presets/dodge-guided.pst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ connect:blend:dodge:output:blend:burn:back
connect:blend:burn:output:colour:01:input
param:blend:dodge:opacity:1
param:blend:dodge:mode:0
param:blend:dodge:mask:2
param:blend:dodge:mask:1
param:exposure:dodge:exposure:-2
param:draw:dodge:opacity:5
param:draw:dodge:hardness:1
2 changes: 1 addition & 1 deletion bin/data/presets/dodge.pst
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ connect:blend:dodge:output:blend:burn:back
connect:blend:burn:output:colour:01:input
param:blend:dodge:opacity:1
param:blend:dodge:mode:0
param:blend:dodge:mask:2
param:blend:dodge:mask:1
param:exposure:dodge:exposure:-2
4 changes: 2 additions & 2 deletions src/pipe/modules/blend/main.comp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ main()
if(params.mask == 1)
{
float mask = texture(img_mask, tc).r;
t = clamp(params.opacity*(1.0-mask), 0, 1);
t = clamp(params.opacity*mask, 0, 1);
}
else if(params.mask == 2)
{
float mask = texture(img_mask, tc).r;
t = clamp(params.opacity*mask, 0, 1);
t = clamp(params.opacity*(1.0-mask), 0, 1);
}

if(params.mode == 0)
Expand Down
4 changes: 2 additions & 2 deletions src/pipe/modules/shared/guided2f.comp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ main()
const float var = mean_corr.z - mean_corr.x * mean_corr.x;
const float cov = mean_corr.w - mean_corr.x * mean_corr.y;
// XXX what's the valid range here?
// const float a = clamp(cov / (var + 100*cov*params.epsilon), 0.0f, 1.0f);
const float a = clamp(cov / (var + 1e-8 + params.epsilon*params.epsilon), -1e5, 1e5); // some safety margin to avoid infty etc
const float a = clamp(cov / (var + 1e-8 + params.epsilon*params.epsilon), -5.0f, 5.0f);
// const float a = clamp(cov / (var + 1e-8 + params.epsilon*params.epsilon), -1e5, 1e5); // some safety margin to avoid infty etc
// const float a = cov / (var + params.epsilon*params.epsilon);
const float b = mean_corr.y - a * mean_corr.x;
imageStore(img_out, ipos, vec4(a, b, 0.0, 0.0));
Expand Down

0 comments on commit 1ed5467

Please sign in to comment.