Skip to content

Commit 389764b

Browse files
committed
shaders for prtls in domain
1 parent edbeddb commit 389764b

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

docs/js/scripts/domains.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,26 @@ document.addEventListener(
361361
"color",
362362
new THREE.BufferAttribute(prtl_colors, 3),
363363
);
364-
const material = new THREE.PointsMaterial({
365-
sizeAttenuation: true,
366-
size: 0.2,
367-
vertexColors: true,
364+
const material = new THREE.ShaderMaterial({
365+
depthWrite: false,
366+
transparent: true,
367+
vertexShader: `
368+
attribute vec3 color;
369+
varying vec3 vColor;
370+
void main() {
371+
vColor = color;
372+
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
373+
gl_PointSize = 100.0 / -mvPosition.z;
374+
gl_Position = projectionMatrix * mvPosition;
375+
}
376+
`,
377+
fragmentShader: `
378+
varying vec3 vColor;
379+
void main() {
380+
float dist = distance(gl_PointCoord, vec2(0.5, 0.5));
381+
gl_FragColor = vec4(vColor, step(dist, 0.5));
382+
}
383+
`,
368384
});
369385
const mesh = new THREE.Points(prtl_geometry, material);
370386
scene.add(mesh);

0 commit comments

Comments
 (0)