Hi
I’m in need of rendering a unique color per triangle of a mesh, thinking of using a vertexColor buffer.
However, it must be separate from the mesh own vertexColors.
Is it possible to pass such a buffer to a shaderMaterial or custom shader?
I looked around, but was unable to find any information on it, few examples used “vColor” in shader code but turned out to just be a singlular color.
Any examples, documentation, pointers and/or other ideas to achieve it are more than welcome!
Thanks
With a ShaderMaterial, you need to pass the name of your custom attribute through the attributes property of the options parameter passed to the constructor.
Yes, even for the ShaderMaterial material you have some reserved names, like position / normal / uv / color for the attributes, world / projection / … for the uniforms.
If your geometry has a “color” vertex buffer and the mesh is flagged to use vertex colors, you will get a “color” attribute in your shader.
Don’t you have to declare “color” in the attribute list for the shader instance in the constructor though? Otherwise I was under the impression it did not.
Coming back to this looking to increase precision of the triangle display (no blending)
Can we set/use a custom UV buffer in a simular manner to @Evgeni_Popov solution ?