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

Dynamic, transparent, chroma keyS shader

Discussion in 'Shaders' started by Guillaumzed, Dec 10, 2015.

  1. Guillaumzed

    Guillaumzed

    Joined:
    Mar 29, 2015
    Posts:
    70
    Hello !
    I'm new in shaders, I don't know if what I'm trying to do is even feasible.

    I'm wandering if it's possible to make a chroma keyS shader to hide multiple colors of the same, one, texture.
    Let's say I have 256 different colors on my texture, and I want to "hide" 50 of them, by code (by replacing these different colors by a see-through hole or a transparent color)

    Is that possible ?
     
    Last edited: Dec 10, 2015
  2. Flailer

    Flailer

    Joined:
    Apr 1, 2014
    Posts:
    66
    Totally possible, probably not great for someone new. Also might not wanna be a shader for as many as 50 colours. Seems like a nightmare unless you generalise over colour ranges.
     
  3. Guillaumzed

    Guillaumzed

    Joined:
    Mar 29, 2015
    Posts:
    70
    Thanks for your reply !

    No, I don't want to generalize over colour ranges because I have that many colours to deal with ... it's a 2D map with 200 regions (one region = one unique color) which can be switch-off or switch-on, on their own.

    Now I'm dealing with 200 different gameobjects with different textures reassembled as a puzzle to form the big map ... it's already a nightmare to manage, really, but I don't think I'll change for another one :)
     
  4. Flailer

    Flailer

    Joined:
    Apr 1, 2014
    Posts:
    66
    From what you've said, you're only loading the texture once and not changing it loads, so what you could do is generate the texture at run time and store it in memory with as many hidden as you want - have 1 colour reserved as the alpha key - and then just use that as the alpha?

    The problem with doing it in shader is that they don't deal with with indefinite lengths and branching statements which selecting x amount of colours would do, as it kinda ruins their power which is in their parallelism.