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

How do D3FC's webgl shaders draw overlapping data? #1756

Open
johncardiologs opened this issue Jul 6, 2022 · 2 comments
Open

How do D3FC's webgl shaders draw overlapping data? #1756

johncardiologs opened this issue Jul 6, 2022 · 2 comments
Labels

Comments

@johncardiologs
Copy link

I'm making a scatterplot using WebGL. The chart uses chartCartesian and webglPlotArea. My use case is roughly similar to @ColinEberhardt 's hathi-explorer.

Say I have two collection of data points that I want to draw on my plot. Some datapoints are in both collections, however I want each collection (series) to be colored (decorated) differently.

My question is this: will the WebGL shaders realize that points in the first collection which overlap with points in the second collection are not to be drawn twice? Or will 'backgrounded' and foregrounded points both be in the webgl context (more data for the GPU to handle = slower performance)?

I am working with over a million points and am trying to figure out whether having duplicates in either collection is a performance issue, or whether WebGl will optimize and avoid redrawing points that have already been drawn.

This article may be relevant: https://webglfundamentals.org/webgl/lessons/webgl-drawing-multiple-things.html

@chrisprice
Copy link
Contributor

chrisprice commented Jul 7, 2022 via email

@johncardiologs
Copy link
Author

johncardiologs commented Jul 7, 2022

I see -- just to confirm, the code that enables alpha blending in your example is the following, right?

gl.blendFuncSeparate(
    gl.DST_COLOR,
    gl.ZERO,
    gl.CONSTANT_ALPHA,
    gl.ZERO
);

In my code, I use the following to decorate my data:

series.decorate((program: Function, data: DataPoint[]) => {
  webglFillColor(color)(program);
});

where color is for instance (1, 0, 0, 0.5). Is this alpha blending? How can I turn alpha blending off otherwise?

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

No branches or pull requests

3 participants