overte/libraries/entities-renderer/src/paintStroke.slf
2024-02-28 15:23:04 -08:00

51 lines
1.6 KiB
Text

<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// <$_SCRIBE_FILENAME$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Eric Levin on 8/10/2015
// Copyright 2015 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
//
<@if not HIFI_USE_FORWARD@>
<@include DeferredBufferWrite.slh@>
<@else@>
layout(location=0) out vec4 _fragColor0;
<@endif@>
<@include paintStroke.slh@>
<$declarePolyLineBuffers()$>
<@include CullFace.slh@>
LAYOUT(binding=0) uniform sampler2D _texture;
<@include render-utils/ShaderConstants.h@>
<@if not HIFI_USE_FORWARD@>
layout(location=RENDER_UTILS_ATTR_NORMAL_WS) in vec3 _normalWS;
layout(location=RENDER_UTILS_ATTR_PREV_POSITION_CS) in vec4 _prevPositionCS;
<@endif@>
layout(location=RENDER_UTILS_ATTR_TEXCOORD01) in vec2 _texCoord;
layout(location=RENDER_UTILS_ATTR_COLOR) in vec4 _color;
layout(location=2) in float _distanceFromCenter;
void main(void) {
vec4 texel = texture(_texture, _texCoord);
texel *= _color;
texel.a *= mix(1.0, pow(1.0 - min(1.0, abs(_distanceFromCenter)), 10.0), _polylineData.faceCameraGlow.y);
<@if not HIFI_USE_FORWARD@>
<@if HIFI_USE_TRANSLUCENT@>
packDeferredFragmentTranslucentUnlit(_prevPositionCS, evalFrontOrBackFaceNormal(_normalWS), texel.a, texel.rgb);
<@else@>
packDeferredFragmentUnlit(_prevPositionCS, evalFrontOrBackFaceNormal(_normalWS), texel.a, texel.rgb);
<@endif@>
<@else@>
_fragColor0 = texel;
<@endif@>
}