summaryrefslogtreecommitdiff
path: root/data/shaders/pbr-vert.glsl
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2021-05-12 20:49:48 -0400
committerDavid Thompson <dthompson2@worcester.edu>2021-05-12 20:49:48 -0400
commitf88da6fb6d50568d8d1889cca3f9ed32c4451a06 (patch)
treebccf5fb2b2bd947a0c2a173d8f9ca7657907d8e3 /data/shaders/pbr-vert.glsl
parent21ab482f62b6f12469b56e7533a1b41d0ff7a0cd (diff)
graphics: model: Add support for dynamic lights in PBR models.
Diffstat (limited to 'data/shaders/pbr-vert.glsl')
-rw-r--r--data/shaders/pbr-vert.glsl9
1 files changed, 3 insertions, 6 deletions
diff --git a/data/shaders/pbr-vert.glsl b/data/shaders/pbr-vert.glsl
index 530c564..bf43e81 100644
--- a/data/shaders/pbr-vert.glsl
+++ b/data/shaders/pbr-vert.glsl
@@ -21,14 +21,12 @@ attribute vec4 color0;
#ifdef GLSL120
varying vec3 fragWorldPos;
-varying vec3 fragCamPos;
varying vec3 fragNormal;
varying vec2 fragTexcoord0;
varying vec2 fragTexcoord1;
varying vec4 fragColor0;
#else
out vec3 fragWorldPos;
-out vec3 fragCamPos;
out vec3 fragNormal;
out vec2 fragTexcoord0;
out vec2 fragTexcoord1;
@@ -40,11 +38,10 @@ uniform mat4 view;
uniform mat4 projection;
void main(void) {
- fragWorldPos = (model * vec4(position.xyz, 1.0)).xyz;
- fragCamPos = (view * vec4(0.0, 0.0, 0.0, 1.0)).xyz;
- fragNormal = normal;
+ fragWorldPos = vec3(model * vec4(position, 1.0));
+ fragNormal = mat3(model) * normal;
fragTexcoord0 = texcoord0;
fragTexcoord1 = texcoord1;
fragColor0 = color0;
- gl_Position = projection * view * model * vec4(position.xyz, 1.0);
+ gl_Position = projection * view * vec4(fragWorldPos, 1.0);
}