0

I'm trying to write some GLSL fragment shaders to model physarum bacteria. The simulation works as follows:

  • initiate a 2D array of intensities, all zeroed to start with

  • initiate a certain number of agents at arbitrary positions

  • for each iteration:

    • move each agent to its next position according to some movement function (the movement function isn't important for this question)
    • increase the intensity at each agent's new position by 1
    • dampen all the intensities by a constant factor

Simulating this and treating the intensity values as a grayscale color yields interesting visuals like those in this demo.

I'm not sure how to model this correctly with textures and fragment shaders though.

To move each agent to its next position in a fragment shader, I need a texture where each pixel is an agent, and the R and G color values are the agent's x and y position.

However, to increase the intensity at each agent's new position by 1, I need to be able to query, for each position, "is there an agent there?", which I can't do with the model above.

Thanks for any help!

JonathanR
  • 101
  • 1
  • 1
    you should add image(s) of wanted output as most of us are not microbiologists so we can see what you want to achieve. Also you want single frame or whole animation of some growth which would require more info about how it looks ... the result should be 2D or 3D ? Also you should add your current shaders ... – Spektre Sep 13 '21 at 04:59
  • i've purposefully kept most of the details abstract as i'm just running into the specific modeling problem described above, and would like to figure out the rest by myself. going from a single frame to an animation and from 2d to 3d should be easy. i don't have any current shaders, i'm still at the design stage since i realized the model i came up with intuitively doesn't allow me to write the 2nd step of the loop efficiently. – JonathanR Sep 13 '21 at 06:56
  • 2
    Without at least some details no one could help as we really do not know the goal ... from a simple image search the bacteria looks varies a lot ... the difference between 2D and 3D is also a huge from the modeling aspect as its you either handle [meshes](https://stackoverflow.com/a/53564088/2521214) or just [textures](https://stackoverflow.com/a/29366412/2521214) without narrowing down this would be too broad ... – Spektre Sep 13 '21 at 07:16
  • btw I think you could use [stencil](https://stackoverflow.com/a/39466130/2521214) for the is "agent there" test. Or you could use Alpha channel along with blending to achieve the increments ... however you would need to repeatedly render geometry instead of doing all in single fragment shader or use compute shader instead – Spektre Sep 13 '21 at 07:22

0 Answers0