This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
YASMIN/res/gl/vertex1.glsl
2016-09-11 12:11:54 +02:00

43 lines
919 B
GLSL

#ifdef GL_ES
// Set default precision to medium
precision mediump int;
precision mediump float;
#endif
uniform mat4 m_matrix;
uniform mat4 mv_matrix;
uniform mat4 mvp_matrix;
attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_texcoord;
attribute vec3 a_tangent;
varying vec3 v_WorldPos;
varying vec3 v_CamPos;
varying vec3 v_normal;
varying vec2 v_texcoord;
varying mat3 normalMat;
void main() {
// interpolation:
v_WorldPos = vec3(m_matrix * vec4(a_position, 1.0));
v_CamPos = vec3(mv_matrix * vec4(a_position, 1.0));
v_normal = a_normal;//normalize(vec3(mv_matrix * vec4(a_normal, 0.0)));
v_texcoord = a_texcoord;
// http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-13-normal-mapping/
vec3 bitangent = cross(a_normal, a_tangent);
normalMat = mat3(a_tangent, bitangent, a_normal);
// 2D position for the vertex
gl_Position = mvp_matrix * vec4(a_position, 1.0);
}