Advertisement
eddietree

Aurora Effect Vert Shader

Jan 30th, 2012
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.04 KB | None | 0 0
  1. /*
  2. Aurora Effect Vert Shader
  3.  
  4. by Eddie Lee (twitter: @eddietree)
  5. http://illogictree.com
  6. Jan 30, 2012
  7. */
  8.  
  9. #version 110
  10.  
  11. varying vec2 uv;
  12.  
  13. uniform vec4 v0;
  14. uniform vec4 v1;
  15. uniform vec4 tan0;
  16. uniform vec4 tan1;
  17.  
  18. vec3 hermite( vec3 p0, vec3 t0, vec3 p1, vec3 t1, float alpha )
  19. {
  20.     float t = alpha;
  21.     float t_sqr = alpha*alpha;
  22.     float t_cubed = alpha*alpha*alpha;
  23.    
  24.  
  25.     float h1 =  2.0*t_cubed - 3.0*t_sqr + 1.0;          // calculate basis function 1
  26.     float h2 = -2.0*t_cubed + 3.0*t_sqr;              // calculate basis function 2
  27.     float h3 =  t_cubed - 2.0*t_sqr + t;         // calculate basis function 3
  28.     float h4 =  t_cubed -  t_sqr;              // calculate basis function 4
  29.  
  30.     return h1*p0 + h2*p1 + h3*t0 + h4*t1;
  31. }
  32.  
  33. void main()
  34. {
  35.     // interpolate on x (assume verts are normalized in x,y )
  36.     float splineAlpha = gl_Vertex.x;
  37.    
  38.     vec3 pos = hermite( v0.xyz, tan0.xyz, v1.xyz, tan1.xyz, splineAlpha);
  39.     pos.y += gl_Vertex.y * 600.0;  
  40.     gl_Position = gl_ModelViewProjectionMatrix * vec4(pos.xy,0.0,1.0);
  41.     uv = gl_Vertex.xy;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement