Results 1 to 3 of 3

Thread: Strange edge artifacts with gl_FrontFacing

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2010
    Posts
    3

    Strange edge artifacts with gl_FrontFacing

    I'm trying to do two-sided lighting, but I'm getting these annoying artifacts on the edges (see attached picture). Apparently for these fragments gl_FrontFacing is false..?

    Shaders are simply:

    Code :
    #version 120
    void main()
    {
        gl_Position = ftransform();
    }

    and..
    Code :
    #version 120
    void main()
    {
        if (gl_FrontFacing)
          gl_FragColor = vec4(1,0,1,1);
        else
          gl_FragColor = vec4(0,0,1,1);
    }

    Thanks!

  2. #2
    Super Moderator OpenGL Guru imported_dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,966

    Re: Strange edge artifacts with gl_FrontFacing

    This is zfighting at the silhouettes due to the back facing fragments winning the zbuffer evaluation, due to front back order and z fragment equality at the silhouette.

    Try to increase z precision if you can, push near clip plane out and pull far clip plane in.

    You could also do a two pass render, in pass one have front faces off, then in pass 2 with backfaces off you make sure you have less than or equal to instead of a less than test.

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2010
    Posts
    3

    Re: Strange edge artifacts with gl_FrontFacing

    Okay, thanks!

    I managed to get it work using glPolygonOffset, so that the backfaces are offset a bit before being drawn.

Similar Threads

  1. Texture Atlas edge artifacts...how to fix?
    By Keith Z. Leonard in forum OpenGL: Advanced Coding
    Replies: 10
    Last Post: 10-10-2008, 04:12 PM
  2. Strange rendering artifacts...
    By dagcrack in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 04-18-2005, 04:58 AM
  3. strange pixel artifacts
    By bumby in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-09-2004, 04:36 AM
  4. Near-edge texturing artifacts
    By iNsaNEiVaN in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 04-16-2002, 11:01 PM
  5. Strange black artifacts
    By Punchey in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-09-2000, 07:00 AM

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