Hello, let's me first introduce myself 
I'm currently writing a cross-platform framework and now i'm at a good point: when four months ago i started the project, i searched for some good information about cross-platform programming and so, because this was my first cross-platform project and i thought some background information was necessary, mostly because i never had a PocketPC (really!)
While thinking how to organize things, i took my latest rasterization functions and started thinking on how to write them in a generic and mostly reusable way, since my previous one-platform framework really lacked genericity in rasterization functions.
I came up with some working templates, but i faced a really huge problem: eMbedded Visual C++ wasn't supporting "friends templates" at all: i was really shocked and, due to this, i decided to search around for some solutions.
One "googling" day, PocketFrog come to my attention: despite its PocketPc-oriented approach, the most obviously inspirating thing for me were the templated rasterizer functions.
I immediately realized "friends templates" wasn't needed at all (at least for the rasterization part, but now i know there are no patch from Microsoft for this): so really a great finding and keep up the good work on it!
Now, i'm currently writing a particle engine and i found out that the blending shader produce greenish results with low blending values, here is a screenshot of what i'm talking about. The particle is a black&white rgba png:


The particles at the left are blended with the actual PocketFrog alpha-blending shader: the middle one is a slighty minor change in the shader code but yet showing scattered greenish: the right one is a rewrite of the shader by using what i call a "lossy green mask" in order to lose the least significative bit while retaining all the 6-bits of green.
Whereas there is a great improvement on the colors and the greenish goes away, losing 1-bit on the green channel also means losing the nice shading (the second screenshot better shows the shading going away).
Here is the code for the modified shader:
I'm looking forward for your considerations: i think having color-correct stuff is good, but in 565 this came at a cost.
What do you think? Can this be seen as an improvement? Arduous question
<edit>
Well, i just realized there is no need to compensate, and also doing it could lead to some artifacts (visible on a solid dark/black background)
</edit>
I'm currently writing a cross-platform framework and now i'm at a good point: when four months ago i started the project, i searched for some good information about cross-platform programming and so, because this was my first cross-platform project and i thought some background information was necessary, mostly because i never had a PocketPC (really!)
While thinking how to organize things, i took my latest rasterization functions and started thinking on how to write them in a generic and mostly reusable way, since my previous one-platform framework really lacked genericity in rasterization functions.
I came up with some working templates, but i faced a really huge problem: eMbedded Visual C++ wasn't supporting "friends templates" at all: i was really shocked and, due to this, i decided to search around for some solutions.
One "googling" day, PocketFrog come to my attention: despite its PocketPc-oriented approach, the most obviously inspirating thing for me were the templated rasterizer functions.
I immediately realized "friends templates" wasn't needed at all (at least for the rasterization part, but now i know there are no patch from Microsoft for this): so really a great finding and keep up the good work on it!
Now, i'm currently writing a particle engine and i found out that the blending shader produce greenish results with low blending values, here is a screenshot of what i'm talking about. The particle is a black&white rgba png:


The particles at the left are blended with the actual PocketFrog alpha-blending shader: the middle one is a slighty minor change in the shader code but yet showing scattered greenish: the right one is a rewrite of the shader by using what i call a "lossy green mask" in order to lose the least significative bit while retaining all the 6-bits of green.
Whereas there is a great improvement on the colors and the greenish goes away, losing 1-bit on the green channel also means losing the nice shading (the second screenshot better shows the shading going away).
Here is the code for the modified shader:
- Code:
// declares lossy green masking and compensation values
const Pixel LOSSY_GREEN_MASK = 0x1F << 6;
const Pixel GREEN_COMPENSATION = 0x01 << 5;
- Code:
// the shader itself
struct AlphaBlend : public PixelShader
{
int blendQuantity;
Pixel operator()( Pixel src, Pixel dest ) const
{
Pixel RB1 = dest & (RED_MASK | BLUE_MASK);
Pixel G1 = dest & ( LOSSY_GREEN_MASK );
Pixel RB2 = src & (RED_MASK | BLUE_MASK);
Pixel G2 = src & ( LOSSY_GREEN_MASK );
int32_t blendingQ = blendQuantity >> 3;
Pixel RB = RB1 + (((RB2-RB1) * (blendingQ)) >> 5);
Pixel G = G1 + (((G2-G1)*(blendingQ))>>5);
RB &= (RED_MASK | BLUE_MASK);
G &= ( LOSSY_GREEN_MASK );
//if( G > 0 )
//G |= GREEN_COMPENSATION; // compensate for the green masking
return (RB | G);
}
};
I'm looking forward for your considerations: i think having color-correct stuff is good, but in 565 this came at a cost.
What do you think? Can this be seen as an improvement? Arduous question
<edit>
Well, i just realized there is no need to compensate, and also doing it could lead to some artifacts (visible on a solid dark/black background)
</edit>



