Results 1 to 10 of 10

Thread: GL_LINE_SMOOTH produces "bold" lines (big width)

  1. #1
    Member Contributor
    Join Date
    Oct 2010
    Location
    France
    Posts
    59

    GL_LINE_SMOOTH produces "bold" lines (big width)

    Hello,

    All is in the subject : only enabling or disabling GL_LINE_SMOOTH gives thick or thin lines.
    I join an image.
    What is the cause that thick lines ? How to disable that ?

    I enabled GL_LINE_SMOOTH to do antialiasing on lines...

    Thanks for your help.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jun 2009
    Location
    FL , USA
    Posts
    192

    Re: GL_LINE_SMOOTH produces "bold" lines (big width)

    What is the cause that thick lines ?
    To remove aliasing, the line gets dilated by partially affecting neighboring pixels' values (lying adjacent to pixels belonging to line) to give smooth appearance hence the thickness.

  3. #3
    Member Contributor
    Join Date
    Oct 2010
    Location
    France
    Posts
    59

    Re: GL_LINE_SMOOTH produces "bold" lines (big width)

    Thanks for your answer.

    Yes but there is a so big difference between thin and thick lines...
    The 3D view looks like a cartoon with big edges.
    In 2D when I zoom out I have "bold" black areas where there a many lines (details).
    Enabling the blending does not change anything.
    For me it seems unusable like this...

    Do you confirm that it is the correct behavior ?

  4. #4
    Senior Member Regular Contributor
    Join Date
    Jun 2009
    Location
    FL , USA
    Posts
    192

    Re: GL_LINE_SMOOTH produces "bold" lines (big width)

    From hardware point of view. It also depends on the card that you use. What card are you using?

    Enabling the blending does not change anything.
    What king of blending functions are you using?

    Try using options in glHint().

  5. #5
    Member Contributor
    Join Date
    Apr 2018
    Posts
    83

    Re: GL_LINE_SMOOTH produces "bold" lines (big width)

    Quote Originally Posted by AllForum
    What is the cause that thick lines ?
    Your line coordinates are most likely bad (between pixels instead of at center of pixels). However, i guess something else is also going on as the partially covered pixels look full color and not a mix between line and scene colors (blending not enabled? used blend mode needs, but is missing an alpha channel? overdraw? user has overridden anti-alias in drivers?).

  6. #6
    V-man
    Guest

    Re: GL_LINE_SMOOTH produces "bold" lines (big width)

    Quote Originally Posted by AllForum
    Do you confirm that it is the correct behavior ?
    I checked. Your line has a thickness of 1 pixel.
    When you enable smoothing, thickness becomes 3. So it is normal.

    Perhaps you shouldn't use a old feature like smoothing. I recommend using FSAA instead.

  7. #7
    Member Contributor
    Join Date
    Oct 2010
    Location
    France
    Posts
    59

    Re: GL_LINE_SMOOTH produces "bold" lines (big width)

    Thanks for your answers.

    Yes the blending is disable on my screenshot. It does not change the rendering "quality" : the lines look thick.
    And I think I used the classical code :
    Code :
    	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    	glEnable (GL_BLEND);
     
    	glEnable (GL_LINE_SMOOTH);
    	glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);

    @V-man
    I saw when searching on the net that there is a FSAA method.
    Will this method generate more thin lines or will I only have better performances ?

    Thanks

  8. #8
    V-man
    Guest

    Re: GL_LINE_SMOOTH produces "bold" lines (big width)

    With FSAA, the lines would look fine. Different vendors implement FSAA differently and of course, different GPU generation support different AA-levels : some support 2x and 4x and some support 2x, 6x, 4x, 8x and some support 2x, 4x, 8x and Quincunx ( http://www.tomshardware.com/reviews/...on,2868-5.html ) and some support up to 16x)

    Try them and see which one you like. You can just go into control panel and enable it. IMO, 6x and above yields good results. If you like it, then you can create a FSAA context programmatically.

  9. #9
    Senior Member Regular Contributor remdul's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands
    Posts
    346

    Re: GL_LINE_SMOOTH produces "bold" lines (big width)

    As pointed out above, use alpha blending for GL_LINE_SMOOTH. Call glLineWidth to tweak the thickness when wider than 1px (with alpha=1.0). To draw lines that appear thinner than 1px, scale the alpha, e.g. glColor(1,1,1,0.5) for 0.5px wide lines. glLineWidth does not accept values smaller than 1.0 (=1px width).

    Tip: use glLineWidth(~1.3) for consistent anti-aliasing. Perfectly vertical or horizontal lines with glLineWidth(1) wide may seem thinner than diagonal lines. Likewise, if you still prefer to keep perfectly vertical/horizontal 1px wide, you can scale the alpha of diagonal lines.

    GL_LINE_SMOOTH generally gives nicer anti-aliased lines than FSAA/MSAA, unless you got 16x and up. It may be more efficient memory wise (smaller framebuffer footprint). But be aware that GL_LINE_SMOOTH quality/rasterization may (subtly) vary between vendors.

    Also take note that some Intel hardware has absolutely p!ss-poor line rendering qualiy. I've seen some on-board chipsets drivers fail to even rasterize regular aliased 1px wide lines properly on diagonals, similar to your screenshot, but with inexplicably alternating thickness and occasionally jittering pixels.

  10. #10
    Member Contributor
    Join Date
    Oct 2010
    Location
    France
    Posts
    59

    Re: GL_LINE_SMOOTH produces "bold" lines (big width)

    Hello,

    So FSAA is a solution for me.

    Remdul, I tested again after your post but no : I can not obtain good results. And blending works but gives artifacts in some cases (in 3D view). If you say that it may work then there are errors in our code but I can not find where...

    I tested FSAA like V-man suggested : that gives good results in 2D and 3D.
    So I did a test in my code using a Nehe tutorial.
    I join the result. It is ok for me and I have no more artifacts in 3D.

    Many thanks for your help !

Similar Threads

  1. glEnableVertexAttribArray Produces "Invalid Value" - OpenGL 3.1
    By tmason in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-14-2014, 02:04 PM
  2. egl gles2 "function is no-op" "Mesa: User error"
    By unixmania in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-17-2013, 05:30 AM
  3. Replies: 1
    Last Post: 10-26-2012, 02:19 AM
  4. Drawing to FBO produces odd "effect." Ideas???
    By metko in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 05-05-2009, 08:44 AM
  5. Stippled Lines into "Dancing Ants"
    By coolguyclay in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-13-2009, 02:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean