mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 01:00:50 +02:00
66 lines
2.2 KiB
Text
66 lines
2.2 KiB
Text
<@include gpu/Config.slh@>
|
|
<$VERSION_HEADER$>
|
|
// Generated on <$_SCRIBE_DATE$>
|
|
//
|
|
// directional_skybox_light_shadow.frag
|
|
// fragment shader
|
|
//
|
|
// Created by Zach Pomerantz on 1/18/2016.
|
|
// Copyright 2016 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 Shadow.slh@>
|
|
<@include DeferredBufferRead.slh@>
|
|
<@include DeferredGlobalLight.slh@>
|
|
<@include render-utils/ShaderConstants.h@>
|
|
|
|
<$declareEvalLightmappedColor()$>
|
|
<$declareEvalSkyboxGlobalColor(isScattering)$>
|
|
|
|
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec4 _texCoord01;
|
|
#define _texCoord0 _texCoord01.xy
|
|
#define _texCoord1 _texCoord01.zw
|
|
layout(location=0) out vec4 _fragColor;
|
|
|
|
void main(void) {
|
|
DeferredFrameTransform deferredTransform = getDeferredFrameTransform();
|
|
DeferredFragment frag = unpackDeferredFragment(deferredTransform, _texCoord0);
|
|
|
|
vec4 viewPos = vec4(frag.position.xyz, 1.0);
|
|
vec4 worldPos = getViewInverse() * viewPos;
|
|
Light shadowLight = getKeyLight();
|
|
vec3 worldLightDirection = getLightDirection(shadowLight);
|
|
float shadowAttenuation = evalShadowAttenuation(worldLightDirection, worldPos, -viewPos.z, frag.normal);
|
|
|
|
// Light mapped or not ?
|
|
if (frag.mode == FRAG_MODE_UNLIT) {
|
|
discard;
|
|
} else if (frag.mode == FRAG_MODE_LIGHTMAPPED) {
|
|
discard;
|
|
} else {
|
|
vec4 midNormalCurvature = vec4(0);
|
|
vec4 lowNormalCurvature = vec4(0);
|
|
if (frag.mode == FRAG_MODE_SCATTERING) {
|
|
unpackMidLowNormalCurvature(_texCoord0, midNormalCurvature, lowNormalCurvature);
|
|
}
|
|
vec3 color = evalSkyboxGlobalColor(
|
|
getViewInverse(),
|
|
shadowAttenuation,
|
|
frag.obscurance,
|
|
frag.position.xyz,
|
|
frag.normal,
|
|
frag.albedo,
|
|
frag.fresnel,
|
|
frag.metallic,
|
|
frag.roughness,
|
|
frag.scattering,
|
|
midNormalCurvature,
|
|
lowNormalCurvature);
|
|
|
|
|
|
_fragColor = vec4(color, 1.0);
|
|
}
|
|
}
|