source: opengl-game/shaders/ship.frag@ 06d959f

feature/imgui-sdl points-test
Last change on this file since 06d959f was aa00bf2, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 5 years ago

Re-enable some of the logic to render lights in the ship shader for vulkangame

  • Property mode set to 100644
File size: 1.9 KB
RevLine 
[1908591]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;
5layout(location = 0) in vec3 position_eye;
6layout(location = 1) in vec3 color;
[aa00bf2]7layout(location = 2) in vec3 light_position_eye;
8layout(location = 3) in vec3 light2_position_eye;
[1908591]9
10layout(location = 0) out vec4 outColor;
11
12// fixed point light properties
13vec3 Ls = vec3(1.0, 1.0, 1.0);
14vec3 Ld = vec3(1.0, 1.0, 1.0);
15vec3 La = vec3(0.2, 0.2, 0.2);
16
17// surface reflectance
18vec3 Ks = vec3(1.0, 1.0, 1.0);
19vec3 Kd = vec3(1.0, 1.5, 1.0);
20vec3 Ka = vec3(0.2, 0.2, 0.2);
21float specular_exponent = 100.0; // specular 'power'
22
23void main() {
[8e02b6b]24 // ambient intensity
25 vec3 Ia = La * Ka;
[1908591]26
[8e02b6b]27 // ambient intensity
28 vec3 Ia2 = La * Ka;
[1908591]29
[aa00bf2]30 vec3 direction_to_light_eye = normalize(light_position_eye - position_eye);
[8e02b6b]31 //float dot_prod = max(dot(direction_to_light_eye, normal_eye), 0.0);
[1908591]32
[8e02b6b]33 // diffuse intensity
34 //vec3 Id = Ld * color * dot_prod;
[1908591]35
[aa00bf2]36 vec3 direction_to_light2_eye = normalize(light2_position_eye - position_eye);
[8e02b6b]37 //float dot_prod2 = max(dot(direction_to_light2_eye, normal_eye), 0.0);
[1908591]38
[8e02b6b]39 // diffuse intensity
40 //vec3 Id2 = Ld * color * dot_prod2;
[1908591]41
[8e02b6b]42 //vec3 surface_to_viewer_eye = normalize(-position_eye);
[1908591]43
[8e02b6b]44 //vec3 reflection_eye = reflect(-direction_to_light_eye, normal_eye);
45 //float dot_prod_specular = max(dot(reflection_eye, surface_to_viewer_eye), 0.0);
46 //float specular_factor = pow(dot_prod_specular, specular_exponent);
[1908591]47
[8e02b6b]48 //vec3 reflection_eye2 = reflect(-direction_to_light2_eye, normal_eye);
49 //float dot_prod_specular2 = max(dot(reflection_eye2, surface_to_viewer_eye), 0.0);
50 //float specular_factor2 = pow(dot_prod_specular2, specular_exponent);
[1908591]51
[8e02b6b]52 // specular intensity
53 //vec3 Is = Ls * Ks * specular_factor;
54 //vec3 Is2 = Ls * Ks * specular_factor2;
[1908591]55
[aa00bf2]56 //outColor = vec4((Is + Id + Ia + Is2 + Id2 + Ia2)/2, 1.0);
[8e02b6b]57 outColor = vec4(color, 1.0);
[1908591]58}
Note: See TracBrowser for help on using the repository browser.