default.vertex.fx 4.2 KB

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