overte/libraries/render-utils/src/glowLine.slf
2017-11-08 18:35:26 -07:00

33 lines
925 B
Text

<@include gpu/Config.slh@>
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
//
// Created by Bradley Austin Davis on 2016/07/05
// Copyright 2013-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
//
in vec4 _color;
in float distanceFromCenter;
out vec4 _fragColor;
void main(void) {
// The incoming value actually ranges from -1 to 1, so modify it
// so that it goes from 0 -> 1 -> 0 with the solid alpha being at
// the center of the line
float alpha = 1.0 - abs(distanceFromCenter);
// Convert from a linear alpha curve to a sharp peaked one
alpha = _color.a * pow(alpha, 10.0);
// Drop everything where the curve falls off to nearly nothing
if (alpha <= 0.05) {
discard;
}
// Emit the color
_fragColor = vec4(_color.rgb, alpha);
}