2#include <NDEVR/GLComputeShader.h>
3#include <NDEVR/Matrix.h>
4#include <NDEVR/PointContainer.h>
5#include <NDEVR/Buffer.h>
6#include <NDEVR/RGBColor.h>
16 class ColorPositionShaderLogic :
public GLComputeShader
19 ColorPositionShaderLogic();
23 struct alignas(16)
UBO {
44 static_assert(
sizeof(
UBO) == 176,
"UBO size mismatch");
62 template<
class t_po
int_type>
72 m_gl->glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT | GL_BUFFER_UPDATE_BARRIER_BIT);
95 void setQtGL(QOpenGLFunctions_4_3_Core* gl);
The equivelent of std::vector but with a bit more control.
void getInput(PointContainer< t_point_type > &active)
Read back computed 3D positions and weights from the GPU.
GLuint m_csA
Compute shader handle.
GLuint m_ssboPos
Shader storage buffer for output positions.
void updateImage(const uint01 *data, const Vector< 2, uint04 > &size)
Upload new depth data to the GPU texture.
Buffer< RGBColor > m_last_colors
Previously computed color buffer.
GLuint m_uboU
Uniform buffer object handle.
void uploadInputs(const uint01 *depth, Vector< 2, uint04 > size)
Upload depth data and ensure GPU storage buffers are large enough.
QOpenGLShaderProgram * m_shader
Compiled compute shader program.
void createUBOBuffer()
Create the GPU uniform buffer object for shader parameters.
void buildShader()
Compile and link the compute shader program.
void setQtGL(QOpenGLFunctions_4_3_Core *gl)
Set the OpenGL function pointer table used by this shader.
void runAll(Buffer< RGBColor > &last_colors)
Dispatch the compute shader and read back colors.
bool has_normal
Whether the shader outputs normals.
GLuint m_depth_image
GPU texture handle for the depth image.
GLuint m_ssboW
Shader storage buffer for output weights.
uint04 m_size_i
Total number of pixels being processed.
void createImage(const Vector< 2, uint04 > &size)
Create the GPU depth image texture.
void setUBO(const UBO &u)
Upload uniform buffer data to the GPU.
GLuint m_tex
Color texture handle.
Templated logic for doing matrix multiplication.
A templated container for 3D point cloud data with per-point positions, typed attributes,...
Buffer< Vertex< 3, fltp04 > > locations
3D positions of each point
Buffer< uint04 > weights
Per-point confidence weights.
void clear()
Clear all buffers, removing all points.
void setSize(uint04 size)
Resize all internal buffers to hold the given number of points.
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
Uniform buffer object layout for the color-position compute shader.
Vector< 4, fltp04 > cam_pos4
Camera position in world space (bytes 128..143).
Matrix< fltp04 > view_matrix
Camera view matrix (bytes 0..63).
float max_dist2
Maximum squared distance threshold.
Vector< 2, fltp04 > inv_f
Inverse focal length (bytes 80..87).
Vector< 2, fltp04 > f
Focal length in pixels (bytes 72..79).
Vector< 2, fltp04 > size_f
Frame size as float (bytes 88..95).
Vector< 2, uint04 > center_i
Frame center as integer pixels (bytes 96..103).
float k3
Radial distortion coefficient k3.
Vector< 2, fltp04 > pp
Principal point in pixels (bytes 64..71).
Vector< 2, uint04 > size_i
Frame size as integer pixels (bytes 104..111).
Vector< 4, uint04 > weight_info
Weight parameters: mode, bytes/pixel, max, reduce (bytes 160..175).
Vector< 4, fltp04 > k12p1p2
Distortion coefficients k1, k2, p1, p2 (bytes 112..127).
float max_error_percent_sqrd
Maximum error percentage squared for filtering.
float depth_scale
Scale factor converting raw depth to metres.