- Timestamp:
- Nov 22, 2019, 6:27:13 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- f97c5e7
- Parents:
- 683dd55
- git-author:
- Dmitry Portnoy <dmitry.portnoy@…> (11/22/19 18:26:59)
- git-committer:
- Dmitry Portnoy <dmitry.portnoy@…> (11/22/19 18:27:13)
- Location:
- shaders
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
shaders/ship.frag
r683dd55 r8e02b6b 8 8 layout(location = 0) out vec4 outColor; 9 9 10 /*11 10 // fixed point light properties 12 11 vec3 Ls = vec3(1.0, 1.0, 1.0); … … 19 18 vec3 Ka = vec3(0.2, 0.2, 0.2); 20 19 float specular_exponent = 100.0; // specular 'power' 21 */22 20 23 21 void main() { 24 /* 25 // ambient intensity 26 vec3 Ia = La * Ka; 22 // ambient intensity 23 vec3 Ia = La * Ka; 27 24 28 // ambient intensity29 vec3 Ia2 = La * Ka;25 // ambient intensity 26 vec3 Ia2 = La * Ka; 30 27 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);28 //vec3 direction_to_light_eye = normalize(light_position_eye - position_eye); 29 //float dot_prod = max(dot(direction_to_light_eye, normal_eye), 0.0); 33 30 34 // diffuse intensity35 vec3 Id = Ld * color * dot_prod;31 // diffuse intensity 32 //vec3 Id = Ld * color * dot_prod; 36 33 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);34 //vec3 direction_to_light2_eye = normalize(light2_position_eye - position_eye); 35 //float dot_prod2 = max(dot(direction_to_light2_eye, normal_eye), 0.0); 39 36 40 // diffuse intensity41 vec3 Id2 = Ld * color * dot_prod2;37 // diffuse intensity 38 //vec3 Id2 = Ld * color * dot_prod2; 42 39 43 vec3 surface_to_viewer_eye = normalize(-position_eye);40 //vec3 surface_to_viewer_eye = normalize(-position_eye); 44 41 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);42 //vec3 reflection_eye = reflect(-direction_to_light_eye, normal_eye); 43 //float dot_prod_specular = max(dot(reflection_eye, surface_to_viewer_eye), 0.0); 44 //float specular_factor = pow(dot_prod_specular, specular_exponent); 48 45 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);46 //vec3 reflection_eye2 = reflect(-direction_to_light2_eye, normal_eye); 47 //float dot_prod_specular2 = max(dot(reflection_eye2, surface_to_viewer_eye), 0.0); 48 //float specular_factor2 = pow(dot_prod_specular2, specular_exponent); 52 49 53 // specular intensity54 vec3 Is = Ls * Ks * specular_factor;55 vec3 Is2 = Ls * Ks * specular_factor2;50 // specular intensity 51 //vec3 Is = Ls * Ks * specular_factor; 52 //vec3 Is2 = Ls * Ks * specular_factor2; 56 53 57 outColor = vec4((Is + Id + Ia + Is2 + Id2 + Ia2)/2, 1.0); 58 */ 59 outColor = vec4(color, 1.0); 54 //frag_color = vec4((Is + Id + Ia + Is2 + Id2 + Ia2)/2, 1.0); 55 outColor = vec4(color, 1.0); 60 56 } -
shaders/ship.vert
r683dd55 r8e02b6b 2 2 #extension GL_ARB_separate_shader_objects : enable 3 3 4 // TODO: Figure out if the UniformBufferObject label is necessary and, if not, remove it 4 5 layout (binding = 0) uniform UniformBufferObject { 5 6 mat4 model; … … 10 11 layout(location = 0) in vec3 vertex_position; 11 12 layout(location = 1) in vec3 vertex_color; 13 //layout(location = 2) in vec3 vertex_normal; 14 //layout(location = 3) in uint ubo_index; 12 15 13 16 //out vec3 position_eye, normal_eye, color, light_position_eye, light2_position_eye; … … 20 23 21 24 void main() { 22 // ORIG:position_eye = vec3(view * model_mats[ubo_index] * vec4(vertex_position, 1.0));23 position_eye = vec3(ubo.view * ubo.model * vec4(vertex_position, 1.0));24 //normal_eye = normalize(vec3(view * model_mats[ubo_index] * vec4(vertex_normal, 0.0)));25 color = vertex_color;26 //light_position_eye = vec3(view * vec4(light_position_world, 1.0));27 //light2_position_eye = vec3(view * vec4(light2_position_world, 1.0));25 //position_eye = vec3(view * model_mats[ubo_index] * vec4(vertex_position, 1.0)); 26 position_eye = vec3(ubo.view * ubo.model * vec4(vertex_position, 1.0)); 27 //normal_eye = normalize(vec3(view * model_mats[ubo_index] * vec4(vertex_normal, 0.0))); 28 color = vertex_color; 29 //light_position_eye = vec3(view * vec4(light_position_world, 1.0)); 30 //light2_position_eye = vec3(view * vec4(light2_position_world, 1.0)); 28 31 29 gl_Position = ubo.proj * vec4(position_eye, 1.0);32 gl_Position = ubo.proj * vec4(position_eye, 1.0); 30 33 }
Note:
See TracChangeset
for help on using the changeset viewer.