Search Unity

Progressive texture flood fill effect

Discussion in '2D' started by aev, Sep 6, 2015.

  1. aev

    aev

    Joined:
    Sep 2, 2015
    Posts:
    7
    Hello,

    I am working on a paint program and am implementing the TextureFloodFill extension with FloodFillBorder method available at http://wiki.unity3d.com/index.php?title=TextureFloodFill.

    The method works fine however I would like to modify it so that we can see the algorithm working, so that when an area is clicked, the paint slowly fills up the region starting from the point clicked until it gets to the edges, as in this animation: https://en.wikipedia.org/wiki/Flood_fill#/media/File:Wfm_floodfill_animation_queue.gif

    Is it possible to modify TextureFloodFill to achieve this effect, or is there another way I can do this?

    Thanks!
     
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    You would have to maybe keep a count of how many pixels you've filled, start over in each frame with no pixels filled, and fill up to that many pixels... then in the next frame do more pixels, until you're totally done. But flood fill algorithms usually don't just go `bottom up` they recurse, which may not be the effect you're after.
     
  3. aev

    aev

    Joined:
    Sep 2, 2015
    Posts:
    7
    Thanks. Could you tell me exactly how I might modify the code just to see how this particular algorithm is working?

    I tried inserting the lines

    aTex.SetPixels(colors);
    aTex.Apply();

    inside the while and for loops, hoping it would update the texture while progressing through the algorithm, however it did not work.
     
  4. GameforU

    GameforU

    Joined:
    Feb 8, 2019
    Posts:
    2
    i also looking this process of filling.. if you find then through light toward me
    thanks in advance.
     
  5. cdr9042

    cdr9042

    Joined:
    Apr 22, 2018
    Posts:
    173