Skip to content

Particles: premultiply the texel when the texture arrived straight - #31

Merged
ivan-ushakov merged 1 commit into
crossplatformfrom
fix/particle-premultiplied-alpha
Aug 4, 2026
Merged

Particles: premultiply the texel when the texture arrived straight#31
ivan-ushakov merged 1 commit into
crossplatformfrom
fix/particle-premultiplied-alpha

Conversation

@ivan-ushakov

Copy link
Copy Markdown
Collaborator

No description provided.

SDLWorldQuadRenderer blends (ONE, 1-SRC_ALPHA) and worldquad premultiplies the
vertex colour, so everything downstream of that shader -- the blend factors, the
fog rules, the soft-depth fade -- is written for a premultiplied source.  The
DDS decoder produces one (Render/src/DDSImage.cpp, to stop bilinear filtering
bleeding transparent-texel colour into opaque edges).  A .tga or an .avi frame
does not, and in both games every texture this renderer draws is one of those:
particle sprites, coast foam, the sun and moon, the rain.

Left straight, a texel's colour enters at full strength however transparent it
is, so the soft border of a smoke puff draws as hard as its middle and the
sprite reads as a bright square with a picture in it.

cTexture now records which of the two its reload produced and the renderer
passes that to the shader, which premultiplies where the decoder did not.
Keying off the decoder rather than the file extension keeps the one exception
honest: a specular or bump map is deliberately not premultiplied, its alpha
being power or nothing rather than opacity.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ivan-ushakov
ivan-ushakov merged commit f86fdb2 into crossplatform Aug 4, 2026
4 checks passed
@ivan-ushakov
ivan-ushakov deleted the fix/particle-premultiplied-alpha branch August 4, 2026 17:59
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