geometry shader test
This commit is contained in:
parent
a61e8d7cb0
commit
c3c55ae4c7
4 changed files with 78 additions and 15 deletions
|
@ -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);
|
||||
|
|
55
zoneb/bin/data/shaders/particles/draw.geom
Normal file
55
zoneb/bin/data/shaders/particles/draw.geom
Normal file
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -365,6 +365,11 @@ void ofApp::draw()
|
|||
if (blendAdd)
|
||||
{
|
||||
ofEnableBlendMode(OF_BLENDMODE_ADD);
|
||||
ofDisableDepthTest();
|
||||
}
|
||||
else
|
||||
{
|
||||
ofEnableDepthTest();
|
||||
}
|
||||
particles.draw();
|
||||
if (blendAdd)
|
||||
|
|
Loading…
Reference in a new issue