Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

How to Start - Flowing paint in a canvas effect - Help needed!

Discussion in 'General Discussion' started by Ulises_P, Dec 8, 2019.

  1. Ulises_P

    Ulises_P

    Joined:
    Feb 4, 2018
    Posts:
    15
    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.

    Thanks for your time community.
     
  2. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,009
  3. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,984
    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?
     
  4. Voronoi

    Voronoi

    Joined:
    Jul 2, 2012
    Posts:
    571
    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.
     
    Kiwasi likes this.
  5. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,325
    The way I understand the request:

    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.
     
  6. Ulises_P

    Ulises_P

    Joined:
    Feb 4, 2018
    Posts:
    15
    Sorry if I were not clear enough, I'm trying to achieve a basic version of something like this:



    Just one color at the time instead of the crazy color mix
     
  7. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,469
    Render texture (source) -> custom render texture (effect)
     
    Ryiah likes this.
  8. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,984
    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.

    This code (well you have to reverse it first) may come in handy for you to find the UV position from world space: http://answers.unity.com/answers/372156/view.html

    Very useful, I used it in a compute shader to generate a seamless planet texture from 3D perlin and voronoi noise.
     
  9. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,149
    Last edited: Dec 9, 2019
  10. Ulises_P

    Ulises_P

    Joined:
    Feb 4, 2018
    Posts:
    15
  11. Billy4184

    Billy4184

    Joined:
    Jul 7, 2014
    Posts:
    5,984
    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.