Search Unity

need help with screen blendmode layer alpha

Discussion in 'Shaders' started by Taran3D, Apr 24, 2018.

  1. Taran3D

    Taran3D

    Joined:
    Jun 13, 2013
    Posts:
    4
    hi have a shader that will screen each layer on top of the other but I'm struggling to add an alpha option so that I can dim the texture layer 1 either with alpha multiplier or even with a colour picker so i can fade it to black.

    Code (CSharp):
    1. fixed4 frag(VertexToFragment i) : COLOR {
    2.                 //Multitexturing Shader - Start with Layer 0
    3.                 fixed4 Result = tex2D(_Texture0, i.uv);        //Start with Texture Layer 0 as-is
    4.                 fixed4 Pixel;                                //Temporary pixel from texture layer
    5.                 //Screen Layer 1
    6.                 Pixel=tex2D(_Texture1, i.uv);                //Read pixel from Layer 1
    7.                 Result = fixed4(1.0-((1.0-Result.r)*(1.0-Pixel.r)), 1.0-((1.0-Result.g)*(1.0-Pixel.g)), 1.0-((1.0-Result.b)*(1.0-Pixel.b)), Result.a);    //Screen this texture with the previous result
    any help would be appreciated as i'm really struggling with this

    thanks

    taran