default.vertex.fx 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. #include<__decl__defaultVertex>
  2. // Attributes
  3. #define CUSTOM_VERTEX_BEGIN
  4. attribute vec3 position;
  5. #ifdef NORMAL
  6. attribute vec3 normal;
  7. #endif
  8. #ifdef TANGENT
  9. attribute vec4 tangent;
  10. #endif
  11. #ifdef UV1
  12. attribute vec2 uv;
  13. #endif
  14. #ifdef UV2
  15. attribute vec2 uv2;
  16. #endif
  17. #ifdef VERTEXCOLOR
  18. attribute vec4 color;
  19. #endif
  20. #include<helperFunctions>
  21. #include<bonesDeclaration>
  22. // Uniforms
  23. #include<instancesDeclaration>
  24. #ifdef PREPASS
  25. varying vec3 vViewPos;
  26. #endif
  27. #ifdef MAINUV1
  28. varying vec2 vMainUV1;
  29. #endif
  30. #ifdef MAINUV2
  31. varying vec2 vMainUV2;
  32. #endif
  33. #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
  34. varying vec2 vDiffuseUV;
  35. #endif
  36. #if defined(DETAIL) && DETAILDIRECTUV == 0
  37. varying vec2 vDetailUV;
  38. #endif
  39. #if defined(AMBIENT) && AMBIENTDIRECTUV == 0
  40. varying vec2 vAmbientUV;
  41. #endif
  42. #if defined(OPACITY) && OPACITYDIRECTUV == 0
  43. varying vec2 vOpacityUV;
  44. #endif
  45. #if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0
  46. varying vec2 vEmissiveUV;
  47. #endif
  48. #if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0
  49. varying vec2 vLightmapUV;
  50. #endif
  51. #if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0
  52. varying vec2 vSpecularUV;
  53. #endif
  54. #if defined(BUMP) && BUMPDIRECTUV == 0
  55. varying vec2 vBumpUV;
  56. #endif
  57. // Output
  58. varying vec3 vPositionW;
  59. #ifdef NORMAL
  60. varying vec3 vNormalW;
  61. #endif
  62. #ifdef VERTEXCOLOR
  63. varying vec4 vColor;
  64. #endif
  65. #include<bumpVertexDeclaration>
  66. #include<clipPlaneVertexDeclaration>
  67. #include<fogVertexDeclaration>
  68. #include<__decl__lightFragment>[0..maxSimultaneousLights]
  69. #include<morphTargetsVertexGlobalDeclaration>
  70. #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
  71. #ifdef REFLECTIONMAP_SKYBOX
  72. varying vec3 vPositionUVW;
  73. #endif
  74. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  75. varying vec3 vDirectionW;
  76. #endif
  77. #include<logDepthDeclaration>
  78. #define CUSTOM_VERTEX_DEFINITIONS
  79. void main(void) {
  80. #define CUSTOM_VERTEX_MAIN_BEGIN
  81. vec3 positionUpdated = position;
  82. #ifdef NORMAL
  83. vec3 normalUpdated = normal;
  84. #endif
  85. #ifdef TANGENT
  86. vec4 tangentUpdated = tangent;
  87. #endif
  88. #ifdef UV1
  89. vec2 uvUpdated = uv;
  90. #endif
  91. #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
  92. #ifdef REFLECTIONMAP_SKYBOX
  93. vPositionUVW = positionUpdated;
  94. #endif
  95. #define CUSTOM_VERTEX_UPDATE_POSITION
  96. #define CUSTOM_VERTEX_UPDATE_NORMAL
  97. #include<instancesVertex>
  98. #include<bonesVertex>
  99. vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);
  100. #ifdef NORMAL
  101. mat3 normalWorld = mat3(finalWorld);
  102. #if defined(INSTANCES) && defined(THIN_INSTANCES)
  103. vNormalW = normalUpdated / vec3(dot(normalWorld[0], normalWorld[0]), dot(normalWorld[1], normalWorld[1]), dot(normalWorld[2], normalWorld[2]));
  104. vNormalW = normalize(normalWorld * vNormalW);
  105. #else
  106. #ifdef NONUNIFORMSCALING
  107. normalWorld = transposeMat3(inverseMat3(normalWorld));
  108. #endif
  109. vNormalW = normalize(normalWorld * normalUpdated);
  110. #endif
  111. #endif
  112. #define CUSTOM_VERTEX_UPDATE_WORLDPOS
  113. #ifdef MULTIVIEW
  114. if (gl_ViewID_OVR == 0u) {
  115. gl_Position = viewProjection * worldPos;
  116. } else {
  117. gl_Position = viewProjectionR * worldPos;
  118. }
  119. #else
  120. gl_Position = viewProjection * worldPos;
  121. #endif
  122. vPositionW = vec3(worldPos);
  123. #ifdef PREPASS
  124. vViewPos = (view * worldPos).rgb;
  125. #endif
  126. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  127. vDirectionW = normalize(vec3(finalWorld * vec4(positionUpdated, 0.0)));
  128. #endif
  129. // Texture coordinates
  130. #ifndef UV1
  131. vec2 uvUpdated = vec2(0., 0.);
  132. #endif
  133. #ifndef UV2
  134. vec2 uv2 = vec2(0., 0.);
  135. #endif
  136. #ifdef MAINUV1
  137. vMainUV1 = uvUpdated;
  138. #endif
  139. #ifdef MAINUV2
  140. vMainUV2 = uv2;
  141. #endif
  142. #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
  143. if (vDiffuseInfos.x == 0.)
  144. {
  145. vDiffuseUV = vec2(diffuseMatrix * vec4(uvUpdated, 1.0, 0.0));
  146. }
  147. else
  148. {
  149. vDiffuseUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
  150. }
  151. #endif
  152. #if defined(DETAIL) && DETAILDIRECTUV == 0
  153. if (vDetailInfos.x == 0.)
  154. {
  155. vDetailUV = vec2(detailMatrix * vec4(uvUpdated, 1.0, 0.0));
  156. }
  157. else
  158. {
  159. vDetailUV = vec2(detailMatrix * vec4(uv2, 1.0, 0.0));
  160. }
  161. #endif
  162. #if defined(AMBIENT) && AMBIENTDIRECTUV == 0
  163. if (vAmbientInfos.x == 0.)
  164. {
  165. vAmbientUV = vec2(ambientMatrix * vec4(uvUpdated, 1.0, 0.0));
  166. }
  167. else
  168. {
  169. vAmbientUV = vec2(ambientMatrix * vec4(uv2, 1.0, 0.0));
  170. }
  171. #endif
  172. #if defined(OPACITY) && OPACITYDIRECTUV == 0
  173. if (vOpacityInfos.x == 0.)
  174. {
  175. vOpacityUV = vec2(opacityMatrix * vec4(uvUpdated, 1.0, 0.0));
  176. }
  177. else
  178. {
  179. vOpacityUV = vec2(opacityMatrix * vec4(uv2, 1.0, 0.0));
  180. }
  181. #endif
  182. #if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0
  183. if (vEmissiveInfos.x == 0.)
  184. {
  185. vEmissiveUV = vec2(emissiveMatrix * vec4(uvUpdated, 1.0, 0.0));
  186. }
  187. else
  188. {
  189. vEmissiveUV = vec2(emissiveMatrix * vec4(uv2, 1.0, 0.0));
  190. }
  191. #endif
  192. #if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0
  193. if (vLightmapInfos.x == 0.)
  194. {
  195. vLightmapUV = vec2(lightmapMatrix * vec4(uvUpdated, 1.0, 0.0));
  196. }
  197. else
  198. {
  199. vLightmapUV = vec2(lightmapMatrix * vec4(uv2, 1.0, 0.0));
  200. }
  201. #endif
  202. #if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0
  203. if (vSpecularInfos.x == 0.)
  204. {
  205. vSpecularUV = vec2(specularMatrix * vec4(uvUpdated, 1.0, 0.0));
  206. }
  207. else
  208. {
  209. vSpecularUV = vec2(specularMatrix * vec4(uv2, 1.0, 0.0));
  210. }
  211. #endif
  212. #if defined(BUMP) && BUMPDIRECTUV == 0
  213. if (vBumpInfos.x == 0.)
  214. {
  215. vBumpUV = vec2(bumpMatrix * vec4(uvUpdated, 1.0, 0.0));
  216. }
  217. else
  218. {
  219. vBumpUV = vec2(bumpMatrix * vec4(uv2, 1.0, 0.0));
  220. }
  221. #endif
  222. #include<bumpVertex>
  223. #include<clipPlaneVertex>
  224. #include<fogVertex>
  225. #include<shadowsVertex>[0..maxSimultaneousLights]
  226. #ifdef VERTEXCOLOR
  227. // Vertex color
  228. vColor = color;
  229. #endif
  230. #include<pointCloudVertex>
  231. #include<logDepthVertex>
  232. #define CUSTOM_VERTEX_MAIN_END
  233. }