This commit is contained in:
micuat 2020-10-20 11:16:21 +02:00
parent 99257694cb
commit ea8d680277
6 changed files with 37 additions and 11 deletions

View file

@ -105,7 +105,7 @@ void main() {
// dispColor.rgb = vec3(depthToSilhouette(texture2D(u_depth, st/u_resolution).r)); // dispColor.rgb = vec3(depthToSilhouette(texture2D(u_depth, st/u_resolution).r));
gl_FragColor = vec4(dispColor, 1.0); gl_FragColor = vec4(dispColor, 1.0);
gl_FragColor += pointCloudColor; // not good gl_FragColor += pointCloudColor; // not good
gl_FragColor = pointCloudColor; // not good gl_FragColor = vec4(pointCloudColor.rgb, 1.0); // not good
// gl_FragColor = texture2D(u_v4l2cam, st/3); // gl_FragColor = texture2D(u_v4l2cam, st/3);

View file

@ -4,6 +4,7 @@ precision mediump float;
uniform sampler2D u_depth; uniform sampler2D u_depth;
uniform sampler2D u_world; uniform sampler2D u_world;
uniform sampler2D u_v4l2cam;
uniform ivec2 uFrameSize; uniform ivec2 uFrameSize;
uniform ivec2 uDepthFrameSize; uniform ivec2 uDepthFrameSize;
@ -117,6 +118,18 @@ void main() {
if(depth < 0.012) vValid = 0; if(depth < 0.012) vValid = 0;
if(depth > 0.04) vValid = 0; if(depth > 0.04) vValid = 0;
vec2 v4l2st = st;
v4l2st /= 3;
v4l2st -= vec2(0.5);
v4l2st *= 1.45;
v4l2st += vec2(0.5);
v4l2st.s += 0.15;
v4l2st.t += 0.16;
float thermo = texture2D(u_v4l2cam, v4l2st).r;
vec4 pos = texture2D(u_buffer1, st);
float age = pos.w;//mod(pos.w, 100);
float lastThermo = floor(pos.w / 100);
if(vValid == 1 && mod(u_time * 3 + random3(vec3(v_texcoord, 0)).r, 1.0) < 0.5) { if(vValid == 1 && mod(u_time * 3 + random3(vec3(v_texcoord, 0)).r, 1.0) < 0.5) {
vec4 posWorld = vec4(1); vec4 posWorld = vec4(1);
@ -127,19 +140,21 @@ void main() {
// Flip X as OpenGL and K4A have different conventions on which direction is positive. // Flip X as OpenGL and K4A have different conventions on which direction is positive.
posWorld.x *= -1; posWorld.x *= -1;
// float tmp = mix(texture2D(u_depth, st).r, texture2D(u_buffer1, st).r, 0.9); // float tmp = mix(texture2D(u_depth, st).r, texture2D(u_buffer1, st).r, 0.9);
// color = vec4(vec3(tmp), 1.0); // color = vec4(vec3(tmp), 1.0);
color.rgb = posWorld.rgb; color.rgb = posWorld.rgb;
color.a = vValid; // color.a = thermo * 100;//vValid;
color.a = 0.1;
} }
else { else {
vec4 pos = texture2D(u_buffer1, st); float th = 3.1415 * 4 * simplex3d_fractal(vec3(pos.xyz * 0.001 + vec3(0, 0, u_time * 0.01)));
float th = 3.1415 * 4 * simplex3d_fractal(pos.xyz * 0.001);
float phi = 3.1415 * simplex3d_fractal(pos.xyz * 0.002); float phi = 3.1415 * simplex3d_fractal(pos.xyz * 0.002);
pos.x += cos(th) * cos(phi) * 7; pos.x += cos(th) * cos(phi) * 7;
pos.y += sin(th) * cos(phi) * 7; pos.y += sin(th) * cos(phi) * 7;
pos.z += sin(phi) * 7; pos.z += sin(phi) * 7;
// age = min(1, age + 0.01);
pos.w = age;
color = pos; color = pos;
} }
@ -154,8 +169,8 @@ void main() {
gl_FragColor = texture2D(u_buffer0, st); gl_FragColor = texture2D(u_buffer0, st);
#else #else
// Main Buffer // Main Buffer
vec3 buf1 = texture2D(u_buffer1, st).rgb; vec4 buf1 = texture2D(u_buffer1, st);
gl_FragColor = vec4(buf1, 1.0); gl_FragColor = buf1;
#endif #endif

View file

@ -10,6 +10,7 @@ uniform sampler2D u_gradient;
uniform sampler2D u_particle; uniform sampler2D u_particle;
in vec2 gTexCoord; in vec2 gTexCoord;
in float gTemperature;
void main() void main()
{ {
@ -20,7 +21,7 @@ void main()
st += vec2(0.5); st += vec2(0.5);
st.s += 0.15; st.s += 0.15;
st.t += 0.16; st.t += 0.16;
float thermo = texture2D(u_v4l2cam, st).r; float thermo = gTemperature;//texture2D(u_v4l2cam, st).r;
gl_FragColor = vec4(texture2D(u_gradient, vec2(thermo, 0.5)).rgb, 1); gl_FragColor = vec4(texture2D(u_gradient, vec2(thermo, 0.5)).rgb, 1);
// gl_FragColor = texture2D(u_particle, gTexCoord); // gl_FragColor = texture2D(u_particle, gTexCoord);
// gl_FragColor = vec4(1); // gl_FragColor = vec4(1);

View file

@ -16,6 +16,9 @@ in vec4 vPosition[];
in vec2 vTexCoord[]; in vec2 vTexCoord[];
flat in int vValid[]; flat in int vValid[];
in float vTemperature[];
out float gTemperature;
out vec2 gTexCoord; out vec2 gTexCoord;
void main() void main()
@ -23,6 +26,7 @@ void main()
if (vValid[0] == 0) return; if (vValid[0] == 0) return;
gTexCoord = vTexCoord[0]; gTexCoord = vTexCoord[0];
gTemperature = vTemperature[0];
for (int i = 0; i < gl_in.length(); ++i) for (int i = 0; i < gl_in.length(); ++i)
{ {

View file

@ -21,6 +21,8 @@ out vec4 vPosition;
out vec2 vTexCoord; out vec2 vTexCoord;
flat out int vValid; flat out int vValid;
out float vTemperature;
void main() void main()
{ {
vTexCoord = vec2(gl_InstanceID % uFrameSize.x, gl_InstanceID / uFrameSize.x) / uDepthFrameSize; vTexCoord = vec2(gl_InstanceID % uFrameSize.x, gl_InstanceID / uFrameSize.x) / uDepthFrameSize;
@ -29,8 +31,11 @@ void main()
// vValid = (depth != 0 && ray.x != 0 && ray.y != 0) ? 1 : 0; // vValid = (depth != 0 && ray.x != 0 && ray.y != 0) ? 1 : 0;
vec4 posWorld = vec4(1); vec4 posWorld = texture2D(u_particle, vTexCoord);
posWorld = texture2D(u_particle, vTexCoord);
vTemperature = posWorld.w;
posWorld.w = 1;
// posWorld.xyz *= 65535; // posWorld.xyz *= 65535;
// // posWorld.xy = vTexCoord * 10000; // // posWorld.xy = vTexCoord * 10000;

View file

@ -69,7 +69,7 @@ void ofApp::setup()
boundShader.load("shaders/bound.frag"); boundShader.load("shaders/bound.frag");
fbos.insert({"ofcam", ofFbo()}); fbos.insert({"ofcam", ofFbo()});
fbos.at("ofcam").allocate(ofGetWidth(), ofGetHeight(), GL_RGB32F_ARB); fbos.at("ofcam").allocate(ofGetWidth(), ofGetHeight(), GL_RGBA32F_ARB);
gradient.load("gradient.png"); gradient.load("gradient.png");
} }
@ -162,6 +162,7 @@ void ofApp::draw()
auto wtex = kinectDevice.getDepthToWorldTex(); auto wtex = kinectDevice.getDepthToWorldTex();
particleShader.setUniformTexture("u_depth", dtex); particleShader.setUniformTexture("u_depth", dtex);
particleShader.setUniformTexture("u_world", wtex); particleShader.setUniformTexture("u_world", wtex);
particleShader.setUniformTexture("u_v4l2cam", v4l2Tex);
particleShader.setUniform2i("uFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight()); particleShader.setUniform2i("uFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight());
particleShader.setUniform2i("uDepthFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight()); particleShader.setUniform2i("uDepthFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight());
particleShader.render(); particleShader.render();