I'm doing a simple Image Effect that distorts the image based on a sine function:
fixed4 frag (v2f i) : COLOR
{
//Rotation vars (as used in VortexEffect.shader)
//float cosLength, sinLength;
//sincos (_Angle, sinLength, cosLength);
float2 uv = i.texcoord;
uv += float2(0, sin(uv[0]*_Frequency) * _Amplitude);
float4 texCol = tex2D(_MainTex, uv);
return _Tint * texCol;
}
This distorts the image vertically in a nice sine wave, but how can I change the distortion direction to an arbitrary angle? I've tried looking at the VortexEffect.shader as it has rotation, but haven't been able to translate that to my needs.
/Patrik
Given the value of your sine function:
float sine = sin(uv[0] * _Frequency);
And the _Amplitude of your effect, what you're effectively doing at the moment is this:
uv += float2(0, 1) * sine * _Amplitude;
That float2(0, 1) represents the direction that the effect is acting in. Change it to a different vector - say, (1, 0) - to make it act in a different direction.