<@include gpu/Config.slh@> <$VERSION_HEADER$> // Generated on <$_SCRIBE_DATE$> // // model_normal_specular_map.frag // fragment shader // // Created by Andrzej Kapolka on 5/6/14. // Copyright 2014 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 DeferredBufferWrite.slh@> <@include model/Material.slh@> // the diffuse texture uniform sampler2D diffuseMap; // the normal map texture uniform sampler2D normalMap; // the specular map texture uniform sampler2D specularMap; in vec4 _position; in vec2 _texCoord0; in vec3 _normal; in vec3 _tangent; in vec3 _color; void main(void) { // compute the view normal from the various bits vec3 normalizedNormal = normalize(_normal); vec3 normalizedTangent = normalize(_tangent); vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent)); vec3 localNormal = normalize(vec3(texture(normalMap, _texCoord0)) - vec3(0.5, 0.5, 0.5)); vec4 viewNormal = vec4(normalizedTangent * localNormal.x + normalizedBitangent * localNormal.y + normalizedNormal * localNormal.z, 0.0); // set the diffuse, normal, specular data vec4 diffuse = texture(diffuseMap, _texCoord0); vec3 specular = texture(specularMap, _texCoord0).rgb; Material mat = getMaterial(); packDeferredFragment( normalize(viewNormal.xyz), evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a), getMaterialDiffuse(mat) * diffuse.rgb * _color, specular, //getMaterialSpecular(mat), getMaterialShininess(mat)); }