close
Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions vello_shaders/shader/shared/blend.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const MIX_HUE = 12u;
const MIX_SATURATION = 13u;
const MIX_COLOR = 14u;
const MIX_LUMINOSITY = 15u;
const MIX_LUMINANCE_CLIP = 64u;
const MIX_CLIP = 128u;

fn screen(cb: vec3<f32>, cs: vec3<f32>) -> vec3<f32> {
Expand Down Expand Up @@ -218,11 +219,12 @@ fn blend_compose(
cs: vec3<f32>,
ab: f32,
as_: f32,
mode: u32
compose_mode: u32,
mix_mode: u32
) -> vec4<f32> {
var fa = 0.0;
var fb = 0.0;
switch mode {
switch compose_mode {
case COMPOSE_COPY: {
fa = 1.0;
fb = 0.0;
Expand All @@ -241,6 +243,9 @@ fn blend_compose(
}
case COMPOSE_SRC_IN: {
fa = ab;
if mix_mode == MIX_LUMINANCE_CLIP {
fa *= lum(cb);
}
fb = 0.0;
}
case COMPOSE_DEST_IN: {
Expand Down Expand Up @@ -305,6 +310,6 @@ fn blend_mix_compose(backdrop: vec4<f32>, src: vec4<f32>, mode: u32) -> vec4<f32
let co = mix(backdrop.rgb, cs, src.a);
return vec4(co, src.a + backdrop.a * (1.0 - src.a));
} else {
return blend_compose(cb, cs, backdrop.a, src.a, compose_mode);
return blend_compose(cb, cs, backdrop.a, src.a, compose_mode, mix_mode);
}
}
Loading