2 #extension GL_ARB_separate_shader_objects : enable
4 layout(binding = 0) uniform sampler2D tex;
6 layout(location = 3) in vec3 vpos;
7 layout(location = 4) in vec3 norm;
8 layout(location = 5) in vec3 ldir;
9 layout(location = 6) in vec2 texcoord;
11 layout(location = 0) out vec4 color;
15 vec4 texel = texture(tex, texcoord);
17 vec3 vdir = -normalize(vpos);
18 vec3 n = normalize(norm);
19 vec3 l = normalize(ldir);
20 vec3 h = normalize(vdir + ldir);
22 float ndotl = max(dot(n, l), 0.0);
23 float ndoth = max(dot(n, h), 0.0);
25 // XXX (1, 1, 1) diffuse color implied * texel * ndotl
26 vec3 diffuse = texel.rgb * ndotl;
27 vec3 specular = vec3(1.0, 1.0, 1.0) * pow(ndoth, 50.0);
28 // XXX (1, 1, 1) specular color, 50.0 shininess
30 // XXX ambient (implied 0) + diffuse + specular
31 color.rgb = diffuse + specular;