|
|
|
|
|
|
Make "demo2d.elf" work.
Posted on 2005-09-03 00:00:00 |
|
After a bit of reading, I figured out some stuff about the alpha blending process of the GS. First, this demo was using an alpha value of 0x80 (128) for the visible pixels in its textures, which seemed a bit odd to me.
Then I checked the GS alpha blending formulae again and everything started to make sense. Here's the way this demo setups the formulae: D = D + (S - D) * (As >> 7) D stands for the destination color, S for the source color and As the alpha value of the source. The (As >> 7) part can be rewritten as (As / 128). So, if we take a pixel that has an alpha value of 128, then the above formulae can be simplified like this: D = S This represents a normal pixel copy, which means that the alpha value for an opaque pixel is 0x80 when alpha blending is enabled and set up this way. So all the text in this demo is supposed to look opaque. I don't know why GStaris isn't doing it right... Maybe it was fixed in a more recent version... Anyways, that's not important. So knowing this, I changed the GS handler so it enables alpha blending on sprite primitives that need it and so that it sets up the OpenGL blending function correctly in this demo's case. Also made OpenGL multiply all the alpha values by 2 when it uploads the textures to obtain the right results on screen. Here's what it gives: This is all for this demo. And there isn't more in this series anymore, so the next one will probably be more interesting. |