- Timestamp:
- Dec 18, 2019, 2:48:28 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- a79be34
- Parents:
- 7c929fc
- Location:
- shaders
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
shaders/ship.frag
r7c929fc r60578ce 6 6 layout(location = 2) in vec3 normal_eye; 7 7 layout(location = 3) in vec3 light_position_eye; 8 layout(location = 4) in vec3 light2_position_eye; 8 9 9 layout(location = 0) out vec4 outColor;10 layout(location = 0) out vec4 frag_color; 10 11 11 12 // fixed point light properties … … 34 35 vec3 Id = Ld * Kd * dot_prod; 35 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 * Kd * dot_prod2; 42 36 43 vec3 surface_to_viewer_eye = normalize(-position_eye); 37 44 … … 43 50 vec3 Is = Ls * Ks * specular_factor; 44 51 45 outColor = vec4(Is + Id + Ia, 1.0); 52 vec3 reflection_eye2 = reflect(-direction_to_light2_eye, normal_eye); 53 float dot_prod_specular2 = max(dot(reflection_eye2, surface_to_viewer_eye), 0.0); 54 float specular_factor2 = pow(dot_prod_specular2, specular_exponent); 55 56 // specular intensity 57 vec3 Is2 = Ls * Ks * specular_factor2; 58 59 frag_color = vec4((Is + Id + Ia + Is2 + Id2 + Ia2)/2, 1.0); 46 60 } -
shaders/ship.vert
r7c929fc r60578ce 24 24 layout(location = 2) out vec3 normal_eye; 25 25 layout(location = 3) out vec3 light_position_eye; 26 layout(location = 4) out vec3 light2_position_eye; 26 27 27 // fixed point light position 28 // fixed point light positions 28 29 //vec3 light_position_world = vec3(0.0, 0.0, 2.0); 29 //vec3 light_position_world = vec3(0.4, 1.5, 0.8); 30 vec3 light_position_world = vec3(0.4, 0.0, 0.2); 30 //vec3 light2_position_world = vec3(0.0, 1.5, -0.1); 31 vec3 light_position_world = vec3(7.0, -7.0, -10.0); 32 vec3 light2_position_world = vec3(4.0, -3.0, -10.0); 31 33 32 34 // TODO: This does not account for scaling in the model matrix 33 35 // Check Anton's book to see how to fix this 34 36 void main() { 35 //position_eye = vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_position, 1.0)); 36 position_eye = vec3(vec4(vertex_position, 1.0)); 37 position_eye = vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_position, 1.0)); 37 38 38 39 // Using 0.0 instead of 1.0 means translations won't effect the normal 39 //normal_eye = normalize(vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_normal, 0.0)));40 normal_eye = normalize(vec3(vec4(vertex_normal, 0.0))); 40 normal_eye = normalize(vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_normal, 0.0))); 41 41 42 color = vertex_color; 42 //light_position_eye = vec3(ubo.view * vec4(light_position_world, 1.0));43 light_position_eye = vec3(vec4(light_position_world, 1.0));44 43 45 //gl_Position = ubo.proj * vec4(position_eye, 1.0); 46 gl_Position = vec4(vertex_position, 1.0); 44 light_position_eye = vec3(ubo.view * vec4(light_position_world, 1.0)); 45 light2_position_eye = vec3(ubo.view * vec4(light2_position_world, 1.0)); 46 47 gl_Position = ubo.proj * vec4(position_eye, 1.0); 47 48 }
Note:
See TracChangeset
for help on using the changeset viewer.