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

    rb01b50c r67527a5  
    99};
    1010
    11 layout (binding = 0) uniform UniformBufferObject {
     11layout (binding = 0) uniform camera_block {
    1212   mat4 view;
    1313   mat4 proj;
    1414   float cur_time;
     15} camera;
     16
     17layout(binding = 1) uniform ubo_block {
     18   Object objects[1024];
    1519} ubo;
    16 
    17 layout(binding = 1) readonly buffer StorageBufferObject {
    18    Object objects[];
    19 } sbo;
    2020
    2121layout(location = 0) in vec3 particle_start_velocity;
     
    2626
    2727void main() {
    28    mat4 model = sbo.objects[obj_index].model;
    29    float explosion_start_time = sbo.objects[obj_index].explosion_start_time;
    30    float explosion_duration = sbo.objects[obj_index].explosion_duration;
    31    bool deleted = sbo.objects[obj_index].deleted;
     28   mat4 model = ubo.objects[obj_index].model;
     29   float explosion_start_time = ubo.objects[obj_index].explosion_start_time;
     30   float explosion_duration = ubo.objects[obj_index].explosion_duration;
     31   bool deleted = ubo.objects[obj_index].deleted;
    3232
    33    float t = ubo.cur_time - explosion_start_time - particle_start_time;
     33   float t = camera.cur_time - explosion_start_time - particle_start_time;
    3434
    3535   if (t < 0.0) {
     
    5656      p += normalize(particle_start_velocity) * mod(t, explosion_duration) / explosion_duration * 0.3;
    5757
    58       gl_Position = ubo.proj * ubo.view * model * vec4(p, 1.0);
     58      gl_Position = camera.proj * camera.view * model * vec4(p, 1.0);
    5959   }
    6060   gl_PointSize = 10.0; // size in pixels
Note: See TracChangeset for help on using the changeset viewer.