Skip to content

Instantly share code, notes, and snippets.

@luruke
Created October 25, 2019 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luruke/b713d854fe004d20f9a1650e8083518c to your computer and use it in GitHub Desktop.
Save luruke/b713d854fe004d20f9a1650e8083518c to your computer and use it in GitHub Desktop.
this.geometry = new BufferGeometry();
this.geometry.addAttribute('position', new BufferAttribute(ids, 1));
this.material = new RawShaderMaterial({
name: 'Particles',
fragmentShader: `
precision highp float;
void main() {
gl_FragColor = vec4(0.584,0.052,0.880, 1.0);
}
`,
vertexShader: `
precision highp float;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
uniform float uTime;
uniform sampler2D uData;
attribute float position;
varying float vInfo;
float when_gt(float x, float y) {
return max(sign(x - y), 0.0);
}
void main() {
vec4 data = texture2D(uData, vec2(position, 0.0));
vec3 pos = data.xyz;
vInfo = data.a;
gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);
gl_PointSize = mix(0.8, 1.0, when_gt(fract(vInfo), 0.8));
}
`,
transparent: true,
uniforms: {
uTime: { value: 0 },
uData: { value: this.fbo.target },
},
});
this.mesh = new Points(this.geometry, this.material);
this.mesh.frustumCulled = false;
const SIZE_BUFFER = 512;
this.scene = new Scene();
this.rt = new WebGLRenderTarget(SIZE_BUFFER, SIZE_BUFFER);
this.scene.add(this.mesh);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment