default.vertex.fx 5.8 KB

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