feature/imgui-sdl
Line | |
---|
1 | #version 450
|
---|
2 | #extension GL_ARB_separate_shader_objects : enable
|
---|
3 |
|
---|
4 | struct Object {
|
---|
5 | mat4 model;
|
---|
6 | };
|
---|
7 |
|
---|
8 | layout (binding = 0) uniform UniformBufferObject {
|
---|
9 | mat4 view;
|
---|
10 | mat4 proj;
|
---|
11 | } ubo;
|
---|
12 |
|
---|
13 | layout(binding = 1) readonly buffer StorageBufferObject {
|
---|
14 | Object objects[];
|
---|
15 | } sbo;
|
---|
16 |
|
---|
17 | layout (binding = 2) uniform UboInstance {
|
---|
18 | mat4 model;
|
---|
19 | } uboInstance;
|
---|
20 |
|
---|
21 | layout(location = 0) in vec3 inPosition;
|
---|
22 | layout(location = 1) in vec3 inColor;
|
---|
23 | layout(location = 2) in vec2 inTexCoord;
|
---|
24 | layout(location = 3) in vec3 vertex_normal;
|
---|
25 | layout(location = 4) in uint obj_index;
|
---|
26 |
|
---|
27 | layout(location = 0) out vec3 fragColor;
|
---|
28 | layout(location = 1) out vec2 fragTexCoord;
|
---|
29 | layout(location = 2) out vec3 normal_eye;
|
---|
30 |
|
---|
31 | void main() {
|
---|
32 | // Using 0.0 instead of 1.0 means translations won't effect the normal
|
---|
33 | normal_eye = normalize(vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_normal, 0.0)));
|
---|
34 |
|
---|
35 | fragColor = inColor;
|
---|
36 | fragTexCoord = inTexCoord;
|
---|
37 |
|
---|
38 | gl_Position = ubo.proj * ubo.view * sbo.objects[obj_index].model * vec4(inPosition, 1.0);
|
---|
39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.