BMFont pack chars in multiple channels with outline?

Started by
2 comments, last by WitchLord 15 years, 5 months ago
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?
Advertisement
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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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;				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 = 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)
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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement