default.vertex.fx 5.5 KB

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