Advertisement
Guest User

Untitled

a guest
May 28th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. Shader "Hidden/NewImageEffectShader"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. _EffectScaler ("Effect Scaler", float) = 0
  7. _EffectLerp ("Effect Lerp", float) = 0
  8. }
  9. SubShader
  10. {
  11. // No culling or depth
  12. Cull Off ZWrite Off ZTest Always
  13.  
  14. Pass
  15. {
  16. CGPROGRAM
  17. #pragma vertex vert
  18. #pragma fragment frag
  19.  
  20. #include "UnityCG.cginc"
  21.  
  22. struct appdata
  23. {
  24. float4 vertex : POSITION;
  25. float2 uv : TEXCOORD0;
  26. };
  27.  
  28. struct v2f
  29. {
  30. float2 uv : TEXCOORD0;
  31. float4 vertex : SV_POSITION;
  32. float4 scrPos:TEXCOORD1;
  33. };
  34.  
  35. v2f vert (appdata v)
  36. {
  37. v2f o;
  38. o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
  39. o.uv = v.uv;
  40. o.scrPos = ComputeScreenPos(o.vertex);
  41. return o;
  42. }
  43.  
  44. sampler2D _MainTex;
  45. uniform half4 _MainTex_TexelSize;
  46. sampler2D _CameraDepthTexture;
  47. float _EffectScaler;
  48. float _EffectLerp;
  49.  
  50. fixed4 frag (v2f i) : SV_Target
  51. {
  52. // pixel to uv ratios
  53. float pr_x = 1 / _MainTex_TexelSize.x;
  54. float pr_y = 1 / _MainTex_TexelSize.y;
  55.  
  56. fixed4 col = tex2D(_MainTex, i.uv);
  57. fixed4 ogCol = col;
  58.  
  59. float ogColPowerScaler = ogCol.x;//length(ogCol);
  60. float depth = pow(1 - Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv)), 10);
  61.  
  62. float2 offsetCoord_1 = float2(i.uv.x + frac(i.uv.y/7) * _EffectScaler * ogColPowerScaler, i.uv.y);
  63. float2 offsetCoord_2 = float2(i.uv.x - frac(i.uv.y / 7) * _EffectScaler * ogColPowerScaler, i.uv.y);
  64.  
  65. fixed4 samp_1 = tex2D(_MainTex, offsetCoord_1);
  66. fixed4 samp_2 = tex2D(_MainTex, offsetCoord_2);
  67.  
  68. fixed4 effectCol_1 = (depth *ogCol + samp_1 + samp_2) /3;
  69.  
  70. //col = pow( 1- Linear01Depth(tex2D(_CameraDepthTexture, i.uv)), 100 );
  71.  
  72. //float depth = 1- pow( Linear01Depth(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.scrPos)).r), 1) ;
  73.  
  74.  
  75. col = lerp(ogCol, effectCol_1, _EffectLerp );
  76.  
  77. //col = fixed4(depth,depth,depth,1);
  78.  
  79. //col = abs(col - brightness);
  80. // just invert the colors
  81. //col = 1 - col;
  82. return col;
  83. }
  84. ENDCG
  85. }
  86. }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement