Shader "Mochie/Shake" {
Properties {
_MinRange("Min Range", Range(0, 49.9)) = 30
_MaxRange("Max Range", Range (0.1, 50)) = 50
_Amp("Amplitude", Range(0,250)) = 0
}
SubShader {
GrabPass {"_gpShake"}
Tags {"RenderType" = "Overlay" "Queue" = "Overlay" "Lightmode" = "Always" "ForceNoShadowCasting" = "True"}
ZWrite off
ZTest Always
Cull Front
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _gpShake;
float4 _gpShake_TexelSize;
float4 _BumpMap_ST;
float _Amp, _MinRange, _MaxRange;
struct appdata_t {
float4 vertex : remove_style_tag;
float3 normals : NORMAL;
};
struct v2f {
float4 vertex : SV_remove_style_tag;
float falloff : TEXCOORD1;
float4 pos : TEXCOORD2;
float4 distance: TEXCOORD3;
};
v2f vert (appdata_t v) {
v2f o;
o.vertex = UnityToClipPos(v.vertex);
o.uvgrab = ComputeGrabScreenPos(o.vertex);
o.distance = distance(_WorldSpaceCameraPos, mul(unity_ToWorld, float4(0, 0, 0, 1)));
o.pos = o.vertex - o.vertexstep(_MaxRange, o.distance);
o.falloff = pow(min(1, 1 - (1/(_MaxRange - _MinRange))(o.distance - _MinRange)), 2) * o.pos.w;
return o;
}
float4안씀