Added README
[gl4] / pixel.glsl
1 #version 450
2 #extension GL_ARB_separate_shader_objects : enable
3
4 layout(binding = 0) uniform sampler2D tex;
5
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;
10
11 layout(location = 0) out vec4 color;
12
13 void main()
14 {
15         vec4 texel = texture(tex, texcoord);
16
17         vec3 vdir = -normalize(vpos);
18         vec3 n = normalize(norm);
19         vec3 l = normalize(ldir);
20         vec3 h = normalize(vdir + ldir);
21
22         float ndotl = max(dot(n, l), 0.0);
23         float ndoth = max(dot(n, h), 0.0);
24
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
29
30         // XXX ambient (implied 0) + diffuse + specular
31         color.rgb = diffuse + specular;
32         color.a = texel.a;
33 }