[PyOpenGL-Users] shader errors
Brought to you by:
mcfletch
From: Michael L. <mic...@gm...> - 2010-07-28 12:25:22
|
Hi! i have some very strange behaviour with my shader. the code i took here: http://www.geeks3d.com/20091013/shader-library-phong-shader-with-multiple- lights-glsl/ [CODE] program = compileProgram( [''' varying vec3 normal, eyeVec; #define MAX_LIGHTS 8 varying vec3 lightDir[MAX_LIGHTS]; varying vec2 texture_coordinate; uniform int numLights; void main() { gl_Position = ftransform(); normal = gl_NormalMatrix * gl_Normal; vec4 vVertex = gl_ModelViewMatrix * gl_Vertex; eyeVec = -vVertex.xyz; int i; texture_coordinate = vec2(gl_MultiTexCoord0); for (i=0; i<numLights; ++i) lightDir[i] = vec3(gl_LightSource[i].position.xyz - vVertex.xyz); } ''',], [''' varying vec3 normal, eyeVec; #define MAX_LIGHTS 8 varying vec3 lightDir[MAX_LIGHTS]; varying vec2 texture_coordinate; uniform sampler2D my_color_texture; uniform int numLights; void main (void) { vec4 final_color = gl_FrontLightModelProduct.sceneColor; vec4 texel = texture2D(my_color_texture, texture_coordinate); vec3 N = normalize(normal); int i; for (i=0; i<numLights; ++i) { vec3 L = normalize(lightDir[i]); float lambertTerm = dot(N,L); if (lambertTerm > 0.0) { final_color += gl_LightSource[i].diffuse * gl_FrontMaterial.diffuse * lambertTerm; vec3 E = normalize(eyeVec); vec3 R = reflect(-L, N); float specular = pow(max(dot(R, E), 0.0), gl_FrontMaterial.shininess); final_color += gl_LightSource[i].specular * gl_FrontMaterial.specular * specular; } } gl_FragColor = final_color*texel; } ''',]) #after this -> if program: glUseProgramObjectARB(program) num_lights = glGetUniformLocationARB(program, "numLights") glUniform1iARB(num_lights, 4) [/CODE] ###################################################### it's ok at work but at home it crashes (win x64, geforce 7600 GT). Other shaders work fine - i found that it crashes somewhere near for-loop for (i=0; i<numLights; ++i) lightDir[i] = vec3(gl_LightSource[i].position.xyz - vVertex.xyz); The main question is can i somehow debug shader and print some log what's going on? and how it can be that everything is ok at one machine and invalidOperation at other?.. thank you! |