Skip to content
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: implement CopyX BlendModes #2695

Open
wants to merge 5 commits into
base: ags4
Choose a base branch
from

Conversation

ivan-mogilko
Copy link
Contributor

@ivan-mogilko ivan-mogilko commented Feb 28, 2025

This implements 3 new BlendModes:

  • Copy - copies full color from src to dest, fully discards dest;
  • CopyRGB - copies rgb color component from src to dest, mixing with dest alpha;
  • CopyAlpha - copies src alpha to dest, mixing with dest rgb.
    /// copy source color to destination
    eBlendCopy,
    /// copy source rgb to destination (keep destination alpha)
    eBlendCopyRGB,
    /// copy source alpha to destination (keep destination rgb)
    eBlendCopyAlpha

Initially my intention was to implement only Copy, meant for drawing transparent primitives on DrawingSurface. This should replace an ability to draw with transparent color, which does not exactly work now after implemented alpha support (#2661).

After adding this mode to object rendering as well, it came to me that having a mode which copies only alpha might complement (if not replace in some circumstances) DynamicSprite.CopyTransparencyMask() function. That's why I added CopyAlpha, and then CopyRGB just to have all 3 variants.

CopyAlpha blend mode allows to copy transparency when using DrawingSurface.BlendImage() method.
But it also in theory might allow to "cut holes" in underlying surface for composite objects such as GUIs. I.e. if you have a GUI and a button with a mask sprite assigned to it, then you could assign eBlendCopyAlpha to such button and have it produce a transparent whole of any arbitrary shape in GUI background.

I say in theory above, because somehow we still do not have GUIControls support BlendMode property. I might just address this next. In order to test the OpenGL and Direct3D renderers with the new modes I had to hardcode BlendMode for GUI controls right into the engine.

Note that any other object won't benefit from these Copy modes much, because copying transparency will replace it on final screen image rather than, say, only an object immediately below, that's how rendering works. In order to "cut holes" only in selected objects we'll have to implement a special feature which combines two textures separately prior to rendering the final one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant