Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions example-ofxKinect/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "testApp.h"
#include "ofAppGLFWWindow.h"

#include "ofGLProgrammableRenderer.h"

int main() {
ofAppGLFWWindow window;
ofSetCurrentRenderer(ofGLProgrammableRenderer::TYPE);
ofSetupOpenGL(&window, 2048, 768, OF_WINDOW);
ofRunApp(new testApp());

Expand Down
2 changes: 1 addition & 1 deletion src/ofxReprojectionCalibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ void ofxReprojectionCalibration::updateStatusMessages() {
void ofxReprojectionCalibration::drawChessboard(float x, float y, float w, float h) {
if(!chessboardImage.isAllocated() || chessboardImage.getWidth() < w || chessboardImage.getHeight() < h) {
ofLogVerbose("ofxReprojection") << "allocating " << w << "," << h ;
chessboardImage.allocate(w,h,GL_LUMINANCE);
chessboardImage.allocate(w,h,GL_RGB);
updateChessboard();
}
chessboardImage.draw(x,y,w,h);
Expand Down
52 changes: 33 additions & 19 deletions src/ofxReprojectionUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ const string ofxReprojectionUtils::stringGeometryShader2DPoints = "";



const string ofxReprojectionUtils::stringVertexShader2DTriangles = "#version 120\n"
"#extension GL_ARB_texture_rectangle : enable\n"
const string ofxReprojectionUtils::stringVertexShader2DTriangles = "#version 150\n"
STRINGIFY(

// depth_map: R32F format, 32 bit floats in red channel
Expand All @@ -82,52 +81,67 @@ const string ofxReprojectionUtils::stringVertexShader2DTriangles = "#version 12
uniform sampler2DRect color_image;

uniform mat4 transform;

uniform mat4 modelViewProjectionMatrix;

in vec4 position;

out vec3 frontColorVertex;

void main() {
vec4 pos = gl_Vertex;
gl_FrontColor.rgb = texture2DRect(color_image, pos.xy).rgb;
float z = texture2DRect(depth_map, pos.xy).r;
vec4 pos = position;
frontColorVertex.rgb = texture(color_image, pos.xy).rgb;
float z = texture(depth_map, pos.xy).r;
pos.z = z;
pos = pos*transform;
pos.z = z;
gl_Position = gl_ModelViewProjectionMatrix * pos;
gl_Position = modelViewProjectionMatrix * pos;
if(abs(pos.z) < 1e-5) {
gl_FrontColor.rgb = vec3(0,0,0);
frontColorVertex.rgb = vec3(0,0,0);
}
}
);

const string ofxReprojectionUtils::stringFragmentShader2DTriangles = "#version 120\n"
const string ofxReprojectionUtils::stringFragmentShader2DTriangles = "#version 150\n"
STRINGIFY(
in vec3 frontColorGeometry;
out vec4 outputColor;

void main() {
gl_FragColor = gl_Color;
outputColor = vec4(frontColorGeometry, 1);
}
);

// TODO: Clean up this shader a little?
const string ofxReprojectionUtils::stringGeometryShader2DTriangles = "#version 120\n"
"#extension GL_EXT_geometry_shader4 : enable\n"
const string ofxReprojectionUtils::stringGeometryShader2DTriangles = "#version 150\n"
STRINGIFY(
// Pointsize variable used as maximum length of triangle side.
// 0.2 seems like a good value here, but a better measure
// for distortion should be used (TODO)

layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;

in vec3 frontColorVertex[];
out vec3 frontColorGeometry;

uniform float pointsize;
void main() {
vec3 sumcolor = vec3(1,1,1);
for (int i = 0; i < gl_VerticesIn; i++) {
if(gl_FrontColorIn[i].rgb == vec3(0,0,0)) {
for (int i = 0; i < gl_in.length(); i++) {
if(frontColorVertex[i].rgb == vec3(0,0,0)) {
sumcolor = vec3(0,0,0);
}
}

float lena = length((gl_PositionIn[1] - gl_PositionIn[0]).xy);
float lenb = length((gl_PositionIn[2] - gl_PositionIn[0]).xy);
float lenc = length((gl_PositionIn[2] - gl_PositionIn[1]).xy);
float lena = length((gl_in[1].gl_Position - gl_in[0].gl_Position).xy);
float lenb = length((gl_in[2].gl_Position - gl_in[0].gl_Position).xy);
float lenc = length((gl_in[2].gl_Position - gl_in[1].gl_Position).xy);

if(sumcolor != vec3(0,0,0) && lena < pointsize && lenb < pointsize && lenc < pointsize) {
for (int i = 0; i < gl_VerticesIn; i++) {
gl_Position = gl_PositionIn[i];
gl_FrontColor = gl_FrontColorIn[i];
for (int i = 0; i < gl_in.length(); i++) {
gl_Position = gl_in[i].gl_Position;
frontColorGeometry = frontColorVertex[i];
EmitVertex();
}

Expand Down