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

post effect gives me this strange effect

Discussion in 'General Graphics' started by JohnSonLi, Jan 9, 2015.

  1. JohnSonLi

    JohnSonLi

    Joined:
    Apr 15, 2012
    Posts:
    586
    Code (csharp):
    1.  
    2. public class DungePostEffect : MonoBehaviour {
    3.     public Material mat;
    4.     private void OnRenderImage(RenderTexture src, RenderTexture dest)
    5.     {
    6.         Graphics.Blit(src, dest, mat);
    7.     }
    8. }
    9.  
    shader code of mat
    Code (csharp):
    1.  
    2. Properties {
    3.         _MainTex ("Base (RGB)", 2D) = "white" {}
    4.         _Multiple ("sub", Range(0,1)) = 1
    5.     }
    6.     SubShader {
    7.         Pass
    8.         {
    9.            alphaTest gequal .001
    10.            Blend SrcAlpha OneMinusSrcAlpha
    11.            
    12.             LOD 200
    13.             CGPROGRAM
    14.             #include "UnityCG.cginc"
    15.            sampler2D _MainTex;
    16.            float _Multiple;
    17.            
    18.            struct verData
    19.            {
    20.                float4 vertex:POSITION;
    21.                float2 texcoord:TEXCOORD0;
    22.            };
    23.            
    24.            struct v2f
    25.            {
    26.                float4 pos:SV_POSITION;
    27.                float2 uv:TEXCOORD0;
    28.            };
    29.            
    30.            v2f vert(verData v)
    31.            {
    32.                v2f o;
    33.                o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    34.                o.uv = v.texcoord;
    35.                return o;
    36.            }
    37.            
    38.            half4 frag(v2f i):COLOR
    39.            {
    40.                half4 col = tex2D(_MainTex,i.uv);
    41.                return half4(col.r*_Multiple,col.g*_Multiple,col.b*_Multiple,col.a);
    42.            }
    43.            
    44.            #pragma vertex vert
    45.            #pragma fragment frag
    46.            
    47.             ENDCG
    48.         }
    49.  
    anyone tells me where the problem is?
     
  2. JohnSonLi

    JohnSonLi

    Joined:
    Apr 15, 2012
    Posts:
    586
    .
     

    Attached Files:

    • 37.png
      37.png
      File size:
      665.1 KB
      Views:
      786