Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (33 sloc) 728 Bytes
// input vertex
struct VertIn
{
float4 pos : POSITION;
uniform float4x4 modelViewProj : state.matrix.mvp;
};
// output vertex
struct VertOut
{
float4 pos : POSITION;
float2 texcoord : TEXCOORD0;
};
uniform float4 center;
uniform float4x4 xform;
// vertex shader main entry
VertOut main(VertIn IN)
{
VertOut OUT;
OUT.pos = mul(IN.modelViewProj, IN.pos);
OUT.pos = mul(xform, OUT.pos);
// Calc texcoord values
float d = sqrt(IN.pos.x * IN.pos.x + IN.pos.y * IN.pos.y);
float a = atan2(IN.pos.x,IN.pos.y) / 3.1415;
if (a < 0) a += 1;
a *= 2;
a -= int(a);
IN.pos -= center;
float h = IN.pos.z;
h = abs(2 * atan2(h,d) / 3.1415);
OUT.texcoord.x = a;
OUT.texcoord.y = h;
return OUT;
}