NDEVR
API Documentation
ColorPositionShaderLogic

GPU compute shader that converts depth and color raster frames into 3D colored point positions. More...

Collaboration diagram for ColorPositionShaderLogic:
[legend]

Classes

struct  UBO
 Uniform buffer object layout for the color-position compute shader. More...

Public Member Functions

void buildShader ()
 Compile and link the compute shader program.
void createImage (const Vector< 2, uint04 > &size)
 Create the GPU depth image texture.
void createUBOBuffer ()
 Create the GPU uniform buffer object for shader parameters.
template<class t_point_type>
void getInput (PointContainer< t_point_type > &active)
 Read back computed 3D positions and weights from the GPU.
void runAll (Buffer< RGBColor > &last_colors)
 Dispatch the compute shader and read back colors.
void setQtGL (QOpenGLFunctions_4_3_Core *gl)
 Set the OpenGL function pointer table used by this shader.
void setUBO (const UBO &u)
 Upload uniform buffer data to the GPU.
void updateImage (const uint01 *data, const Vector< 2, uint04 > &size)
 Upload new depth data to the GPU texture.
void uploadInputs (const uint01 *depth, Vector< 2, uint04 > size)
 Upload depth data and ensure GPU storage buffers are large enough.

Protected Attributes

bool has_normal = false
 Whether the shader outputs normals.
GLuint m_csA = 0
 Compute shader handle.
GLuint m_depth_image = 0
 GPU texture handle for the depth image.
Buffer< RGBColorm_last_colors
 Previously computed color buffer.
QOpenGLShaderProgram * m_shader = nullptr
 Compiled compute shader program.
uint04 m_size_i = 0
 Total number of pixels being processed.
GLuint m_ssboPos = 0
 Shader storage buffer for output positions.
GLuint m_ssboW = 0
 Shader storage buffer for output weights.
GLuint m_tex = 0
 Color texture handle.
GLuint m_uboU = 0
 Uniform buffer object handle.

Detailed Description

GPU compute shader that converts depth and color raster frames into 3D colored point positions.


Uses OpenGL 4.3 compute shaders to unproject depth pixels into world-space 3D points, applying camera intrinsics (focal length, principal point, distortion coefficients) and an extrinsic view matrix. Outputs position and weight buffers consumed by the point pipeline.

Definition at line 16 of file ColorPositionShaderLogic.h.

Member Function Documentation

◆ createImage()

void ColorPositionShaderLogic::createImage ( const Vector< 2, uint04 > & size)

Create the GPU depth image texture.

Parameters
[in]sizeWidth and height of the depth image in pixels.

Referenced by uploadInputs().

◆ getInput()

template<class t_point_type>
void ColorPositionShaderLogic::getInput ( PointContainer< t_point_type > & active)
inline

Read back computed 3D positions and weights from the GPU.

Parameters
[in,out]activePoint container to receive the output positions and weights.

Definition at line 63 of file ColorPositionShaderLogic.h.

References PointContainer< t_point_type >::clear(), PointContainer< t_point_type >::locations, m_size_i, m_ssboPos, m_ssboW, PointContainer< t_point_type >::setSize(), and PointContainer< t_point_type >::weights.

◆ runAll()

void ColorPositionShaderLogic::runAll ( Buffer< RGBColor > & last_colors)

Dispatch the compute shader and read back colors.

Parameters
[in,out]last_colorsBuffer to receive the computed color data.

◆ setQtGL()

void ColorPositionShaderLogic::setQtGL ( QOpenGLFunctions_4_3_Core * gl)

Set the OpenGL function pointer table used by this shader.

Parameters
[in]glPointer to the OpenGL 4.3 core functions.

◆ setUBO()

void ColorPositionShaderLogic::setUBO ( const UBO & u)

Upload uniform buffer data to the GPU.

Parameters
[in]uThe uniform buffer contents to upload.

◆ updateImage()

void ColorPositionShaderLogic::updateImage ( const uint01 * data,
const Vector< 2, uint04 > & size )

Upload new depth data to the GPU texture.

Parameters
[in]dataRaw depth image bytes.
[in]sizeWidth and height of the depth image in pixels.

Referenced by uploadInputs().

◆ uploadInputs()

void ColorPositionShaderLogic::uploadInputs ( const uint01 * depth,
Vector< 2, uint04 > size )
inline

Upload depth data and ensure GPU storage buffers are large enough.

Parameters
[in]depthRaw depth image bytes.
[in]sizeWidth and height of the depth image in pixels.

Definition at line 80 of file ColorPositionShaderLogic.h.

References createImage(), m_depth_image, m_size_i, m_ssboPos, m_ssboW, and updateImage().


The documentation for this class was generated from the following file: