Jump to content

Recommended Posts

Posted

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.

BadFontRendering.thumb.png.af7f28d399791312ca12f943351cc414.png

Here's my inventory.

BadFont_002.png.c0aee2cf589781cc1c0974b4f8234457.png

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. :)

  • Solution
Posted

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.

  • Thanks 1

Let's build cool stuff and have fun. :)

  • 1 month later...
Posted

There's still a difference between the widget fonts and my own.

FontDifference.thumb.png.d052e290f68180b89b30907ea0d6aab9.png

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.

FontDifference_002.thumb.png.7bf2398d6de518cfc75f9dc31ec0ceae.png

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...

Posted

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.

Posted

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.

s8s8p4feu7s6mjqvs65lfgopn7mm

  • Thanks 1

Let's build cool stuff and have fun. :)

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...