default.vertex.fx 5.0 KB

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