Advertisement
Guest User

Unity image effect shader boilerplate

a guest
Dec 17th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/ImageEffect"
  2. {
  3.     Properties
  4.     {
  5.         _MainTex ("Texture", 2D) = "white" {}
  6.     }
  7.     SubShader
  8.     {
  9.         Tags { "RenderType"="Opaque" }
  10.         LOD 100
  11.  
  12.         Pass
  13.         {
  14.             CGPROGRAM
  15.             #pragma vertex vert
  16.             #pragma fragment frag
  17.            
  18.             #include "UnityCG.cginc"
  19.  
  20.             struct appdata
  21.             {
  22.                 float4 vertex : POSITION;
  23.                 float2 uv : TEXCOORD0;
  24.             };
  25.  
  26.             struct v2f
  27.             {
  28.                 float2 uv : TEXCOORD0;
  29.                 float4 vertex : SV_POSITION;
  30.             };
  31.  
  32.             sampler2D _MainTex;
  33.             float4 _MainTex_ST;
  34.            
  35.             v2f vert (appdata v)
  36.             {
  37.                 v2f o;
  38.                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  39.                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  40.                 return o;
  41.             }
  42.            
  43.             fixed4 frag (v2f i) : SV_Target
  44.             {
  45.                 // sample the texture
  46.                 fixed4 col = tex2D(_MainTex, i.uv);
  47.  
  48.                 // MODIFY col HERE TO DO STUFF WITH THE IMAGE!
  49.  
  50.                 return col;
  51.             }
  52.             ENDCG
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement