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