Include vertex color alpha?
See original GitHub issueDescription of the problem
I’m working with a set of models that use vertex color alpha. Now that threejs uses buffer geometry almost exclusively, adding in vertex color alpha is pretty simple, and it would be nice to see these changes upstream. The changes mostly involve declaring color as a vec4 instead of vec3.
'#ifdef USE_COLOR',
' attribute vec4 color;',
'#endif',
var color_fragment = `
#ifdef USE_COLOR
diffuseColor.rgb *= vColor.xyz;
diffuseColor.a *= vColor.a;
#endif
`;
var color_pars_fragment = "#ifdef USE_COLOR\n\tvarying vec4 vColor;\n#endif\n";
var color_pars_vertex = "#ifdef USE_COLOR\n\tvarying vec4 vColor;\n#endif";
var color_vertex = "#ifdef USE_COLOR\n\tvColor.xyzw = color.xyzw;\n#endif";
Example Without Vertex Color Alpha

Example With Vertex Color Alpha

Three.js version
- [ x ] Dev
- r104
- …
Browser
- All of them
- Chrome
- Firefox
- Internet Explorer
OS
- All of them
- Windows
- macOS
- Linux
- Android
- iOS
Hardware Requirements (graphics card, VR Device, …)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Is it possible to set the vertex color alpha component?
There is no alpha component in vertex colors in Blender. The property is array with size 3, not 4. You can have any...
Read more >How do you use the Alpha channel of Vertex Colors?
The vertex colors do seem to have an alpha channel since you can choose “Add Alpha” or “Erase Alpha” in the blend mode...
Read more >Alpha channel for vertex color — Right-Click Select
Alpha channel for vertex color — Right-Click Select. We can use another vertex color set to define alpha for internal work but what...
Read more >How to set alpha of all vertex colors to 0? : r/blenderhelp - Reddit
I am trying to transfer some vertex groups to the node/shader editor, in order to have a mockup of fur colour before I...
Read more >MSFS - How to see vertex paint alpha channel - FSDeveloper
To see the vertex paint alpha channel you can Add - Input - Vertex Color. Set the source to be Object Data Properties...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Unfortunately, doing that will break all of the existing models that have RGB vertex colors so it’s not that simple.
See previous discussions: #2118 and #6014
It would be nice to revisit this issue and add support for RGBA vertex colors at some point. That would match the glTF spec which supports both RGB and RGBA .
In the meantime, you will need to create a custom shader to achieve this.
@donmccurdy guided me here. I’ll leave my implementation for discussion.
In https://github.com/chubei/three.js/tree/opacity, I added an aOpacity attribute, which is controlled by a shader macro USE_OPACITY, which is then controlled by a material property vertexOpacities (all of this mirrored the implementation of vertex colors).
In this way, users only pay for the vertex opacity attribute if they choose to.