# OpenGL shader problem

So, I've been working on this game engine for a while now, and just the other day my friend tried running the program and his output doesn't match my output...

My Program Output:

His Program Output:

both are supposed to be donuts, but his donut is very much misformed. I made sure that all the vertices and indices were loaded on his machine correctly so it has to be something going wrong in the shaders

#version 150
in vec3 in_Position;
in vec3 in_Normal;
in vec2 in_TexCoord;

out vec2 ex_TexCoord;
out vec3 Normal;

uniform mat4 model_matrix;
uniform mat4 view_matrix;
uniform mat4 projection_matrix;

void main(void){
ex_TexCoord = in_TexCoord;
Normal = vec3(transpose(inverse(model_matrix * view_matrix)) * vec4(in_Normal, 1.0));
gl_Position = projection_matrix * view_matrix * model_matrix * vec4(in_Position,1.0);
}


#version 150

in vec2 ex_TexCoord;
in vec3 Normal;

out vec4 frag_color;

uniform vec3 lambient;
uniform vec3 ldifuse;
uniform vec3 lspecular;

uniform vec3 light_pos;
uniform vec3 position;
uniform vec3 lstrength;
uniform sampler2D color_texture;

float dcont;
vec3 light_dir;
float intensity;
vec3 normal;
vec3 light;

void main(void){
float dist = length(position-light_pos);
float att = (1/(1.0+(0.01*dist)+(0.001*dist*dist)));
light_dir=normalize(light_pos-position);
normal = normalize(Normal);
intensity = dot(light_dir,normal);
light = normalize(light_pos-position);
dcont = max(0.0,dot(normal,light));
vec3 ambient = lambient;
vec3 difuse = dcont * ldifuse;
vec3 specular = lspecular;

if(intensity > 0.95){
frag_color= vec4((difuse + ambient) * vec3(texture2D(color_texture,ex_TexCoord))*(att),1.0);
}
else if(intensity > 0.5){
frag_color = vec4((difuse + ambient) * vec3(texture2D(color_texture,ex_TexCoord))*0.9*(att),1.0);
}
else if(intensity > 0.25){
frag_color = vec4((difuse + ambient) * vec3(texture2D(color_texture,ex_TexCoord))*0.7*(att),1.0);
}
else{
frag_color = vec4((difuse + ambient) * vec3(texture2D(color_texture,ex_TexCoord))*0.4*(att),1.0);
}
}

• Is your system the only computer this works on? It may help to know the differences in hardware. Also, based on what you've said, it appears that the loading is not the issue. If you've matched up the vertices being loaded as exactly the same then it's the display that's the issue, so you may want to rephrase your title. – MichaelHouse May 29 '13 at 23:27
• yeah, it seems like it could be a harware dependent problem – Brendan Webster May 29 '13 at 23:28
• Your shaders might be buggy. Different drivers will do different things with non-conforming shader code. – Sean Middleditch May 29 '13 at 23:29
• Could it be lack of support for GL_UNSIGNED_INT index data? Although you don't have so many vertices that it would be a problem. Just an idea. – DaleyPaley May 30 '13 at 0:09
• @BrendanWebster: You should post that in an answer (perfectly fine to answer yourself, if you've found the solution), so others will be able to find this in case they encounter something similar. – Mario May 30 '13 at 8:53