I've been testing a variety of shockwave or ripple effect shaders, and spent time on this cleaned up and improved version on shadertoy.
I'm not entirely satisfied with that because it produces an ugly "bubbling" effect in the center. I'm trying to add a stronger "compression" effect to the shockwave itself but everything I do results in a stronger bubbling effect in the center.
I've found an example of what I want which uses an image for the displacement map: example
The author of that example only provided a sample of the shader code which I've been able to port. However, I don't understand how to animate this (to expand outward) over time.
Here's my current port into hlsl for Unity:
Shader "Hidden/Shockwave2"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_GradientTex ("Texture", 2D) = "white" {}
}
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest Always
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;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
sampler2D _MainTex;
sampler2D _GradientTex;
fixed4 frag (v2f i) : SV_Target
{
fixed2 center = fixed2(.5, .5);
fixed2 dir = normalize(i.uv - center);
// Get the pixels off of the maps.
fixed4 gradC = tex2D(_GradientTex, i.uv);
// Read the pixel from the displaced position.
fixed2 pos = i.uv;
pos.x += (gradC.r * 2.0 - 1.0) * 0.025;
pos.y -= (gradC.g * 2.0 - 1.0) * 0.025;
return tex2D(_MainTex, pos * dir);
}
ENDCG
}
}
}
This produces the correct visual, but I need to animate its expansion outward.