Jump to content
  • Advertisement
Sign in to follow this  
mewse

Fragment shaders and GL_LINE_SMOOTH

This topic is 3844 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently doing a lot of line drawing, using wide lines with GL_LINE_SMOOTH enabled. I've discovered that if I enable a shader during the drawing process, I lose the smoothing done by GL_LINE_SMOOTH; even if the shader is a trivial one that just passes through the input values:
(vertex shader)

void main(void)
{
gl_FrontColor = gl_Color;
gl_BackColor = gl_Color;
gl_Position = ftransform();
}

(fragment shader)

void main(void)
{
gl_FragColor = gl_Color;
}
Is this a "yes, that's the way it works" thing, or have I perhaps missed an attribute variable that I should be using in my shader?

Share this post


Link to post
Share on other sites
Advertisement
Possibly related to this, I've noticed that if I render extremely wide lines using glLineWidth() (say, ten pixels or so), then with no fragment shader, I get very nice rectangles oriented along the direction of the line, as you would expect.

If I have enabled a fragment shader, though, then it seems to give the parallelograms of fragments; two edges parallel to the direction of the line, and the other two edges either horizontal or vertical, depending on the slope of the line. With a thin line this makes very little difference, but it's starting to explain a couple of the strange subtle glitches I've been noticing at line endpoints. Is this standard behaviour?

Share this post


Link to post
Share on other sites
Rendering lines have been iffy since GL was invented. Each implementation can give different results.
And today, with shaders, if you enable GL_LINE_SMOOTH and use shaders, it runs n software mode on ATI.

I would make my lines into quads and emulate GL_LINE_SMOOTH yourself or just use FSAA.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!