Changeset 6385d0f in opengl-game
- Timestamp:
- Apr 17, 2020, 3:09:05 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 4994692
- Parents:
- a52ba87
- Location:
- shaders
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
shaders/asteroid.frag
ra52ba87 r6385d0f 22 22 23 23 void main() { 24 // ambient intensity25 vec3 Ia = La * Ka;24 // ambient intensity 25 vec3 Ia = La * Ka; 26 26 27 // ambient intensity28 vec3 Ia2 = La * Ka;27 // ambient intensity 28 vec3 Ia2 = La * Ka; 29 29 30 vec3 direction_to_light_eye = normalize(light_position_eye - position_eye);31 float dot_prod = max(dot(direction_to_light_eye, normal_eye), 0.0);30 vec3 direction_to_light_eye = normalize(light_position_eye - position_eye); 31 float dot_prod = max(dot(direction_to_light_eye, normal_eye), 0.0); 32 32 33 // diffuse intensity34 vec3 Id = Ld * color * dot_prod;33 // diffuse intensity 34 vec3 Id = Ld * color * dot_prod; 35 35 36 vec3 direction_to_light2_eye = normalize(light2_position_eye - position_eye);37 float dot_prod2 = max(dot(direction_to_light2_eye, normal_eye), 0.0);36 vec3 direction_to_light2_eye = normalize(light2_position_eye - position_eye); 37 float dot_prod2 = max(dot(direction_to_light2_eye, normal_eye), 0.0); 38 38 39 // diffuse intensity40 vec3 Id2 = Ld * color * dot_prod2;39 // diffuse intensity 40 vec3 Id2 = Ld * color * dot_prod2; 41 41 42 vec3 surface_to_viewer_eye = normalize(-position_eye);42 vec3 surface_to_viewer_eye = normalize(-position_eye); 43 43 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);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); 47 47 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);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); 51 51 52 // specular intensity53 vec3 Is = Ls * Ks * specular_factor;54 vec3 Is2 = Ls * Ks * specular_factor2;52 // specular intensity 53 vec3 Is = Ls * Ks * specular_factor; 54 vec3 Is2 = Ls * Ks * specular_factor2; 55 55 56 frag_color = vec4((Is + Id + Ia + Is2 + Id2 + Ia2)/2, 1.0);56 frag_color = vec4((Is + Id + Ia + Is2 + Id2 + Ia2)/2, 1.0); 57 57 } -
shaders/asteroid.vert
ra52ba87 r6385d0f 14 14 15 15 layout(binding = 1) readonly buffer StorageBufferObject { 16 16 Object objects[]; 17 17 } sbo; 18 18 … … 33 33 34 34 void main() { 35 position_eye = vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_position, 1.0));36 normal_eye = normalize(vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_normal, 0.0)));35 position_eye = vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_position, 1.0)); 36 normal_eye = normalize(vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_normal, 0.0))); 37 37 38 float hp_percent = sbo.objects[obj_index].hp / 10.0;39 vec3 damage_color = vec3(1.0, 0.0, 0.0);40 color = (vertex_color * hp_percent) + (damage_color * (1.0 - hp_percent));38 float hp_percent = sbo.objects[obj_index].hp / 10.0; 39 vec3 damage_color = vec3(1.0, 0.0, 0.0); 40 color = (vertex_color * hp_percent) + (damage_color * (1.0 - hp_percent)); 41 41 42 light_position_eye = vec3(ubo.view * vec4(light_position_world, 1.0));43 light2_position_eye = vec3(ubo.view * vec4(light2_position_world, 1.0));42 light_position_eye = vec3(ubo.view * vec4(light_position_world, 1.0)); 43 light2_position_eye = vec3(ubo.view * vec4(light2_position_world, 1.0)); 44 44 45 if (sbo.objects[obj_index].deleted) {46 gl_Position = vec4(0.0, 0.0, 2.0, 1.0);47 } else {48 gl_Position = ubo.proj * vec4(position_eye, 1.0);49 }45 if (sbo.objects[obj_index].deleted) { 46 gl_Position = vec4(0.0, 0.0, 2.0, 1.0); 47 } else { 48 gl_Position = ubo.proj * vec4(position_eye, 1.0); 49 } 50 50 } -
shaders/scene.vert
ra52ba87 r6385d0f 12 12 13 13 layout(binding = 1) readonly buffer StorageBufferObject { 14 14 Object objects[]; 15 15 } sbo; 16 16 -
shaders/ship.frag
ra52ba87 r6385d0f 35 35 vec3 Id = Ld * Kd * dot_prod; 36 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);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 39 40 // diffuse intensity41 vec3 Id2 = Ld * Kd * dot_prod2;40 // diffuse intensity 41 vec3 Id2 = Ld * Kd * dot_prod2; 42 42 43 43 vec3 surface_to_viewer_eye = normalize(-position_eye); -
shaders/ship.vert
ra52ba87 r6385d0f 12 12 13 13 layout(binding = 1) readonly buffer StorageBufferObject { 14 14 Object objects[]; 15 15 } sbo; 16 16
Note:
See TracChangeset
for help on using the changeset viewer.