Changeset 67527a5 in opengl-game for shaders/ship.vert


Ignore:
Timestamp:
Jun 21, 2021, 4:12:08 PM (3 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
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)
Message:

Switch all per-object buffers to be dynamic uniform buffers instead of shader storage buffers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • shaders/ship.vert

    rb01b50c r67527a5  
    66};
    77
    8 layout (binding = 0) uniform UniformBufferObject {
     8layout (binding = 0) uniform camera_block {
    99   mat4 view;
    1010   mat4 proj;
     11} camera;
     12
     13layout(binding = 1) uniform ubo_block {
     14   Object objects[1024];
    1115} ubo;
    12 
    13 layout(binding = 1) readonly buffer StorageBufferObject {
    14    Object objects[];
    15 } sbo;
    1616
    1717layout(location = 0) in vec3 vertex_position;
     
    3535// Check Anton's book to see how to fix this
    3636void 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));
    3838
    3939   // 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)));
    4141
    4242   color = vertex_color;
     
    4444   fragTexCoord = inTexCoord;
    4545
    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));
    4848
    49    gl_Position = ubo.proj * vec4(position_eye, 1.0);
     49   gl_Position = camera.proj * vec4(position_eye, 1.0);
    5050}
Note: See TracChangeset for help on using the changeset viewer.