I

create a glue shader that glues different objects!

Italianes

I want to create a shader that visually glues different objects together

objects are particles

each particle occupies a cell in the overall grid

all particles see each other in this grid

all particles have a common class and they are all from a common subclass

every particle is a square like in the game noitia

visually it looks like sand from that game

but I want to make a shader that will visually make this sand not square like there, but like a heap with round edges

so that it would be possible to create some kind of shape along the edges of the particles, and in general, so that it would be possible to control the shape, let’s say make bushes along the edges, etc.

also, for example, to make adhesions between water particles, for example, if two particles are located through a cell or two, then there would be mucus between them, for example, and so on

The question is how can this be implemented and where to look?

Thanks

  • Nathan Lovato replied

    Hi,

    This is a bit too far outside of my area of expertise, as it sounds complex and quite unique, so I'll try to share some ideas that might help you get started, but it's hard to know how to do something like this without a lot of experimentation and iteration.

    Generally, to make blobs that kind of connect, the easiest way is to draw particles with a soft texture and to use a shader to harden the pixel transition based on how opaque drawn pixels are. This is called a "threshold" operation, which you can achieve using the smoothstep() shader function. It's a common way to make things look like they're made of blobs.

    Here's an example image I found here: https://patomkin.com/blog/metaball-tutorial/

    1.png

    In 3D, this concept is called metaball, and it seems some people use this keyword in 2D as well. This technique could be useful if I understood what you're trying to achieve correctly.

    Now, the thing is, it sounds like you want way more than that, in particular, to draw different visuals between or around your particles depending on how they're arranged. I think this would probably require doing calculations on the CPU to figure out what to draw, and then drawing it using a shader. And the logic for that would be pretty unique, you would have to iterate to achieve this.

    Best of luck in your research!