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

Use alpha value from vertex colors in LineMaterial and LineGeometry #92

Closed
wants to merge 4 commits into from
Closed

Use alpha value from vertex colors in LineMaterial and LineGeometry #92

wants to merge 4 commits into from

Conversation

albert-schilling
Copy link

@albert-schilling albert-schilling commented Nov 2, 2021

Why

Ability to pass an alpha value as fourth vector component to vertex colors in order to paint a line with varying opacity per vertex.

What

Allowed to set the item size for vertex colors in LineGeomtry and LineSegmentsGeometry.
Extended the shaders in LineMaterial to be able to use the alpha value from the vertex colors.

Checklist

  • Documentation updated
  • Storybook entry added
  • Ready to be merged

There are still some minor issues that should be improved and for which I need some help.
E. g. I used a varying vAlpha to pass the alpha value from the vertex shader to the fragment shader. It should be possible to just use the fourth component from the varying vColor as alpha value. But somehow the size of vColor does not properly adapt. It should be a 4 component vector if USE_COLOR_ALPHA is defined, but somehow it isn't.

Any help would be much appreciated.

@vercel
Copy link

vercel bot commented Nov 2, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pmndrs/three-stdlib/B7wAERGMCY5beH63G381DuoBtwEU
✅ Preview: https://three-stdlib-git-fork-albert-schilling-feat-verte-79e2f7-pmndrs.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 5, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e39eb68:

Sandbox Source
Vanilla Configuration

@CodyJasonBennett
Copy link
Member

I think I'll have to rebase this and use an alpha define. three.js built-in defines and shader magic are very much internal and unstable, the defines in question come from:

@albert-schilling
Copy link
Author

@CodyJasonBennett Thanks for reviewing the PR (after it sat there for a long time untouched and sad ;) ) Have you reimplemented the feature in another way?

@CodyJasonBennett
Copy link
Member

None other than https://github.com/pmndrs/meshline no. The above USE_COLOR_ALPHA defines only apply to vertexColors which three now automatically enables if colors have a length of four or greater. We can't leverage this with custom instanced attributes and have to do so manually.

@albert-schilling
Copy link
Author

Okay, thanks for the explanation!

@CodyJasonBennett
Copy link
Member

Implemented in #335.

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

Successfully merging this pull request may close these issues.

2 participants