yutannihilation / wgpugd

A WebGPU Graphics Device for R
https://yutannihilation.github.io/wgpugd/
Other
45 stars 3 forks source link

Use instancing? #11

Closed yutannihilation closed 2 years ago

yutannihilation commented 2 years ago

Instancing should contribute to a better performance especially when a scatter plot contains millions of the same shape of points.

yutannihilation commented 2 years ago

https://sotrh.github.io/learn-wgpu/beginner/tutorial7-instancing/

yutannihilation commented 2 years ago

Actually, the code below crashes my GPU...

wgpugd::wgpugd(10, 10)
col <- scales::alpha(viridisLite::viridis(20, option = "H"), 0.65)
set.seed(16)
plot(runif(300000), col = col, bg = NA, cex = 30, lwd = 50, pch = 21)
dev.off()
yutannihilation commented 2 years ago

If I use instanced rendering, the order of rendering doesn't match with the actual order, so probably depth testing will be needed.

yutannihilation commented 2 years ago

Wait, do I really need to tessellate the circle on CPU...?

yutannihilation commented 2 years ago

Now circles are rendered on GPU's side