Interactive texture modification (such as fluid mixing) in Unity

I am working on a game where I want to allow users to mix multiple colors (similar to shown in this video):

.

I have the following questions:

  • I am expecting that this is done using shaders. What kind of shader I have to use for such implementation? What will be the logic to create this type of shader?
  • Are there any other ways using which this feature can be implemented?
  • Are there any open source tutorials or examples?

I would appreciate any suggestions and thoughts on this topic. Thank you.

2D fluid simulation is what you’re looking for. Can be done with pixel or compute shaders. Here’s an open source example for Unity:

Thank you for your reply @OCASM . I tried the plugin suggested by you. I was able to simulate the fluid mixing effect but I facing one issue described here.

Have you used this plugin in any project? if yes, did you face such a problem?

Honestly I haven’t tried it myself so I can’t be of help there.

hey there! I know it’s been a while, but I’m struggling now with the same task for my university:
I need to simulate fluids in unity in a way, that it is simulated in a repo you’ve used. But only need to do it in a way you need to (on some mesh). Did you eventually come to any solution on this topic? I am stuck and desperate and any help would be appreciated!

You can start googling for “GDGPU fluids” or “GDGPU 2d fluids”. The algorithms should be well known by now, as they appeared for the first at least a decade ago, and were part of gpu gems book series.

Yeah that doesn’t help at all. I’ve studied how the algorithm works (Based on Navier-Stocks) and have an example of implementation in unity (keijiro repo) but my problem is in implementing this shader to work on mesh surfaces.

WHAT problem though? We aren’t psychic.

You are not. But the question was adressed not to you, huh? It was adressed to a person, who already had the same problem and the same experience. No need to be rude

That same person literally hasn’t been on the forum for nearly a year. That tends to happen when you necro a two year old thread posted in the wrong forum.

But this is a public forum and there might be others who have experienced it who haven’t spoken up yet. There are also some very smart and helpful people here who might have a suggestion or idea even if they haven’t directly experienced it.

Even in the future there might be someone who experiences it, and finds this thread, and would be able to help if you had given more details.

Your attitude is self-defeating.

Thanks for letting me know, I’ve axed the original reply.

Not sure that’s exactly what you want but have you seen FluXY on the asset store? It has some examples that apply to meshes.

In the end the output of such simulations are a texture and a texture can be used quite directly in a shader.

Thanks mate! Yup, they did exactly what i wanted to achieve