Sign in to follow this  

BMFont pack chars in multiple channels with outline?

This topic is 3335 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a way to avoid the heavy floating point math when packing the chars in multiple channels with outlines. Because im doing this on a mobile device (J2ME). It feels that the shader that was in the documentation was really floating point heavy and really adapted to the GPU. So how do I do this efficiently?

Share this post


Link to post
Share on other sites
Yes, the shader was definitely meant for the GPU.

I should think that it would be quite easy to use bitwise operations instead of floating point to do the same thing. The shader uses floating point, because the GPUs are not very good at bitwise operations.

On the mobile device you probably don't have any benefit from packing the chars in multiple channels (unless you're also including colored icons), so you can probably skip the check for the channel by creating a larger 8bit texture instead.

Regards,
Andreas

Share this post


Link to post
Share on other sites
Quote:
Original post by WitchLord
Yes, the shader was definitely meant for the GPU.

I should think that it would be quite easy to use bitwise operations instead of floating point to do the same thing. The shader uses floating point, because the GPUs are not very good at bitwise operations.

On the mobile device you probably don't have any benefit from packing the chars in multiple channels (unless you're also including colored icons), so you can probably skip the check for the channel by creating a larger 8bit texture instead.

Regards,
Andreas


I see. I have tried to make a implementation of the coloring of the outline. I really dunno why it fails. Have I misunderstood the encoding of the colors or something?


int redOutline = 0, greenOutline = 0, blueOutline = 0, alphaOutline = 255;
int redFill = 255, greenFill = 0, blueFill = 0, alphaFill = 255;
int tmpColor = alphaColor & rawData[i];
int fill = 0xF & tmpColor, outline = 0x0F & tmpColor;
outline <<= 4;
final int red = (redOutline*outline/127 + redFill*fill/127)*2,
green = (greenOutline*outline/127 + greenFill*fill/127)*2,
blue = (blueOutline*outline/127 + blueFill*fill/127)*2,
alpha = (alphaOutline*outline/127 + alphaFill*fill/127)*2;
ARGB[i] = alpha | (red>>8) | (green>>16) | (blue>>24);


Maybe Im just tierd. I don't see anythng wrong with this.(Other than maybe a little bit too many divisions and multiplications)

Share this post


Link to post
Share on other sites
I think this should work:


dword decode(byte raw)
{
byte alpha = (raw & 0x70) ? 0xFF : (raw << 1);
byte color = (raw & 0x70) ? (raw & 0x7F) << 1) : 0;
dword argb = (alpha << 24) | (color << 16) | (color << 8) | (color);
return argb;
}


Of course, the above just decodes the raw data into white glyphs with black outline. You seem to want to be able to set both glyph color and outline color, so you'll need to add more computations to it.

Share this post


Link to post
Share on other sites

This topic is 3335 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this