Source browser
examples/shaders/harris_tensor.cpp
Read the complete file below or download its original bytes. Line numbers provide stable links to a declaration or processing step.
File fingerprint
1#ifdef __cplusplus // Expose host declarations only when a C++ compiler reads this shader.
2#include "shdr.h" // Include shdr.h declarations.
3#endif // Finish this conditional compilation branch.
4
5// Encode the symmetric gradient outer product as (dx*dx,dx*dy,dy*dy,0).
6layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; // Group 64 independent invocations along x.
7layout(std430, binding = 0) readonly buffer Inputs { // Read the preceding stage's input elements through buffer binding 0.
8 vec2 input_values[]; // Store the preceding stage's input elements.
9}; // Finish this declaration.
10layout(std430, binding = 1) writeonly buffer Outputs { // Write this stage's output elements through buffer binding 1.
11 vec4 output_values[]; // Store this stage's output elements.
12}; // Finish this declaration.
13uniform uint count; // Limit work to the valid element count, including a partial final workgroup.
14
15void main() { // Form one symmetric structure tensor from the two image derivatives.
16 uint i = gl_GlobalInvocationID.x; // Select this invocation's global x coordinate.
17 if (i >= count) // Stop padding invocations before reading or writing an element.
18 return; // Stop this invocation before performing another resource access.
19 vec2 g = input_values[i]; // Read the horizontal and vertical image derivatives.
20 output_values[i] = vec4(g.x * g.x, g.x * g.y, g.y * g.y, 0.0); // Pack dx squared, dx times dy and dy squared into the symmetric tensor.
21} // End this block.