1 | #version 450
|
---|
2 | #extension GL_ARB_separate_shader_objects : enable
|
---|
3 |
|
---|
4 | //in vec3 position_eye, normal_eye, color, light_position_eye, light2_position_eye;
|
---|
5 | layout(location = 0) in vec3 position_eye;
|
---|
6 | layout(location = 1) in vec3 color;
|
---|
7 |
|
---|
8 | layout(location = 0) out vec4 outColor;
|
---|
9 |
|
---|
10 | /*
|
---|
11 | // fixed point light properties
|
---|
12 | vec3 Ls = vec3(1.0, 1.0, 1.0);
|
---|
13 | vec3 Ld = vec3(1.0, 1.0, 1.0);
|
---|
14 | vec3 La = vec3(0.2, 0.2, 0.2);
|
---|
15 |
|
---|
16 | // surface reflectance
|
---|
17 | vec3 Ks = vec3(1.0, 1.0, 1.0);
|
---|
18 | vec3 Kd = vec3(1.0, 1.5, 1.0);
|
---|
19 | vec3 Ka = vec3(0.2, 0.2, 0.2);
|
---|
20 | float specular_exponent = 100.0; // specular 'power'
|
---|
21 | */
|
---|
22 |
|
---|
23 | void main() {
|
---|
24 | /*
|
---|
25 | // ambient intensity
|
---|
26 | vec3 Ia = La * Ka;
|
---|
27 |
|
---|
28 | // ambient intensity
|
---|
29 | vec3 Ia2 = La * Ka;
|
---|
30 |
|
---|
31 | vec3 direction_to_light_eye = normalize(light_position_eye - position_eye);
|
---|
32 | float dot_prod = max(dot(direction_to_light_eye, normal_eye), 0.0);
|
---|
33 |
|
---|
34 | // diffuse intensity
|
---|
35 | vec3 Id = Ld * color * dot_prod;
|
---|
36 |
|
---|
37 | vec3 direction_to_light2_eye = normalize(light2_position_eye - position_eye);
|
---|
38 | float dot_prod2 = max(dot(direction_to_light2_eye, normal_eye), 0.0);
|
---|
39 |
|
---|
40 | // diffuse intensity
|
---|
41 | vec3 Id2 = Ld * color * dot_prod2;
|
---|
42 |
|
---|
43 | vec3 surface_to_viewer_eye = normalize(-position_eye);
|
---|
44 |
|
---|
45 | vec3 reflection_eye = reflect(-direction_to_light_eye, normal_eye);
|
---|
46 | float dot_prod_specular = max(dot(reflection_eye, surface_to_viewer_eye), 0.0);
|
---|
47 | float specular_factor = pow(dot_prod_specular, specular_exponent);
|
---|
48 |
|
---|
49 | vec3 reflection_eye2 = reflect(-direction_to_light2_eye, normal_eye);
|
---|
50 | float dot_prod_specular2 = max(dot(reflection_eye2, surface_to_viewer_eye), 0.0);
|
---|
51 | float specular_factor2 = pow(dot_prod_specular2, specular_exponent);
|
---|
52 |
|
---|
53 | // specular intensity
|
---|
54 | vec3 Is = Ls * Ks * specular_factor;
|
---|
55 | vec3 Is2 = Ls * Ks * specular_factor2;
|
---|
56 |
|
---|
57 | outColor = vec4((Is + Id + Ia + Is2 + Id2 + Ia2)/2, 1.0);
|
---|
58 | */
|
---|
59 | outColor = vec4(color, 1.0);
|
---|
60 | }
|
---|