Hey guys I’m looking for some directions on how to get started with a project that I have and I’m not sure if this is the right place to ask, but here goes.
I’m trying to achieve an effect of liquid paint dripping and flowing through a white canvas. The dripping effect I’m doing it using an asset called Obi Fluid, the effect is pretty cool but now I need to colorize the canvas with the color of the particles used in the obi fluid object.
Is there a way to maybe detect a collision between a particle and the mesh and get the color of the particle and maybe change the color by vertex coordinate, would that be efficient? I would like if someone could point me in the right direction.
It’s very hard to understand the kind of result you are looking for. What exactly does it mean for the canvas to be ‘colorized’? What would the appearance be? Is this a baked effect, or controlled by the player?
Vertex colors tend to operate at the resolution of the mesh, which means that unless you have a mesh with a vertex resolution around the same resolution as the screen pixels, you’ll see jagged fading effect. This might be good enough but until you show us what you want it’s hard to say.
What kind of data object is the obi fluid object? Is it a Unity Particle System?
I think using a RenderTexture would be the best for this. Have a camera view the particle effect head-on to a Rendertexture. The rendertexure can be converted to a texture2D and applied to the canvas.
Imagine you’re standing in front of a white canvas. Then you splash of bucket of paint on it.
Whatever’s left on the canvas and not end up on the floor is intended result.
Render texture won’t produce a correct result, by the way, because canvas is supposed to absorb a portion of paint, flow off the canvas, etc.
What I would probably try first is use vertex colors and touch it up in a normal mapped shader that cleans up the edges, smooths them out and creates a lip at the edge of the liquid. Using compute shaders you could maybe do it all on the texture in real time.
By the way, if you’re just using a simple object such as a flat plane, you can get the uv coordinates of the texture from a mesh collider that has the same UV unwrapping as the mesh, just by using RaycastHit.textureCoord.