From feb3c58215960f2bac66922e8d1a1f8e32b7ff95 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 7 May 2021 09:53:23 -0400 Subject: graphics: phong: Extract shader code to separate files. --- data/shaders/phong-vert.glsl | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 data/shaders/phong-vert.glsl (limited to 'data/shaders/phong-vert.glsl') 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; +} -- cgit v1.2.3