source: opengl-game/shaders/ship.vert@ 7f60b28

feature/imgui-sdl
Last change on this file since 7f60b28 was 6385d0f, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 4 years ago

Change all shaders to have 3-space indentation

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[1908591]1#version 450
2#extension GL_ARB_separate_shader_objects : enable
3
[055750a]4struct Object {
[1908591]5 mat4 model;
[055750a]6};
7
8layout (binding = 0) uniform UniformBufferObject {
[1908591]9 mat4 view;
10 mat4 proj;
11} ubo;
12
[055750a]13layout(binding = 1) readonly buffer StorageBufferObject {
[6385d0f]14 Object objects[];
[055750a]15} sbo;
16
[1908591]17layout(location = 0) in vec3 vertex_position;
18layout(location = 1) in vec3 vertex_color;
[e1308e8]19layout(location = 2) in vec3 vertex_normal;
[cf727ca]20layout(location = 3) in uint obj_index;
[1908591]21
22layout(location = 0) out vec3 position_eye;
23layout(location = 1) out vec3 color;
[e1308e8]24layout(location = 2) out vec3 normal_eye;
25layout(location = 3) out vec3 light_position_eye;
[60578ce]26layout(location = 4) out vec3 light2_position_eye;
[1908591]27
[60578ce]28// fixed point light positions
[a79be34]29vec3 light_position_world = vec3(0.0, 0.0, 2.0);
30vec3 light2_position_world = vec3(0.0, 1.5, -0.1);
[1908591]31
[e1308e8]32// TODO: This does not account for scaling in the model matrix
33// Check Anton's book to see how to fix this
[1908591]34void main() {
[60578ce]35 position_eye = vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_position, 1.0));
[e1308e8]36
37 // Using 0.0 instead of 1.0 means translations won't effect the normal
[60578ce]38 normal_eye = normalize(vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_normal, 0.0)));
39
[8e02b6b]40 color = vertex_color;
[1908591]41
[60578ce]42 light_position_eye = vec3(ubo.view * vec4(light_position_world, 1.0));
43 light2_position_eye = vec3(ubo.view * vec4(light2_position_world, 1.0));
44
45 gl_Position = ubo.proj * vec4(position_eye, 1.0);
[1908591]46}
Note: See TracBrowser for help on using the repository browser.