Open salinecitrine opened 1 year ago
Firstly, try to avoid gl.Text() as its interfaces is somewhat more limited than dedicated Lua font API https://springrts.com/wiki/Lua_Fonts Secondly, can you provide the exact snippet which didn't work as expected for you? The gist you linked doesn't seem to use engine outlines at all.
Firstly, try to avoid gl.Text() as its interfaces is somewhat more limited than dedicated Lua font API https://springrts.com/wiki/Lua_Fonts Secondly, can you provide the exact snippet which didn't work as expected for you? The gist you linked doesn't seem to use engine outlines at all.
I had assumed that gl.Text(...)
in widgets referred to this function; does it actually point to a different one?
There isn't a direct example in the gist, since I replaced it with a workaround, but something like this is what I had before (with "o" added for outline here compared to the gist):
glText(text, 0, 0, currentFontSize, "cdo")
Thanks for the tip on Lua Fonts, I'll try that out instead.
Automatic outline has fixed outline colors:
0.95f, 0.95f, 0.95f, 0.8f
for light outline and
0.15f, 0.15f, 0.15f, 0.8f
for dark outline
As far as I can tell we have no alpha testing enabled or anything similar during the font rendering so any reasonable alpha should get in. 0.02f
/ 2% is pretty low though and it might be easy to miss.
Just to be 100% sure in the statement above I additionally disabled alpha testing, though it should have had no effect with a shader in place anyway. https://github.com/beyond-all-reason/spring/commit/2f128c398cccde38b7c9b6ebe003b9cdc28d1000
I think the request here is to keep the outline alpha relative to the main text, so something like:
1, 1, 1, 1.0
-> outline becomes 0.15, 0.15, 0.15, 0.8
1, 1, 1, 0.5
-> outline becomes 0.15, 0.15, 0.15, 0.4
1, 1, 1, 0.125
-> outline becomes 0.15, 0.15, 0.15, 0.1
0, 0, 0, 1.0
-> outline becomes 0.95, 0.95, 0.95, 0.8
0, 0, 0, 0.2
-> outline becomes 0.95, 0.95, 0.95, 0.16
I'm thinking to extend the inline color marking to include outline/shadow color and alpha channel. https://github.com/beyond-all-reason/spring/issues/884
Automatic color of the outline is currently defined by option o
or O
to do light or dark outlines, they use a fixed alpha value. I'm happy to change that if someone can come up with a sane formula of how to derive the outline's alpha, from the main color or main's alpha.
I'm thinking to extend the inline color marking to include outline/shadow color and alpha channel. #884
Automatic color of the outline is currently defined by option
o
orO
to do light or dark outlines, they use a fixed alpha value. I'm happy to change that if someone can come up with a sane formula of how to derive the outline's alpha, from the main color or main's alpha.
Just my opinion, but from my own work on the widget I linked, I found that outlineAlpha = 0.7 * mainAlpha
was simple and looked good to me.
I only tested with red and green, so perception might vary for other colors. I also tested out subtracting a small amount (~.05
) from the outline alpha so that you never had a case where the outline was more visible than the main text (I ultimately removed it; the discontinuity when fading was hard to make look ok). outlineAlpha = 0.7 * mainAlpha * mainAlpha
might work better for the same effect.
Current:
This draws the inside of the letter twice, so at any values of <1 text alpha and >0 outline alpha it will be polluted by the outline color even on the inside of the letter.
How about this?
For very low alpha values, the result is drawing basically just the outline, which looks awkward.
alpha = 0.1:
alpha = 0.02:
I encountered this while developing https://gist.github.com/salinecitrine/7f6e21ed304eeaba9ad4a122019c0d82 . I ended up using a workaround where I draw extra black copies of the text, offset by a few pixels.
alpha = 0.1, with my workaround (indicating very approximately what I think it should look like instead):