overte-HifiExperiments/libraries/render-utils/src/directional_skybox_light_shadow_map.slf
2015-05-09 11:40:46 -07:00

49 lines
1.5 KiB
Text
Executable file

<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// directional_light.frag
// fragment shader
//
// Created by Sam Gateau on 5/8/2015.
// 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
//
// Everything about deferred buffer
<@include DeferredBuffer.slh@>
<@include DeferredGlobalLight.slh@>
// Everything about shadow
<@include Shadow.slh@>
void main(void) {
DeferredFragment frag = unpackDeferredFragment(gl_TexCoord[0].st);
// Eval shadow Texcoord and then Attenuation
vec4 shadowTexcoord = evalShadowTexcoord(frag.position);
float shadowAttenuation = evalShadowAttenuation(shadowTexcoord);
// Light mapped or not ?
if ((frag.normalVal.a >= 0.45) && (frag.normalVal.a <= 0.55)) {
gl_FragColor = vec4(evalLightmappedColor(
shadowAttenuation,
frag.normal,
frag.diffuse,
frag.specularVal.xyz),
1.0);
} else {
vec3 color = evalSkyboxGlobalColor(shadowAttenuation,
frag.position.xyz,
frag.normal,
frag.diffuse,
frag.specular,
frag.gloss);
gl_FragColor = vec4(color, frag.normalVal.a);
}
}