mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-23 05:29:17 +02:00
94 lines
2.9 KiB
Text
94 lines
2.9 KiB
Text
<@include gpu/Config.slh@>
|
|
<$VERSION_HEADER$>
|
|
// Generated on <$_SCRIBE_DATE$>
|
|
// model_translucent_fade.frag
|
|
// Created by Olivier Prat on 06/05/17.
|
|
// Copyright 2017 High Fidelity, Inc.
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE
|
|
|
|
<@include graphics/Material.slh@>
|
|
<@include DeferredGlobalLight.slh@>
|
|
|
|
<$declareEvalGlobalLightingAlphaBlendedWithHaze()$>
|
|
|
|
<@include LightLocal.slh@>
|
|
<@include gpu/Transform.slh@>
|
|
<$declareStandardCameraTransform()$>
|
|
|
|
<@include MaterialTextures.slh@>
|
|
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
|
|
|
|
<@include Fade.slh@>
|
|
<$declareFadeFragment()$>
|
|
|
|
in vec2 _texCoord0;
|
|
in vec2 _texCoord1;
|
|
in vec4 _positionES;
|
|
in vec4 _positionWS;
|
|
in vec3 _normalWS;
|
|
in vec3 _color;
|
|
in float _alpha;
|
|
|
|
out vec4 _fragColor;
|
|
|
|
void main(void) {
|
|
vec3 fadeEmissive;
|
|
FadeObjectParams fadeParams;
|
|
|
|
<$fetchFadeObjectParams(fadeParams)$>
|
|
applyFade(fadeParams, _positionWS.xyz, fadeEmissive);
|
|
|
|
Material mat = getMaterial();
|
|
BITFIELD matKey = getMaterialKey(mat);
|
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
|
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
|
|
|
float opacity = getMaterialOpacity(mat) * _alpha;
|
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
|
|
|
vec3 albedo = getMaterialAlbedo(mat);
|
|
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
|
albedo *= _color;
|
|
|
|
float roughness = getMaterialRoughness(mat);
|
|
<$evalMaterialRoughness(roughnessTex, roughness, matKey, roughness)$>;
|
|
|
|
float metallic = getMaterialMetallic(mat);
|
|
vec3 fresnel = getFresnelF0(metallic, albedo);
|
|
|
|
vec3 emissive = getMaterialEmissive(mat);
|
|
<$evalMaterialEmissive(emissiveTex, emissive, matKey, emissive)$>;
|
|
|
|
vec3 fragPositionES = _positionES.xyz;
|
|
vec3 fragPositionWS = _positionWS.xyz;
|
|
// Lighting is done in world space
|
|
vec3 fragNormalWS = normalize(_normalWS);
|
|
|
|
TransformCamera cam = getTransformCamera();
|
|
vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS;
|
|
vec3 fragToEyeDirWS = normalize(fragToEyeWS);
|
|
SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);
|
|
|
|
vec4 localLighting = vec4(0.0);
|
|
|
|
<$fetchClusterInfo(_positionWS)$>;
|
|
if (hasLocalLights(numLights, clusterPos, dims)) {
|
|
localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS,
|
|
metallic, fresnel, albedo, 0.0,
|
|
vec4(0), vec4(0), opacity);
|
|
}
|
|
|
|
_fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze(
|
|
cam._viewInverse,
|
|
1.0,
|
|
occlusionTex,
|
|
fragPositionES,
|
|
fragPositionWS,
|
|
albedo,
|
|
fresnel,
|
|
metallic,
|
|
emissive + fadeEmissive,
|
|
surfaceWS, opacity, localLighting.rgb),
|
|
opacity);
|
|
}
|