GLMaterial* oddness

Howdy all

I recently moved from using a Radeon 9600 to a GeForce 6800, and this seems to have uncovered a strange bug in my code (It also appears when using Mesa).

It seems that when I specify the ambient, diffuse or specular colours using glMaterialfv(), the colour values passed in are clamped to be either 0 or 1.
So for instance, passing in [ 0, 0, 0, 0 ] works as expected, but any non-zero value behaves as though it were 1.0, so [ 0.1, 0, 0, 0 ] is indistinguishable from [ 1, 0, 0, 0 ].
The emissive colour does not display this behaviour.
Also the only active light has it’s ambient, diffuse and specular colours all set to pure white.

Is there some OpenGL state flag that will cause this behaviour? Are ATI’s drivers just more permissive/buggy than nVidia’s?

Cheers in advance.

edit: I should clarify that it’s only the RGB values that are clamped, alpha works as expected

Are you sure the normals aren’t just too long? (This can happen for several reasons.)

You could try adding a gl.glEnable(GL.GL_RESCALE_NORMALS), but keep in mind that keeping that state enabled is probably a bad idea, as it’s kinda slow.

It already was I’m afraid. I tried slipping in a GL_NORMALIZE, but still no dice :frowning:

You might be on to something with the normals though, as the specular highlight is very large, and doesn’t appear to change very much as GL_SHININESS is changed.

I still can’t understand how something that is so badly broken on nVidia and Mesa worked fine on ATI.

The GLGears jogl demo works fine, so it must be my own stupidity at fault >:(

edit: curse my lack of completeness! I should also mention that I’m rendering gluSphere()s, so it’s not me who’s specifying normals. All scaling is uniform across the axes.

What kind of SHININESS values are you specifying? 16 is a good starting place. A common mistake is to try to specify in the 0-1 range but this will cause the problem you are seeing. The SHININESS is the exponent in the specular equation, so the higher the SHININESS, the tighter the highlight. 8-32 is a common range.

I’ve tried the entire range of SHININESS ( 0 to 128 ) and while the size of the highlight does cover the entire diffuse-lit area at 0, at 128 it’s only slightly smaller.

Also, the SHININESS doesn’t explain the colour oddness. I reckon there must be something going awry in the scaling that I’m doing. I shall investigate and report back either way.

As expected, the problem lay between the keyboard and chair ::slight_smile:

For some reason, i was setting the all the attenuation terms of the light to 0. This, clearly, is a silly thing to do.

Cheers for the suggestions anyway.