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

support RGBA color values #513

Open
lidaof opened this issue Apr 20, 2021 · 8 comments
Open

support RGBA color values #513

lidaof opened this issue Apr 20, 2021 · 8 comments

Comments

@lidaof
Copy link
Contributor

lidaof commented Apr 20, 2021

Is it possible to support RGBA color values? I am trying to color one chain with a color function using resi to assign colors?
I would like resi not selected to be a little bit transparent, tried using RGBA or hex code with alpha not working.

Thanks.

@dkoes
Copy link
Contributor

dkoes commented Apr 21, 2021

opacity can be set as a separate parameter, like here:
https://3dmol.csb.pitt.edu/tests/auto/generate_test.cgi?test=test98

But I agree that also supporting RGBA values would be convenient.

@dkoes
Copy link
Contributor

dkoes commented May 4, 2021

What would be your preferred syntax for specifying rgba in one value? It doesn't seem to be common to use hex.

@lidaof
Copy link
Contributor Author

lidaof commented May 4, 2021

Agree, i think css rgba way is more common. Thanks for consideration.

dkoes added a commit that referenced this issue May 11, 2021
If rgba is provided, a warning message is produced since alpha values
must be specified speparately using an opacity attribute.

Issue #513
@dkoes
Copy link
Contributor

dkoes commented May 11, 2021

I've added support for parsing rgb(a) color specifications, but any alpha value will be ignored and warning message generated on the console saying to use the separate opacity property. Fully supporting rgba would require crawling through any style specification to identify rgba specifiers and creating separate opacity properties.

@lidaof
Copy link
Contributor Author

lidaof commented May 11, 2021

thanks you @dkoes

@lidaof
Copy link
Contributor Author

lidaof commented Jul 31, 2021

Hi @dkoes, rethinking about this issue, is it possible to allow colorfunc to return an object with opacity instead of just a color string? Thank you in advance for consideration.

@jaxmatrix
Copy link
Contributor

I have another thought on this lets not change the way color works but rather the way the shader is processing the color. Inside the fragment shaders we can change varying vec3 vColor to varying vec4 vColor and gl_FragColor = vec4( vColor.x, vColor.y, vColor.z, vColor.w*opacity) this will accommodate both rgba colors along with opacity. And in the renderer loading of the color uniform can be done using this._gl.uniform3f(uniformLoc, uniformVal.r, uniformVal.g, uniformVal.b, uniformVal.a ? uniformVal.a : 1). These are just my initial thoughts, I still don't know what other changes might be required.

@dkoes
Copy link
Contributor

dkoes commented Feb 6, 2023

That only works if everything is properly depth sorted (so everything beneath the transparent fragment has already been drawn to the buffer before you color max). Unfortunately, that's not true (transparency is hard).

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

3 participants