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.
78 lines
2.1 KiB
Plaintext
78 lines
2.1 KiB
Plaintext
Shader "Custom/PostProcessing"
|
|
{
|
|
Properties
|
|
{
|
|
_MainTex ("MainTexture", 2D) = "white" {}
|
|
_ScreenSize ("ScreenSize", Vector) = (0,0,0,0)
|
|
_Wave1 ("Wave1", Vector) = (0,0,0,0)
|
|
}
|
|
SubShader
|
|
{
|
|
Tags { "RenderType"="Opaque"}
|
|
ZWrite Off
|
|
Cull Off
|
|
|
|
Pass {
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
|
|
CGPROGRAM
|
|
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
#include "UnityCG.cginc"
|
|
|
|
#define PI 3.1415926
|
|
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float2 uv : TEXCOORD0;
|
|
float4 vertex : SV_POSITION;
|
|
};
|
|
|
|
sampler2D _MainTex;
|
|
float4 _MainTex_ST;
|
|
float4 _ScreenSize;
|
|
float4 _Wave1;
|
|
|
|
v2f vert (appdata v)
|
|
{
|
|
v2f o;
|
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
|
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
|
return o;
|
|
}
|
|
|
|
fixed4 frag (v2f i) : SV_Target
|
|
{
|
|
fixed4 basic = tex2D(_MainTex, i.uv);
|
|
fixed2 screen_pos = i.uv * _ScreenSize.xy;
|
|
fixed2 wave_dir = (0,0);
|
|
fixed dist1 = length(screen_pos - _Wave1.xy);
|
|
if(dist1<_Wave1.z){
|
|
if(abs(dist1/_Wave1.z-_Wave1.w*2)<0.25){
|
|
fixed wave = cos(PI*4*abs(dist1/_Wave1.z-_Wave1.w*2))*8;
|
|
wave_dir = wave_dir + normalize(screen_pos-_Wave1.xy)*wave;
|
|
// if(wave>3.99){
|
|
// return(1,0,0,1);
|
|
// }
|
|
|
|
}
|
|
}
|
|
wave_dir = wave_dir / _ScreenSize.xy;
|
|
return tex2D(_MainTex, i.uv+wave_dir);
|
|
}
|
|
ENDCG
|
|
|
|
}
|
|
|
|
}
|
|
FallBack "Diffuse"
|
|
}
|