Changeset 67527a5 in opengl-game for shaders/ship.vert
- Timestamp:
- Jun 21, 2021, 4:12:08 PM (3 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- 27e580e
- Parents:
- b01b50c
- git-author:
- Dmitry Portnoy <dportnoy@…> (06/21/21 15:13:03)
- git-committer:
- Dmitry Portnoy <dportnoy@…> (06/21/21 16:12:08)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
shaders/ship.vert
rb01b50c r67527a5 6 6 }; 7 7 8 layout (binding = 0) uniform UniformBufferObject{8 layout (binding = 0) uniform camera_block { 9 9 mat4 view; 10 10 mat4 proj; 11 } camera; 12 13 layout(binding = 1) uniform ubo_block { 14 Object objects[1024]; 11 15 } ubo; 12 13 layout(binding = 1) readonly buffer StorageBufferObject {14 Object objects[];15 } sbo;16 16 17 17 layout(location = 0) in vec3 vertex_position; … … 35 35 // Check Anton's book to see how to fix this 36 36 void main() { 37 position_eye = vec3( ubo.view * sbo.objects[obj_index].model * vec4(vertex_position, 1.0));37 position_eye = vec3(camera.view * ubo.objects[obj_index].model * vec4(vertex_position, 1.0)); 38 38 39 39 // Using 0.0 instead of 1.0 means translations won't effect the normal 40 normal_eye = normalize(vec3( ubo.view * sbo.objects[obj_index].model * vec4(vertex_normal, 0.0)));40 normal_eye = normalize(vec3(camera.view * ubo.objects[obj_index].model * vec4(vertex_normal, 0.0))); 41 41 42 42 color = vertex_color; … … 44 44 fragTexCoord = inTexCoord; 45 45 46 light_position_eye = vec3( ubo.view * vec4(light_position_world, 1.0));47 light2_position_eye = vec3( ubo.view * vec4(light2_position_world, 1.0));46 light_position_eye = vec3(camera.view * vec4(light_position_world, 1.0)); 47 light2_position_eye = vec3(camera.view * vec4(light2_position_world, 1.0)); 48 48 49 gl_Position = ubo.proj * vec4(position_eye, 1.0);49 gl_Position = camera.proj * vec4(position_eye, 1.0); 50 50 }
Note:
See TracChangeset
for help on using the changeset viewer.