ポイントセットシェーダー
attribute vec3 position;
attribute vec3 color;
uniform float time;
uniform float size;
uniform mat4 modelViewMatrix;
uniform mat4 modelViewMatrixInverse;
uniform mat4 modelViewProjectionMatrix;
varying float fragAlpha;
void main()
{
float lifetime = color.r * 4.0;
float shift = color.g;
float t = fract(time / lifetime + shift);
float c = pow(t, 1.7) * 10.0;
float s = ceil(c);
float y = (1.0 - pow((s - c) * 2.0 - 1.0, 2.0)) / (s * s);
fragAlpha = 1.0 - smoothstep(0.8, 1.0, t);
vec3 p;
p.x = position.x * t;
p.y = position.y * y;
p.z = position.z * t;
vec4 mvPosition = vec4(p, 1.0);
gl_Position = modelViewProjectionMatrix * mvPosition;
float r = length(p);
if(r < 1.0) r = 256.0;
gl_PointSize = size * (256.0 / r) * (1.0 + smoothstep(0.8, 1.0, t) * 6.0);
}
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
uniform vec3 matCol;
uniform sampler2D tex;
varying float fragAlpha;
void main()
{
vec4 texCol = texture2D(tex, gl_PointCoord);
float sq = 1.4142135623;
vec2 p = (gl_PointCoord - 0.5) * 2.0;
float r = (1.0 - length(p) / sq) * 1.5;
vec4 col = vec4(matCol, fragAlpha);
col.r = col.r * r * 0.9;
col.g = col.g * r * 0.9;
col.b = col.b * r * 0.9;
col.a = col.a * r * 0.9;
//col.r = texCol.r * col.r * r * 0.9;
//col.g = texCol.g * col.g * r * 0.9;
//col.b = texCol.b * col.b * r * 0.9;
//col.a = texCol.a * col.a * r * 0.9;
col = clamp(col, 0.0, 1.0);
gl_FragColor = mix(col, texCol, 0.3);
//gl_FragColor = col;
}
戻る