HugoPeters1024 / blog

0 stars 0 forks source link

Voronoi shading the web #26

Open HugoPeters1024 opened 1 year ago

HugoPeters1024 commented 1 year ago

https://hugopeters.me/posts/19/

SamHatami commented 1 year ago

Hey! I just was directed to this. But I have a very hard time where you are actually creating the Voronoi diagram? in void main () you start finding distances. But what happens next?

HugoPeters1024 commented 1 year ago

@SamHatami Hey! I just was directed to this. But I have a very hard time where you are actually creating the Voronoi diagram? in void main () you start finding distances. But what happens next?

Hi Sam! Thanks for reading :). In the void main of the fragment shader I find the distances to each point, and keep track of the smallest distance (min_dis), as well as the index of that point (min_id). After the loop we know which point this fragment (pixel) associates with. By using a deterministic function to map this min_id to a color value, each pixel that associates with that same point gets the same color. This forms the voronoi diagram.

Does that clear things up? Feel free to follow up if something is still unclear.

SamHatami commented 1 year ago

Hey, thanks for the quick reply!

No unfortunately not. I'm quite new at computational geometry, and actually don't know anything about shader programming. I'm trying to understand the generation of Voronoi diagrams using either delaunay or Fortunes algorithms. I've probably taken water over my head. But I'll keep digging and trying until I manage something.

Again, Thanks!

FredGannett commented 1 year ago

Can you show some result pictures on this page ? Would brighten it up and make the code more accessible :-)

HugoPeters1024 commented 11 months ago

@FredGannett Can you show some result pictures on this page ? Would brighten it up and make the code more accessible :-)

If your browser supports WebGL2 then the program is actually running right there at the start of the post!