topical media & game development
Web3D/VR
shader(s) -- dizzy
// rotated texture
// a bit based on Dizzy from Ati Render Monkey
// Holger Grahn hg . snafu.de
float time=0;
float sampleDist = 1.0f/512.0f; // distance one pixel in u/v
float rings: register(c1) = 2;
float speed: register(c2)=5;
float exponent: register(c3)=1.5;
float2 center = { 0.5, 0.5 };
float2 scale = { 2, 2 };
// input
sampler2D image : register(s0);
float4 main(
float4 Pos : POSITION,
float2 texCoord: TEXCOORD0) : COLOR
{
texCoord = scale* (texCoord-center);
float radius = length(texCoord);
float ang = atan2(texCoord.x, texCoord.y);
float rad = pow(dot(texCoord, texCoord), exponent);
ang = ang + rings * sin(time*6.28) * rad + speed * time;
float2 newTexCoord = float2(0.5 * (1 + radius*sin(ang)),0.5 * (1 + radius*cos(ang)));
float4 img = tex2D(image, newTexCoord);
return img;
}
(C) Æliens
20/08/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.