Skip to content

sparse_strips: Apply image sampler opacity instead of panicking#1736

Open
AdrianEddy wants to merge 2 commits into
linebender:mainfrom
AdrianEddy:image-opacity-tint-fold
Open

sparse_strips: Apply image sampler opacity instead of panicking#1736
AdrianEddy wants to merge 2 commits into
linebender:mainfrom
AdrianEddy:image-opacity-tint-fold

Conversation

@AdrianEddy

Copy link
Copy Markdown
Contributor

Image::encode_into currently does unimplemented!("Applying opacity to image commands") whenever ImageSampler.alpha != 1.0, so any image drawn with less-than-full opacity panics the renderer.

This folds sampler.alpha into the paint's straight-alpha tint (scaling the tint's alpha channel, synthesizing a white Multiply tint when none exists) and resets sampler.alpha = 1.0. It's output-equivalent for both tint modes, since the strip shader computes sample_premul * tint_premul (Multiply) and tint_premul * sample.alpha (AlphaMask) — pre-scaling the tint's alpha scales the result uniformly.

The second commit fixes a latent GPU bug this newly exposes: the GPU packed tint used packed_color == 0 as the "no tint" sentinel, so a present but fully transparent tint (α=0, which premultiplies to 0) was read as "no tint" and rendered opaque on GPU while the CPU path rendered it correctly transparent. Tint presence is now carried by the mode field (0=none / 1=alpha-mask / 2=multiply) rather than the color, which also fixes any directly-set fully-transparent Tint.

Tests: 4 encoder unit tests (both modes, α=0, existing-tint scaling) and a pack_tint regression test; the WGSL is naga-validated by the shader build.

This PR was generated by Claude.

@AdrianEddy
AdrianEddy force-pushed the image-opacity-tint-fold branch from 5179894 to 37d270b Compare July 20, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant