Semi-transparent images render test

General discussion about Super Mario Bros. X.

Moderator: Userbase Moderators

Wohlstand
Chargin' Chuck
Chargin' Chuck
Posts: 2008
Joined: Tue Feb 11, 2014 4:44 pm
Flair: [ˈvoːlˌʃtant], 狐エンジニア
Pronouns: he/him
Contact:

Semi-transparent images render test

Postby Wohlstand » Sat Jun 21, 2014 3:18 am

For checking SMBX's image renderer, I made this little comparing of SMBX and PGE with new mask renderer (0.1-alpha, what support using of the Alpha-channel by masks (in 0.0.8 semi-transparent possible only by PNG, by masks you can get only 1-bit)). Masks give to using semi-transparent in image formats, what not supporting of internal transparent, example: BMP, JPG, or GIF, what have only one bit of transparency (PNG have 255 grades of semi-transparency).

Test #1
I made vertical gradient background image:
Spoiler: show
Image
And gray-grade masks:
Spoiler: show
Image Image
Image Image
And run this interesting test:
ImageImage

Result:
- SMBX calculating image in real-time render by color-mixing, as you see, appeared a lot of color glitches.
- The PGE applying masks only on image-loading process, and calculated image saving in RAM, and after using always in working process.

Get this test


Test #2
Will be made test with horizontal gradient:
Spoiler: show
Image
And graded masks of same sprite, but saved in npc-1, npc-2,...,npc-20:
Spoiler: show
ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
And ran this test:
ImageImage

Result:
- SMBX uses Color-Mixing for imitating semi-transparency
- PGE uses a alpha-channel for generating target sprites from masks, and renders real semi-transparency.

Get this test


Test #3
Little programming examples:
For make real test, I got THIS example for Visual Basic 6 (Language, used for made SMBX):
http://www.vbexplorer.com/VBExplorer/gdi1.asp

And I replaced images to my SMBX's sprites:
Image
And build them.

I take this result:
Image
As you see, result is same, what displayed in SMBX.

VisualBasic 6 source, what creating this mask (And I think, this is same method, what uses in SMBX for render sprites)

Code: Select all

Private Sub cmdDrawMask_Click()

'Draws the mask with vbSrcAnd raster operation
BitBlt Me.hDC, 0, 0, picMask.ScaleWidth, picMask.ScaleHeight, picMask.hDC, 0, 0, vbSrcAnd

End Sub

Private Sub cmdDrawSprite_Click()

'Draws the sprite witht the vbSrcPaint raster operation
BitBlt Me.hDC, 0, 0, picSprite.ScaleWidth, picSprite.ScaleHeight, picSprite.hDC, 0, 0, vbSrcPaint

End Sub
All sources and test EXE of this you can get here: VB6 Mask Example.zip

In C++ with Qt I using mask for define alpha-channel of image:
https://github.com/Wohlhabend-Networks/ ... cs.cpp#L24

Code: Select all


QPixmap setAlphaMask(QPixmap image, QPixmap mask)
{
    if(mask.isNull())
        return image;

    if(image.isNull())
        return image;

    QImage target = image.toImage();
    QImage newmask = mask.toImage();

    if(target.size()!= newmask.size())
    {
        newmask = newmask.copy(0,0, target.width(), target.height());
    }

    newmask.invertPixels();

    target.setAlphaChannel(newmask);

    return QPixmap::fromImage(target);
}
This allow to using any grades of semi-transparency.

But you must fix all lazy-made sprites (What is this?), what sometimes using in SMBX's custom graphics
Last edited by Wohlstand on Sun Jun 22, 2014 4:25 am, edited 5 times in total.

Warlock
Eerie
Eerie
Posts: 759
Joined: Thu Jan 09, 2014 8:50 am
Flair: bep
Pronouns: they/them
Contact:

Re: Semi-transparent images render test

Postby Warlock » Sat Jun 21, 2014 3:26 am

Very impressive Wohlstand.

This could come in very handy for my SMBX projects and stuff.

Wohlstand
Chargin' Chuck
Chargin' Chuck
Posts: 2008
Joined: Tue Feb 11, 2014 4:44 pm
Flair: [ˈvoːlˌʃtant], 狐エンジニア
Pronouns: he/him
Contact:

Re: Semi-transparent images render test

Postby Wohlstand » Sat Jun 21, 2014 8:04 am

Main post updated:
added third test


Return to “General”

Who is online

Users browsing this forum: No registered users and 3 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari