diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2018-04-30 12:51:12 +0100 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2018-04-30 12:51:12 +0100 |
commit | 89b5603110c47e30450ce05573c6b95ef38d8fd7 (patch) | |
tree | ec999b76f6434ab1e0038b665145f6cf5820aa6c /vert.glsl | |
parent | 9e27cc3d7565d7c98957a517ecad8257a86265cd (diff) | |
download | faqe-89b5603110c47e30450ce05573c6b95ef38d8fd7.tar.gz faqe-89b5603110c47e30450ce05573c6b95ef38d8fd7.tar.xz faqe-89b5603110c47e30450ce05573c6b95ef38d8fd7.zip |
Implement basic fixed point light source and phong shading
This patch places a single point light source in the scene and
implements view-space phong shading around it. This is in preparation
for texture values being fed in from a set of textures.
Diffstat (limited to 'vert.glsl')
-rw-r--r-- | vert.glsl | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -2,16 +2,24 @@ // SPDX-License-Identifier: MIT #version 330 core layout (location = 0) in vec3 pos; -layout (location = 1) in vec3 normal; +layout (location = 1) in vec3 norm; layout (location = 2) in vec2 uv; -out vec3 vcolor; +out vec3 vnorm; +out vec3 fpos; +out vec3 lipos; + uniform mat4 model; uniform mat4 view; uniform mat4 proj; void main() { + vec3 light = { 1.2, 1.0, 2.0 }; + gl_Position = proj * view * model * vec4(pos, 1.0); - vcolor = normal; + fpos = vec3(view * model * vec4(pos, 1.0)); + // TODO: Try to work out how to only do this ONCE in C or see if it matters + vnorm = mat3(transpose(inverse(view * model))) * norm; + lipos = vec3(view * vec4(light, 1.0)); } |