Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Shader with coloured transparent sheets effect

Discussion in 'Shaders' started by AndreasBoye, Jul 20, 2014.

  1. AndreasBoye

    AndreasBoye

    Joined:
    Jul 20, 2014
    Posts:
    3
    Hi,

    I am trying to make a shader that will have the effect of overlaying coloured transparent sheets, e.g. http://www.amazon.com/Impact-Images-Colored-Transparent-Sheets/dp/B003XX99V2. This is the first time dealing with shaders and in my initial attempt I tried to make 2 quads of different colours, each with alpha 0.5 and both facing the camera (this is a 2D project) and then use this shader to mix them:

    Shader"Custom/VertextLit4" {
    Properties {
    _Color ("MainColor", Color) = (1,1,1,1)
    }
    SubShader {
    Tags {"Queue"="Transparent"}
    Pass {
    BlendSrcAlphaOneMinusSrcAlpha
    Material {
    Diffuse [_Color]
    Emission [_Color]
    }
    LightingOn
    }
    }


    The problem is that when the two quads are rendered, it seems that the quad closest to the camera contributes more than the other one, therefore not really blending the colours. Is there any way to blend colours such that the order does not matter? And does it even involve transparency at all?

    Any help on this is much appreciated.
     
  2. drudiverse

    drudiverse

    Joined:
    May 16, 2013
    Posts:
    218
    There are lots of unity commands for adding transparent shaders together, BlendSrcAlphaOneMinusSrcAlpha this line can have many version, i spent a while coding those, it's abit hit and miss when you learn the options


    it would be cool to have a unity reference with pics for all the "blend factors combinations" in table format please Unity!!!! if the documentor personnel is has time to take screens of them and write explanations :D

    technically you have to know how light is filtered by color sheets, it's kind of substracting one wavelength from another, abit confusing for me to explain and figure out,

    do you know how color sheets mix? http://docs.unity3d.com/Manual/SL-Blend.html
     
  3. AndreasBoye

    AndreasBoye

    Joined:
    Jul 20, 2014
    Posts:
    3
    Yes, agree that it would be very cool with some kind over overview of this. I ended up accepting that the layer order did have an effect, but then ensured that the order of sheets would always be the same. If I get around to it I will play around some more with the blending modes and make a post it with some examples.

    Thanks though!