Search Unity

Color Change for texture

Discussion in 'Shaders' started by True-Story, Feb 3, 2014.

  1. True-Story

    True-Story

    Joined:
    Jan 18, 2013
    Posts:
    33
    Greetings!
    I need to change a color of a part of texture (diffuse), wich will not hit on my performance couse this is going on mobiles.
    For example i have a house with red roof and i wanna change it to blue roof.
    How i can do this? with color mask or maybe switch materials on runtime? any ideas? :confused:
     
    Last edited: Feb 3, 2014
  2. Duney

    Duney

    Joined:
    Aug 19, 2013
    Posts:
    170
    Try adding a ColorTint variable and then using Shader.SetGlobalColor("ColorTint") in a script to Red (1,0,0,1) and then multiply your _MainTex (Diffuse Texture) by that value.

    If it's a specific part of the texture, you could just create another texture with the different colour and swap them out at run time.
     
  3. True-Story

    True-Story

    Joined:
    Jan 18, 2013
    Posts:
    33
    yeah tnx, i will try this alpha channel mask.
    Not strong in shaders... maybe somebody have this shader with alpha channel mask for color change? maybe with scroll wheel for change colors?:rolleyes:
    Thank you for your attention :cool:
     
  4. Annihlator

    Annihlator

    Joined:
    Oct 15, 2012
    Posts:
    378
  5. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Do you need to display houses with different coloured roofs at the same time? If not, then creating textures at runtime might be faster than accessing multiple textures every frame.

    That said, the bandwidth used by uncompressed textures (required for runtime editing) might cost more than the two accesses.
     
    Last edited: Feb 4, 2014
  6. True-Story

    True-Story

    Joined:
    Jan 18, 2013
    Posts:
    33
    Yeah i need many colored roofs at the same time.
    Tryed this colored mask shader, perhaps i will need more than 1 material for them all, and than this shader doenst needed, better make nicely colors what i need in diffuses and change thems, cause i have dozens of same objects with 4-5 different colors, so it is anyway minimum 5 materials... i think atlas on run time for them will save me...)

    tnx you guys for answers:cool: