source: opengl-game/shaders/ship.vert@ e1308e8

feature/imgui-sdl points-test
Last change on this file since e1308e8 was e1308e8, checked in by Dmitry Portnoy <dmp1488@…>, 5 years ago

In VulkanGame, add normals to the ship pipeline and get lighting to work

  • Property mode set to 100644
File size: 1.4 KB
Line 
1#version 450
2#extension GL_ARB_separate_shader_objects : enable
3
4layout (binding = 0) uniform UniformBufferObject {
5 mat4 model;
6 mat4 view;
7 mat4 proj;
8} ubo;
9
10layout(location = 0) in vec3 vertex_position;
11layout(location = 1) in vec3 vertex_color;
12layout(location = 2) in vec3 vertex_normal;
13//layout(location = 3) in uint ubo_index;
14
15layout(location = 0) out vec3 position_eye;
16layout(location = 1) out vec3 color;
17layout(location = 2) out vec3 normal_eye;
18layout(location = 3) out vec3 light_position_eye;
19
20// fixed point light position
21//vec3 light_position_world = vec3(0.0, 0.0, 2.0);
22vec3 light_position_world = vec3(0.4, 1.5, 0.8);
23//vec3 light_position_world = vec3(0.0, 1.0, -1.0);
24
25// TODO: This does not account for scaling in the model matrix
26// Check Anton's book to see how to fix this
27void main() {
28 position_eye = vec3(ubo.view * ubo.model * vec4(vertex_position, 1.0));
29 //position_eye = vec3(view * model_mats[ubo_index] * vec4(vertex_position, 1.0));
30
31 // Using 0.0 instead of 1.0 means translations won't effect the normal
32 normal_eye = normalize(vec3(ubo.view * ubo.model * vec4(vertex_normal, 0.0)));
33 //normal_eye = normalize(vec3(view * model_mats[ubo_index] * vec4(vertex_normal, 0.0)));
34 color = vertex_color;
35 light_position_eye = vec3(ubo.view * vec4(light_position_world, 1.0));
36
37 gl_Position = ubo.proj * vec4(position_eye, 1.0);
38}
Note: See TracBrowser for help on using the repository browser.