mirror of
https://github.com/overte-org/overte.git
synced 2025-07-10 13:58:56 +02:00
58 lines
1.7 KiB
Text
Executable file
58 lines
1.7 KiB
Text
Executable file
<@include gpu/Config.slh@>
|
|
<$VERSION_HEADER$>
|
|
// Generated on <$_SCRIBE_DATE$>
|
|
//
|
|
// model_lightmap_normal_map.frag
|
|
// fragment shader
|
|
//
|
|
// Created by Samuel Gateau on 11/19/14.
|
|
// 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 DeferredBufferWrite.slh@>
|
|
|
|
<@include model/Material.slh@>
|
|
|
|
// the diffuse texture
|
|
uniform sampler2D diffuseMap;
|
|
|
|
// the normal map texture
|
|
uniform sampler2D normalMap;
|
|
|
|
// the emissive map texture and parameters
|
|
uniform sampler2D emissiveMap;
|
|
uniform vec2 emissiveParams;
|
|
|
|
in vec4 _position;
|
|
in vec2 _texCoord0;
|
|
in vec2 _texCoord1;
|
|
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 = 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);
|
|
vec4 emissive = texture(emissiveMap, _texCoord1);
|
|
|
|
Material mat = getMaterial();
|
|
|
|
packDeferredFragmentLightmap(
|
|
normalize(viewNormal.xyz),
|
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
|
getMaterialDiffuse(mat) * diffuse.rgb * _color,
|
|
getMaterialSpecular(mat),
|
|
getMaterialShininess(mat),
|
|
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
|
}
|