Fixed interaction of trail points with ATM. (#602)

* Fixed interaction of trail points with ATM.
* Added fix from SunEarh day.
This commit is contained in:
Jonathas Costa
2018-04-20 22:47:17 -04:00
committed by Alexander Bock
parent b4be63af65
commit d5af5aab5d
2 changed files with 21 additions and 6 deletions
+18 -5
View File
@@ -27,6 +27,7 @@
in vec4 vs_positionScreenSpace;
in vec4 vs_gPosition;
in float fade;
in float v_pointSize;
uniform vec3 color;
uniform int renderPhase;
@@ -45,18 +46,30 @@ Fragment getFragment() {
frag.depth = vs_positionScreenSpace.w;
frag.blend = BLEND_MODE_ADDITIVE;
vec4 depthCorrection = vec4(0.0, 0.0, 100.0, 0.0);
if (renderPhase == RenderPhasePoints) {
// Use the length of the vector (dot(circCoord, circCoord)) as factor in the
// smoothstep to gradually decrease the alpha on the edges of the point
vec2 circCoord = 2.0 * gl_PointCoord - 1.0;
frag.color.a *= 1.0 - smoothstep(1.0 - Delta, 1.0, dot(circCoord, circCoord));
}
//float circleClipping = 1.0 - smoothstep(1.0 - Delta, 1.0, dot(circCoord, circCoord));
float circleClipping = smoothstep(1.0, 1.0 - Delta, dot(circCoord, circCoord));
float transparencyCorrection = frag.color.a * circleClipping;
if (transparencyCorrection < 0.9) {
discard;
}
frag.color.a = transparencyCorrection;
}
// G-Buffer
frag.gPosition = vs_gPosition;
// JCC: The depthCorrection here is a temporary tweak
// to fix precision problems.
frag.gPosition = vs_gPosition + depthCorrection;
// There is no normal here
// TODO: Add the correct normal if necessary (JCC)
frag.gNormal = vec4(0.0, 0.0, 0.0, 1.0);
frag.gNormal = vec4(0.0, 0.0, -1.0, 1.0);
return frag;
}
+3 -1
View File
@@ -31,6 +31,7 @@ layout(location = 0) in vec3 in_point_position;
out vec4 vs_positionScreenSpace;
out vec4 vs_gPosition;
out float fade;
out float v_pointSize;
uniform dmat4 modelViewTransform;
uniform mat4 projectionTransform;
@@ -75,5 +76,6 @@ void main() {
vs_positionScreenSpace = z_normalization(projectionTransform * vs_gPosition);
gl_PointSize = (stride == 1 || int(modId) % stride == 0) ? float(pointSize) : float(pointSize) / 2;
gl_Position = vs_positionScreenSpace;
v_pointSize = gl_PointSize;
gl_Position = vs_positionScreenSpace;
}