default.vertex.fx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. #include<__decl__defaultVertex>
  2. // Attributes
  3. attribute vec3 position;
  4. #ifdef NORMAL
  5. attribute vec3 normal;
  6. #endif
  7. #ifdef TANGENT
  8. attribute vec4 tangent;
  9. #endif
  10. #ifdef UV1
  11. attribute vec2 uv;
  12. #endif
  13. #ifdef UV2
  14. attribute vec2 uv2;
  15. #endif
  16. #ifdef VERTEXCOLOR
  17. attribute vec4 color;
  18. #endif
  19. #include<bonesDeclaration>
  20. // Uniforms
  21. #include<instancesDeclaration>
  22. #ifdef MAINUV1
  23. varying vec2 vMainUV1;
  24. #endif
  25. #ifdef MAINUV2
  26. varying vec2 vMainUV2;
  27. #endif
  28. #ifdef DIFFUSE
  29. varying vec2 vDiffuseUV;
  30. #endif
  31. #ifdef AMBIENT
  32. varying vec2 vAmbientUV;
  33. #endif
  34. #ifdef OPACITY
  35. varying vec2 vOpacityUV;
  36. #endif
  37. #ifdef EMISSIVE
  38. varying vec2 vEmissiveUV;
  39. #endif
  40. #ifdef LIGHTMAP
  41. varying vec2 vLightmapUV;
  42. #endif
  43. #if defined(SPECULAR) && defined(SPECULARTERM)
  44. varying vec2 vSpecularUV;
  45. #endif
  46. #ifdef BUMP
  47. varying vec2 vBumpUV;
  48. #endif
  49. // Output
  50. varying vec3 vPositionW;
  51. #ifdef NORMAL
  52. varying vec3 vNormalW;
  53. #endif
  54. #ifdef VERTEXCOLOR
  55. varying vec4 vColor;
  56. #endif
  57. #include<bumpVertexDeclaration>
  58. #include<clipPlaneVertexDeclaration>
  59. #include<fogVertexDeclaration>
  60. #include<__decl__lightFragment>[0..maxSimultaneousLights]
  61. #include<morphTargetsVertexGlobalDeclaration>
  62. #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
  63. #ifdef REFLECTIONMAP_SKYBOX
  64. varying vec3 vPositionUVW;
  65. #endif
  66. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  67. varying vec3 vDirectionW;
  68. #endif
  69. #include<logDepthDeclaration>
  70. void main(void) {
  71. vec3 positionUpdated = position;
  72. #ifdef NORMAL
  73. vec3 normalUpdated = normal;
  74. #endif
  75. #ifdef TANGENT
  76. vec4 tangentUpdated = tangent;
  77. #endif
  78. #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
  79. #ifdef REFLECTIONMAP_SKYBOX
  80. vPositionUVW = positionUpdated;
  81. #endif
  82. #include<instancesVertex>
  83. #include<bonesVertex>
  84. gl_Position = viewProjection * finalWorld * vec4(positionUpdated, 1.0);
  85. vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);
  86. vPositionW = vec3(worldPos);
  87. #ifdef NORMAL
  88. vNormalW = normalize(vec3(finalWorld * vec4(normalUpdated, 0.0)));
  89. #endif
  90. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  91. vDirectionW = normalize(vec3(finalWorld * vec4(positionUpdated, 0.0)));
  92. #endif
  93. // Texture coordinates
  94. #ifndef UV1
  95. vec2 uv = vec2(0., 0.);
  96. #endif
  97. #ifndef UV2
  98. vec2 uv2 = vec2(0., 0.);
  99. #endif
  100. #ifdef MAINUV1
  101. vMainUV1 = uv;
  102. #endif
  103. #ifdef MAINUV2
  104. vMainUV2 = uv;
  105. #endif
  106. #if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0
  107. if (vDiffuseInfos.x == 0.)
  108. {
  109. vDiffuseUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
  110. }
  111. else
  112. {
  113. vDiffuseUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
  114. }
  115. #endif
  116. #ifdef AMBIENT
  117. if (vAmbientInfos.x == 0.)
  118. {
  119. vAmbientUV = vec2(ambientMatrix * vec4(uv, 1.0, 0.0));
  120. }
  121. else
  122. {
  123. vAmbientUV = vec2(ambientMatrix * vec4(uv2, 1.0, 0.0));
  124. }
  125. #endif
  126. #ifdef OPACITY
  127. if (vOpacityInfos.x == 0.)
  128. {
  129. vOpacityUV = vec2(opacityMatrix * vec4(uv, 1.0, 0.0));
  130. }
  131. else
  132. {
  133. vOpacityUV = vec2(opacityMatrix * vec4(uv2, 1.0, 0.0));
  134. }
  135. #endif
  136. #ifdef EMISSIVE
  137. if (vEmissiveInfos.x == 0.)
  138. {
  139. vEmissiveUV = vec2(emissiveMatrix * vec4(uv, 1.0, 0.0));
  140. }
  141. else
  142. {
  143. vEmissiveUV = vec2(emissiveMatrix * vec4(uv2, 1.0, 0.0));
  144. }
  145. #endif
  146. #ifdef LIGHTMAP
  147. if (vLightmapInfos.x == 0.)
  148. {
  149. vLightmapUV = vec2(lightmapMatrix * vec4(uv, 1.0, 0.0));
  150. }
  151. else
  152. {
  153. vLightmapUV = vec2(lightmapMatrix * vec4(uv2, 1.0, 0.0));
  154. }
  155. #endif
  156. #if defined(SPECULAR) && defined(SPECULARTERM)
  157. if (vSpecularInfos.x == 0.)
  158. {
  159. vSpecularUV = vec2(specularMatrix * vec4(uv, 1.0, 0.0));
  160. }
  161. else
  162. {
  163. vSpecularUV = vec2(specularMatrix * vec4(uv2, 1.0, 0.0));
  164. }
  165. #endif
  166. #ifdef BUMP
  167. if (vBumpInfos.x == 0.)
  168. {
  169. vBumpUV = vec2(bumpMatrix * vec4(uv, 1.0, 0.0));
  170. }
  171. else
  172. {
  173. vBumpUV = vec2(bumpMatrix * vec4(uv2, 1.0, 0.0));
  174. }
  175. #endif
  176. #include<bumpVertex>
  177. #include<clipPlaneVertex>
  178. #include<fogVertex>
  179. #include<shadowsVertex>[0..maxSimultaneousLights]
  180. #ifdef VERTEXCOLOR
  181. // Vertex color
  182. vColor = color;
  183. #endif
  184. #include<pointCloudVertex>
  185. #include<logDepthVertex>
  186. }