Sign in to follow this  

Fragment shaders and GL_LINE_SMOOTH

This topic is 3594 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
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

This topic is 3594 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this