-
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
AGS4: Attribute DrawingSurface::DrawingTransparency
#1514
Comments
I mentioned this elsewhere, so will restate here. Besides finding a good script API for this feature there seem to be a couple of major problems blocking it:
Perhaps it's worth to have at least p1 as a separate ticket. In regards to the script API, this is of course an open topic and will be discussed further, but my IMHO currently is:
EDIT: regarding p4 of imho, I may have a false memory, but I think @AlanDrake once suggested to have a argb Color property for every object in game, which would determine its blending operation (optionally replacing Tint and Transparency properties altogether, or used by these properties under the hood). Such property would also include alpha value. |
I like the idea of having something like But I can see that this is going to be a lot of work if the internal coding doesn't fully provide for the alpha channel yet. |
I remember we discussed about the use cases and limitations of Tint, that it could cover more uses if it were possible to also apply a pure color ove the sprite, but that had more to do with shaders. Then there's LightLevel that reused some of those values. This represents a Brigthness adjustment in HW, while SW rendering applies a flat white/black color (which would be directly translatable to HSL adjustment). Both namings and implementations are misleading. Tint and Brightness should be made separate properties. Sorry for having derailed the topic with these separate topics. Anyway, I agree with all points, @ivan-mogilko . |
Opened a ticket regarding 32-bit color values: #1980 But this ticket, I think, may be repurposed into proposal to support alpha channel during primitive drawing operations, as it's not clear whether it will work automatically with the allegro sources we're currently using. So, an extra work may be required for that purpose (also see my comment above). |
So, the colors are now defined as full ARGB values since #2525. We may return to this proposal. As I mentioned elsewhere, there's a question of which operation is used when a color with alpha is used to draw on a surface. ags/Editor/AGS.Editor/Resources/agsdefns.sh Lines 597 to 608 in fc5359d
|
I don't think that's right (apart from the fact that if dest is opaque the result will be opaque, which is usually what you want; otherwise you need to clear it first). The final alpha (in a [0,1] range) should be |
Ah... my mistake. I probably was confusing this with something else. Well, then, what remains is implementation. AFAIK allegro functions drawing primitives do not use alpha. I think that a solution could be to provide alternate function variants that accept a blender func as an argument and call it for each pixel, just like when blending sprites is done. EDIT: ah, here it is: Lines 505 to 511 in 6eda31d
There are also corresponding functions as do_circle, do_ellipse, and do_arc: ags/libsrc/allegro/include/allegro/draw.h Line 44 in 6eda31d
I suppose that "do_line" is internally used for any shape that has straight lines, like rectangle and triangle. |
From what I see, right now DrawingSurface can already use "alpha" component of a DrawingColor, but it copies the color, fully replacing the pixels, not blends it. DrawingSurface.Clear is the only function that works as expected. |
Hmm, this may be good news. I did not know that before, but apparently Allegro 4 has a setting called "draw mode", set by a I tested this quickly, and this seem to affect any shape drawing and filling function: rectangle, line, circle, triangle. This means that not only the functionality is available, but also that we may actually have our custom "blending mode" for raw drawing too. I'll try to make a working PR tomorrow. |
Resolved by #2661 |
Describe the problem
True-colour space provides a full-fledged alpha channel (RGBA). This alpha channel isn't easily accessible in AGS games.
In AGS, when you want to draw onto a
DrawingSurface
in true-colour games, you can set the pen colour withDrawingSurface::DrawingColor
. However, there's no way to set the pen transparency. So convoluted workarounds are needed in order to draw semi-transparent shapes onto a surface.Suggested change
Introduce
int DrawingSurface::DrawingTransparency
to set the alpha channel value of the drawing pen.The range of this attribute would need to be discussed:
AFAIK, the real range of the alpha channel in true-colour space is
[0 .. 255]
. However, traditionally in AGS, alpha values are given in percent. This must by needs be inexact from the get-go, and 255 isn't an exact multiple of 100, so some percentages must by needs be “more inexact” than others.[0 .. 100]
(100 means completely transparent, so nothing drawn is visible)[0 .. 255]
(255 means completely transparent)[0 .. 99]
(99 translates to 252 in the scale of [0 .. 255])float [0.0 .. 1.0}
We also need to discuss how this parameter should be handled in non-true-colour games, i.e., games where pixels can only be completely transparent or completely opaque.
The text was updated successfully, but these errors were encountered: