Advertisement
Guest User

Shader source

a guest
Jul 7th, 2016
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. Shader "Custom/ColourBleedShader"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. }
  7. SubShader
  8. {
  9.  
  10. Pass
  11. {
  12. Blend One OneMinusSrcAlpha
  13. CGPROGRAM
  14. #pragma vertex vert
  15. #pragma fragment frag
  16.  
  17. #include "UnityCG.cginc"
  18.  
  19. struct appdata
  20. {
  21. float4 vertex : POSITION;
  22. float2 uv : TEXCOORD0;
  23. };
  24.  
  25. struct v2f
  26. {
  27. float2 uv : TEXCOORD0;
  28. float4 vertex : SV_POSITION;
  29. };
  30.  
  31. sampler2D _MainTex;
  32. float4 _MainTex_TexelSize;
  33.  
  34. v2f vert (appdata v)
  35. {
  36. v2f o;
  37. o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  38. o.uv = v.uv;
  39. return o;
  40. }
  41.  
  42. float4 colorBleed (v2f i, sampler2D mainTexture, float4 texelSize)
  43. {
  44. fixed4 tex = tex2D(_MainTex, i.uv);
  45.  
  46. float2 RoffsetUV = float2(i.uv.x - texelSize.x*2, i.uv.y);
  47. float2 BoffsetUV = float2(i.uv.x + texelSize.x*2, i.uv.y);
  48.  
  49. fixed4 rTex = tex2D(_MainTex, RoffsetUV);
  50. fixed4 bTex = tex2D(_MainTex, BoffsetUV);
  51.  
  52. rTex = float4 (rTex.r, 0, 0, 0.5);
  53. bTex = float4 (0, 0, bTex.b, 0.5);
  54. tex = float4 (0, tex.g, 0, 0.5);
  55.  
  56. float2 myuv = float2(i.uv.x+_MainTex_TexelSize.x*5, i.uv.y+_MainTex_TexelSize.x*20);
  57. fixed4 endTex = float4 (rTex + bTex + tex);
  58.  
  59. return endTex;
  60.  
  61. }
  62.  
  63. fixed4 frag (v2f i) : SV_Target
  64. {
  65.  
  66. float4 finalTex = colorBleed(i, _MainTex, _MainTex_TexelSize);
  67.  
  68. return finalTex;
  69.  
  70. //TODO: make picture a bit blurrier, add grain effect, scanlines? CRT screen bend?
  71.  
  72.  
  73. }
  74. ENDCG
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement