File: vertex.cg

package info (click to toggle)
libopengl-perl 0.7000%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 2,308 kB
  • sloc: perl: 10,178; ansic: 8,576; makefile: 113
file content (40 lines) | stat: -rwxr-xr-x 728 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// 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;
}