File: Twisted.glsl

package info (click to toggle)
vtk 5.8.0-13
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 130,524 kB
  • sloc: cpp: 1,129,256; ansic: 708,203; tcl: 48,526; python: 20,875; xml: 6,779; yacc: 4,208; perl: 3,121; java: 2,788; lex: 931; sh: 660; asm: 471; makefile: 299
file content (39 lines) | stat: -rw-r--r-- 1,223 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
uniform float Rate;

void main()
{
  float angle = gl_Vertex[2];
  float rate = Rate;
  vec4 newPos;
  newPos[0] = cos(angle* rate) * gl_Vertex[0] + sin(angle* rate) *gl_Vertex[1];
  newPos[1] = -sin(angle* rate) * gl_Vertex[0] + cos(angle* rate) *gl_Vertex[1];
  newPos[2] = gl_Vertex[2];
  newPos[3] = gl_Vertex[3];

  vec3 newNormal;
  newNormal[0] = cos(angle* rate) * gl_Normal[0] + sin(angle* rate) *gl_Normal[1];
  newNormal[1] = -sin(angle* rate) * gl_Normal[0] + cos(angle* rate) *gl_Normal[1];
  newNormal[2] = gl_Normal[2];

  vec4 ambient = gl_FrontMaterial.ambient * gl_LightSource[0].ambient;
  vec3 normal = normalize(gl_NormalMatrix * newNormal);
  vec3 lightDir = normalize(vec3(gl_LightSource[0].position));
  float NdotL = max(dot(normal, lightDir), 0.0);

  vec4 col = vec4(0,0.5,0.5,1);
  vec4 diffuse = col * gl_LightSource[0].diffuse * NdotL;
  vec4 specular;
  
  if (NdotL > 0.0) 
    {
    float NdotHV = max(dot(normal, gl_LightSource[0].halfVector.xyz), 0.0);
    specular = gl_FrontMaterial.specular * gl_LightSource[0].specular * 
      pow(NdotHV, gl_FrontMaterial.shininess);
    }
  gl_FrontColor = diffuse + ambient + specular;

  gl_Position = gl_ModelViewProjectionMatrix * newPos;



}