Particles: premultiply the texel when the texture arrived straight - #31
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.