Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

My Fade Post Processing effect doesn't work in 5.6

Discussion in '5.6 Beta' started by PlaguedShadow, Feb 22, 2017.

  1. PlaguedShadow

    PlaguedShadow

    Joined:
    May 1, 2014
    Posts:
    1
    I had a fade effect on my camera to fade in/out. When I was in Unity 5.5 it worked fine, but now that I upgraded to 5.6 it no longer works. Was something changed with how post processing works now?

    Here is the code I am using:


    public class Fade : MonoBehaviour
    {

    [SerializeField]
    private Color _colour = Color.white;

    [SerializeField]
    [Range(0, 10)]
    private float _fadeSpeed;

    [SerializeField]
    [Range(0, 1)]
    private float _alpha;

    [SerializeField]
    private Material _material;

    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
    _material.SetColor("_Color", _colour);
    _material.SetFloat("_Alpha", _alpha);
    Graphics.Blit(source, destination, _material);
    }

    }


    Shader "Post Processing/Fade"
    {
    Properties{
    _Color("Color", Color) = (1,1,1,1)
    _MainTex("Texture", 2D) = "white" { }
    _Alpha("Alpha", Range(0,1)) = 1
    }
    SubShader{
    LOD 200
    Tags
    {
    //"Queue" = "Transparent"
    //"RenderType" = "Transparent"
    }

    Pass{
    Blend SrcAlpha OneMinusSrcAlpha


    CGPROGRAM
    #pragma vertex vert
    #pragma fragment frag

    #include "UnityCG.cginc"

    float4 _Color;
    sampler2D _MainTex;
    float _Alpha;

    struct v2f {
    float4 pos : SV_POSITION;
    float2 uv : TEXCOORD0;
    };

    float4 _MainTex_ST;

    v2f vert(appdata_base v)
    {
    v2f o;
    o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
    return o;
    }

    half4 frag(v2f i) : COLOR
    {
    half4 texcol = tex2D(_MainTex, i.uv);

    texcol = half4(_Color.rgb, _Alpha);
    //texcol.rgb = dot(texcol.rgb, float3(0.3, 0.59, 0.11));

    return texcol;
    }
    ENDCG

    }
    }
    Fallback "Diffuse"
    }
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Use code tags.
     
    m4d and Peter77 like this.
  3. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,904
    I think you need to review the fragment shader logic.