Search Unity

Question How a color gradient between 3 to 5 points be made

Discussion in 'General Graphics' started by Mhmd-Subhi, Apr 16, 2021.

  1. Mhmd-Subhi

    Mhmd-Subhi

    Joined:
    Mar 13, 2015
    Posts:
    28
    Hello everyone,

    I have a texture as seen below:



    Box positions and sizes are not fixed, and can be changed by the user. I want to fill-in the black pixels between them with a gradient depending on the surrounding boxes.

    I am thinking of something like gaussian blur, but I didn't try anything currently.
     
    Last edited: Apr 16, 2021
  2. RyanKeable

    RyanKeable

    Joined:
    Oct 16, 2013
    Posts:
    62
    A gaussian blur seems like a good place to start?

    Otherwise you have to write out a 2D ray caster that can interpoltate between the edges of each box as they move
     
  3. Mhmd-Subhi

    Mhmd-Subhi

    Joined:
    Mar 13, 2015
    Posts:
    28
    Thanks very much, I tried gaussian blur and it worked like a charm.

    For the future if anybody have the same problem, you can also check the answer in the comment on this post:
    https://stackoverflow.com/questions/67129876/how-can-a-color-gradient-between-3-to-5-points-be-made

    It presents a reference for other algorithms aside from using blur.
     
  4. RyanKeable

    RyanKeable

    Joined:
    Oct 16, 2013
    Posts:
    62
    great resource in the link thank you