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

DrawingSurface::DrawSurface doesn't process transparency properly #1513

Closed
fernewelten opened this issue Jan 23, 2022 · 5 comments
Closed

DrawingSurface::DrawSurface doesn't process transparency properly #1513

fernewelten opened this issue Jan 23, 2022 · 5 comments
Assignees
Labels
context: graphics type: bug unexpected/erroneous behavior in the existing functionality
Milestone

Comments

@fernewelten
Copy link
Contributor

fernewelten commented Jan 23, 2022

Describe the bug
In a true-colour game, when a DrawingSurface is drawn onto a DrawingSurface, the calculations don't process the transparency parameter and/or the alpha channel of the drawing surfaces properly. See screenshots below.

Also, apparently transparency cannot be 100. This should be an allowed value and result in an unchanged surface (because something is drawn onto it that is completely transparent).

AGS Version
Build 3.5.1.14
Edit: A quick test seems to show that AGS4 does handle DrawingSurface::DrawSurface() properly.

Game
Test351.zip

Here's the relevant code of Room 1:

DynamicSprite *ds;

function test(int transp)
{
    DrawingSurface *dsu = ds.GetDrawingSurface();
    dsu.DrawingColor = Game.GetColorFromRGB(255, 255, 255);
    dsu.DrawRectangle(10, 10, 50, 50);
    DrawingSurface *dsu_copy = dsu.CreateCopy();
    dsu.DrawingColor = Game.GetColorFromRGB(250, 100, 100);
    dsu.DrawCircle(20, 20, 20);
    dsu.DrawSurface(dsu_copy, transp);
    dsu.Release();
    dsu_copy.Release();
    player.Say("This is DrawSurface with %d %% transparency", transp);
}

function room_AfterFadeIn()
{
    ds = DynamicSprite.Create(50, 50, true);
    oTestTest.Graphic = ds.Graphic;
    
    test(99);
    test(70);
    test(20);
    test(1);
    test(0);
}

The setup in Room 1:
image

To Reproduce
Run game, observe screens:

Screenshots and expected behaviour
image
The square seems to be completely cut out of the circle although it is nearly completely transparent as per the transparency parameter (99 %).
I'd expect some of the circle to show through.

image
The circle has completely disappeared.
Outside of the white square, the alpha channel of the copy should be "transparent", so copying should not obliterate the circle in that area.

image
Transparency 20 % seems to do exactly the same as transparency 70 %. That can't be right.

image
Even transparency 1 % seems to do exactly the same as transparency 70 %

image
At 0 % transparency, the copy seems to replace the surface completely.
But, seeing that most of the copy has a completely transparent alpha channel, I'd expect the red circle to stay on surface wherever the white square isn't.

Desktop (please complete the following information):

  • Windows 10, German edition

Smartphone (please complete the following information):

  • n/a
@ivan-mogilko ivan-mogilko added context: graphics type: bug unexpected/erroneous behavior in the existing functionality labels Jan 23, 2022
@ericoporto
Copy link
Member

ericoporto commented Jan 23, 2022

Curiously the Test351.ags game in Compiled/Data did not ran for me. I rebuilt the attached game project and ran it with the latest 3.6.0.X editor release. And the bug doesn't happen in the master, so I tried 3.5.1.14, and it happened there.

Edit: A quick test seems to show that AGS4 does handle DrawingSurface::DrawSurface() properly.

Yeah, I think AGS4 is building from master merges, this is why it's fixed there already.

This could be added to the SDL2 milestone to be tracked as things fixed by it.

@ivan-mogilko
Copy link
Contributor

ivan-mogilko commented Jan 23, 2022

I recall merging DrawingImage and DrawingSurface internal implementation to go through the same draw function in the end, so maybe that actually fixed that.

This maybe could be fixed in 3.5.1 too, and a new patch released later while 3.6.0 is still in alpha/beta. I wonder when it got broken though.

@ivan-mogilko ivan-mogilko added this to the 3.5.1 milestone Jan 23, 2022
@ivan-mogilko ivan-mogilko self-assigned this Jan 23, 2022
@ivan-mogilko
Copy link
Contributor

ivan-mogilko commented Jan 23, 2022

Fixed in release-3.5.1 with 2710b99.

Don't know if/when there will be a next 3.5.1 patch release yet, I'd rather wait for a while in case someone finds another bug there.

@fernewelten
Copy link
Contributor Author

I wonder when it got broken though.

I seem to have unearthed a function that hasn't been used for a long time, or else somebody would have complained already. 😀

@ivan-mogilko
Copy link
Contributor

The fix was included to 3.5.1.15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context: graphics type: bug unexpected/erroneous behavior in the existing functionality
Projects
None yet
Development

No branches or pull requests

3 participants