diff --git a/shaders/cylindrical_proj.glsl b/shaders/cylindrical_proj.glsl index b78b0c2a..ffd4c59d 100644 --- a/shaders/cylindrical_proj.glsl +++ b/shaders/cylindrical_proj.glsl @@ -159,7 +159,9 @@ void main() if (markerShape < 0) // markerShape == -1: discarded. discard; // (markerShape == 0: Square shape) - float fragDepth = gl_FragCoord.z; +# ifndef BROKEN_GL_FRAG_COORD + gl_FragDepth = gl_FragCoord.z; +# endif if (markerShape > 0 && pointScreenSize > pointScreenSizeLimit) { float w = markerWidth; @@ -174,9 +176,11 @@ void main() float r = length(p); if (r > 1) discard; - fragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w - // TODO: Why is the factor of 0.5 required here? - * 0.5*modifiedPointRadius*sqrt(1-r*r); +# ifndef BROKEN_GL_FRAG_COORD + gl_FragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w + // TODO: Why is the factor of 0.5 required here? + * 0.5*modifiedPointRadius*sqrt(1-r*r); +# endif } else if (markerShape == 2) // shape: o { @@ -197,9 +201,6 @@ void main() discard; } } -# ifndef NO_GL_FRAG_DEPTH - gl_FragDepth = fragDepth; -# endif fragColor = vec4(pointColor, 1); } diff --git a/shaders/generic_points.glsl b/shaders/generic_points.glsl index 4cc342de..15bd2d44 100644 --- a/shaders/generic_points.glsl +++ b/shaders/generic_points.glsl @@ -88,7 +88,9 @@ void main() if (markerShape2 < 0) // markerShape2 == -1: discarded. discard; // (markerShape2 == 1: Square shape) - float fragDepth = gl_FragCoord.z; +# ifndef BROKEN_GL_FRAG_COORD + gl_FragDepth = gl_FragCoord.z; +# endif if (markerShape2 != 1 && pointScreenSize > pointScreenSizeLimit) { float w = markerWidth; @@ -103,9 +105,11 @@ void main() float r = length(p); if (r > 1) discard; - fragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w - // TODO: Why is the factor of 0.5 required here? - * 0.5*modifiedPointRadius*sqrt(1-r*r); +# ifndef BROKEN_GL_FRAG_COORD + gl_FragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w + // TODO: Why is the factor of 0.5 required here? + * 0.5*modifiedPointRadius*sqrt(1-r*r); +# endif } else if (markerShape2 == 2) // shape: o { @@ -126,9 +130,6 @@ void main() discard; } } -# ifndef NO_GL_FRAG_DEPTH - gl_FragDepth = fragDepth; -# endif fragColor = vec4(pointColor, 1); } diff --git a/shaders/las_points.glsl b/shaders/las_points.glsl index d7ae0c05..10317f5b 100644 --- a/shaders/las_points.glsl +++ b/shaders/las_points.glsl @@ -165,7 +165,9 @@ void main() if (markerShape < 0) // markerShape == -1: discarded. discard; // (markerShape == 0: Square shape) - float fragDepth = gl_FragCoord.z; +# ifndef BROKEN_GL_FRAG_COORD + gl_FragDepth = gl_FragCoord.z; +# endif if (markerShape > 0 && pointScreenSize > pointScreenSizeLimit) { float w = markerWidth; @@ -180,9 +182,11 @@ void main() float r = length(p); if (r > 1) discard; - fragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w - // TODO: Why is the factor of 0.5 required here? - * 0.5*modifiedPointRadius*sqrt(1-r*r); +# ifndef BROKEN_GL_FRAG_COORD + gl_FragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w + // TODO: Why is the factor of 0.5 required here? + * 0.5*modifiedPointRadius*sqrt(1-r*r); +# endif } else if (markerShape == 2) // shape: o { @@ -203,9 +207,6 @@ void main() discard; } } -# ifndef NO_GL_FRAG_DEPTH - gl_FragDepth = fragDepth; -# endif fragColor = vec4(pointColor, 1); } diff --git a/shaders/las_points_lod.glsl b/shaders/las_points_lod.glsl index 250e7394..6cf4fb74 100644 --- a/shaders/las_points_lod.glsl +++ b/shaders/las_points_lod.glsl @@ -107,7 +107,9 @@ void main() if (stippleThresholds[int(gl_FragCoord.x) % 4 + 4*(int(gl_FragCoord.y) % 4)] > fragCoverage) discard; */ - float fragDepth = gl_FragCoord.z; +# ifndef BROKEN_GL_FRAG_COORD + gl_FragDepth = gl_FragCoord.z; +# endif if (fragMarkerShape > 0 && pointScreenSize > pointScreenSizeLimit) { vec2 p = 2*(gl_PointCoord - 0.5); @@ -116,14 +118,13 @@ void main() discard; if (fragMarkerShape == 1) // shape: sphere { - fragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w - // TODO: Why is the factor of 0.5 required here? - * 0.5*modifiedPointRadius*sqrt(1-r*r); +# ifndef BROKEN_GL_FRAG_COORD + gl_FragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w + // TODO: Why is the factor of 0.5 required here? + * 0.5*modifiedPointRadius*sqrt(1-r*r); +# endif } } -# ifndef NO_GL_FRAG_DEPTH - gl_FragDepth = fragDepth; -# endif fragColor = vec4(pointColor, 1); } diff --git a/shaders/lod_debug.glsl b/shaders/lod_debug.glsl index 565689d5..db9a884f 100644 --- a/shaders/lod_debug.glsl +++ b/shaders/lod_debug.glsl @@ -168,7 +168,9 @@ void main() if (markerShape < 0) // markerShape == -1: discarded. discard; // (markerShape == 0: Square shape) - float fragDepth = gl_FragCoord.z; +# ifndef BROKEN_GL_FRAG_COORD + gl_FragDepth = gl_FragCoord.z; +# endif if (markerShape > 0 && pointScreenSize > pointScreenSizeLimit) { float w = markerWidth; @@ -183,9 +185,11 @@ void main() float r = length(p); if (r > 1) discard; - fragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w - // TODO: Why is the factor of 0.5 required here? - * 0.5*modifiedPointRadius*sqrt(1-r*r); +# ifndef BROKEN_GL_FRAG_COORD + gl_FragDepth += projectionMatrix[3][2] * gl_FragCoord.w*gl_FragCoord.w + // TODO: Why is the factor of 0.5 required here? + * 0.5*modifiedPointRadius*sqrt(1-r*r); +# endif } else if (markerShape == 2) // shape: o { @@ -206,9 +210,6 @@ void main() discard; } } -# ifndef NO_GL_FRAG_DEPTH - gl_FragDepth = fragDepth; -# endif fragColor = vec4(pointColor, 1); } diff --git a/src/shader.cpp b/src/shader.cpp index 79029c59..00a74197 100644 --- a/src/shader.cpp +++ b/src/shader.cpp @@ -40,7 +40,7 @@ /// Make shader #define flags for hardware or driver-dependent blacklisted /// features. Current list: /// -/// NO_GL_FRAG_DEPTH +/// BROKEN_GL_FRAG_COORD /// static QByteArray makeBlacklistDefines() { @@ -55,11 +55,11 @@ static QByteArray makeBlacklistDefines() if (vendorStr.contains("intel", Qt::CaseInsensitive)) isIntel = true; QByteArray defines; - // Blacklist use of gl_FragDepth with Intel drivers on windows - for some - // reason, this interacts badly with any use of gl_FragCoord, leading to - // gross rendering artifacts. + // Blacklist use of gl_FragCoord/gl_FragDepth with Intel drivers on + // windows. For some reason, this interacts badly with any use of + // gl_PointCoord, leading to gross rendering artifacts. if (isWindows && isIntel) - defines += "#define NO_GL_FRAG_DEPTH\n"; + defines += "#define BROKEN_GL_FRAG_COORD\n"; return defines; }