gfx2d: alpha blending Sprite2D

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2023-09-02 09:52:47 -07:00
parent 67dbe9b3ee
commit 2b9ec3ba4c

View file

@ -117,7 +117,18 @@ pub fn engineSprite2dInit(
); );
const shader_module = device.createShaderModuleWGSL("shader.wgsl", @embedFile("shader.wgsl")); const shader_module = device.createShaderModuleWGSL("shader.wgsl", @embedFile("shader.wgsl"));
const blend = gpu.BlendState{}; const blend = gpu.BlendState{
.color = .{
.operation = .add,
.src_factor = .src_alpha,
.dst_factor = .one_minus_src_alpha,
},
.alpha = .{
.operation = .add,
.src_factor = .one,
.dst_factor = .zero,
},
};
const color_target = gpu.ColorTargetState{ const color_target = gpu.ColorTargetState{
.format = core.descriptor.format, .format = core.descriptor.format,
.blend = &blend, .blend = &blend,