diff --git a/glsl/color.frag b/glsl/color.frag index 456c5a2706..c84c7e1aba 100644 --- a/glsl/color.frag +++ b/glsl/color.frag @@ -1,6 +1,21 @@ varying vec4 vColor; uniform bool EnableDepthPreview; +float jet_r(float x) +{ + return x < 0.7 ? 4.0 * x - 1.5 : -4.0 * x + 4.5; +} + +float jet_g(float x) +{ + return x < 0.5 ? 4.0 * x - 0.5 : -4.0 * x + 3.5; +} + +float jet_b(float x) +{ + return x < 0.3 ? 4.0 * x + 0.5 : -4.0 * x + 2.5; +} + void main() { float depth = gl_FragCoord.z; @@ -10,8 +25,11 @@ void main() if (EnableDepthPreview) { - // Front of the depth buffer is at 0, but we want to render it as bright - gl_FragColor = vec4(vec3(1.0 - gl_FragDepth), 1.0); + float x = 1.0 - gl_FragDepth; + float r = clamp(jet_r(x), 0.0, 1.0); + float g = clamp(jet_g(x), 0.0, 1.0); + float b = clamp(jet_b(x), 0.0, 1.0); + gl_FragColor = vec4(r, g, b, 1.0); } else gl_FragColor = vColor; diff --git a/glsl/rgba.frag b/glsl/rgba.frag index eced13e89f..cbe92009f4 100644 --- a/glsl/rgba.frag +++ b/glsl/rgba.frag @@ -3,6 +3,21 @@ uniform bool EnableDepthPreview; varying vec4 vTexCoord; +float jet_r(float x) +{ + return x < 0.7 ? 4.0 * x - 1.5 : -4.0 * x + 4.5; +} + +float jet_g(float x) +{ + return x < 0.5 ? 4.0 * x - 0.5 : -4.0 * x + 3.5; +} + +float jet_b(float x) +{ + return x < 0.3 ? 4.0 * x + 0.5 : -4.0 * x + 2.5; +} + void main() { vec4 c = texture2D(DiffuseTexture, vTexCoord.st); @@ -17,8 +32,11 @@ void main() if (EnableDepthPreview) { - // Front of the depth buffer is at 0, but we want to render it as bright - gl_FragColor = vec4(vec3(1.0 - gl_FragDepth), 1.0); + float x = 1.0 - gl_FragDepth; + float r = clamp(jet_r(x), 0.0, 1.0); + float g = clamp(jet_g(x), 0.0, 1.0); + float b = clamp(jet_b(x), 0.0, 1.0); + gl_FragColor = vec4(r, g, b, 1.0); } else gl_FragColor = c; diff --git a/glsl/shp.frag b/glsl/shp.frag index b167d55721..aa16bc3196 100644 --- a/glsl/shp.frag +++ b/glsl/shp.frag @@ -8,6 +8,21 @@ varying vec2 vTexMetadata; varying vec4 vChannelMask; varying vec4 vDepthMask; +float jet_r(float x) +{ + return x < 0.7 ? 4.0 * x - 1.5 : -4.0 * x + 4.5; +} + +float jet_g(float x) +{ + return x < 0.5 ? 4.0 * x - 0.5 : -4.0 * x + 3.5; +} + +float jet_b(float x) +{ + return x < 0.3 ? 4.0 * x + 0.5 : -4.0 * x + 2.5; +} + void main() { vec4 x = texture2D(DiffuseTexture, vTexCoord.st); @@ -30,8 +45,11 @@ void main() if (EnableDepthPreview) { - // Front of the depth buffer is at 0, but we want to render it as bright - gl_FragColor = vec4(vec3(1.0 - gl_FragDepth), 1.0); + float x = 1.0 - gl_FragDepth; + float r = clamp(jet_r(x), 0.0, 1.0); + float g = clamp(jet_g(x), 0.0, 1.0); + float b = clamp(jet_b(x), 0.0, 1.0); + gl_FragColor = vec4(r, g, b, 1.0); } else gl_FragColor = c;