5

I see that Threejs has a Points Material to draw a geometry as points rather than as triangles. However, I want to manipulate the vertices using my own vertex shader, using a Shader Material. In WebGL, I think I could just call gl_drawArrays using gl.Points instead of gl.Triangles. How can I tell the renderer to draw the geometry as points? Is there a better way to go about this?

2 Answers 2

8

little addition, I had no joy until I added gl_PointSize to my vertex shader:

void main(){
    gl_PointSize = 100.;
    gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.);
}

found the answer in the GPU particle system example.

Sign up to request clarification or add additional context in comments.

Comments

5

Found my solution right after asking the question. Just create a THREE.Points object instead of THREE.Mesh using whatever geometry and the Shader Material you want to use.

THREE.Points(geometry, new THREE.ShaderMaterial(parameters));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.