Any examples of vertex alpha color?

Are there any examples of using alpha with vertex colors? I can’t seem to get it to work, so I’ve been trying to see some working examples, but I can’t find any.

Want to share what you’ve tried and we can debug? I’m not sure if there are examples using that feature. But it’s very similar to normal vertex colors, just with vec4 rather than vec3. You’ll need to set material.transparent or material.alphaTest or make use of the alpha channel some other way.

1 Like

I think the problem might be related to a shader that I am using ( I forgot it was being used ). It seems to be adjusting the vertex color, so maybe it isn’t taking into account the alpha. I’ll have to investigate it some more…

2 Likes
const cnt = geo.attributes['position'].count;
    const color: any = new THREE.Color('#ff6000');
    const color1: any = new THREE.Color('#00c777');
    geo.setAttribute('color', new THREE.BufferAttribute(new Float32Array(cnt * 4), 4));
    const colors = geo.attributes['color'];

    for (let i = 0; i < (cnt / 3); i++) {

      if (Math.random() > .85) {
        // color.setHSL(Math.random(), 0.7, Math.random() * 0.2 + 0.05);
        colors.setXYZW(i * 3 + 0, color.r, color.g, color.b, 1);
        colors.setXYZW(i * 3 + 1, color.r, color.g, color.b, 1);
        colors.setXYZW(i * 3 + 2, color.r, color.g, color.b, 1);
      } else {
        colors.setXYZW(i * 3 + 0, color1.r, color1.g, color1.b, .1);
        colors.setXYZW(i * 3 + 1, color1.r, color1.g, color1.b, .1);
        colors.setXYZW(i * 3 + 2, color1.r, color1.g, color1.b, .1);
      }
    }