default.vertex.fx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
  83. #ifdef REFLECTIONMAP_SKYBOX
  84. #ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED
  85. vPositionUVW = (reflectionMatrix * vec4(position, 1.0)).xyz;
  86. #else
  87. vPositionUVW = position;
  88. #endif
  89. #endif
  90. #define CUSTOM_VERTEX_UPDATE_POSITION
  91. #define CUSTOM_VERTEX_UPDATE_NORMAL
  92. #include<instancesVertex>
  93. #include<bonesVertex>
  94. #ifdef MULTIVIEW
  95. if (gl_ViewID_OVR == 0u) {
  96. gl_Position = viewProjection * finalWorld * vec4(positionUpdated, 1.0);
  97. } else {
  98. gl_Position = viewProjectionR * finalWorld * vec4(positionUpdated, 1.0);
  99. }
  100. #else
  101. gl_Position = viewProjection * finalWorld * vec4(positionUpdated, 1.0);
  102. #endif
  103. vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);
  104. vPositionW = vec3(worldPos);
  105. #ifdef NORMAL
  106. mat3 normalWorld = mat3(finalWorld);
  107. #ifdef NONUNIFORMSCALING
  108. normalWorld = transposeMat3(inverseMat3(normalWorld));
  109. #endif
  110. vNormalW = normalize(normalWorld * normalUpdated);
  111. #endif
  112. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  113. vDirectionW = normalize(vec3(finalWorld * vec4(positionUpdated, 0.0)));
  114. #endif
  115. // Texture coordinates
  116. #ifndef UV1
  117. vec2 uv = vec2(0., 0.);
  118. #endif
  119. #ifndef UV2
  120. vec2 uv2 = vec2(0., 0.);
  121. #endif
  122. #ifdef MAINUV1
  123. vMainUV1 = uv;
  124. #endif
  125. #ifdef MAINUV2
  126. vMainUV2 = uv2;
  127. #endif
  128. #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
  129. if (vDiffuseInfos.x == 0.)
  130. {
  131. vDiffuseUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
  132. }
  133. else
  134. {
  135. vDiffuseUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
  136. }
  137. #endif
  138. #if defined(AMBIENT) && AMBIENTDIRECTUV == 0
  139. if (vAmbientInfos.x == 0.)
  140. {
  141. vAmbientUV = vec2(ambientMatrix * vec4(uv, 1.0, 0.0));
  142. }
  143. else
  144. {
  145. vAmbientUV = vec2(ambientMatrix * vec4(uv2, 1.0, 0.0));
  146. }
  147. #endif
  148. #if defined(OPACITY) && OPACITYDIRECTUV == 0
  149. if (vOpacityInfos.x == 0.)
  150. {
  151. vOpacityUV = vec2(opacityMatrix * vec4(uv, 1.0, 0.0));
  152. }
  153. else
  154. {
  155. vOpacityUV = vec2(opacityMatrix * vec4(uv2, 1.0, 0.0));
  156. }
  157. #endif
  158. #if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0
  159. if (vEmissiveInfos.x == 0.)
  160. {
  161. vEmissiveUV = vec2(emissiveMatrix * vec4(uv, 1.0, 0.0));
  162. }
  163. else
  164. {
  165. vEmissiveUV = vec2(emissiveMatrix * vec4(uv2, 1.0, 0.0));
  166. }
  167. #endif
  168. #if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0
  169. if (vLightmapInfos.x == 0.)
  170. {
  171. vLightmapUV = vec2(lightmapMatrix * vec4(uv, 1.0, 0.0));
  172. }
  173. else
  174. {
  175. vLightmapUV = vec2(lightmapMatrix * vec4(uv2, 1.0, 0.0));
  176. }
  177. #endif
  178. #if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0
  179. if (vSpecularInfos.x == 0.)
  180. {
  181. vSpecularUV = vec2(specularMatrix * vec4(uv, 1.0, 0.0));
  182. }
  183. else
  184. {
  185. vSpecularUV = vec2(specularMatrix * vec4(uv2, 1.0, 0.0));
  186. }
  187. #endif
  188. #if defined(BUMP) && BUMPDIRECTUV == 0
  189. if (vBumpInfos.x == 0.)
  190. {
  191. vBumpUV = vec2(bumpMatrix * vec4(uv, 1.0, 0.0));
  192. }
  193. else
  194. {
  195. vBumpUV = vec2(bumpMatrix * vec4(uv2, 1.0, 0.0));
  196. }
  197. #endif
  198. #include<bumpVertex>
  199. #include<clipPlaneVertex>
  200. #include<fogVertex>
  201. #include<shadowsVertex>[0..maxSimultaneousLights]
  202. #ifdef VERTEXCOLOR
  203. // Vertex color
  204. vColor = color;
  205. #endif
  206. #include<pointCloudVertex>
  207. #include<logDepthVertex>
  208. #define CUSTOM_VERTEX_MAIN_END
  209. }