Drake
drake::systems::sensors::shaders Namespace Reference

Variables

constexpr char kDepthVS []
 A vertex shader program for rendering depth images, which computes vertices and normals for the fragment shader program coming after. More...
 
constexpr char kDepthFS []
 A fragment shader program for rendering depth images, which computes depth values for each pixel in depth images, converts them to be in range [0, 1] and packs those values to three color channels. More...
 

Variable Documentation

constexpr char kDepthFS[]

A fragment shader program for rendering depth images, which computes depth values for each pixel in depth images, converts them to be in range [0, 1] and packs those values to three color channels.

In other words, we encode a depth image into a color image and output the color image. For the detail of packing algorithm, please refer to: https://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/ Note that we are only using three channels instead of four channels to express a float value. This differs from the example code in the link above. The reason is that we need to set one to alpha channel so that the rendered "image" will be opaque. Otherwise, we will have different colors from what we output here, thus expect, in the end.

constexpr char kDepthVS[]
Initial value:
=
"//VTK::System::Dec\n"
"attribute vec4 vertexMC;\n"
"attribute vec3 normalMC;\n"
"uniform mat3 normalMatrix;\n"
"uniform mat4 MCDCMatrix;\n"
"uniform mat4 MCVCMatrix;\n"
"varying vec3 normalVCVSOutput;\n"
"varying vec4 vertexVCVSOutput;\n"
"attribute vec2 tcoordMC;\n"
"varying vec2 tcoordVCVSOutput;\n"
"void main () {\n"
" normalVCVSOutput = normalMatrix * normalMC;\n"
" tcoordVCVSOutput = tcoordMC;\n"
" vertexVCVSOutput = MCVCMatrix * vertexMC;\n"
" gl_Position = MCDCMatrix * vertexMC;\n"
"}\n"

A vertex shader program for rendering depth images, which computes vertices and normals for the fragment shader program coming after.