Use the MATLAB Jet colormap for displaying depth data.
This commit is contained in:
@@ -1,6 +1,21 @@
|
|||||||
varying vec4 vColor;
|
varying vec4 vColor;
|
||||||
uniform bool EnableDepthPreview;
|
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()
|
void main()
|
||||||
{
|
{
|
||||||
float depth = gl_FragCoord.z;
|
float depth = gl_FragCoord.z;
|
||||||
@@ -10,8 +25,11 @@ void main()
|
|||||||
|
|
||||||
if (EnableDepthPreview)
|
if (EnableDepthPreview)
|
||||||
{
|
{
|
||||||
// Front of the depth buffer is at 0, but we want to render it as bright
|
float x = 1.0 - gl_FragDepth;
|
||||||
gl_FragColor = vec4(vec3(1.0 - gl_FragDepth), 1.0);
|
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
|
else
|
||||||
gl_FragColor = vColor;
|
gl_FragColor = vColor;
|
||||||
|
|||||||
@@ -3,6 +3,21 @@ uniform bool EnableDepthPreview;
|
|||||||
|
|
||||||
varying vec4 vTexCoord;
|
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()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 c = texture2D(DiffuseTexture, vTexCoord.st);
|
vec4 c = texture2D(DiffuseTexture, vTexCoord.st);
|
||||||
@@ -17,8 +32,11 @@ void main()
|
|||||||
|
|
||||||
if (EnableDepthPreview)
|
if (EnableDepthPreview)
|
||||||
{
|
{
|
||||||
// Front of the depth buffer is at 0, but we want to render it as bright
|
float x = 1.0 - gl_FragDepth;
|
||||||
gl_FragColor = vec4(vec3(1.0 - gl_FragDepth), 1.0);
|
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
|
else
|
||||||
gl_FragColor = c;
|
gl_FragColor = c;
|
||||||
|
|||||||
@@ -8,6 +8,21 @@ varying vec2 vTexMetadata;
|
|||||||
varying vec4 vChannelMask;
|
varying vec4 vChannelMask;
|
||||||
varying vec4 vDepthMask;
|
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()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 x = texture2D(DiffuseTexture, vTexCoord.st);
|
vec4 x = texture2D(DiffuseTexture, vTexCoord.st);
|
||||||
@@ -30,8 +45,11 @@ void main()
|
|||||||
|
|
||||||
if (EnableDepthPreview)
|
if (EnableDepthPreview)
|
||||||
{
|
{
|
||||||
// Front of the depth buffer is at 0, but we want to render it as bright
|
float x = 1.0 - gl_FragDepth;
|
||||||
gl_FragColor = vec4(vec3(1.0 - gl_FragDepth), 1.0);
|
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
|
else
|
||||||
gl_FragColor = c;
|
gl_FragColor = c;
|
||||||
|
|||||||
Reference in New Issue
Block a user