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

Combining Primary Colors?

Discussion in '2D' started by Senladar, Feb 7, 2015.

  1. Senladar

    Senladar

    Joined:
    Jan 1, 2015
    Posts:
    45
    Is there an easy way to combined primary colors?

    I want to update the color value of an object based on the last color value to touch it and it's own value.

    For example, if the object is blue and it gets touched by something that is yellow, I want it to turn green.
     
  2. Senladar

    Senladar

    Joined:
    Jan 1, 2015
    Posts:
    45
    So I've been playing around with this more and can't find any automatic way of doing it. Have read up on some shader stuff, but nothing that I understand currently :)

    I guess for now I'll manually do it through a loop of ifs, unless anyone has any suggestions?
     
  3. bewl

    bewl

    Joined:
    Nov 7, 2014
    Posts:
    1
  4. Senladar

    Senladar

    Joined:
    Jan 1, 2015
    Posts:
    45
    Sadly that does not work :(

    For example, Color.yellow + Color.blue just gives a slightly off white, not green.
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yellow + blue = green only works for RYB subtractive color; computers use RGB additive color, where R + G + B = white.

    --Eric
     
  6. Senladar

    Senladar

    Joined:
    Jan 1, 2015
    Posts:
    45
    Understood.

    Given that, is there any easy way using RGB to get similar results?
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    How many colors do you have? If it's just primary colors, I think a few if/then statements would make more sense than implementing a RYB subtractive color model.

    --Eric
     
  8. Senladar

    Senladar

    Joined:
    Jan 1, 2015
    Posts:
    45
    True. I don't expect that it will be a lot of color combinations (maybe 10-15?).

    Thanks!