<@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; // the interpolated normal varying vec4 interpolatedNormal; // the interpolated tangent varying vec4 interpolatedTangent; varying vec3 color; void main(void) { // compute the view normal from the various bits vec3 normalizedNormal = normalize(vec3(interpolatedNormal)); vec3 normalizedTangent = normalize(vec3(interpolatedTangent)); vec3 normalizedBitangent = normalize(cross(normalizedNormal, normalizedTangent)); vec3 localNormal = normalize(vec3(texture2D(normalMap, gl_TexCoord[0].st)) - 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 = texture2D(diffuseMap, gl_TexCoord[0].st); vec3 specular = texture2D(specularMap, gl_TexCoord[0].st).rgb; Material mat = getMaterial(); packDeferredFragment( normalize(viewNormal.xyz), evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a), getMaterialDiffuse(mat) * diffuse.rgb * color, specular, //getMaterialSpecular(mat), getMaterialShininess(mat)); }