Advertisement

[BMFont] Dropshadow effect possible with Pixel Shader alone?

Started by May 27, 2021 08:17 AM
2 comments, last by ehmdjii 3 years, 6 months ago

Hello,

I would like to add a dropshadow effects to my fonts. Now the obvious way is to render the glyphs with an offset in black before the actual glyphs are rendered. But as soon as transparency comes in the effect gets ugly because the whole shadow glyph can be seen through the actual glyph.

So I was wondering if there is a “trick” to get a dropshadow effect without this “double-painting"? Maybe something can be done in the pixelshader?

Thanks!

To do this properly you need to render the glyphs to a texture to form the text first, and then render that texture to the display while applying the transparency as desired.

Although a bit more complex than rendering the glyphs directly to the display this has a couple of additional benefits:

1. You will be able to apply more complex effects on the font that can handle cases where glyphs overlap without any problem (e.g. blurring)
2. You can get a performance benefit by keeping the texture with the text between frames so it doesn't have to be rendered anew each frame

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

Advertisement

Thanks! Goode idea, ill get to the implementing right away!

This topic is closed to new replies.

Advertisement