diff options
author | David Thompson <dthompson2@worcester.edu> | 2021-05-07 09:53:23 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2021-05-07 09:53:23 -0400 |
commit | feb3c58215960f2bac66922e8d1a1f8e32b7ff95 (patch) | |
tree | 476c9d973cec76aa7caf34545f15140415d0973c /data/shaders/phong-vert.glsl | |
parent | e142166c3e2d6f567ed0d4e4c414fa510271260f (diff) |
graphics: phong: Extract shader code to separate files.
Diffstat (limited to 'data/shaders/phong-vert.glsl')
-rw-r--r-- | data/shaders/phong-vert.glsl | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/data/shaders/phong-vert.glsl b/data/shaders/phong-vert.glsl new file mode 100644 index 0000000..51461fa --- /dev/null +++ b/data/shaders/phong-vert.glsl @@ -0,0 +1,34 @@ +// -*- mode: c -*- + +#ifdef GLSL330 +layout (location = 0) in vec3 position; +layout (location = 1) in vec2 texcoord; +layout (location = 2) in vec3 normal; +#elif defined(GLSL130) +in vec3 position; +in vec2 texcoord; +in vec3 normal; +#elif defined(GLSL120) +attribute vec3 position; +attribute vec2 texcoord; +attribute vec3 normal; +#endif + +#ifdef GLSL120 +varying vec3 fragNorm; +varying vec2 fragTex; +#else +out vec3 fragNorm; +out vec2 fragTex; +#endif + +uniform mat4 model; +uniform mat4 view; +uniform mat4 projection; + +void main() { + gl_Position = projection * view * model * vec4(position, 1.0); + // TODO: Calculate normal matrix on CPU + fragNorm = normalize(model * vec4(normal, 1.0)).xyz; + fragTex = texcoord; +} |