PDA

View Full Version : GL_COLOR_MATERIAL



JanHH
04-23-2003, 05:17 PM
Hello,

another stupid question from me: When using material properties (ambient, diffuse, specular) and specifiying them separatly with glMaterial, the performance of my app is extremely slow (rendering a terrain with some 100.000 triangles). However, when enabling GL_COLOR_MATERIAL and using glColor instead of glMaterial, it speeds up dramatically.. running absolutely smooth and fast, compared to nearly "standbilder" with glMaterial. It's obvious that it gets faster because of less calls to set the color, but that does not explain this extremely big difference in performance. I guess that other things that happen inside OpenGL are also different with GL_COLOR_MATERIAL enabled? A whole different/simpler lightnig model without specular highlights?

Regards
Jan

Perspective
04-23-2003, 06:26 PM
your right, lighting = lighting calculations.

if you want to speed up the app and still use your lighting effects, look into frustum culling to avoid rendering what cant be seen.

Deiussum
04-24-2003, 04:31 AM
Are you using the glMaterial calls between a begin/end? If I remember correctly, there was a discussion once on the advanced boards about it being more efficient to use glColor with GL_COLOR_MATERIAL enabled if you needed to change material properties between a glBegin/glEnd.

JanHH
04-24-2003, 03:54 PM
The color calls are not between glbegin and glend. And I am not sure if lightning calculations are less complex with GL_COLOR_MATERIAL, I would rather think that enabling this simply changes the way material properties are specified, and not the way OpenGL internally calculates the lighning.

And the idea about frustum culling is surely a good one, so convincing that we have this in the app since 1999 http://www.opengl.org/discussion_boards/ubb/wink.gif.

Jan

Deiussum
04-25-2003, 04:07 AM
Yeah, GL_COLOR_MATERIAL only changes how you specify material properties. It shouldn't be changing the way lighting is calculated.