AGS 4: implement CopyX BlendModes #2695
Open
+191
−80
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.
This implements 3 new BlendModes:
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.