background.vertex.fx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. precision highp float;
  2. #include<__decl__backgroundVertex>
  3. #include<helperFunctions>
  4. // Attributes
  5. attribute vec3 position;
  6. #ifdef NORMAL
  7. attribute vec3 normal;
  8. #endif
  9. #include<bonesDeclaration>
  10. // Uniforms
  11. #include<instancesDeclaration>
  12. // Output
  13. varying vec3 vPositionW;
  14. #ifdef NORMAL
  15. varying vec3 vNormalW;
  16. #endif
  17. #ifdef UV1
  18. attribute vec2 uv;
  19. #endif
  20. #ifdef UV2
  21. attribute vec2 uv2;
  22. #endif
  23. #ifdef MAINUV1
  24. varying vec2 vMainUV1;
  25. #endif
  26. #ifdef MAINUV2
  27. varying vec2 vMainUV2;
  28. #endif
  29. #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
  30. varying vec2 vDiffuseUV;
  31. #endif
  32. #include<clipPlaneVertexDeclaration>
  33. #include<fogVertexDeclaration>
  34. #include<__decl__lightFragment>[0..maxSimultaneousLights]
  35. #ifdef REFLECTIONMAP_SKYBOX
  36. varying vec3 vPositionUVW;
  37. #endif
  38. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  39. varying vec3 vDirectionW;
  40. #endif
  41. void main(void) {
  42. #ifdef REFLECTIONMAP_SKYBOX
  43. #ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED
  44. vPositionUVW = (reflectionMatrix * vec4(position, 1.0)).xyz;
  45. #else
  46. vPositionUVW = position;
  47. #endif
  48. #endif
  49. #include<instancesVertex>
  50. #include<bonesVertex>
  51. gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
  52. vec4 worldPos = finalWorld * vec4(position, 1.0);
  53. vPositionW = vec3(worldPos);
  54. #ifdef NORMAL
  55. mat3 normalWorld = mat3(finalWorld);
  56. #ifdef NONUNIFORMSCALING
  57. normalWorld = transposeMat3(inverseMat3(normalWorld));
  58. #endif
  59. vNormalW = normalize(normalWorld * normal);
  60. #endif
  61. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  62. vDirectionW = normalize(vec3(finalWorld * vec4(position, 0.0)));
  63. #ifdef EQUIRECTANGULAR_RELFECTION_FOV
  64. mat3 screenToWorld = inverseMat3(mat3(finalWorld * viewProjection));
  65. vec3 segment = mix(vDirectionW, screenToWorld * vec3(0.0,0.0, 1.0), abs(fFovMultiplier - 1.0));
  66. if (fFovMultiplier <= 1.0) {
  67. vDirectionW = normalize(segment);
  68. } else {
  69. vDirectionW = normalize(vDirectionW + (vDirectionW - segment));
  70. }
  71. #endif
  72. #endif
  73. #ifndef UV1
  74. vec2 uv = vec2(0., 0.);
  75. #endif
  76. #ifndef UV2
  77. vec2 uv2 = vec2(0., 0.);
  78. #endif
  79. #ifdef MAINUV1
  80. vMainUV1 = uv;
  81. #endif
  82. #ifdef MAINUV2
  83. vMainUV2 = uv2;
  84. #endif
  85. #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
  86. if (vDiffuseInfos.x == 0.)
  87. {
  88. vDiffuseUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
  89. }
  90. else
  91. {
  92. vDiffuseUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
  93. }
  94. #endif
  95. // Clip plane
  96. #include<clipPlaneVertex>
  97. // Fog
  98. #include<fogVertex>
  99. // Shadows
  100. #include<shadowsVertex>[0..maxSimultaneousLights]
  101. // Vertex color
  102. #ifdef VERTEXCOLOR
  103. vColor = color;
  104. #endif
  105. // Point size
  106. #ifdef POINTSIZE
  107. gl_PointSize = pointSize;
  108. #endif
  109. }