This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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