Skip to content
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

Add vertex color alpha channel support to LineMaterial #23680

Open
jhurliman opened this issue Mar 8, 2022 · 7 comments
Open

Add vertex color alpha channel support to LineMaterial #23680

jhurliman opened this issue Mar 8, 2022 · 7 comments

Comments

@jhurliman
Copy link
Contributor

Is your feature request related to a problem? Please describe.

I am using Line2 with vertex colors and my data source provides RGBA values, but I cannot support the alpha channel without creating my own copy of LineMaterial.js.

Describe the solution you'd like

#20975 added support for vertex color alpha, but the LineMaterial class assumes vec3 colors only. I would like to see the LineMaterial class natively support vec4 vertex colors.

Describe alternatives you've considered

I've created my own copy of LineMaterial that uses vec4, but automatically doing the correct thing for vec3 and vec4 colors and upstreaming this change would be preferable.

@WestLangley
Copy link
Collaborator

Related: #16570

@Mugen87
Copy link
Collaborator

Mugen87 commented Mar 9, 2022

It was stated in #16570 to not support transparency because of the resulting artifacts.

@jhurliman Don't you experience these in your custom version of LineMaterial?

@jhurliman
Copy link
Contributor Author

@Mugen87 the artifacts are acceptable for my use case (user-generated content).

@WestLangley
Copy link
Collaborator

@Mugen87 if @mrdoob and @gkjohnson agree, we could add opacity and alpha-channel support to Fat Lines.

Some users will be happy... others will complain.

@gkjohnson
Copy link
Collaborator

gkjohnson commented Mar 9, 2022

With two draws (one depth only, one with stencil operations) it's possible to alleviate the corner artifacts though you sacrifice any line overlap rendering. But it does look cleaner:

https://gkjohnson.github.io/threejs-sandbox/fat-line-opacity/webgl_lines_fat.html

It may look odd if a very transparent line is in front of an opaque line, though. I don't have strong opinions either way. Transparent thick lines seem to be something a lot of users ask for.

@jhurliman
Copy link
Contributor Author

@gkjohnson thanks for the pointer, we are using this technique in Foxglove Studio (see https://github.com/foxglove/studio/blob/main/packages/studio-base/src/panels/ThreeDeeRender/renderables/markers/RenderableLineList.ts#L39)

@vincerubinetti
Copy link

vincerubinetti commented Aug 10, 2024

@jhurliman Your link is now broken. I'm guessing that link contains an example where you modified LineMaterial to accept vertex alphas?

I've created my own copy of LineMaterial that uses vec4

On a related note, in my case the overlapping thing isn't an issue because I'm rendering disconnected line segments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants