home *** CD-ROM | disk | FTP | other *** search
- //dp logo swirl swirl
-
- //Luke Lenhart
- //(C)2004-2005 Digipen Institute of Technology
-
- //combined world,view,projection transform
- float4x4 matViewProj;
-
- //animation position modifier (vary from 5 to 0)
- float mod;
-
- //rotation around the z axis
- float hRot;
-
- //direction of the light
- float3 lgtDirection;
-
- //shader input
- struct VS_INPUT
- {
- float4 Pos : POSITION;
- float4 Normal : NORMAL;
- float2 Tex0 : TEXCOORD0;
- };
-
- //shader output
- struct VS_OUTPUT
- {
- float4 Pos : POSITION;
- float2 Tex0 : TEXCOORD0;
- float4 Color : COLOR;
- };
-
- //shader code
- VS_OUTPUT VShader(VS_INPUT In)
- {
- VS_OUTPUT Out;
-
- //copy tex coord
- Out.Tex0=In.Tex0;
-
- //animation vertex position swirl
- float dist=distance(In.Pos.xz,float2(0,0)); //dist from center
- float theta=dist*0.25f*mod + 2.0f*mod; //make a rotation
- float2x2 matRot={cos(theta),sin(theta),-sin(theta),cos(theta)};
- float4 pos=In.Pos;
- pos.xz=mul(matRot,In.Pos.xz);
-
- //scale
- pos.xz*=mod+1.0f;
-
- //rotate around z axis (pos and normal)
- matRot=float2x2(cos(hRot),sin(hRot),-sin(hRot),cos(hRot));
- pos.xy=mul(matRot,pos.xy);
-
- //calc transformed position
- Out.Pos=mul(matViewProj,pos);
-
- //simple color calc
- Out.Color.xyz=abs(dot(lgtDirection.xyz,In.Normal.xyz)*0.7f + float3(0.2f,0.2f,0.2f));
-
- //calc alpha
- float alpha=0.2f + 1.0f - mod*(1.0f/5.0f); //generally fade in from nothing
- alpha-=0.1f*(dist*mod*mod)*0.2f; //middle fades in first
- Out.Color.a=alpha;
-
- //spit out the results
- return Out;
- }
-