屏幕信号干扰效果

 以上只是技术演示并非代表最终效果.

Shader "Unlit/ScreenInterference1"
{
	Properties
	{
		_Noise("Noise", 2D) = "white" {}
		_ShakeInterval("ShakeInterval", Range(0, 100)) = 2
		_ShakeStrength("ShakeStrength", Range(-5, 5)) = 0.05
		_StripeColor("StripeColor", Color) = (0.8, 0.8, 0.8, 1)
		_StripeWidth("StripeWidth", Range(0, 1)) = 0.5
		_NoisePoint("NoisePoint",Range(0, 1))=1
	}
	SubShader
	{
		Tags { "RenderType"="Opaque" }
		LOD 100

		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;
			};

			sampler2D _MainTex;
			float4 _MainTex_ST;
			sampler2D _Noise;
			float4 _Noise_ST;
			half _ShakeInterval;
			half _ShakeStrength;
			half4 _StripeColor;
			half _StripeWidth;
			float _NoisePoint;
			
			v2f vert (appdata v)
			{
				v2f o;
				o.vertex = UnityObjectToClipPos(v.vertex);
				o.uv = v.uv;
				return o;
			}

			float random(float x, float y)
			{
				return frac(sin(dot(x,y)) * 43758.5453);
			}
			
			fixed4 frag (v2f i) : SV_Target
			{
				half tmpValue = saturate(sin(_Time.y % _ShakeInterval));
				i.uv.x +=  random(i.uv.y,_Time.y) * tex2D(_Noise,TRANSFORM_TEX( i.uv,_Noise)).r * _ShakeStrength * tmpValue;
				fixed4 col = tex2D(_MainTex, i.uv);
				col = lerp(col,col * _StripeColor,step(frac(_Time.y * i.uv.y),0.01+_StripeWidth));
				col.rgb += random(i.uv.x,i.uv.y+_Time.y)*_NoisePoint;
				return col;
			}
			ENDCG
		}
	}
}

技术讲解技术难点主要分成三部分:

1.先用随机函数把uv的x轴通过扰动图做左右随机抖动效果

2.做滚动条纹效果,原理是每隔一定的间隔出现条纹效果方法有很多

3.做随机噪声点,利用随机函数对当前UV做微量偏移.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值