I am trying to create an effect called wormhole effect. I am using a shader file but I am not getting the exact effect. Does anyone have any idea or any smple shader file which can help me?
The effect looks something like the effect named "Wormhole" at found here (bottom right).
The shader file I am trying to improve is based on "Ripple" effect but I am not able to get that much smooth effect.
/// <class>RippleTransitionEffect</class>
/// <description>A transition effect </description>
/// <summary>The amount(%) of the transition from first texture to the second texture. </summary>
/// <minValue>0</minValue>
/// <maxValue>1</maxValue>
/// <defaultValue>0</defaultValue>
float Progress : register(C0);
sampler input : register(s0);
texture Texture;
sampler Texture2 = sampler_state
{
texture = <Texture>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
AddressU = mirror;
AddressV = mirror;
};
float4 Ripple(float2 uv,float progress)
{
float radius = progress * 0.75;
float FuzzyAmount = 0.001;
float2 CenterPoint = float2(0.5,0.5);
float fromCenter = length((uv - CenterPoint) / float2(0.75, 1));
float distFromCircle = fromCenter - radius;
float frequency = 10;
float speed = 1;
float amplitude = 0.005;
float wave = cos(frequency * distFromCircle - speed * progress) + 2;
float offset1 = progress * wave * amplitude;
float offset2 = (1.0 - progress) * wave * amplitude;
float2 normToUV = (uv - CenterPoint) / distFromCircle;
float2 newUV1 = CenterPoint + normToUV * (distFromCircle + offset1);
float2 newUV2 = CenterPoint + normToUV * (distFromCircle + offset2);
float4 c1 = tex2D(Texture2, newUV1);
float4 c2 = tex2D(input, newUV2);
float p = saturate((distFromCircle + FuzzyAmount) / (1.0 * FuzzyAmount));
return lerp(c1, c2, p );
}
float4 main(float2 tex: TEXCOORD) : COlOR
{
return Ripple(tex, Progress);
}
technique TransformTexture {
pass P0 {
PixelShader = compile ps_2_0 main();
}
}