Merge pull request #11441 from SamGondelman/glowAlpha

Fix alpha on Line3DOverlays with glow
This commit is contained in:
Sam Gateau 2017-09-22 17:17:23 -07:00 committed by GitHub
commit d68577be7e
2 changed files with 10 additions and 9 deletions

View file

@ -9,7 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
layout(location = 0) in vec4 inColor;
in vec4 _color;
in float distanceFromCenter;
out vec4 _fragColor;
@ -17,10 +18,10 @@ 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(inColor.a);
float alpha = 1.0 - abs(distanceFromCenter);
// Convert from a linear alpha curve to a sharp peaked one
alpha = pow(alpha, 10);
alpha = _color.a * pow(alpha, 10);
// Drop everything where the curve falls off to nearly nothing
if (alpha <= 0.05) {
@ -28,6 +29,5 @@ void main(void) {
}
// Emit the color
_fragColor = vec4(inColor.rgb, alpha);
return;
_fragColor = vec4(_color.rgb, alpha);
}

View file

@ -18,7 +18,9 @@ layout(std140) uniform lineData {
vec4 color;
};
layout(location = 0) out vec4 _color;
out vec4 _color;
// the distance from the center in 'quad space'
out float distanceFromCenter;
void main(void) {
_color = color;
@ -45,11 +47,10 @@ void main(void) {
// Add or subtract the orthogonal vector based on a different vertex ID
// calculation
if (gl_VertexID < 2) {
// Use the alpha channel to store the distance from the center in 'quad space'
_color.a = -1.0;
distanceFromCenter = -1.0;
eye.xyz -= orthogonal;
} else {
_color.a = 1.0;
distanceFromCenter = 1.0;
eye.xyz += orthogonal;
}