I have a 3D scan of a rock that I have represented as a point cloud using Three.js, and I wanted to more explicitly show the features of the rock, perhaps using lighting to show depths with Three. Viewing the rock from the top, I see this:
When looking closely from the side, you can see rigid features that I would like to show more closely:
I am unsure in how to approach this, and was hoping for some help in showing these rock features within this visualization. For context, this is my current shader setup:
vertexShader: `
precision mediump float;
varying vec3 vColor;
attribute float alpha;
varying float vAlpha;
void main() {
vAlpha = alpha;
vColor = color;
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
gl_PointSize = 2.0;
gl_Position = projectionMatrix * mvPosition;
}
`
fragmentShader: `
#ifdef GL_OES_standard_derivatives
#extension GL_OES_standard_derivatives : enable
#endif
precision mediump float;
varying vec3 vColor;
varying float vAlpha;
void main() {
float r = 0.0, delta = 0.0, alpha = 1.0;
vec2 cxy = 2.0 * gl_PointCoord.xy - 1.0;
r = dot(cxy, cxy);
//#ifdef GL_OES_standard_derivatives
delta = fwidth(r);
alpha = vAlpha - smoothstep(vAlpha - delta, vAlpha + delta, r);
//#endif
if (r > 1.0) {
discard;
}
gl_FragColor = vec4(vColor, alpha);
}
//varying vec3 vColor;
//varying float vAlpha;
//void main() {
//gl_FragColor = vec4( vColor, vAlpha );
//}
`
I am creating my point cloud using THREE.Points
, with a BufferGeometry
geometry and ShaderMaterial
material.
Is there a way to go about this more explicitly showing my point cloud depths?
Thank you!