simple.vertex.fx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. precision highp float;
  2. // Attributes
  3. attribute vec3 position;
  4. #ifdef NORMAL
  5. attribute vec3 normal;
  6. #endif
  7. #ifdef UV1
  8. attribute vec2 uv;
  9. #endif
  10. #ifdef UV2
  11. attribute vec2 uv2;
  12. #endif
  13. #ifdef VERTEXCOLOR
  14. attribute vec4 color;
  15. #endif
  16. #include<bonesDeclaration>
  17. // Uniforms
  18. #include<instancesDeclaration>
  19. uniform mat4 view;
  20. uniform mat4 viewProjection;
  21. #ifdef DIFFUSE
  22. varying vec2 vDiffuseUV;
  23. uniform mat4 diffuseMatrix;
  24. uniform vec2 vDiffuseInfos;
  25. #endif
  26. #ifdef POINTSIZE
  27. uniform float pointSize;
  28. #endif
  29. // Output
  30. varying vec3 vPositionW;
  31. #ifdef NORMAL
  32. varying vec3 vNormalW;
  33. #endif
  34. #ifdef VERTEXCOLOR
  35. varying vec4 vColor;
  36. #endif
  37. #ifdef CLIPPLANE
  38. uniform vec4 vClipPlane;
  39. varying float fClipDistance;
  40. #endif
  41. #include<fogVertexDeclaration>
  42. #include<shadowsVertexDeclaration>
  43. void main(void) {
  44. #include<instancesVertex>
  45. #include<bonesVertex>
  46. gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
  47. vec4 worldPos = finalWorld * vec4(position, 1.0);
  48. vPositionW = vec3(worldPos);
  49. #ifdef NORMAL
  50. vNormalW = normalize(vec3(finalWorld * vec4(normal, 0.0)));
  51. #endif
  52. // Texture coordinates
  53. #ifndef UV1
  54. vec2 uv = vec2(0., 0.);
  55. #endif
  56. #ifndef UV2
  57. vec2 uv2 = vec2(0., 0.);
  58. #endif
  59. #ifdef DIFFUSE
  60. if (vDiffuseInfos.x == 0.)
  61. {
  62. vDiffuseUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
  63. }
  64. else
  65. {
  66. vDiffuseUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
  67. }
  68. #endif
  69. // Clip plane
  70. #ifdef CLIPPLANE
  71. fClipDistance = dot(worldPos, vClipPlane);
  72. #endif
  73. // Fog
  74. #include<fogVertex>
  75. #include<shadowsVertex>
  76. // Vertex color
  77. #ifdef VERTEXCOLOR
  78. vColor = color;
  79. #endif
  80. // Point size
  81. #ifdef POINTSIZE
  82. gl_PointSize = pointSize;
  83. #endif
  84. }