Skip to content

Color and alpha blending bug fix for scenes with transparent gl3d objects #4234

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

Closed
wants to merge 7 commits into from

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Sep 30, 2019

Addressing an old bug in gl3d scenes with transparent objects affected scatter3d, mesh3d, surface, volume and possibly other 3-D traces:
#1267
#3243
#4111

One codepen for comparing before vs after of all 3d mocks with transparency added

Before
After

Before
After

Before
After

Before
After

As well as point clouds (scatter3d plots), this PR improves renderings of volumes and surfaces.

Also please refer to 3632eea that illustrates some issues fixed in this PR.

cc: @plotly/plotly_js

- separate color and alpha blending
- the applied algorithm works for point clouds, surfaces as well as volume rendering
- remove unnecessary calls to axes draw
package.json Outdated
@@ -81,7 +81,7 @@
"gl-mat4": "^1.2.0",
"gl-mesh3d": "^2.1.1",
"gl-plot2d": "^1.4.2",
"gl-plot3d": "^2.2.2",
"gl-plot3d": "git://github.com/gl-vis/gl-plot3d.git#67b5aed84d02429bbc4e8c5a45d4cd23e03280c6",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -6,10 +6,10 @@
"lighting": {
"facenormalsepsilon": 0
},
"opacity": 0.2,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This opacity for a volume trace was too high.

"opacityscale": "extremes",
"colorscale": "Blackbody",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bad colorscale choice for a volume with extreme opacityscale.

@archmoj archmoj added this to the v1.50.0 milestone Sep 30, 2019
@etpinard
Copy link
Contributor

Hmm. At first look, the new baseline for the gl3d_opacity-scaling-spikes mock looks worse than before:

Peek 2019-09-30 10-49

@archmoj can you tell us why this happens? Note that, this mock is used on https://plot.ly/javascript/3d-scatter-plots/

@etpinard
Copy link
Contributor

gl3d_scatter3d_line3d_error3d_enable-alpha-with-rgba-color also looks off:

image

Why are we blending the colors here? Shouldn't blending the opacity be sufficient?

@archmoj
Copy link
Contributor Author

archmoj commented Sep 30, 2019

Hmm. At first look, the new baseline for the gl3d_opacity-scaling-spikes mock looks worse than before:

Peek 2019-09-30 10-49

@archmoj can you tell us why this happens? Note that, this mock is used on https://plot.ly/javascript/3d-scatter-plots/

This happens because we need to blend colors and opacity values while the opacity values (as well as the marker sizes) are too large on this mock.
On the mentioned mock if you reduce marker.opacity values (now at 0.8 and 0.9) or marker sizes values you would get a nice looking point cloud.
codepen

@archmoj
Copy link
Contributor Author

archmoj commented Oct 1, 2019

By applying transparency to our mocks here are some of the cases where this PR can help fix:
Before (left) | After (right)
Screenshot from 2019-09-30 15-38-46
Screenshot from 2019-09-30 16-54-37
Screenshot from 2019-09-30 19-57-41
Screenshot from 2019-09-30 19-58-19
Screenshot from 2019-09-30 20-04-51
Screenshot from 2019-09-30 20-05-40
Screenshot from 2019-09-30 20-14-03

@archmoj
Copy link
Contributor Author

archmoj commented Oct 2, 2019

gl3d_scatter3d_line3d_error3d_enable-alpha-with-rgba-color also looks off:

image

Why are we blending the colors here? Shouldn't blending the opacity be sufficient?

Addressed in 40b1c6c.

@archmoj
Copy link
Contributor Author

archmoj commented Oct 2, 2019

@etpinard would you mind review the changes after 40b1c6c?
It would be great to have it in 1.50.0
Thanks.

@etpinard
Copy link
Contributor

etpinard commented Oct 2, 2019

@archmoj can you explain what you did in 40b1c6c that changed the some scatter3d baselines?

@etpinard
Copy link
Contributor

etpinard commented Oct 2, 2019

Does this underlying mock:

image

have a set opacity? I can't say that either of the before and after rendering look good.

@etpinard
Copy link
Contributor

etpinard commented Oct 2, 2019

This looks off to me:

image

Can you explain why the new baseline is suppositively better?

@archmoj
Copy link
Contributor Author

archmoj commented Oct 2, 2019

This looks off to me:

image

Good call. That one is actually a scatter3d plot!
Fixed by ebc99b8.

@archmoj
Copy link
Contributor Author

archmoj commented Oct 2, 2019

Does this underlying mock:

image

have a set opacity? I can't say that either of the before and after rendering look good.

The opacity values are set to 0.5 for these two mocks.
The one on the left clearly has glitches. I could add another example in that regard.

@archmoj
Copy link
Contributor Author

archmoj commented Oct 2, 2019

@archmoj can you explain what you did in 40b1c6c that changed the some scatter3d baselines?

For point-clouds (including scatter3d and cone) the depth mask is recorded when drawing new points.
Plus in respect to your #4234 (comment) for the mentioned traces alpha is applied (instead of color) for blending rgb values (i.e. similar to what used before).

@archmoj archmoj closed this Nov 10, 2019
@etpinard
Copy link
Contributor

I'm curious @archmoj - what made you close this?

@archmoj
Copy link
Contributor Author

archmoj commented Nov 18, 2019

Am working on another branch to make darker color blending not lighter.

@archmoj archmoj deleted the revise-gl3d-color-and-alpha-blending branch December 3, 2019 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants