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 Regl customizes the shape of Points? #657

Open
Knell0714 opened this issue Sep 19, 2022 · 1 comment
Open

How Regl customizes the shape of Points? #657

Knell0714 opened this issue Sep 19, 2022 · 1 comment

Comments

@Knell0714
Copy link

Because of the huge amount of data, I switched from SVG to WebGL. But I need to render Points of different shapes in the same Canvas, how does Regl do it, thanks!

@rreusser
Copy link
Member

Hi, @Knell0714! There's not a single answer to your question, and regl (or more generally, webgl) doesn't enforce any choices here. Point primitives work fine up to the maximum permitted size, but beyond that you might need to use two triangles to make a quad (instanced rendering might help here). Points are probably a perfect adequate place to start though. Then for each point, you could either apply a texture directly, or you could use the strategy used in regl-scatter2d and compute an SDF from an SVG or bitmap, see: svg-path-sdf, bitmap-sdf. Then you can just adjust the colors using the SDF value to get the look you want.

I made an example of this strategy here: https://observablehq.com/@rreusser/sdf-points-with-regl

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

No branches or pull requests

2 participants