Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8123333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:08:44+00:00 2026-06-06T06:08:44+00:00

I’m attempting to write a shader to put a border around text. It compiles

  • 0

I’m attempting to write a shader to put a border around text. It compiles and runs ok, but the border is grainy and aliased. Any suggestions for making it better please?

Shader

This is the first shader I have written so don’t have much knowledge about the API. Could any example code be commented please? I don’t want to just copy and paste an answer; I’d like to understand it.

Additionally, I have a problem when I make the text smaller which is best explained by this image. Any suggestions on fixing this too please?

Shader

The edge detection could be better too. So far I take advantage of the fact that the antialiased texture I use for input has edges with 0.0 < alpha < 1.0

So far I have this:

#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texCoord;
uniform sampler2D u_texture;
uniform vec4 u_borderColor;
uniform float u_width;
uniform float u_height;

void main()
{
    mediump vec4 total = vec4(0.0);

    float alpha = texture2D(u_texture, v_texCoord).a; 
    //If somewhere between complete transparent and completely opaque
    if (alpha > 0.0 && alpha < 1.0)
    {
        total.rgb = u_borderColor.rgb;
        total.a *= u_borderColor.a;
        gl_FragColor = u_borderColor;
    }
    else
    {
        gl_FragColor = texture2D(u_texture, v_texCoord);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:08:46+00:00Added an answer on June 6, 2026 at 6:08 am

    Why aren’t you setting the value of gl_FragColor to total? Alpha is no more maintained correctly….

    Next, total.a = 1 – alpha; (from outer to inner)

    or a variant like:

    total.a = abs(0.5 – alpha); (blend both sides)

    would probably make more sense, when blending.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
Seemingly simple, but I cannot find anything relevant on the web. What is the
I want to construct a data frame in an Rcpp function, but when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.