Advertisement
Guest User

Untitled

a guest
Oct 17th, 2014
738
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1.  
  2. // Compiler should remove unneeded stuff
  3. attribute vec3 vertex_position;
  4. attribute vec3 vertex_normal;
  5. attribute vec4 vertex_tangent;
  6. attribute vec2 vertex_texCoord0;
  7. attribute vec2 vertex_texCoord1;
  8. attribute vec4 vertex_color;
  9.  
  10. uniform mat4 matrix_viewProjection;
  11. uniform mat4 matrix_model;
  12. uniform mat3 matrix_normal;
  13. uniform vec3 view_position;
  14.  
  15. varying vec3 vPositionW;
  16. varying vec3 vNormalW;
  17. varying vec3 vTangentW;
  18. varying vec3 vBinormalW;
  19. varying vec2 vUv0;
  20. varying vec2 vUv1;
  21. varying vec4 vVertexColor;
  22. varying vec3 vNormalV;
  23.  
  24. struct vsInternalData {
  25. vec3 positionW;
  26. mat4 modelMatrix;
  27. mat3 normalMatrix;
  28. };
  29.  
  30.  
  31. vec2 getUv0(inout vsInternalData data) {
  32. return vertex_texCoord0;
  33. }
  34.  
  35. mat4 getModelMatrix(inout vsInternalData data) {
  36. return matrix_model;
  37. }
  38.  
  39. vec3 getNormal(inout vsInternalData data) {
  40. data.normalMatrix = matrix_normal;
  41. return normalize(data.normalMatrix * vertex_normal);
  42. }
  43.  
  44.  
  45. vec4 getPosition(inout vsInternalData data) {
  46. data.modelMatrix = getModelMatrix(data);
  47. vec4 posW = data.modelMatrix * vec4(vertex_position, 1.0);
  48. data.positionW = posW.xyz;
  49. return matrix_viewProjection * posW;
  50. }
  51.  
  52. vec3 getWorldPosition(inout vsInternalData data) {
  53. return data.positionW;
  54. }
  55.  
  56.  
  57. void main(void) {
  58. vsInternalData data;
  59.  
  60. gl_Position = getPosition(data);
  61. vPositionW = getWorldPosition(data);
  62. vNormalW = getNormal(data);
  63. vUv0 = getUv0(data);
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement