Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Custom/ColourBleedShader"
- {
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- }
- SubShader
- {
- Pass
- {
- Blend One OneMinusSrcAlpha
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #include "UnityCG.cginc"
- struct appdata
- {
- float4 vertex : POSITION;
- float2 uv : TEXCOORD0;
- };
- struct v2f
- {
- float2 uv : TEXCOORD0;
- float4 vertex : SV_POSITION;
- };
- sampler2D _MainTex;
- float4 _MainTex_TexelSize;
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
- o.uv = v.uv;
- return o;
- }
- float4 colorBleed (v2f i, sampler2D mainTexture, float4 texelSize)
- {
- fixed4 tex = tex2D(_MainTex, i.uv);
- float2 RoffsetUV = float2(i.uv.x - texelSize.x*2, i.uv.y);
- float2 BoffsetUV = float2(i.uv.x + texelSize.x*2, i.uv.y);
- fixed4 rTex = tex2D(_MainTex, RoffsetUV);
- fixed4 bTex = tex2D(_MainTex, BoffsetUV);
- rTex = float4 (rTex.r, 0, 0, 0.5);
- bTex = float4 (0, 0, bTex.b, 0.5);
- tex = float4 (0, tex.g, 0, 0.5);
- float2 myuv = float2(i.uv.x+_MainTex_TexelSize.x*5, i.uv.y+_MainTex_TexelSize.x*20);
- fixed4 endTex = float4 (rTex + bTex + tex);
- return endTex;
- }
- fixed4 frag (v2f i) : SV_Target
- {
- float4 finalTex = colorBleed(i, _MainTex, _MainTex_TexelSize);
- return finalTex;
- //TODO: make picture a bit blurrier, add grain effect, scanlines? CRT screen bend?
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement