source: opengl-game/shaders/model.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: 1.0 KB
Line 
1#version 450
2#extension GL_ARB_separate_shader_objects : enable
3
4struct Object {
5 mat4 model;
6};
7
8layout (binding = 0) uniform camera_block {
9 mat4 view;
10 mat4 proj;
11} camera;
12
13// TODO: Verify that I can actually store 1024 values here. They last time I checked, I think I could only store 1016 values
14layout (binding = 1) uniform ubo_block {
15 Object objects[1024];
16} ubo;
17
18layout(location = 0) in vec3 inPosition;
19layout(location = 1) in vec3 inColor;
20layout(location = 2) in vec2 inTexCoord;
21layout(location = 3) in vec3 vertex_normal;
22layout(location = 4) in uint obj_index;
23
24layout(location = 0) out vec3 fragColor;
25layout(location = 1) out vec2 fragTexCoord;
26layout(location = 2) out vec3 normal_eye;
27
28void main() {
29 // Using 0.0 instead of 1.0 means translations won't effect the normal
30 normal_eye = normalize(vec3(camera.view * ubo.objects[obj_index].model * vec4(vertex_normal, 0.0)));
31
32 fragColor = inColor;
33 fragTexCoord = inTexCoord;
34
35 gl_Position = camera.proj * camera.view * ubo.objects[obj_index].model * vec4(inPosition, 1.0);
36}
Note: See TracBrowser for help on using the repository browser.