source: opengl-game/shaders/laser.vert

feature/imgui-sdl
Last change on this file was 67527a5, checked in by Dmitry Portnoy <dportnoy@…>, 3 years ago

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

  • Property mode set to 100644
File size: 863 bytes
Line 
1#version 450
2#extension GL_ARB_separate_shader_objects : enable
3
4struct Object {
5 mat4 model;
6 vec3 color;
7 bool deleted;
8};
9
10layout (binding = 0) uniform camera_block {
11 mat4 view;
12 mat4 proj;
13} camera;
14
15layout(binding = 1) uniform ubo_block {
16 Object objects[1024];
17} ubo;
18
19layout(location = 0) in vec3 vertex_position;
20layout(location = 1) in vec2 texcoords_vs;
21layout(location = 2) in uint obj_index_vs;
22
23layout(location = 0) out vec2 texcoords_fs;
24layout(location = 1) out uint obj_index_fs;
25
26void main() {
27 vec3 position_eye = vec3(camera.view * ubo.objects[obj_index_vs].model * vec4(vertex_position, 1.0));
28
29 texcoords_fs = texcoords_vs;
30 obj_index_fs = obj_index_vs;
31
32 if (ubo.objects[obj_index_vs].deleted) {
33 gl_Position = vec4(0.0, 0.0, 2.0, 1.0);
34 } else {
35 gl_Position = camera.proj * vec4(position_eye, 1.0);
36 }
37}
Note: See TracBrowser for help on using the repository browser.