pbr.vertex.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. // Do not edit.
  2. import { ShaderStore } from "../Engines/shaderStore.js";
  3. import "./ShadersInclude/pbrVertexDeclaration.js";
  4. import "./ShadersInclude/pbrUboDeclaration.js";
  5. import "./ShadersInclude/uvAttributeDeclaration.js";
  6. import "./ShadersInclude/mainUVVaryingDeclaration.js";
  7. import "./ShadersInclude/helperFunctions.js";
  8. import "./ShadersInclude/bonesDeclaration.js";
  9. import "./ShadersInclude/bakedVertexAnimationDeclaration.js";
  10. import "./ShadersInclude/instancesDeclaration.js";
  11. import "./ShadersInclude/prePassVertexDeclaration.js";
  12. import "./ShadersInclude/samplerVertexDeclaration.js";
  13. import "./ShadersInclude/harmonicsFunctions.js";
  14. import "./ShadersInclude/bumpVertexDeclaration.js";
  15. import "./ShadersInclude/clipPlaneVertexDeclaration.js";
  16. import "./ShadersInclude/fogVertexDeclaration.js";
  17. import "./ShadersInclude/lightVxFragmentDeclaration.js";
  18. import "./ShadersInclude/lightVxUboDeclaration.js";
  19. import "./ShadersInclude/morphTargetsVertexGlobalDeclaration.js";
  20. import "./ShadersInclude/morphTargetsVertexDeclaration.js";
  21. import "./ShadersInclude/logDepthDeclaration.js";
  22. import "./ShadersInclude/morphTargetsVertexGlobal.js";
  23. import "./ShadersInclude/morphTargetsVertex.js";
  24. import "./ShadersInclude/instancesVertex.js";
  25. import "./ShadersInclude/bonesVertex.js";
  26. import "./ShadersInclude/bakedVertexAnimation.js";
  27. import "./ShadersInclude/prePassVertex.js";
  28. import "./ShadersInclude/uvVariableDeclaration.js";
  29. import "./ShadersInclude/samplerVertexImplementation.js";
  30. import "./ShadersInclude/bumpVertex.js";
  31. import "./ShadersInclude/clipPlaneVertex.js";
  32. import "./ShadersInclude/fogVertex.js";
  33. import "./ShadersInclude/shadowsVertex.js";
  34. import "./ShadersInclude/vertexColorMixing.js";
  35. import "./ShadersInclude/logDepthVertex.js";
  36. const name = "pbrVertexShader";
  37. const shader = `precision highp float;
  38. #include<__decl__pbrVertex>
  39. #define CUSTOM_VERTEX_BEGIN
  40. attribute vec3 position;
  41. #ifdef NORMAL
  42. attribute vec3 normal;
  43. #endif
  44. #ifdef TANGENT
  45. attribute vec4 tangent;
  46. #endif
  47. #ifdef UV1
  48. attribute vec2 uv;
  49. #endif
  50. #include<uvAttributeDeclaration>[2..7]
  51. #include<mainUVVaryingDeclaration>[1..7]
  52. #ifdef VERTEXCOLOR
  53. attribute vec4 color;
  54. #endif
  55. #include<helperFunctions>
  56. #include<bonesDeclaration>
  57. #include<bakedVertexAnimationDeclaration>
  58. #include<instancesDeclaration>
  59. #include<prePassVertexDeclaration>
  60. #include<samplerVertexDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo)
  61. #include<samplerVertexDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)
  62. #include<samplerVertexDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)
  63. #include<samplerVertexDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)
  64. #include<samplerVertexDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)
  65. #include<samplerVertexDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)
  66. #include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity)
  67. #include<samplerVertexDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler)
  68. #include<samplerVertexDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance)
  69. #include<samplerVertexDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance)
  70. #include<samplerVertexDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)
  71. #include<samplerVertexDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal)
  72. #ifdef CLEARCOAT
  73. #include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat)
  74. #include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
  75. #include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump)
  76. #include<samplerVertexDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint)
  77. #endif
  78. #ifdef IRIDESCENCE
  79. #include<samplerVertexDeclaration>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence)
  80. #include<samplerVertexDeclaration>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness)
  81. #endif
  82. #ifdef SHEEN
  83. #include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen)
  84. #include<samplerVertexDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
  85. #endif
  86. #ifdef ANISOTROPIC
  87. #include<samplerVertexDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy)
  88. #endif
  89. #ifdef SUBSURFACE
  90. #include<samplerVertexDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness)
  91. #include<samplerVertexDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity)
  92. #include<samplerVertexDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity)
  93. #endif
  94. varying vec3 vPositionW;
  95. #if DEBUGMODE>0
  96. varying vec4 vClipSpacePosition;
  97. #endif
  98. #ifdef NORMAL
  99. varying vec3 vNormalW;
  100. #if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
  101. varying vec3 vEnvironmentIrradiance;
  102. #include<harmonicsFunctions>
  103. #endif
  104. #endif
  105. #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
  106. varying vec4 vColor;
  107. #endif
  108. #include<bumpVertexDeclaration>
  109. #include<clipPlaneVertexDeclaration>
  110. #include<fogVertexDeclaration>
  111. #include<__decl__lightVxFragment>[0..maxSimultaneousLights]
  112. #include<morphTargetsVertexGlobalDeclaration>
  113. #include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
  114. #ifdef REFLECTIONMAP_SKYBOX
  115. varying vec3 vPositionUVW;
  116. #endif
  117. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  118. varying vec3 vDirectionW;
  119. #endif
  120. #include<logDepthDeclaration>
  121. #define CUSTOM_VERTEX_DEFINITIONS
  122. void main(void) {
  123. #define CUSTOM_VERTEX_MAIN_BEGIN
  124. vec3 positionUpdated=position;
  125. #ifdef NORMAL
  126. vec3 normalUpdated=normal;
  127. #endif
  128. #ifdef TANGENT
  129. vec4 tangentUpdated=tangent;
  130. #endif
  131. #ifdef UV1
  132. vec2 uvUpdated=uv;
  133. #endif
  134. #include<morphTargetsVertexGlobal>
  135. #include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
  136. #ifdef REFLECTIONMAP_SKYBOX
  137. vPositionUVW=positionUpdated;
  138. #endif
  139. #define CUSTOM_VERTEX_UPDATE_POSITION
  140. #define CUSTOM_VERTEX_UPDATE_NORMAL
  141. #include<instancesVertex>
  142. #if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)
  143. vCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);vPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);
  144. #endif
  145. #include<bonesVertex>
  146. #include<bakedVertexAnimation>
  147. vec4 worldPos=finalWorld*vec4(positionUpdated,1.0);vPositionW=vec3(worldPos);
  148. #include<prePassVertex>
  149. #ifdef NORMAL
  150. mat3 normalWorld=mat3(finalWorld);
  151. #if defined(INSTANCES) && defined(THIN_INSTANCES)
  152. vNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));vNormalW=normalize(normalWorld*vNormalW);
  153. #else
  154. #ifdef NONUNIFORMSCALING
  155. normalWorld=transposeMat3(inverseMat3(normalWorld));
  156. #endif
  157. vNormalW=normalize(normalWorld*normalUpdated);
  158. #endif
  159. #if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
  160. vec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;
  161. #ifdef REFLECTIONMAP_OPPOSITEZ
  162. reflectionVector.z*=-1.0;
  163. #endif
  164. vEnvironmentIrradiance=computeEnvironmentIrradiance(reflectionVector);
  165. #endif
  166. #endif
  167. #define CUSTOM_VERTEX_UPDATE_WORLDPOS
  168. #ifdef MULTIVIEW
  169. if (gl_ViewID_OVR==0u) {gl_Position=viewProjection*worldPos;} else {gl_Position=viewProjectionR*worldPos;}
  170. #else
  171. gl_Position=viewProjection*worldPos;
  172. #endif
  173. #if DEBUGMODE>0
  174. vClipSpacePosition=gl_Position;
  175. #endif
  176. #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
  177. vDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));
  178. #endif
  179. #ifndef UV1
  180. vec2 uvUpdated=vec2(0.,0.);
  181. #endif
  182. #ifdef MAINUV1
  183. vMainUV1=uvUpdated;
  184. #endif
  185. #include<uvVariableDeclaration>[2..7]
  186. #include<samplerVertexImplementation>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_MATRIXNAME_,albedo,_INFONAME_,AlbedoInfos.x)
  187. #include<samplerVertexImplementation>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)
  188. #include<samplerVertexImplementation>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)
  189. #include<samplerVertexImplementation>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)
  190. #include<samplerVertexImplementation>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)
  191. #include<samplerVertexImplementation>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)
  192. #include<samplerVertexImplementation>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_MATRIXNAME_,reflectivity,_INFONAME_,ReflectivityInfos.x)
  193. #include<samplerVertexImplementation>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_MATRIXNAME_,microSurfaceSampler,_INFONAME_,MicroSurfaceSamplerInfos.x)
  194. #include<samplerVertexImplementation>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_MATRIXNAME_,metallicReflectance,_INFONAME_,MetallicReflectanceInfos.x)
  195. #include<samplerVertexImplementation>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_MATRIXNAME_,reflectance,_INFONAME_,ReflectanceInfos.x)
  196. #include<samplerVertexImplementation>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)
  197. #include<samplerVertexImplementation>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_MATRIXNAME_,decal,_INFONAME_,DecalInfos.x)
  198. #ifdef CLEARCOAT
  199. #include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_MATRIXNAME_,clearCoat,_INFONAME_,ClearCoatInfos.x)
  200. #include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness,_MATRIXNAME_,clearCoatRoughness,_INFONAME_,ClearCoatInfos.z)
  201. #include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_MATRIXNAME_,clearCoatBump,_INFONAME_,ClearCoatBumpInfos.x)
  202. #include<samplerVertexImplementation>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_MATRIXNAME_,clearCoatTint,_INFONAME_,ClearCoatTintInfos.x)
  203. #endif
  204. #ifdef IRIDESCENCE
  205. #include<samplerVertexImplementation>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_MATRIXNAME_,iridescence,_INFONAME_,IridescenceInfos.x)
  206. #include<samplerVertexImplementation>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_MATRIXNAME_,iridescenceThickness,_INFONAME_,IridescenceInfos.z)
  207. #endif
  208. #ifdef SHEEN
  209. #include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_MATRIXNAME_,sheen,_INFONAME_,SheenInfos.x)
  210. #include<samplerVertexImplementation>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness,_MATRIXNAME_,sheenRoughness,_INFONAME_,SheenInfos.z)
  211. #endif
  212. #ifdef ANISOTROPIC
  213. #include<samplerVertexImplementation>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_MATRIXNAME_,anisotropy,_INFONAME_,AnisotropyInfos.x)
  214. #endif
  215. #ifdef SUBSURFACE
  216. #include<samplerVertexImplementation>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_MATRIXNAME_,thickness,_INFONAME_,ThicknessInfos.x)
  217. #include<samplerVertexImplementation>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_MATRIXNAME_,refractionIntensity,_INFONAME_,RefractionIntensityInfos.x)
  218. #include<samplerVertexImplementation>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_MATRIXNAME_,translucencyIntensity,_INFONAME_,TranslucencyIntensityInfos.x)
  219. #endif
  220. #include<bumpVertex>
  221. #include<clipPlaneVertex>
  222. #include<fogVertex>
  223. #include<shadowsVertex>[0..maxSimultaneousLights]
  224. #include<vertexColorMixing>
  225. #if defined(POINTSIZE) && !defined(WEBGPU)
  226. gl_PointSize=pointSize;
  227. #endif
  228. #include<logDepthVertex>
  229. #define CUSTOM_VERTEX_MAIN_END
  230. }`;
  231. // Sideeffect
  232. ShaderStore.ShadersStore[name] = shader;
  233. /** @internal */
  234. export const pbrVertexShader = { name, shader };
  235. //# sourceMappingURL=pbr.vertex.js.map