-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AGS 4: Remove "has alpha channel" sprite flag, and related parameters #1813
AGS 4: Remove "has alpha channel" sprite flag, and related parameters #1813
Conversation
ffdb4b5
to
5c23469
Compare
Returned to this PR, rebased to resolve conflicts. Most of the engine change is done, what's left is fixing nuances when using generated images and drawing primitives, then fix the sprite import in the Editor. |
Note: old editors seem to save 32-bit room backgrounds without alpha channel (so after this change these would be considered fully transparent). After this change the Editor would keep proper alpha in backgrounds. I am not particularly certain if this is a correct behavior though. Maybe we should consider room backgrounds to be strictly opaque. OTOH if we don't - that in theory gives an opportunity to see one room viewport through another, if room background has "cuts". |
Note 2: in regards to drawing primitives (using Bitmap class and allegro functions), apparently the alpha channel is secure there and always set to 0xFF if color set by |
de59088
to
ce70535
Compare
This is ready for review and testing. Updated the first post with details on what was done. |
33cdf37
to
7524af2
Compare
Had to remake something & rebase: reverted an "opaque" flag in textures, because it's not related to the "has alpha" flag, and is used primarily for optimizing bitmap->texture conversions for images that are known to never have transparent pixels: room backgrounds, debug surfaces, built-in gui, fx effects. This flag may be reviewed and refactored later, as a separate task. PS. tested remaining cases, all seem to be working. |
NOTE: left opaque flag for now, as it makes bitmap->texture conversion faster for room bgs and few other things. Still it's not designed very well. Opaque should be either texture data's flag, - in which case same sprite_id will be either opaque or not opaque, - or DDB's flag, but in that case it cannot be applied to the shared texture data. Currently it's possible to share same texture data, but update it with different "opaque" values, which breaks logic.
DrawSpriteBlend will only have 1 variant of blender proc, which assumes that both 32-bit source and dest bitmaps have alpha.
7524af2
to
ee75ada
Compare
Resolves #1808.
In AGS sprites have a "has alpha channel" flag which tells whether the image's alpha channel should be used or not. Certain drawing operations depend on it; for instance a blending op or conversion from the sprite to texture may be performed in one or another way depending on the combination of source and destination surfaces' alpha flags.
The purpose of this change is to remove this flag and those checks altogether, and imply that 32-bit images always have a valid alpha channel. This will simplify a lot of things internally, and probably will make life easier to user who uses true color graphics by default. The only downside I see is that forcing an opaque image will become a responsibility of game author, either when preparing an image for import, or when generating a dynamic sprite in script (in which case one would have to clear the sprite with some color then blit the image on it to ensure there's no transparency).
What is done
What is kept
Kept "Import alpha channel" in the Sprite Import dialog. For now it works simply: if set then do nothing, if unset then the sprite will be made fully opaque by filling alpha channel with 0xFF.
If not wanted, this setting may be removed later as well.
The "magic pink" color constant is still kept internally even in 32-bit. This is unfortunate, but may be necessary for DrawingSurfaces, because currently there's no way to set alpha for a DrawingColor, or in SetPixel/GetPixel, so people will have to use COLOR_TRANSPARENT (see #1514). Unless I'm missing or misunderstanding something here... I may look afterwards if it's okay to completely remove it and any related conversions for 32-bit.
TODO:
- [ ] perhaps merge all thedraw_xxx_sprite
functions, because they seem to do almost same thing now (may be done separately later).This includes: