| 1 |
R"XXX(#version 300 es |
| 2 |
|
| 3 |
// FRAGMENT SHADER: Default shader for MRPT CRenderizable objects |
| 4 |
// Jose Luis Blanco Claraco (C) 2019-2023 |
| 5 |
// Part of the MRPT project |
| 6 |
|
| 7 |
out mediump vec4 FragColor; |
| 8 |
in mediump vec2 frag_UV; |
| 9 |
uniform sampler2D textureId; |
| 10 |
|
| 11 |
highp float near_plane = 0.1; |
| 12 |
highp float far_plane = 30.0; |
| 13 |
|
| 14 |
// required when using a perspective projection matrix |
| 15 |
highp float LinearizeDepth(highp float depth) |
| 16 |
{ |
| 17 |
highp float z = depth * 2.0 - 1.0; // Back to NDC |
| 18 |
return (2.0 * near_plane * far_plane) / (far_plane + near_plane - z * (far_plane - near_plane)); |
| 19 |
} |
| 20 |
|
| 21 |
void main() |
| 22 |
{ |
| 23 |
highp float depthValue = texture(textureId, frag_UV).r; |
| 24 |
// FragColor = vec4(vec3(LinearizeDepth(depthValue) / far_plane), 1.0); // perspective |
| 25 |
FragColor = vec4(vec3(depthValue), 1.0); // orthographic |
| 26 |
} |
| 27 |
)XXX" |