background.vertex.fx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. vPositionUVW = position;
  44. #endif
  45. #include<instancesVertex>
  46. #include<bonesVertex>
  47. #ifdef MULTIVIEW
  48. if (gl_ViewID_OVR == 0u) {
  49. gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
  50. } else {
  51. gl_Position = viewProjectionR * finalWorld * vec4(position, 1.0);
  52. }
  53. #else
  54. gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
  55. #endif
  56. vec4 worldPos = finalWorld * vec4(position, 1.0);
  57. vPositionW = vec3(worldPos);
  58. #ifdef NORMAL
  59. mat3 normalWorld = mat3(finalWorld);
  60. #ifdef NONUNIFORMSCALING
  61. normalWorld = transposeMat3(inverseMat3(normalWorld));
  62. #endif
  63. vNormalW = normalize(normalWorld * normal);
  64. #endif
  65. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  66. vDirectionW = normalize(vec3(finalWorld * vec4(position, 0.0)));
  67. #ifdef EQUIRECTANGULAR_RELFECTION_FOV
  68. mat3 screenToWorld = inverseMat3(mat3(finalWorld * viewProjection));
  69. vec3 segment = mix(vDirectionW, screenToWorld * vec3(0.0,0.0, 1.0), abs(fFovMultiplier - 1.0));
  70. if (fFovMultiplier <= 1.0) {
  71. vDirectionW = normalize(segment);
  72. } else {
  73. vDirectionW = normalize(vDirectionW + (vDirectionW - segment));
  74. }
  75. #endif
  76. #endif
  77. #ifndef UV1
  78. vec2 uv = vec2(0., 0.);
  79. #endif
  80. #ifndef UV2
  81. vec2 uv2 = vec2(0., 0.);
  82. #endif
  83. #ifdef MAINUV1
  84. vMainUV1 = uv;
  85. #endif
  86. #ifdef MAINUV2
  87. vMainUV2 = uv2;
  88. #endif
  89. #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
  90. if (vDiffuseInfos.x == 0.)
  91. {
  92. vDiffuseUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
  93. }
  94. else
  95. {
  96. vDiffuseUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
  97. }
  98. #endif
  99. // Clip plane
  100. #include<clipPlaneVertex>
  101. // Fog
  102. #include<fogVertex>
  103. // Shadows
  104. #include<shadowsVertex>[0..maxSimultaneousLights]
  105. // Vertex color
  106. #ifdef VERTEXCOLOR
  107. vColor = color;
  108. #endif
  109. // Point size
  110. #ifdef POINTSIZE
  111. gl_PointSize = pointSize;
  112. #endif
  113. }