// FIXME: Temporary fix! precision highp float; //////////////////////////////////////////////////////////////////////////////// // // Defines // // Maximum number of bones of animated models #define BBMOD_MAX_BONES 128 // Maximum number of vec4 uniforms for dynamic batch data #define BBMOD_MAX_BATCH_VEC4S 192 //////////////////////////////////////////////////////////////////////////////// // // Attributes // attribute vec4 in_Position; attribute vec3 in_Normal; attribute vec2 in_TextureCoord0; attribute vec4 in_TangentW; //////////////////////////////////////////////////////////////////////////////// // // Uniforms // uniform vec2 bbmod_TextureOffset; uniform vec2 bbmod_TextureScale; //////////////////////////////////////////////////////////////////////////////// // // Varyings // varying vec3 v_vVertex; varying vec2 v_vTexCoord; varying mat3 v_mTBN; varying vec4 v_vPosition; varying vec4 v_vPosShadowmap; //////////////////////////////////////////////////////////////////////////////// // // Includes // /// @desc Transforms vertex and normal by animation and/or batch data. /// /// @param vertex Variable to hold the transformed vertex. /// @param normal Variable to hold the transformed normal. /// @param tangent Variable to hold the transformed tangent. /// @param bitangent Variable to hold the transformed bitangent. void Transform( inout vec4 vertex, inout vec3 normal, inout vec3 tangent, inout vec3 bitangent) { vertex = gm_Matrices[MATRIX_WORLD] * vertex; normal = normalize((gm_Matrices[MATRIX_WORLD] * vec4(normal, 0.0)).xyz); tangent = normalize((gm_Matrices[MATRIX_WORLD] * vec4(tangent, 0.0)).xyz); bitangent = normalize((gm_Matrices[MATRIX_WORLD] * vec4(bitangent, 0.0)).xyz); } //////////////////////////////////////////////////////////////////////////////// // // Main // void main() { vec4 position = in_Position; vec3 normal = in_Normal; vec3 tangent = in_TangentW.xyz; vec3 bitangent = cross(normal, tangent) * in_TangentW.w; Transform(position, normal, tangent, bitangent); vec4 positionWVP = gm_Matrices[MATRIX_PROJECTION] * (gm_Matrices[MATRIX_VIEW] * position); v_vVertex = position.xyz; gl_Position = positionWVP; v_vPosition = positionWVP; v_vTexCoord = bbmod_TextureOffset + in_TextureCoord0 * bbmod_TextureScale; v_mTBN = mat3(tangent, bitangent, normal); }