Created
October 17, 2017 15:25
-
-
Save Gorillarigo/9775af23d9dd7fb5e0d9842f9e9ccfaa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//unityのUnlitShaderを改造 | |
fixed4 frag (v2f i) : SV_Target | |
{ | |
//中央からパルスを発するのこぎり関数 | |
float offset = (_Time.y - floor(_Time.y)) / _Time.y; | |
float CurrentTime = (_Time.y)*(offset); | |
//衝撃波のパラメーター | |
fixed3 WaveParams = fixed3(10.0, 0.8, 0.1 ); | |
//衝撃波の中心 | |
float2 WaveCentre = float2(0.5, 0.5); | |
float2 uv = i.uv; | |
fixed4 col = tex2D(_MainTex, uv); | |
//2点の間の距離を図る | |
float Dist = distance(uv, WaveCentre); | |
//パラメーター距離内のピクセルを中心から歪ませます。 | |
if ((Dist <= ((CurrentTime) + (WaveParams.z))) && | |
(Dist >= ((CurrentTime) - (WaveParams.z)))) | |
{ | |
//入力パラメーターに基づくオフセット距離 | |
float Diff = (Dist - CurrentTime); | |
float ScaleDiff = (1.0 - pow(abs(Diff * WaveParams.x), WaveParams.y)); | |
float DiffTime = (Diff * ScaleDiff); | |
//歪みの方向 | |
float2 DiffTexCoord = normalize(uv - WaveCentre); | |
//ディストーションを実行し、時間とともにエフェクトを減らす | |
uv += ((DiffTexCoord * DiffTime) / (CurrentTime * Dist * 40.0)); | |
col = tex2D(_MainTex, uv); | |
//時間とともに色を減らします | |
col += (col * ScaleDiff) / (CurrentTime * Dist * 40.0); | |
} | |
return col; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment