more samples, trim points close to camera...
This commit is contained in:
parent
c97bbf354a
commit
8eadc00377
5 changed files with 48 additions and 18 deletions
|
@ -12,6 +12,8 @@ uniform sampler2DRect cold2;
|
||||||
|
|
||||||
uniform float uAreThereTwoPeopleTween;
|
uniform float uAreThereTwoPeopleTween;
|
||||||
|
|
||||||
|
uniform float u_time;
|
||||||
|
|
||||||
uniform vec3 uHottest0;
|
uniform vec3 uHottest0;
|
||||||
uniform vec3 uHottest1;
|
uniform vec3 uHottest1;
|
||||||
uniform vec3 uHottest3d0;
|
uniform vec3 uHottest3d0;
|
||||||
|
@ -20,6 +22,7 @@ uniform vec3 uBetween;
|
||||||
|
|
||||||
in vec2 texCoordVarying;
|
in vec2 texCoordVarying;
|
||||||
in vec3 vPos;
|
in vec3 vPos;
|
||||||
|
in vec4 vTarget;
|
||||||
in float vTemperature;
|
in float vTemperature;
|
||||||
in float vAge;
|
in float vAge;
|
||||||
|
|
||||||
|
@ -104,13 +107,24 @@ void main()
|
||||||
vec2 palette = vec2(vTemperature*3425, 0.5);
|
vec2 palette = vec2(vTemperature*3425, 0.5);
|
||||||
vec3 remapedColorW = texture(warm1, palette).xyz;
|
vec3 remapedColorW = texture(warm1, palette).xyz;
|
||||||
vec3 remapedColorC = texture(cold2, palette).xyz;
|
vec3 remapedColorC = texture(cold2, palette).xyz;
|
||||||
float d = 50;
|
float d = 80;
|
||||||
float D = 600;
|
float D = 600;
|
||||||
float rate = 1-smoothstep(D - d, D + d, length(vPos.x + uBetween.x) + simplex3d(vPos * vec3(0.001, 0.001, 0.1)) * 100);
|
float n = (simplex3d(vPos * vec3(0.01, 0.01, 0.1 * sin(u_time * 0.01)))) * 100;
|
||||||
|
float rate = 1-smoothstep(D - d, D + d, length(vPos.x + uBetween.x) + n);
|
||||||
rate *= uAreThereTwoPeopleTween;
|
rate *= uAreThereTwoPeopleTween;
|
||||||
vec3 remapedColor = mix(remapedColorC, remapedColorW, rate);
|
vec3 remapedColor = mix(remapedColorC, remapedColorW, rate);
|
||||||
float alpha = max(0, 1 - pow(vAge,4));
|
float alpha = max(0, 1 - pow(vAge,4)) * 1;
|
||||||
|
|
||||||
|
// if(vTemperature < 0.5) {
|
||||||
|
// alpha *= vTemperature * 2;
|
||||||
|
// }
|
||||||
|
// if(vTarget.w >1) {
|
||||||
|
// alpha = 0.1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if(vPos.z > -200) {
|
||||||
|
alpha = 0;
|
||||||
|
}
|
||||||
vec4 color = vec4(remapedColor, alpha);
|
vec4 color = vec4(remapedColor, alpha);
|
||||||
|
|
||||||
fragColor = color;
|
fragColor = color;
|
||||||
|
|
|
@ -2,12 +2,14 @@ uniform mat4 modelViewProjectionMatrix;
|
||||||
uniform sampler2DRect particles0;
|
uniform sampler2DRect particles0;
|
||||||
uniform sampler2DRect particles1;
|
uniform sampler2DRect particles1;
|
||||||
uniform sampler2DRect particles2;
|
uniform sampler2DRect particles2;
|
||||||
|
uniform sampler2DRect particles3;
|
||||||
|
|
||||||
in vec4 position;
|
in vec4 position;
|
||||||
in vec2 texcoord;
|
in vec2 texcoord;
|
||||||
|
|
||||||
out vec2 texCoordVarying;
|
out vec2 texCoordVarying;
|
||||||
out vec3 vPos;
|
out vec3 vPos;
|
||||||
|
out vec4 vTarget;
|
||||||
out float vTemperature;
|
out float vTemperature;
|
||||||
out float vAge;
|
out float vAge;
|
||||||
|
|
||||||
|
@ -15,6 +17,7 @@ void main()
|
||||||
{
|
{
|
||||||
texCoordVarying = texcoord;
|
texCoordVarying = texcoord;
|
||||||
vec4 misc = texture(particles2, texCoordVarying);
|
vec4 misc = texture(particles2, texCoordVarying);
|
||||||
|
vec4 vTarget = texture(particles3, texCoordVarying);
|
||||||
vTemperature = misc.x;
|
vTemperature = misc.x;
|
||||||
vAge = misc.y;
|
vAge = misc.y;
|
||||||
vPos = texture(particles0, texCoordVarying).xyz;
|
vPos = texture(particles0, texCoordVarying).xyz;
|
||||||
|
|
|
@ -112,13 +112,14 @@ void main()
|
||||||
vec3 misc = texture(particles2, texCoordVarying.st).xyz;
|
vec3 misc = texture(particles2, texCoordVarying.st).xyz;
|
||||||
vec4 target = texture(particles3, texCoordVarying.st).xyzw;
|
vec4 target = texture(particles3, texCoordVarying.st).xyzw;
|
||||||
|
|
||||||
float thermo = texture2D(u_v4l2cam, texCoordVarying.st/4).r;
|
float fraction = 8;
|
||||||
|
float thermo = texture2D(u_v4l2cam, texCoordVarying.st/fraction).r;
|
||||||
|
|
||||||
vec2 subPix = mod(texCoordVarying.st / 4, 1.0);
|
vec2 subPix = mod(texCoordVarying.st / fraction, 1.0);
|
||||||
float depth0 = texture(u_depth, texCoordVarying.st/4 - subPix).x;
|
float depth0 = texture(u_depth, texCoordVarying.st/fraction - subPix).x;
|
||||||
float depth1 = texture(u_depth, texCoordVarying.st/4 - subPix + vec2(1, 1)).x;
|
float depth1 = texture(u_depth, texCoordVarying.st/fraction - subPix + vec2(1, 1)).x;
|
||||||
vec4 ray0 = texture(u_world, texCoordVarying.st/4 - subPix);
|
vec4 ray0 = texture(u_world, texCoordVarying.st/fraction - subPix);
|
||||||
vec4 ray1 = texture(u_world, texCoordVarying.st/4 - subPix + vec2(1, 1));
|
vec4 ray1 = texture(u_world, texCoordVarying.st/fraction - subPix + vec2(1, 1));
|
||||||
|
|
||||||
float depth = mix(depth0, depth1, length(subPix));
|
float depth = mix(depth0, depth1, length(subPix));
|
||||||
vec4 ray = mix(ray0, ray1, length(subPix));
|
vec4 ray = mix(ray0, ray1, length(subPix));
|
||||||
|
@ -129,6 +130,7 @@ void main()
|
||||||
posWorld.z = -depth * 65535.0; // Remap to float range.
|
posWorld.z = -depth * 65535.0; // Remap to float range.
|
||||||
posWorld.x = ray.x * posWorld.z;
|
posWorld.x = ray.x * posWorld.z;
|
||||||
posWorld.y = ray.y * posWorld.z;
|
posWorld.y = ray.y * posWorld.z;
|
||||||
|
posWorld.xyz += random3(posWorld.xyz) * 2;
|
||||||
|
|
||||||
float age = misc.y;
|
float age = misc.y;
|
||||||
if(age > 1) { // reached target
|
if(age > 1) { // reached target
|
||||||
|
@ -144,7 +146,7 @@ void main()
|
||||||
target.xyz = pos;
|
target.xyz = pos;
|
||||||
}
|
}
|
||||||
else if (target.w > 0) { // targeted
|
else if (target.w > 0) { // targeted
|
||||||
age += 0.01;
|
age += 10.01;
|
||||||
thermo = misc.x;
|
thermo = misc.x;
|
||||||
}
|
}
|
||||||
else { // wandering
|
else { // wandering
|
||||||
|
@ -159,8 +161,8 @@ void main()
|
||||||
|
|
||||||
// wandering
|
// wandering
|
||||||
vec3 force = vec3(0,0,0);
|
vec3 force = vec3(0,0,0);
|
||||||
float th = 3.1415 * 4 * simplex3d_fractal(vec3(pos.xyz * 0.001));
|
float th = 3.1415 * 4 * simplex3d_fractal(vec3(pos.xyz * 0.01));
|
||||||
float phi = 3.1415 * simplex3d_fractal(pos.xyz * 0.002);
|
float phi = 3.1415 * simplex3d_fractal(pos.xyz * 0.02);
|
||||||
force.x += cos(th) * cos(phi);
|
force.x += cos(th) * cos(phi);
|
||||||
force.y += sin(th) * cos(phi);
|
force.y += sin(th) * cos(phi);
|
||||||
force.z += sin(phi);
|
force.z += sin(phi);
|
||||||
|
@ -168,7 +170,7 @@ void main()
|
||||||
|
|
||||||
if(age < 0.001) { // targetting
|
if(age < 0.001) { // targetting
|
||||||
target.w = 0;
|
target.w = 0;
|
||||||
if(random3(pos).x > pow(length(texCoordVarying.st/4 - uHottest0.st)/5,16*16)+0) {
|
if(random3(pos).x > pow(length(texCoordVarying.st/fraction - uHottest0.st)/5,16*16)+0) {
|
||||||
vec2 h = uHottest1.st;
|
vec2 h = uHottest1.st;
|
||||||
vec4 hray = texture(u_world, h);
|
vec4 hray = texture(u_world, h);
|
||||||
float hdepth = -depth * 65535.0;
|
float hdepth = -depth * 65535.0;
|
||||||
|
@ -182,7 +184,7 @@ void main()
|
||||||
// target.xyz = H + random3(pos);
|
// target.xyz = H + random3(pos);
|
||||||
// target.w = 1;
|
// target.w = 1;
|
||||||
}
|
}
|
||||||
else if(random3(pos).x > pow(length(texCoordVarying.st/4 - uHottest1.st)/5,16*16)+0) {
|
else if(random3(pos).x > pow(length(texCoordVarying.st/fraction - uHottest1.st)/5,16*16)+0) {
|
||||||
vec2 h = uHottest0.st;
|
vec2 h = uHottest0.st;
|
||||||
vec4 hray = texture(u_world, h);
|
vec4 hray = texture(u_world, h);
|
||||||
float hdepth = -depth * 65535.0;
|
float hdepth = -depth * 65535.0;
|
||||||
|
|
|
@ -72,8 +72,8 @@ void ofApp::setupThermal()
|
||||||
void ofApp::setupParticles()
|
void ofApp::setupParticles()
|
||||||
{
|
{
|
||||||
// 1,000,000 particles
|
// 1,000,000 particles
|
||||||
unsigned w = 512*4;
|
unsigned w = 512 * 4 * 2;
|
||||||
unsigned h = 512*4;
|
unsigned h = 512 * 4 * 2;
|
||||||
|
|
||||||
particles.init(w, h, OF_PRIMITIVE_POINTS, false, 4);
|
particles.init(w, h, OF_PRIMITIVE_POINTS, false, 4);
|
||||||
|
|
||||||
|
@ -132,6 +132,7 @@ void ofApp::setupGui()
|
||||||
gui.add(registrationScale.setup("scale", 2.0, 0.1, 3));
|
gui.add(registrationScale.setup("scale", 2.0, 0.1, 3));
|
||||||
gui.add(v4l2Delay.setup("thermo delay", 0, 0, 59));
|
gui.add(v4l2Delay.setup("thermo delay", 0, 0, 59));
|
||||||
gui.add(captureDeviceName.setup("device", "video3"));
|
gui.add(captureDeviceName.setup("device", "video3"));
|
||||||
|
gui.add(blendAdd.setup("blend add", false));
|
||||||
gui.loadFromFile("settings.xml");
|
gui.loadFromFile("settings.xml");
|
||||||
gui.setPosition(10, 10);
|
gui.setPosition(10, 10);
|
||||||
|
|
||||||
|
@ -248,7 +249,8 @@ void ofApp::updateThermal()
|
||||||
areThereTwoPeople = true;
|
areThereTwoPeople = true;
|
||||||
areThereTwoPeopleTween = ofClamp(areThereTwoPeopleTween + 0.02, 0, 1);
|
areThereTwoPeopleTween = ofClamp(areThereTwoPeopleTween + 0.02, 0, 1);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
areThereTwoPeople = false;
|
areThereTwoPeople = false;
|
||||||
areThereTwoPeopleTween = ofClamp(areThereTwoPeopleTween - 0.02, 0, 1);
|
areThereTwoPeopleTween = ofClamp(areThereTwoPeopleTween - 0.02, 0, 1);
|
||||||
}
|
}
|
||||||
|
@ -351,7 +353,15 @@ void ofApp::draw()
|
||||||
fbos.at("ofcam").begin();
|
fbos.at("ofcam").begin();
|
||||||
ofClear(0);
|
ofClear(0);
|
||||||
cam.begin();
|
cam.begin();
|
||||||
|
if (blendAdd)
|
||||||
|
{
|
||||||
|
ofEnableBlendMode(OF_BLENDMODE_ADD);
|
||||||
|
}
|
||||||
particles.draw();
|
particles.draw();
|
||||||
|
if (blendAdd)
|
||||||
|
{
|
||||||
|
ofDisableBlendMode();
|
||||||
|
}
|
||||||
cam.end();
|
cam.end();
|
||||||
fbos.at("ofcam").end();
|
fbos.at("ofcam").end();
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ private:
|
||||||
ofxFloatSlider registrationScale;
|
ofxFloatSlider registrationScale;
|
||||||
ofxIntSlider v4l2Delay;
|
ofxIntSlider v4l2Delay;
|
||||||
ofxInputField<std::string> captureDeviceName;
|
ofxInputField<std::string> captureDeviceName;
|
||||||
|
ofxToggle blendAdd;
|
||||||
ofxPanel gui;
|
ofxPanel gui;
|
||||||
|
|
||||||
ofxToggle calibMode;
|
ofxToggle calibMode;
|
||||||
|
|
Loading…
Reference in a new issue