2
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.6 KiB
Plaintext

Shader "Custom/AirWall"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Threshold1 ("Threshold 1", Range(0, 10)) = 0.5
_Threshold2 ("Threshold 2", Range(0, 10)) = 2
_WorldPos ("WorldPos", Vector) = (0, 0, 0, 0)
_Color ("Color", Color) = (1,1,1,1)
_FlowSpeed ("Flow Speed", Range(0, 1)) = 0.1
_NoiseTex ("Noise Texture", 2D) = "white" {}
_Speed ("Speed", Range(0, 10)) = 1
_Strength ("Strength", Range(0, 1)) = 0.1
}
SubShader
{
Tags
{
"Queue"="Transparent" "RenderType"="Transparent"
}
Blend SrcAlpha OneMinusSrcAlpha
Cull Off
Zwrite off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 pos : SV_POSITION;
float3 worldPos : TEXCOORD0;
float2 uv : TEXCOORD1;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float _Threshold1;
float _Threshold2;
float4 _WorldPos;
fixed4 _Color;
uniform float _FlowSpeed;
float4 _LevelRect;
sampler2D _NoiseTex;
float _Speed;
float _Strength;
v2f vert(appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
o.uv = v.uv;
return o;
}
fixed4 frag(v2f i) : SV_Target
{
//裁剪
float distance = length(i.worldPos - _WorldPos.xyz);
float rate = saturate((distance - _Threshold1) / (_Threshold2 - _Threshold1));
float alpha = 1.0 - pow(rate, 0.5f);
float2 offset = float2(0, _Time[0] * _FlowSpeed);
float2 offsetNoise = float2(_Time[0] * _Speed, _Time[0] * _Speed);
float4 noise = tex2D(_NoiseTex, i.uv + offsetNoise);
float2 uv = i.uv + offset + noise.rg * _Strength;
alpha = alpha * tex2D(_MainTex, uv * _MainTex_ST.xy).r;
fixed4 col = fixed4(_Color.rgb, alpha);
return col;
}
ENDCG
}
}
FallBack "Diffuse"
}