New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include vertex color alpha? #16403
Comments
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. |
Specifically in geometry, buffer.fromGeometry, and then in importers that parse directly to buffers. I suppose that the library would have to declare a warning to indicate upcoming changes if rgba color is going to be implemented. I've read over #6041, though the issue was closed in 2015 for what seem to be technical issues at the time.
I'm glad you agree. Now that Threejs has started moving towards buffer geometry (almost exclusively), it seems like a good time to take the issue into consideration. Another approach would be to add alpha as a separate vec1 attribute, or declare a separate 'colora' vec4 with alpha.
In the meantime I'll continue to clone and add the changes into the existing shaders for the projects I use threejs. It is nice to be able to create a MeshBasicMaterial and have vertex color alpha "just work". |
Related: #14008 (comment). |
I made a short demo that can be viewed here: https://dashgl.gitlab.io/vertexcolor/ Included are three different patterns. buffer geometry, geometry, and buffer.fromGeometry. BufferGeometry is fine, since you're writing the directly, fromGeometry generally requires adding in a 1.0 for the alpha value, and there are no errors being thrown from the geometry. In terms of source code, the changes required seem minimal on a surface level. So I'm guessing the real question is how much of an effect will these small changes have on developer experience and backwards compatibility? |
@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. |
I like @chubei's solution. Hoping he turns it into a PR 🤞🤓 |
@mrdoob Thanks. I'll find time for it this week. |
Maybe |
Description 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.
Example Without Vertex Color Alpha
Example With Vertex Color Alpha
Three.js version
Browser
OS
Hardware Requirements (graphics card, VR Device, ...)
The text was updated successfully, but these errors were encountered: