Skip to content

Instantly share code, notes, and snippets.

@recp
Last active November 16, 2017 09:11
Show Gist options
  • Save recp/c4ec13ae4f85b4feef1718ca4ec6313d to your computer and use it in GitHub Desktop.
Save recp/c4ec13ae4f85b4feef1718ca4ec6313d to your computer and use it in GitHub Desktop.
/*
* Copyright (c), Recep Aslantas.
* MIT License (MIT), http://opensource.org/licenses/MIT
*/
#version 410
uniform mat4 MVP; // Projection * View * Model matrix
uniform mat4 MV; // View * Model Matrix
uniform mat4 NM; // Normal matrix
uniform int NMU; // Use normal matrix
layout(location = 0) in vec3 POSITION;
layout(location = 1) in vec3 NORMAL;
layout(location = 2) in vec2 TEXCOORD;
layout(location = 3) in vec2 TEXCOORD1;
layout(location = 4) in vec2 TEXCOORD2;
out vec3 vPosition;
out vec3 vNormal;
out vec3 vEye;
out vec2 vTexCoord[3];
void main() {
vec4 pos4 = vec4(POSITION, 1.0);
vPosition = vec3(MV * pos4);
vEye = normalize(-vPosition);
if (NMU == 1)
vNormal = normalize(vec3(NM * vec4(NORMAL, 0.0)));
else
vNormal = normalize(vec3(MV * vec4(NORMAL, 0.0)));
gl_Position = MVP * pos4;
vTexCoord[0] = TEXCOORD;
vTexCoord[1] = TEXCOORD1;
vTexCoord[2] = TEXCOORD2;
}
@recp
Copy link
Author

recp commented Nov 16, 2017

This shader is not used by libgk anymore!
Now there is a shader generator and shader manager for specific purposes/tasks

Check new version at: https://github.com/recp/libgk/tree/master/src/shader/glsl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment