feature/imgui-sdl
Last change
on this file since 27e580e was 67527a5, checked in by Dmitry Portnoy <dportnoy@…>, 4 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
|
Rev | Line | |
---|
[237cbec] | 1 | #version 450
|
---|
| 2 | #extension GL_ARB_separate_shader_objects : enable
|
---|
| 3 |
|
---|
| 4 | struct Object {
|
---|
| 5 | mat4 model;
|
---|
| 6 | vec3 color;
|
---|
| 7 | bool deleted;
|
---|
| 8 | };
|
---|
| 9 |
|
---|
[67527a5] | 10 | layout (binding = 0) uniform camera_block {
|
---|
[237cbec] | 11 | mat4 view;
|
---|
| 12 | mat4 proj;
|
---|
[67527a5] | 13 | } camera;
|
---|
[237cbec] | 14 |
|
---|
[67527a5] | 15 | layout(binding = 1) uniform ubo_block {
|
---|
| 16 | Object objects[1024];
|
---|
| 17 | } ubo;
|
---|
[237cbec] | 18 |
|
---|
| 19 | layout(location = 0) in vec3 vertex_position;
|
---|
| 20 | layout(location = 1) in vec2 texcoords_vs;
|
---|
| 21 | layout(location = 2) in uint obj_index_vs;
|
---|
| 22 |
|
---|
| 23 | layout(location = 0) out vec2 texcoords_fs;
|
---|
| 24 | layout(location = 1) out uint obj_index_fs;
|
---|
| 25 |
|
---|
| 26 | void main() {
|
---|
[67527a5] | 27 | vec3 position_eye = vec3(camera.view * ubo.objects[obj_index_vs].model * vec4(vertex_position, 1.0));
|
---|
[237cbec] | 28 |
|
---|
| 29 | texcoords_fs = texcoords_vs;
|
---|
| 30 | obj_index_fs = obj_index_vs;
|
---|
| 31 |
|
---|
[67527a5] | 32 | if (ubo.objects[obj_index_vs].deleted) {
|
---|
[237cbec] | 33 | gl_Position = vec4(0.0, 0.0, 2.0, 1.0);
|
---|
| 34 | } else {
|
---|
[67527a5] | 35 | gl_Position = camera.proj * vec4(position_eye, 1.0);
|
---|
[237cbec] | 36 | }
|
---|
| 37 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.