diff --git a/zoneb/bin/data/shaders/particles/draw.frag b/zoneb/bin/data/shaders/particles/draw.frag index 80f93d8..6a3db7d 100755 --- a/zoneb/bin/data/shaders/particles/draw.frag +++ b/zoneb/bin/data/shaders/particles/draw.frag @@ -21,10 +21,10 @@ uniform vec3 uHottest3d1; uniform vec3 uBetween; in vec2 texCoordVarying; -in vec3 vPos; -in vec4 vTarget; -in float vTemperature; -in float vAge; +in vec3 gPos; +in vec4 gTarget; +in float gTemperature; +in float gAge; vec3 random3(vec3 c) { @@ -104,16 +104,16 @@ float simplex3d_fractal(vec3 m) { void main() { - vec2 palette = vec2(vTemperature*3425, 0.5); + vec2 palette = vec2(gTemperature*3425, 0.5); vec3 remapedColorW = texture(warm1, palette).xyz; vec3 remapedColorC = texture(cold2, palette).xyz; float d = 80; float D = 600; - 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); + float n = (simplex3d(gPos * vec3(0.01, 0.01, 0.1 * sin(u_time * 0.01)))) * 100; + float rate = 1-smoothstep(D - d, D + d, length(gPos.x + uBetween.x) + n); rate *= uAreThereTwoPeopleTween; vec3 remapedColor = mix(remapedColorC, remapedColorW, rate); - float alpha = max(0, 1 - pow(vAge,4)) * .3; + float alpha = max(0, 1 - pow(gAge,4)) * .2; // if(vTemperature < 0.5) { // alpha *= vTemperature * 2; @@ -122,7 +122,7 @@ void main() // alpha *= 2; // } - if(vPos.z > -200) { + if(gPos.z > -200) { alpha = 0; } vec4 color = vec4(remapedColor, alpha); diff --git a/zoneb/bin/data/shaders/particles/draw.geom b/zoneb/bin/data/shaders/particles/draw.geom new file mode 100644 index 0000000..332837d --- /dev/null +++ b/zoneb/bin/data/shaders/particles/draw.geom @@ -0,0 +1,55 @@ + +layout (points) in; +layout (triangle_strip) out; +layout (max_vertices = 4) out; + +// OF handled uniforms and attributes. +uniform mat4 projectionMatrix; + +// App specific uniforms and attributes. +// uniform float uSpriteSize; + +in vec4 vPosition[]; +in vec2 vTexCoord[]; +flat in int vValid[]; + +out vec2 texCoordVarying; +in vec3 vPos[]; +in vec4 vTarget[]; +in float vTemperature[]; +in float vAge[]; + +// out vec2 gTexCoord; +out vec3 gPos; +out vec4 gTarget; +out float gTemperature; +out float gAge; + +void main() +{ + float uSpriteSize = 1.5; + // if (vValid[0] == 0) return; + + texCoordVarying = vTexCoord[0]; + gPos = vPos[0]; + gTarget = vTarget[0]; + gTemperature = vTemperature[0]; + gAge = vAge[0]; + + for (int i = 0; i < gl_in.length(); ++i) + { + gl_Position = projectionMatrix * (vPosition[i] + vec4(1.0, -1.0, 0.0, 0.0) * uSpriteSize); + EmitVertex(); + + gl_Position = projectionMatrix * (vPosition[i] + vec4(1.0, 1.0, 0.0, 0.0) * uSpriteSize); + EmitVertex(); + + gl_Position = projectionMatrix * (vPosition[i] + vec4(-1.0, -1.0, 0.0, 0.0) * uSpriteSize); + EmitVertex(); + + gl_Position = projectionMatrix * (vPosition[i] + vec4(-1.0, 1.0, 0.0, 0.0) * uSpriteSize); + EmitVertex(); + + EndPrimitive(); + } +} \ No newline at end of file diff --git a/zoneb/bin/data/shaders/particles/draw.vert b/zoneb/bin/data/shaders/particles/draw.vert index 5ff186f..2d9209e 100755 --- a/zoneb/bin/data/shaders/particles/draw.vert +++ b/zoneb/bin/data/shaders/particles/draw.vert @@ -1,4 +1,5 @@ uniform mat4 modelViewProjectionMatrix; +uniform mat4 modelViewMatrix; uniform sampler2DRect particles0; uniform sampler2DRect particles1; uniform sampler2DRect particles2; @@ -7,19 +8,21 @@ uniform sampler2DRect particles3; in vec4 position; in vec2 texcoord; -out vec2 texCoordVarying; +out vec2 vTexCoord; out vec3 vPos; out vec4 vTarget; out float vTemperature; out float vAge; +out vec4 vPosition; void main() { - texCoordVarying = texcoord; - vec4 misc = texture(particles2, texCoordVarying); - vec4 vTarget = texture(particles3, texCoordVarying); + // vTexCoord = vec2(gl_InstanceID % 512, gl_InstanceID / 512); + vTexCoord = texcoord; + vec4 misc = texture(particles2, vTexCoord); + vec4 vTarget = texture(particles3, vTexCoord); vTemperature = misc.x; vAge = misc.y; - vPos = texture(particles0, texCoordVarying).xyz; - gl_Position = modelViewProjectionMatrix * vec4(vPos, 1.0); + vPos = texture(particles0, vTexCoord).xyz; + vPosition = modelViewMatrix * vec4(vPos, 1.0); } diff --git a/zoneb/src/ofApp.cpp b/zoneb/src/ofApp.cpp index 11c1929..654cd18 100644 --- a/zoneb/src/ofApp.cpp +++ b/zoneb/src/ofApp.cpp @@ -365,6 +365,11 @@ void ofApp::draw() if (blendAdd) { ofEnableBlendMode(OF_BLENDMODE_ADD); + ofDisableDepthTest(); + } + else + { + ofEnableDepthTest(); } particles.draw(); if (blendAdd)