Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Hidden/NewImageEffectShader"
- {
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- _EffectScaler ("Effect Scaler", float) = 0
- _EffectLerp ("Effect Lerp", float) = 0
- }
- SubShader
- {
- // No culling or depth
- Cull Off ZWrite Off ZTest Always
- Pass
- {
- 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;
- float4 scrPos:TEXCOORD1;
- };
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
- o.uv = v.uv;
- o.scrPos = ComputeScreenPos(o.vertex);
- return o;
- }
- sampler2D _MainTex;
- uniform half4 _MainTex_TexelSize;
- sampler2D _CameraDepthTexture;
- float _EffectScaler;
- float _EffectLerp;
- fixed4 frag (v2f i) : SV_Target
- {
- // pixel to uv ratios
- float pr_x = 1 / _MainTex_TexelSize.x;
- float pr_y = 1 / _MainTex_TexelSize.y;
- fixed4 col = tex2D(_MainTex, i.uv);
- fixed4 ogCol = col;
- float ogColPowerScaler = ogCol.x;//length(ogCol);
- float depth = pow(1 - Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv)), 10);
- float2 offsetCoord_1 = float2(i.uv.x + frac(i.uv.y/7) * _EffectScaler * ogColPowerScaler, i.uv.y);
- float2 offsetCoord_2 = float2(i.uv.x - frac(i.uv.y / 7) * _EffectScaler * ogColPowerScaler, i.uv.y);
- fixed4 samp_1 = tex2D(_MainTex, offsetCoord_1);
- fixed4 samp_2 = tex2D(_MainTex, offsetCoord_2);
- fixed4 effectCol_1 = (depth *ogCol + samp_1 + samp_2) /3;
- //col = pow( 1- Linear01Depth(tex2D(_CameraDepthTexture, i.uv)), 100 );
- //float depth = 1- pow( Linear01Depth(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.scrPos)).r), 1) ;
- col = lerp(ogCol, effectCol_1, _EffectLerp );
- //col = fixed4(depth,depth,depth,1);
- //col = abs(col - brightness);
- // just invert the colors
- //col = 1 - col;
- return col;
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement