Changeset 67527a5 in opengl-game for shaders/asteroid.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/asteroid.vert

    rb01b50c r67527a5  
    88};
    99
    10 layout (binding = 0) uniform UniformBufferObject {
     10layout (binding = 0) uniform camera_block {
    1111   mat4 view;
    1212   mat4 proj;
     13} camera;
     14
     15layout(binding = 1) uniform ubo_block {
     16   Object objects[1024];
    1317} ubo;
    14 
    15 layout(binding = 1) readonly buffer StorageBufferObject {
    16    Object objects[];
    17 } sbo;
    1818
    1919layout(location = 0) in vec3 vertex_position;
     
    3535
    3636void main() {
    37    position_eye = vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_position, 1.0));
    38    normal_eye = normalize(vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_normal, 0.0)));
     37   position_eye = vec3(camera.view * ubo.objects[obj_index].model * vec4(vertex_position, 1.0));
     38   normal_eye = normalize(vec3(camera.view * ubo.objects[obj_index].model * vec4(vertex_normal, 0.0)));
    3939
    40    float hp_percent = sbo.objects[obj_index].hp / 10.0;
     40   float hp_percent = ubo.objects[obj_index].hp / 10.0;
    4141   vec3 damage_color = vec3(1.0, 0.0, 0.0);
    4242   color = (vertex_color * hp_percent) + (damage_color * (1.0 - hp_percent));
     
    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    if (sbo.objects[obj_index].deleted) {
     49   if (ubo.objects[obj_index].deleted) {
    5050      gl_Position = vec4(0.0, 0.0, 2.0, 1.0);
    5151   } else {
    52       gl_Position = ubo.proj * vec4(position_eye, 1.0);
     52      gl_Position = camera.proj * vec4(position_eye, 1.0);
    5353   }
    5454}
Note: See TracChangeset for help on using the changeset viewer.