View Full Version : What is causing this jagged shading artifact on my sphere?

10-09-2004, 09:24 PM

Please first see this image:


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!



10-11-2004, 10:09 AM
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.

10-11-2004, 05:35 PM
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!


10-11-2004, 05:46 PM
Are you using stencil shadows? If so try turning them off and seeing if that makes a difference.

10-11-2004, 09:08 PM
nope, no stencilling...

10-12-2004, 05:42 AM
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.


10-12-2004, 06:33 AM
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)

10-12-2004, 04:37 PM
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.



10-12-2004, 05:07 PM
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 :

shadow part
lighted partWith 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.