HiGLSL shader

Hi,guys,its my first post here,and I need some help abt GLSL,in C++ I executed command

glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient);

pass material attribute to shaders,and in PS I wrote:

ambient += gl_LightSource[i].ambient * gl_FrontMaterial.ambient;

Im pretty much sure there is value in array ambient,but when I use GLSL devil to debug this GLSL,I realized that my gl_FrontMaterial.Ambient just give zero value.

So I wonder why my information are not transfered into Shader,Am I have to pass those information via self-defined uniformed slot?

You should be able to get the proper frontMaterial values using gl_FrontMaterial, I don’t think you have to pass them in as a uniform, though that is also an option.

Have you tried setting the fragment to gl_FrontMaterial.Ambient so you can see what colour it holds?

thx for ya advise I finally find my error,its my own logical error,wot a shame.:slight_smile:

By the way, do ya guy have a detailed document on GLSL which describ the differences between ATI & Nvidia Card,I use dynamic indexing on Nvidia card 6150LE it compile & run without error,but It failed to compile and link when it comes to ATI card. 1350,as far as I know that 1350 also belongs to SM2.0 card category,so I wonder why.

Thx any way!!!

you should check GLSL version specs and what a specific card is supporting (f.e. GLSL 1.20).
glGetString(GL_SHADING_LANGUAGE_VERSION_ARB);

I think you need to set that value before you bind the shader for it to get set.