#This should make a gold color with a weak specular highlight.
glMaterialfv(GL_FRONT,GL_AMBIENT,(0.2,0.2,0.2,1.0))
glMaterialfv(GL_FRONT,GL_DIFFUSE,(0.8,0.8,0.4,1.0))
glMaterialfv(GL_FRONT,GL_SPECULAR,(1,1,1,1))
glMaterialfv(GL_FRONT,GL_EMISSION,(0,0,0,1))
glMaterialfv(GL_FRONT,GL_SHININESS,128)
Materials in Shaders
Hello,
I'm making a program, and I'm getting a strange bug when rendering a material with this shader (http://www.lighthouse3d.com/opengl/glsl/index.php?pointlight). It runs, but strangely, the ambient and diffuse aspects of the colors aren't being accessed correctly. I set the material every frame, like so:
If I set the material and then use the shader with only specular, I see the specular highlights using the material parameters rendered correctly, and nothing else. This is the expected behavior.
However, if I set the material and then use the shader with only ambient and/or only diffuse, the ambient and diffuse material properties aren't used--instead, both are (1,1,1,1).
In shader jargon, I can change gl_FrontMaterial.specular and gl_FrontMaterial.shininess, but I can't change gl_FrontMaterial.ambient or gl_FrontMaterial.diffuse.
This is a very strange error, and I want to know how to fix it.
Thank you,
-Geometrian
In a very simple example, when using this shader:I get a red object. But when using this shader:I get a white object. I set the materials for this like this
[EDIT: more specific problem continues here: http://www.gamedev.net/community/forums/topic.asp?topic_id=512598]
[Edited by - Geometrian on October 25, 2008 1:31:46 AM]
//vertex shadervoid main() { gl_Position = ftransform(); }//fragment shadervoid main() { gl_FragColor = gl_FrontMaterial.specular;}
//vertex shadervoid main() { gl_Position = ftransform(); }//fragment shadervoid main() { gl_FragColor = gl_FrontMaterial.ambient;}
glMaterialfv(GL_FRONT,GL_SPECULAR,(1,0,0,1))glMaterialfv(GL_FRONT,GL_AMBIENT,(1,0,0,1))
[EDIT: more specific problem continues here: http://www.gamedev.net/community/forums/topic.asp?topic_id=512598]
[Edited by - Geometrian on October 25, 2008 1:31:46 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement