How does one disable interpolation of vertex colors?

new THREE.MeshBasicMaterial( { vertexColors: THREE.VertexColors } );

Trying to get faces with three solid colors instead of gradients.

You’re probably getting something like this:
gradients

because your triangles are sharing vertices (this is called indexed geometry). See the red vertex bleeds color to both tris. Same with the blue vertex, it affects both faces.

What you need to do is make your geometry non-indexed with BufferGeometry.toNonIndexed(). With non-indexed geometry, tris no longer share vertices, so you get three vertices per triangle.

  • Indexed geometry: 2 tris, 4 verts (2 shared in the middle)
  • Non-indexed geometry: 2 tris, 6 verts (no shared vertices)

This way you can make the verts of triangle1 red, red, red, and the verts of triangle2: green, green, green without any color bleeding to another triangle:

solids

4 Likes

Could you provide an explanatory picture of the result?

As there is no feedback from the OP, I’d suppose that there’s something about Voronoi diagram.
I wrote a simple explanatory shader for 4 uv coordinates in a rectangle:

Dots are visual representation of uv coordinates.

But maybe I’m wrong about what the OP wants :slight_smile:

@ prisoner849, better than image.canvas.txt (3.0 KB)

@ marquizzo, I really enjoyed reading your reply. Superb!
But your solution won’t work form me. The script, I’m working is very taxing and can’t switch geo or add vertices.
The Shader that I’m looking for, divides each face to three different colors.

Feel free to check out the txt attachment.

1 Like

Well, it’s questionable that a text file is better than just a single explanatory image.
But anyway, I would achieve the desired result, using that Voronoi diagram :slight_smile:

An example for 3 uv coordinates: Shader - Shadertoy BETA

Another twilight solution:

2 Likes

Backticks to inject shader to script, Nice!! :+1:

I’m afraid there is problem with your script.
I’m assigning different colors to vertices depending on the number of acting bones. That’s 4 colors + 1 for problem vertices.

Running your script, All the colors get replaced.

Looking at

c = vec3(vColor.r >= vColor.g && vColor.r >= vColor.b, vColor.g >= vColor.r && vColor.g >= vColor.b, vColor.b >=vColor.r && vColor.b >= vColor.g);

It seems you are comparing color channels and replacing them with either 1 or 0. That means the shader will produce only 7 colors out of 16.7 mil possible colors.

I changed my color array to match the 7 colors and it works fine.

The shader DOES divide faces at mid-point and centriod, but does not preserve vertex colors.

I see no single image in your post :thinking:

Sorry, I’m still getting used to how to operate this board.
Is there a FAQ on how to post?

Now it’s okay with images :slight_smile:

vertex color no blend

Yeah, no. Thank you :slight_smile: