<@include gpu/Config.slh@> <$VERSION_HEADER$> // Generated on <$_SCRIBE_DATE$> // // skin_model_normal_map.vert // vertex shader // // Created by Andrzej Kapolka on 10/29/13. // Copyright 2013 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // <@include gpu/Inputs.slh@> <@include gpu/Transform.slh@> <$declareStandardTransform()$> const int MAX_TEXCOORDS = 2; const int MAX_CLUSTERS = 128; const int INDICES_PER_VERTEX = 4; uniform mat4 clusterMatrices[MAX_CLUSTERS]; uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; out vec4 _position; out vec2 _texCoord0; out vec3 _normal; out vec3 _tangent; out vec3 _color; void main(void) { vec4 position = vec4(0.0, 0.0, 0.0, 0.0); vec4 interpolatedNormal = vec4(0.0, 0.0, 0.0, 0.0); vec4 interpolatedTangent = vec4(0.0, 0.0, 0.0, 0.0); for (int i = 0; i < INDICES_PER_VERTEX; i++) { mat4 clusterMatrix = clusterMatrices[inSkinClusterIndex[i]]; float clusterWeight = inSkinClusterWeight[i]; position += clusterMatrix * inPosition * clusterWeight; interpolatedNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight; interpolatedTangent += clusterMatrix * vec4(inTangent.xyz, 0.0) * clusterWeight; } // pass along the diffuse color _color = inColor.rgb; // and the texture coordinates _texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st; interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0); interpolatedTangent = vec4(normalize(interpolatedTangent.xyz), 0.0); // standard transform TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); <$transformModelToEyeAndClipPos(cam, obj, inPosition, _position, gl_Position)$> <$transformModelToEyeDir(cam, obj, interpolatedNormal.xyz, interpolatedNormal.xyz)$> <$transformModelToEyeDir(cam, obj, interpolatedTangent.xyz, interpolatedTangent.xyz)$> _normal = interpolatedNormal.xyz; _tangent = interpolatedTangent.xyz; }