<@include gpu/Config.slh@> <$VERSION_HEADER$> // <$_SCRIBE_FILENAME$> // Generated on <$_SCRIBE_DATE$> // // Created by Andrzej Kapolka on 9/15/14. // Copyright 2014 High Fidelity, Inc. // Copyright 2024 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // <@include gpu/Color.slh@> <@include DefaultMaterials.slh@> <@include render-utils/ShaderConstants.h@> <@include CullFace.slh@> <@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@> <@if not HIFI_USE_UNLIT@> <@include gpu/Transform.slh@> <$declareStandardCameraTransform()$> <@else@> <@include LightingModel.slh@> <@endif@> <@endif@> <@if HIFI_USE_FORWARD@> OUTPUT(0, vec4, _fragColor0); <@else@> <@include DeferredBufferWrite.slh@> <@endif@> <@if not HIFI_USE_UNLIT@> <@include GlobalLight.slh@> <@include LightLocal.slh@> <$declareEvalGlobalLightingAlphaBlended()$> <@endif@> <@if HIFI_USE_FADE@> <@include Fade.slh@> <$declareFadeFragmentInstanced()$> <@endif@> <@if HIFI_USE_FORWARD or HIFI_USE_TRANSLUCENT@> <@if not HIFI_USE_UNLIT@> INPUT(RENDER_UTILS_ATTR_POSITION_ES, vec4, _positionES); <@endif@> // workaround for scribe only supporting (A or B) and not (A or B or C) <@if not HIFI_USE_FADE@> layout(location=RENDER_UTILS_ATTR_POSITION_WS) in vec4 _positionWS; <@endif@> <@endif@> <@if not HIFI_USE_FORWARD@> INPUT(RENDER_UTILS_ATTR_PREV_POSITION_CS, vec4, _prevPositionCS); <@endif@> <@if HIFI_USE_FADE@> INPUT(RENDER_UTILS_ATTR_POSITION_WS, vec4, _positionWS); <@endif@> INPUT(RENDER_UTILS_ATTR_NORMAL_WS, vec3, _normalWS); INPUT(RENDER_UTILS_ATTR_COLOR, vec4, _color); INPUT(RENDER_UTILS_ATTR_TEXCOORD01, vec4, _texCoord01); #define _texCoord0 _texCoord01.xy #define _texCoord1 _texCoord01.zw TEXTURE(0, sampler2D, simpleTexture); void main(void) { vec4 texel = texture(simpleTexture, _texCoord0); texel = mix(texel, color_sRGBAToLinear(texel), float(_color.a <= 0.0)); texel.rgb *= _color.rgb; texel.a *= abs(_color.a); <@if HIFI_USE_FADE@> vec3 fadeEmissive; FadeObjectParams fadeParams; <$fetchFadeObjectParamsInstanced(fadeParams)$> applyFade(fadeParams, _positionWS.xyz, fadeEmissive); <@endif@> <@if not HIFI_USE_UNLIT@> <@if HIFI_USE_TRANSLUCENT or HIFI_USE_FORWARD@> float metallic = DEFAULT_METALLIC; vec3 fresnel = getFresnelF0(metallic, texel.rgb); TransformCamera cam = getTransformCamera(); vec3 fragNormalWS = evalFrontOrBackFaceNormal(normalize(_normalWS)); vec3 fragPositionWS = _positionWS.xyz; vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS; vec3 fragToEyeDirWS = normalize(fragToEyeWS); SurfaceData surfaceWS = initSurfaceData(DEFAULT_ROUGHNESS, fragNormalWS, fragToEyeDirWS); vec4 localLighting = vec4(0.0); <$fetchClusterInfo(_positionWS)$> if (hasLocalLights(numLights, clusterPos, dims)) { localLighting = evalLocalLighting(cluster, numLights, fragPositionWS, surfaceWS, metallic, fresnel, texel.rgb, 0.0, vec4(0), vec4(0), texel.a); } vec4 color = vec4(evalGlobalLightingAlphaBlended( cam._viewInverse, 1.0, DEFAULT_OCCLUSION, _positionES.xyz, fragNormalWS, texel.rgb, fresnel, metallic, DEFAULT_EMISSIVE <@if HIFI_USE_FADE@> + fadeEmissive <@endif@> , surfaceWS, texel.a, localLighting.rgb), texel.a); <@if HIFI_USE_FORWARD@> _fragColor0 = color; <@else@> packDeferredFragmentTranslucentUnlit(color.a, color.rgb); <@endif@> <@else@> packDeferredFragment( _prevPositionCS, evalFrontOrBackFaceNormal(normalize(_normalWS)), 1.0, texel.rgb, DEFAULT_ROUGHNESS, DEFAULT_METALLIC, DEFAULT_EMISSIVE <@if HIFI_USE_FADE@> + fadeEmissive <@endif@> , DEFAULT_OCCLUSION, DEFAULT_SCATTERING); <@endif@> <@else@> vec3 color = isUnlitEnabled() * (texel.rgb <@if HIFI_USE_FADE@> + fadeEmissive <@endif@> ); <@if HIFI_USE_FORWARD@> _fragColor0 = vec4(color, texel.a); <@elif HIFI_USE_TRANSLUCENT@> packDeferredFragmentTranslucentUnlit( texel.a, color); <@else@> packDeferredFragmentUnlit( _prevPositionCS, evalFrontOrBackFaceNormal(normalize(_normalWS)), 1.0, color); <@endif@> <@endif@> }