SpiderPig Posted April 29 Share Posted April 29 I'm not using the default widget system here, I've made my own and rasterize my fonts to a texture. In this screenshot you can clearly see the problem I have. I added a background shader to the font shader. The text only looks good when on dark backgrounds. You can see the right side is much nicer than the left side. Here's my inventory. I'm unsure if this is a font shader issue - a rasterization issue - or simply I need better font colours depending on the background color. Thought I'd ask to see if any one here might have any tips. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted May 3 Author Share Posted May 3 @Josh Do you do anything special when rendering font textures? Or is this simply an artistic issue and I need better contrast between the background and text. Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted May 4 Solution Share Posted May 4 Use TEXTUREFILTER_NEAREST for the filtering argument when you create the texture. Otherwise, if your texcoords aren't 100% perfect it will blur the text. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SpiderPig Posted May 4 Author Share Posted May 4 Oh that helped a lot, thanks. That's been driving me nuts for ages. Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 20 Author Share Posted June 20 There's still a difference between the widget fonts and my own. Mine seem to be a little more bolder. It's more noticeable at lower font sizes. This is my rendering of fonts at different fonts sizes from 8 to 38 respectively. Size 8 (the first one) is the worst. I think this might be a hinting issue, although I'm unsure how to get the truetype library to render with hinting if it's not already by default... Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted June 21 Author Share Posted June 21 Aha, I have solved it. It was a shader issue. Old Shader with incorrect way of applying alpha channel. void main() { vec4 tex_sample = texture( sampler2D( materials[ in_MaterialIndex ].textureHandle[ 0 ] ) , in_TexCoords.xy ); color[0] = vec4( 1 , 1 , 1 , tex_sample.x ); color[0] = ( ( color[0] * tex_sample.x ) * in_Color ); } New shader with fixed alpha channel. void main() { vec4 tex_sample = texture( sampler2D( materials[ in_MaterialIndex ].textureHandle[ 0 ] ) , in_TexCoords.xy ); color[0] = vec4( in_Color.x , in_Color.y , in_Color.z , tex_sample.x ); color[0].rgb *= tex_sample.x; } @Josh One thing I've never understood is why this "color[0].rgb *= alpha_value" has to be done to achieve transparency? I thought the alpha component of the vec4 was all that was needed. Quote Link to comment Share on other sites More sharing options...
Josh Posted June 21 Share Posted June 21 Ultra uses pre-multiplied alpha blending. With regular alpha blending the surface in front can only darken the surface behind it. With pre-multiplied, it blends more accurately, and can result in a darker or lighter color. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.