-1
我想調整這個ShaderToy example頂點創建'火花' 他們。已嘗試玩gl_PointCoord
和gl_FragCoord
沒有任何結果。也許,這裏有人可以幫助我?GLSL點燃頂點着色器
我需要類似這樣的gif動畫效果:
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
#define M_PI 3.1415926535897932384626433832795
float rand(vec2 co)
{
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
void main() {
float size = 30.0;
float prob = 0.95;
vec2 pos = floor(1.0/size * gl_FragCoord.xy);
float color = 0.0;
float starValue = rand(pos);
if (starValue > prob)
{
vec2 center = size * pos + vec2(size, size) * 0.5;
float t = 0.9 + sin(time + (starValue - prob)/(1.0 - prob) * 45.0);
color = 1.0 - distance(gl_FragCoord.xy, center)/(0.5 * size);
color = color * t/(abs(gl_FragCoord.y - center.y)) * t/(abs(gl_FragCoord.x - center.x));
}
else if (rand(gl_FragCoord.xy/resolution.xy) > 0.996)
{
float r = rand(gl_FragCoord.xy);
color = r * (0.25 * sin(time * (r * 5.0) + 720.0 * r) + 0.75);
}
gl_FragColor = vec4(vec3(color), 1.0);
}
據我瞭解有VEC 2 POS玩,將其設置爲頂點位置。
將設置爲
fragCoord.xy/iResolution.xy
適應[THREE.PointsMaterial](https://github.com/mrdoob/three.js/blob/dev/src/materials/PointsMaterial.js)並不容易?看看點[three.js示例](https://threejs.org/examples/)。 – 2pha