Update: I created a live example here if you guys could take a look: https://jsfiddle.net/r5ymunhs/
Hi all!, I was trying to mimic actual sphere geometries (below) with point cloud of ball sprite
The best I could do is
As you can see, it’s good but not perfect, especially there are “edges” of the sprite. the sprite I used is here:
I guess it’s kind of a dilemma here, where I want the edges to be completely transparent, but the “ball” to be non-transparent at all.
The material I used is
var pointCloudMaterialInstanced = new THREE.RawShaderMaterial( {
uniforms: uniforms,
vertexShader: `
precision highp float;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
attribute vec3 position;
attribute float size;
attribute vec3 customColor;
attribute vec3 offset;
attribute float alpha;
varying float vAlpha;
varying vec3 vColor;
void main() {
vColor = customColor;
vAlpha = alpha;
vec3 newPosition = position + offset;
vec4 mvPosition = modelViewMatrix * vec4( newPosition, 1.0 );
gl_PointSize = size * ( 300.0 / -mvPosition.z );
gl_Position = projectionMatrix * mvPosition;
}`,
fragmentShader: `
precision highp float;
uniform vec3 color;
uniform sampler2D texture;
varying vec3 vColor;
varying float vAlpha;
void main() {
gl_FragColor = vec4( color * vColor, vAlpha );
gl_FragColor = gl_FragColor * texture2D( texture, gl_PointCoord );
}`,
depthTest: true,
transparent: true,
alphaTest: 0.5,
blending: THREE.NormalBlending,
// depthTest: false,
/// transparent: true
});
As you can see, it’s a customized material for instancing pointcloud.
I vaguely knows that I need to play with depthTest, blending, or alpha test, but haven’t been able to figure out the correct solution here yet. could you guys help me? Thanks a lot!