unity3d - Changing the foreground color of a glyph in a texture -


before dwell issue i'm having, more context needed. i've written fontrenderer class render text. here's how works: during run-time, if display string abc, gameobject generated have 3 quads, each uv coordinates of every glyph looked atlas texture.

simple enough. allows single draw call given same material used.

however, if add feature of, changing foreground of specific glyph, how approach problem? plan \c escape sequence so: \c[a-f]{2}[a-f]{2}[a-f]{2}.

for example, if color a in abc red , rest of string white, pass following string fontrenderer: "\cff0000a\cffffffbc".

my first thought make use of atlas texture. idea behind plot new glyph new foreground color , allocate sprite within atlas texture. however, can quite complex.

my next idea use vertex/fragment shader i'm unsure if possible. issue if possible, instance of material using shader needed every rendered string increasing number of draw calls.

what other way can done?

probably simplest procedural approach change maincolor of diffuse shader color atlas material. caveat here can use 1 color per instanced material means if wanted a, b , c in abc string each different color you'd need split them up, causing 3 draw calls instead of one.

another option use vertex colors , shader procedurally color material. when generate quads you'd set color of each vertex color specified.

couple of quick resources specific unity3d around using shaders color material based on vertex color:

finally, if either of above don't suit suggest taking @ plugin marketplace font rendering either buy or try , learn from.

good luck.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -