Register
Site Login
Site Search
Forums
Advertisement
Welcome to PocketMatrix. PocketMatrix is dedicated to providing the best online community for mobile device developers and enthusiests. What's new?

Speeding up by Alpha-premultiplying RGB?


Speeding up by Alpha-premultiplying RGB?

Postby Bunkai » Dec 15, 2006 @ 11:11pm

Hello Johan,

Based on my experience with GapiDraw 3.6 and AlphaBlt() and AlphaBltFast(), the RGB value expected is in its full value with not Alpha-premultiplied RGB.

However, one very popular optimization technique is premultiplying RGB by its Alpha value and thus reducing one multiplication per each pixel during rendering semi-transparent pixels. Let me explain:

Rendering sprites with non Alpha-premultipied RGB(this is used by AlphaBlt() and AlphaBltFast()):

FinalRGB = RGB * Alpha + (1 - Alpha)*Background;


If we use Alpha-premultiplied RGB (.PNG files support this), the final semi-transparent pixels could be rendered as follows:

FinalRGB = RGB + (1-Alpha)*Background;


As far as I know, all 3D and 2D graphics packages support generating Alpha-premultiplied RGB(that is ready for compositing). Therefore, is there any chance, that in the following release of GapiDraw Alpha-premultiplied RGB would be supported by AlphaBlt() and AlphaBltFast()? This could be easily accomplished by adding a flag to every function, that woud specify whether Alpha-premultiplied RGB is used.

It would not really be a lot of work, and would significantly speed up alpha computations - a great optimization technique.

With regards,
Rene.
Bunkai
pm Member
 
Posts: 71
Joined: Mar 18, 2006 @ 5:01pm


Postby Johan » Dec 19, 2006 @ 9:05am

Hello,

Thanks for the tip! I will look into to see if we can integrate this in some nice way for the next release.

Cheers
Johan
Johan Sanneblad, M.Sc, Ph.D
GapiDraw Systems Architect
[http://www.gapidraw.com]
User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Postby Bunkai » Dec 20, 2006 @ 10:07am

Yeah,

I assume, this could speed up alpha blitting by 30% maybe, and thats not bad at all. All it requires is not to multiply RGB by Alpha value on render time, because alpha premultiplied RGB is already delivered in imported image.

To see that this is a standard and frequently used approach, Google proves that:

http://www.google.com/search?hl=en&lr=& ... iplication

With regards,
Rene.
Bunkai
pm Member
 
Posts: 71
Joined: Mar 18, 2006 @ 5:01pm


Re: Speeding up by Alpha-premultiplying RGB?

Postby InexorableTash » Jan 4, 2011 @ 3:22am

I've been away from GapiDraw for a few years; I just updated my hobby project from 3.7 to 4.2, which went smoothly (unfortunately my architecture propagated the Create*Surfaces calls down the hierarchy so I needed to change many signatures). But back on topic:

Did anything ever become of this request? I have some textures with premultiplied alpha baked in and have been living with the black fringes; I don't see anything in the .H files that would indicate that this went in.

(You can see the effect in http://www.youtube.com/watch?v=Yjmn7WTLZPY at around 3:45 - obviously, this is only a hobby project and would never be released.)
User avatar
InexorableTash
pm Member
 
Posts: 99
Joined: Sep 13, 2002 @ 6:14am


Re: Speeding up by Alpha-premultiplying RGB?

Postby Johan » Jan 17, 2011 @ 9:50am

Hello there,

No, this feature never made it to GapiDraw.

Sincerely
Johan
Johan Sanneblad, M.Sc, Ph.D
GapiDraw Systems Architect
[http://www.gapidraw.com]
User avatar
Johan
pm Member
 
Posts: 1843
Joined: Jan 12, 2002 @ 12:38pm
Location: Sweden


Return to GapiDraw


Sort


Forum Description

The Cross-platform Graphics SDK for Palms, Pocket PCs, Symbian Devices, and Stationary PCs.

Moderators:

sponge, Johan

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron