View Full Version : glMaterialfv and GLSL shaders

Joe Montana
08-19-2005, 04:47 PM
Im having problems with materials and vertex shaders.
I have 3 glDrawElements calls on the same vertices. before each call to glDrawElements, i call

glMaterialfv(GL_FRONT,GL_AMBIENT,colord );
glMaterialfv(GL_FRONT,GL_DIFFUSE,colord );
glMaterialfv(GL_FRONT,GL_SPECULAR,colord );

These come into my GLSL vertex shader as gl_FrontMaterial.diffuse(ambient,specular)

The problem is that only the first glDrawElement call (glMaterialfv) materials are used even through the next 2 glDrawElements calls. If i reverse the order of the calls(and associated materials) then the first one is only used.

Any ideas why. Am I doing something wrong(most likely) or driver problem.

Joe Montana
08-19-2005, 05:27 PM
Well I did this. And it works.
How come with glMaterialf.. doesnt work??
I did call glDisable(GL_COLOR_MATERIAL);


glColorMaterial(GL_FRONT, GL_DIFFUSE );

glColorMaterial(GL_FRONT,GL_AMBIENT );

glColorMaterial(GL_FRONT, GL_SPECULAR);

08-19-2005, 09:15 PM
Maybe you are running out of interpolators, or maybe driver just dont know how to arrange varyings/materials.

08-19-2005, 10:36 PM
He didn't mention he was interpolating the material properties, madman - he doesn't mention fragment shaders at all. Sounds like he's just doing simple lighting in a vertex shader.
Sounds a weird one, Joe.

08-20-2005, 03:12 PM
Perhaps this is the time to request info about platform, gfx h/w and driver version?

From a quick glance it seems like a (driver) bug to me.