Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: What is causing this jagged shading artifact on my sphere?

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2004
    Posts
    26

    What is causing this jagged shading artifact on my sphere?

    Hi,

    Please first see this image:

    http://www.3dwonders.com/images/specular.jpg

    I would like to understand what is causing the jagged black shaded edge you see on the left side of the sphere.

    My program has variance in hundreds of parameters but I only see this effect occasionally - perhaps one in 30 scenes. Most often when the sphere is blue.

    The sphere is a textured, lit gluSphere. Increasing slices/stacks doesn't help. There are always one or more light sources in the scene. The sphere has a little specular and shinyness. However, after playing around with the various material and lighting params I can't deduce the real cause, or a rule to avoid the problem.

    Would appreciate any assistance!

    Cheers,

    Tom

  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: What is causing this jagged shading artifact on my sphere?

    Your eye is very sensitive to changes in blue chroma information (rather counter intuitive considering the calculation of luminance).

    This is a vertex lighting shading artifact where vertices fall into and out of illumination at the edge of that lighting result, the stepped pattern corresponds to the meshing of your object. More subdivision or trying to soften up that lighting edge might mitigate the effect.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2004
    Posts
    26

    Re: What is causing this jagged shading artifact on my sphere?

    Thanks, but neither of these comments seems to tally. The artifact is very strong on blue spheres but seldom seen at all on different colors.

    As I mentioned there are plenty of poly's in the sphere - 35 slices and stacks actually, which clearly does not correspond to the black shading stepping shown.

    Any other comments welcome!

    Tom

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Melbourne,Victoria,Australia
    Posts
    767

    Re: What is causing this jagged shading artifact on my sphere?

    Are you using stencil shadows? If so try turning them off and seeing if that makes a difference.

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2004
    Posts
    26

    Re: What is causing this jagged shading artifact on my sphere?

    nope, no stencilling...

  6. #6
    Junior Member Regular Contributor
    Join Date
    Jan 2001
    Location
    Lafayette, LA
    Posts
    138

    Re: What is causing this jagged shading artifact on my sphere?

    Originally posted by meanfox:

    As I mentioned there are plenty of poly's in the sphere - 35 slices and stacks actually, which clearly does not correspond to the black shading stepping shown.
    I assume "clearly" means you haven't looked at it?

    Can you generate an image where the wireframe of the sphere is drawn over the shaded version, to give us (and yourself) a hint of where the polygons are? The artifact you show typically is due to insufficient tesselation, so having some data to work with would help.

    Dirk

  7. #7
    Intern Newbie
    Join Date
    Jun 2004
    Location
    Berlin, Germany
    Posts
    30

    Re: What is causing this jagged shading artifact on my sphere?

    hmmm...I think that something with the normals is wrong.
    Do you have called glScalef before rendering the sphere?
    If yes, you should renormalize the normals with glEnable(GL_NORMALIZE)

  8. #8
    Junior Member Newbie
    Join Date
    Jun 2004
    Posts
    26

    Re: What is causing this jagged shading artifact on my sphere?

    After further experimentation, the problem is most apparent when I set GL_SHININESS low. Setting it to around 10 to 15 seems to ameliorate the problem.

    I determined that adjusting the tesselation does make a difference - it increase the number of steps, Scaling with the tesselation but not corresponding 1 to 1. For example, with 300 slices and 300 stacks I see maybe 30 steps or so.

    Cheers,

    Tom

  9. #9
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: What is causing this jagged shading artifact on my sphere?

    look meanfox, as everybody said, this is caused by vertex lighting. Lighting is only computed at vertices, and just interpoled along triangles (or quads).
    Why with 300 slices you only get 30 steps ? Look :
    Code :
    shadow part
    ................
    ########........
    ################
    lighted part
    With diffuse lighting, it is barely noticeable, because the lighting is pretty smooth. With specular though, there are cases (ie. almost back-light) when there is a hard step between full specular and no ligthing. That is the way it works.

    To improve that, from easier to harder :
    - don't use specular at all
    - increase sphere vertical subdivisions
    - use a smooth specular (low exponent, as you noticed)
    - use a faint specular (not too bright)
    - do the lighting yourself (that way you may soften the back-light edge)
    - do per pixel lighting with shaders

    I hope it will help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •