@babylonjs/viewer 7.23.0-alpha → 7.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/configuration/configuration.d.ts +107 -0
  2. package/configuration/configuration.js +16 -0
  3. package/configuration/configuration.js.map +1 -0
  4. package/configuration/configurationCompatibility.d.ts +8 -0
  5. package/configuration/configurationCompatibility.js +66 -0
  6. package/configuration/configurationCompatibility.js.map +1 -0
  7. package/configuration/configurationContainer.d.ts +10 -0
  8. package/configuration/configurationContainer.js +10 -0
  9. package/configuration/configurationContainer.js.map +1 -0
  10. package/configuration/globals.d.ts +6 -0
  11. package/configuration/globals.js +18 -0
  12. package/configuration/globals.js.map +1 -0
  13. package/configuration/index.d.ts +2 -0
  14. package/configuration/index.js +4 -0
  15. package/configuration/index.js.map +1 -0
  16. package/configuration/interfaces/cameraConfiguration.d.ts +31 -0
  17. package/configuration/interfaces/cameraConfiguration.js +2 -0
  18. package/configuration/interfaces/cameraConfiguration.js.map +1 -0
  19. package/configuration/interfaces/colorGradingConfiguration.d.ts +81 -0
  20. package/configuration/interfaces/colorGradingConfiguration.js +2 -0
  21. package/configuration/interfaces/colorGradingConfiguration.js.map +1 -0
  22. package/configuration/interfaces/defaultRenderingPipelineConfiguration.d.ts +20 -0
  23. package/configuration/interfaces/defaultRenderingPipelineConfiguration.js +2 -0
  24. package/configuration/interfaces/defaultRenderingPipelineConfiguration.js.map +1 -0
  25. package/configuration/interfaces/environmentMapConfiguration.d.ts +22 -0
  26. package/configuration/interfaces/environmentMapConfiguration.js +2 -0
  27. package/configuration/interfaces/environmentMapConfiguration.js.map +1 -0
  28. package/configuration/interfaces/groundConfiguration.d.ts +24 -0
  29. package/configuration/interfaces/groundConfiguration.js +2 -0
  30. package/configuration/interfaces/groundConfiguration.js.map +1 -0
  31. package/configuration/interfaces/imageProcessingConfiguration.d.ts +45 -0
  32. package/configuration/interfaces/imageProcessingConfiguration.js +2 -0
  33. package/configuration/interfaces/imageProcessingConfiguration.js.map +1 -0
  34. package/configuration/interfaces/index.d.ts +15 -0
  35. package/configuration/interfaces/index.js +16 -0
  36. package/configuration/interfaces/index.js.map +1 -0
  37. package/configuration/interfaces/lightConfiguration.d.ts +60 -0
  38. package/configuration/interfaces/lightConfiguration.js +2 -0
  39. package/configuration/interfaces/lightConfiguration.js.map +1 -0
  40. package/configuration/interfaces/modelAnimationConfiguration.d.ts +26 -0
  41. package/configuration/interfaces/modelAnimationConfiguration.js +2 -0
  42. package/configuration/interfaces/modelAnimationConfiguration.js.map +1 -0
  43. package/configuration/interfaces/modelConfiguration.d.ts +65 -0
  44. package/configuration/interfaces/modelConfiguration.js +2 -0
  45. package/configuration/interfaces/modelConfiguration.js.map +1 -0
  46. package/configuration/interfaces/observersConfiguration.d.ts +5 -0
  47. package/configuration/interfaces/observersConfiguration.js +2 -0
  48. package/configuration/interfaces/observersConfiguration.js.map +1 -0
  49. package/configuration/interfaces/sceneConfiguration.d.ts +48 -0
  50. package/configuration/interfaces/sceneConfiguration.js +2 -0
  51. package/configuration/interfaces/sceneConfiguration.js.map +1 -0
  52. package/configuration/interfaces/sceneOptimizerConfiguration.d.ts +23 -0
  53. package/configuration/interfaces/sceneOptimizerConfiguration.js +2 -0
  54. package/configuration/interfaces/sceneOptimizerConfiguration.js.map +1 -0
  55. package/configuration/interfaces/skyboxConfiguration.d.ts +21 -0
  56. package/configuration/interfaces/skyboxConfiguration.js +2 -0
  57. package/configuration/interfaces/skyboxConfiguration.js.map +1 -0
  58. package/configuration/interfaces/templateConfiguration.d.ts +67 -0
  59. package/configuration/interfaces/templateConfiguration.js +2 -0
  60. package/configuration/interfaces/templateConfiguration.js.map +1 -0
  61. package/configuration/interfaces/vrConfiguration.d.ts +16 -0
  62. package/configuration/interfaces/vrConfiguration.js +2 -0
  63. package/configuration/interfaces/vrConfiguration.js.map +1 -0
  64. package/configuration/loader.d.ts +4 -0
  65. package/configuration/loader.js +17 -0
  66. package/configuration/loader.js.map +1 -0
  67. package/configuration/mappers.d.ts +43 -0
  68. package/configuration/mappers.js +192 -0
  69. package/configuration/mappers.js.map +1 -0
  70. package/configuration/renderOnlyLoader.d.ts +33 -0
  71. package/configuration/renderOnlyLoader.js +162 -0
  72. package/configuration/renderOnlyLoader.js.map +1 -0
  73. package/configuration/types/default.d.ts +6 -0
  74. package/configuration/types/default.js +121 -0
  75. package/configuration/types/default.js.map +1 -0
  76. package/configuration/types/environmentMap.d.ts +5 -0
  77. package/configuration/types/environmentMap.js +14 -0
  78. package/configuration/types/environmentMap.js.map +1 -0
  79. package/configuration/types/extended.d.ts +6 -0
  80. package/configuration/types/extended.js +317 -0
  81. package/configuration/types/extended.js.map +1 -0
  82. package/configuration/types/index.d.ts +14 -0
  83. package/configuration/types/index.js +51 -0
  84. package/configuration/types/index.js.map +1 -0
  85. package/configuration/types/minimal.d.ts +6 -0
  86. package/configuration/types/minimal.js +43 -0
  87. package/configuration/types/minimal.js.map +1 -0
  88. package/configuration/types/renderOnlyDefault.d.ts +30 -0
  89. package/configuration/types/renderOnlyDefault.js +31 -0
  90. package/configuration/types/renderOnlyDefault.js.map +1 -0
  91. package/configuration/types/shadowLight.d.ts +9 -0
  92. package/configuration/types/shadowLight.js +64 -0
  93. package/configuration/types/shadowLight.js.map +1 -0
  94. package/helper/index.d.ts +29 -0
  95. package/helper/index.js +66 -0
  96. package/helper/index.js.map +1 -0
  97. package/index.d.ts +30 -0
  98. package/index.js +46 -0
  99. package/index.js.map +1 -0
  100. package/initializer.d.ts +11 -0
  101. package/initializer.js +35 -0
  102. package/initializer.js.map +1 -0
  103. package/interfaces.d.ts +5 -0
  104. package/interfaces.js +7 -0
  105. package/interfaces.js.map +1 -0
  106. package/labs/environmentSerializer.d.ts +126 -0
  107. package/labs/environmentSerializer.js +191 -0
  108. package/labs/environmentSerializer.js.map +1 -0
  109. package/labs/texture.d.ts +183 -0
  110. package/labs/texture.js +351 -0
  111. package/labs/texture.js.map +1 -0
  112. package/labs/viewerLabs.d.ts +51 -0
  113. package/labs/viewerLabs.js +134 -0
  114. package/labs/viewerLabs.js.map +1 -0
  115. package/loader/modelLoader.d.ts +56 -0
  116. package/loader/modelLoader.js +199 -0
  117. package/loader/modelLoader.js.map +1 -0
  118. package/loader/plugins/applyMaterialConfig.d.ts +12 -0
  119. package/loader/plugins/applyMaterialConfig.js +16 -0
  120. package/loader/plugins/applyMaterialConfig.js.map +1 -0
  121. package/loader/plugins/extendedMaterialLoaderPlugin.d.ts +9 -0
  122. package/loader/plugins/extendedMaterialLoaderPlugin.js +16 -0
  123. package/loader/plugins/extendedMaterialLoaderPlugin.js.map +1 -0
  124. package/loader/plugins/index.d.ts +19 -0
  125. package/loader/plugins/index.js +44 -0
  126. package/loader/plugins/index.js.map +1 -0
  127. package/loader/plugins/loaderPlugin.d.ts +24 -0
  128. package/loader/plugins/loaderPlugin.js +2 -0
  129. package/loader/plugins/loaderPlugin.js.map +1 -0
  130. package/loader/plugins/msftLodLoaderPlugin.d.ts +12 -0
  131. package/loader/plugins/msftLodLoaderPlugin.js +21 -0
  132. package/loader/plugins/msftLodLoaderPlugin.js.map +1 -0
  133. package/loader/plugins/telemetryLoaderPlugin.d.ts +12 -0
  134. package/loader/plugins/telemetryLoaderPlugin.js +36 -0
  135. package/loader/plugins/telemetryLoaderPlugin.js.map +1 -0
  136. package/managers/observablesManager.d.ts +66 -0
  137. package/managers/observablesManager.js +35 -0
  138. package/managers/observablesManager.js.map +1 -0
  139. package/managers/sceneManager.d.ts +245 -0
  140. package/managers/sceneManager.js +1375 -0
  141. package/managers/sceneManager.js.map +1 -0
  142. package/managers/telemetryManager.d.ts +78 -0
  143. package/managers/telemetryManager.js +117 -0
  144. package/managers/telemetryManager.js.map +1 -0
  145. package/model/modelAnimation.d.ts +215 -0
  146. package/model/modelAnimation.js +237 -0
  147. package/model/modelAnimation.js.map +1 -0
  148. package/model/viewerModel.d.ts +233 -0
  149. package/model/viewerModel.js +673 -0
  150. package/model/viewerModel.js.map +1 -0
  151. package/optimizer/custom/extended.d.ts +13 -0
  152. package/optimizer/custom/extended.js +101 -0
  153. package/optimizer/custom/extended.js.map +1 -0
  154. package/optimizer/custom/index.d.ts +9 -0
  155. package/optimizer/custom/index.js +26 -0
  156. package/optimizer/custom/index.js.map +1 -0
  157. package/package.json +27 -17
  158. package/readme.md +21 -35
  159. package/renderOnlyIndex.d.ts +11 -0
  160. package/renderOnlyIndex.js +18 -0
  161. package/renderOnlyIndex.js.map +1 -0
  162. package/templating/eventManager.d.ts +35 -0
  163. package/templating/eventManager.js +66 -0
  164. package/templating/eventManager.js.map +1 -0
  165. package/templating/plugins/hdButtonPlugin.d.ts +9 -0
  166. package/templating/plugins/hdButtonPlugin.js +21 -0
  167. package/templating/plugins/hdButtonPlugin.js.map +1 -0
  168. package/templating/plugins/printButton.d.ts +9 -0
  169. package/templating/plugins/printButton.js +40 -0
  170. package/templating/plugins/printButton.js.map +1 -0
  171. package/templating/templateManager.d.ts +197 -0
  172. package/templating/templateManager.js +561 -0
  173. package/templating/templateManager.js.map +1 -0
  174. package/templating/viewerTemplatePlugin.d.ts +21 -0
  175. package/templating/viewerTemplatePlugin.js +69 -0
  176. package/templating/viewerTemplatePlugin.js.map +1 -0
  177. package/viewer/defaultViewer.d.ts +130 -0
  178. package/viewer/defaultViewer.js +675 -0
  179. package/viewer/defaultViewer.js.map +1 -0
  180. package/viewer/renderOnlyViewer.d.ts +9 -0
  181. package/viewer/renderOnlyViewer.js +46 -0
  182. package/viewer/renderOnlyViewer.js.map +1 -0
  183. package/viewer/viewer.d.ts +258 -0
  184. package/viewer/viewer.js +783 -0
  185. package/viewer/viewer.js.map +1 -0
  186. package/viewer/viewerManager.d.ts +58 -0
  187. package/viewer/viewerManager.js +91 -0
  188. package/viewer/viewerManager.js.map +1 -0
  189. package/viewer/viewerWithTemplate.d.ts +9 -0
  190. package/viewer/viewerWithTemplate.js +20 -0
  191. package/viewer/viewerWithTemplate.js.map +1 -0
  192. package/dist/babylon-viewer.esm.js +0 -2
  193. package/dist/babylon-viewer.esm.js.map +0 -1
  194. package/dist/babylon-viewer.esm.min.js +0 -2
  195. package/dist/babylon-viewer.esm.min.js.map +0 -1
  196. package/dist/chunks/basisTextureLoader-BnIeLUi5.esm.min.js +0 -2
  197. package/dist/chunks/basisTextureLoader-BnIeLUi5.esm.min.js.map +0 -1
  198. package/dist/chunks/basisTextureLoader-D5DAa_qR.esm.js +0 -600
  199. package/dist/chunks/basisTextureLoader-D5DAa_qR.esm.js.map +0 -1
  200. package/dist/chunks/ddsTextureLoader-D9xNsYAT.esm.min.js +0 -2
  201. package/dist/chunks/ddsTextureLoader-D9xNsYAT.esm.min.js.map +0 -1
  202. package/dist/chunks/ddsTextureLoader-DCv39Yn8.esm.js +0 -87
  203. package/dist/chunks/ddsTextureLoader-DCv39Yn8.esm.js.map +0 -1
  204. package/dist/chunks/envTextureLoader-Cmuugxf1.esm.min.js +0 -2
  205. package/dist/chunks/envTextureLoader-Cmuugxf1.esm.min.js.map +0 -1
  206. package/dist/chunks/envTextureLoader-Dl0xiO1G.esm.js +0 -62
  207. package/dist/chunks/envTextureLoader-Dl0xiO1G.esm.js.map +0 -1
  208. package/dist/chunks/exrTextureLoader-C0UEUMfH.esm.js +0 -1682
  209. package/dist/chunks/exrTextureLoader-C0UEUMfH.esm.js.map +0 -1
  210. package/dist/chunks/exrTextureLoader-DVZGHvAz.esm.min.js +0 -2
  211. package/dist/chunks/exrTextureLoader-DVZGHvAz.esm.min.js.map +0 -1
  212. package/dist/chunks/hdrTextureLoader-BM271mLj.esm.min.js +0 -2
  213. package/dist/chunks/hdrTextureLoader-BM271mLj.esm.min.js.map +0 -1
  214. package/dist/chunks/hdrTextureLoader-CrHh5vTV.esm.js +0 -252
  215. package/dist/chunks/hdrTextureLoader-CrHh5vTV.esm.js.map +0 -1
  216. package/dist/chunks/helperFunctions-BQ8X1piK.esm.min.js +0 -2
  217. package/dist/chunks/helperFunctions-BQ8X1piK.esm.min.js.map +0 -1
  218. package/dist/chunks/helperFunctions-CUX6uz_w.esm.js +0 -108
  219. package/dist/chunks/helperFunctions-CUX6uz_w.esm.js.map +0 -1
  220. package/dist/chunks/helperFunctions-ChWwJuKv.esm.min.js +0 -2
  221. package/dist/chunks/helperFunctions-ChWwJuKv.esm.min.js.map +0 -1
  222. package/dist/chunks/helperFunctions-DpMCqZKL.esm.js +0 -80
  223. package/dist/chunks/helperFunctions-DpMCqZKL.esm.js.map +0 -1
  224. package/dist/chunks/index-DHuuBhpP.esm.js +0 -102146
  225. package/dist/chunks/index-DHuuBhpP.esm.js.map +0 -1
  226. package/dist/chunks/index-EA8kJjBu.esm.min.js +0 -56
  227. package/dist/chunks/index-EA8kJjBu.esm.min.js.map +0 -1
  228. package/dist/chunks/ktxTextureLoader-BRR5FQro.esm.min.js +0 -2
  229. package/dist/chunks/ktxTextureLoader-BRR5FQro.esm.min.js.map +0 -1
  230. package/dist/chunks/ktxTextureLoader-gZQU7w7m.esm.js +0 -813
  231. package/dist/chunks/ktxTextureLoader-gZQU7w7m.esm.js.map +0 -1
  232. package/dist/chunks/logDepthDeclaration-B1MaqbwG.esm.min.js +0 -2
  233. package/dist/chunks/logDepthDeclaration-B1MaqbwG.esm.min.js.map +0 -1
  234. package/dist/chunks/logDepthDeclaration-B2UkQWK5.esm.min.js +0 -2
  235. package/dist/chunks/logDepthDeclaration-B2UkQWK5.esm.min.js.map +0 -1
  236. package/dist/chunks/logDepthDeclaration-COhUDa1N.esm.js +0 -73
  237. package/dist/chunks/logDepthDeclaration-COhUDa1N.esm.js.map +0 -1
  238. package/dist/chunks/logDepthDeclaration-CojhsbFY.esm.js +0 -76
  239. package/dist/chunks/logDepthDeclaration-CojhsbFY.esm.js.map +0 -1
  240. package/dist/chunks/pass.fragment-BNKAdmAy.esm.min.js +0 -2
  241. package/dist/chunks/pass.fragment-BNKAdmAy.esm.min.js.map +0 -1
  242. package/dist/chunks/pass.fragment-CDiei_Sn.esm.js +0 -15
  243. package/dist/chunks/pass.fragment-CDiei_Sn.esm.js.map +0 -1
  244. package/dist/chunks/pbr.fragment-BN71FgFx.esm.min.js +0 -2
  245. package/dist/chunks/pbr.fragment-BN71FgFx.esm.min.js.map +0 -1
  246. package/dist/chunks/pbr.fragment-BvCEmvwh.esm.js +0 -4530
  247. package/dist/chunks/pbr.fragment-BvCEmvwh.esm.js.map +0 -1
  248. package/dist/chunks/pbr.fragment-DU4hy3T_.esm.min.js +0 -2
  249. package/dist/chunks/pbr.fragment-DU4hy3T_.esm.min.js.map +0 -1
  250. package/dist/chunks/pbr.fragment-QxF1RFoh.esm.js +0 -4323
  251. package/dist/chunks/pbr.fragment-QxF1RFoh.esm.js.map +0 -1
  252. package/dist/chunks/pbr.vertex-62J9fbA6.esm.js +0 -932
  253. package/dist/chunks/pbr.vertex-62J9fbA6.esm.js.map +0 -1
  254. package/dist/chunks/pbr.vertex-C8vOdMd6.esm.min.js +0 -2
  255. package/dist/chunks/pbr.vertex-C8vOdMd6.esm.min.js.map +0 -1
  256. package/dist/chunks/pbr.vertex-Cp4yABqq.esm.js +0 -809
  257. package/dist/chunks/pbr.vertex-Cp4yABqq.esm.js.map +0 -1
  258. package/dist/chunks/pbr.vertex-DPPPQSbX.esm.min.js +0 -2
  259. package/dist/chunks/pbr.vertex-DPPPQSbX.esm.min.js.map +0 -1
  260. package/dist/chunks/postprocess.vertex-5WWqPw1s.esm.js +0 -20
  261. package/dist/chunks/postprocess.vertex-5WWqPw1s.esm.js.map +0 -1
  262. package/dist/chunks/postprocess.vertex-DzqXlss5.esm.min.js +0 -2
  263. package/dist/chunks/postprocess.vertex-DzqXlss5.esm.min.js.map +0 -1
  264. package/dist/chunks/rgbdDecode.fragment-BdggM8VZ.esm.min.js +0 -2
  265. package/dist/chunks/rgbdDecode.fragment-BdggM8VZ.esm.min.js.map +0 -1
  266. package/dist/chunks/rgbdDecode.fragment-Bpslxg4R.esm.js +0 -17
  267. package/dist/chunks/rgbdDecode.fragment-Bpslxg4R.esm.js.map +0 -1
  268. package/dist/chunks/rgbdDecode.fragment-By7Rc7Xz.esm.js +0 -17
  269. package/dist/chunks/rgbdDecode.fragment-By7Rc7Xz.esm.js.map +0 -1
  270. package/dist/chunks/rgbdDecode.fragment-CnUoEV03.esm.min.js +0 -2
  271. package/dist/chunks/rgbdDecode.fragment-CnUoEV03.esm.min.js.map +0 -1
  272. package/dist/chunks/rgbdEncode.fragment-BBl79-3e.esm.js +0 -17
  273. package/dist/chunks/rgbdEncode.fragment-BBl79-3e.esm.js.map +0 -1
  274. package/dist/chunks/rgbdEncode.fragment-BGkuZmHn.esm.min.js +0 -2
  275. package/dist/chunks/rgbdEncode.fragment-BGkuZmHn.esm.min.js.map +0 -1
  276. package/dist/chunks/rgbdEncode.fragment-LUPpF87m.esm.min.js +0 -2
  277. package/dist/chunks/rgbdEncode.fragment-LUPpF87m.esm.min.js.map +0 -1
  278. package/dist/chunks/rgbdEncode.fragment-PJDNuVns.esm.js +0 -17
  279. package/dist/chunks/rgbdEncode.fragment-PJDNuVns.esm.js.map +0 -1
  280. package/dist/chunks/tgaTextureLoader-CccJYauf.esm.min.js +0 -2
  281. package/dist/chunks/tgaTextureLoader-CccJYauf.esm.min.js.map +0 -1
  282. package/dist/chunks/tgaTextureLoader-DdDpL5u3.esm.js +0 -349
  283. package/dist/chunks/tgaTextureLoader-DdDpL5u3.esm.js.map +0 -1
  284. package/lib/index.d.ts +0 -237
  285. package/lib/index.js +0 -869
  286. package/lib/index.js.map +0 -1
@@ -1,4323 +0,0 @@
1
- import { S as ShaderStore } from './index-DHuuBhpP.esm.js';
2
- import './logDepthDeclaration-COhUDa1N.esm.js';
3
- import './helperFunctions-DpMCqZKL.esm.js';
4
-
5
- // Do not edit.
6
- const name$S = "prePassDeclaration";
7
- const shader$S = `#ifdef PREPASS
8
- #ifdef PREPASS_LOCAL_POSITION
9
- varying vPosition : vec3f;
10
- #endif
11
- #ifdef PREPASS_DEPTH
12
- varying vViewPos: vec3f;
13
- #endif
14
- #if defined(PREPASS_VELOCITY) || defined(PREPASS_VELOCITY_LINEAR)
15
- varying vCurrentPosition: vec4f;varying vPreviousPosition: vec4f;
16
- #endif
17
- #endif
18
- `;
19
- // Sideeffect
20
- ShaderStore.IncludesShadersStoreWGSL[name$S] = shader$S;
21
-
22
- // Do not edit.
23
- const name$R = "oitDeclaration";
24
- const shader$R = `#ifdef ORDER_INDEPENDENT_TRANSPARENCY
25
- #define MAX_DEPTH 99999.0
26
- var oitDepthSamplerSampler: sampler;var oitDepthSampler: texture_2d<f32>;var oitFrontColorSamplerSampler: sampler;var oitFrontColorSampler: texture_2d<f32>;
27
- #endif
28
- `;
29
- // Sideeffect
30
- ShaderStore.IncludesShadersStoreWGSL[name$R] = shader$R;
31
-
32
- // Do not edit.
33
- const name$Q = "pbrFragmentExtraDeclaration";
34
- const shader$Q = `varying vPositionW: vec3f;
35
- #if DEBUGMODE>0
36
- varying vClipSpacePosition: vec4f;
37
- #endif
38
- #include<mainUVVaryingDeclaration>[1..7]
39
- #ifdef NORMAL
40
- varying vNormalW: vec3f;
41
- #if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)
42
- varying vEnvironmentIrradiance: vec3f;
43
- #endif
44
- #endif
45
- #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
46
- varying vColor: vec4f;
47
- #endif
48
- `;
49
- // Sideeffect
50
- ShaderStore.IncludesShadersStoreWGSL[name$Q] = shader$Q;
51
-
52
- // Do not edit.
53
- const name$P = "lightUboDeclaration";
54
- const shader$P = `#ifdef LIGHT{X}
55
- struct Light{X}
56
- {vLightData: vec4f,
57
- vLightDiffuse: vec4f,
58
- vLightSpecular: vec4f,
59
- #ifdef SPOTLIGHT{X}
60
- vLightDirection: vec4f,
61
- vLightFalloff: vec4f,
62
- #elif defined(POINTLIGHT{X})
63
- vLightFalloff: vec4f,
64
- #elif defined(HEMILIGHT{X})
65
- vLightGround: vec3f,
66
- #endif
67
- shadowsInfo: vec4f,
68
- depthValues: vec2f} ;var<uniform> light{X} : Light{X};
69
- #ifdef PROJECTEDLIGHTTEXTURE{X}
70
- uniform textureProjectionMatrix{X}: mat4x4f;var projectionLightTexture{X}Sampler: sampler;var projectionLightTexture{X}: texture_2d<f32>;
71
- #endif
72
- #ifdef SHADOW{X}
73
- #ifdef SHADOWCSM{X}
74
- uniform lightMatrix{X}: array<mat4x4f,SHADOWCSMNUM_CASCADES{X}>;uniform viewFrustumZ{X}: array<f32,SHADOWCSMNUM_CASCADES{X}>;uniform frustumLengths{X}: array<f32,SHADOWCSMNUM_CASCADES{X}>;uniform cascadeBlendFactor{X}: f32;varying vPositionFromLight{X}_0: vec4f;varying vDepthMetric{X}_0: f32;varying vPositionFromLight{X}_1: vec4f;varying vDepthMetric{X}_1: f32;varying vPositionFromLight{X}_2: vec4f;varying vDepthMetric{X}_2: f32;varying vPositionFromLight{X}_3: vec4f;varying vDepthMetric{X}_3: f32;varying vPositionFromCamera{X}: vec4f;var<private> vPositionFromLight{X}: array<vec4f,4>;var<private> vDepthMetric{X} : array<f32,4>;
75
- #if defined(SHADOWPCSS{X})
76
- var shadowTexture{X}Sampler: sampler_comparison;
77
- var shadowTexture{X}: texture_depth_2d_array;var depthTexture{X}Sampler: sampler;var depthTexture{X}: texture_2d_array<f32>;uniform lightSizeUVCorrection{X}: array<vec2f,SHADOWCSMNUM_CASCADES{X}>;uniform depthCorrection{X}: array<f32,SHADOWCSMNUM_CASCADES{X}>;uniform penumbraDarkness{X}: f32;
78
- #elif defined(SHADOWPCF{X})
79
- var shadowTexture{X}Sampler: sampler_comparison;var shadowTexture{X}: texture_depth_2d_array;
80
- #else
81
- var shadowTexture{X}Sampler: sampler;
82
- var shadowTexture{X}: texture_2d_array<f32>;
83
- #endif
84
- #ifdef SHADOWCSMDEBUG{X}
85
- const vCascadeColorsMultiplier{X}: array<vec3f,8>=array<vec3f,8>
86
- (
87
- vec3f ( 1.5,0.0,0.0 ),
88
- vec3f ( 0.0,1.5,0.0 ),
89
- vec3f ( 0.0,0.0,5.5 ),
90
- vec3f ( 1.5,0.0,5.5 ),
91
- vec3f ( 1.5,1.5,0.0 ),
92
- vec3f ( 1.0,1.0,1.0 ),
93
- vec3f ( 0.0,1.0,5.5 ),
94
- vec3f ( 0.5,3.5,0.75 )
95
- );
96
- #endif
97
- #elif defined(SHADOWCUBE{X})
98
- var shadowTexture{X}Sampler: sampler;var shadowTexture{X}: texture_cube<f32>;
99
- #else
100
- varying vPositionFromLight{X}: vec4f;varying vDepthMetric{X}: f32;
101
- #if defined(SHADOWPCSS{X})
102
- var shadowTexture{X}Sampler: sampler_comparison;
103
- var shadowTexture{X}: texture_depth_2d;var depthTexture{X}Sampler: sampler;
104
- var depthTexture{X}: texture_2d<f32>;
105
- #elif defined(SHADOWPCF{X})
106
- var shadowTexture{X}Sampler: sampler_comparison;var shadowTexture{X}: texture_depth_2d;
107
- #else
108
- var shadowTexture{X}Sampler: sampler;
109
- var shadowTexture{X}: texture_2d<f32>;
110
- #endif
111
- uniform lightMatrix{X}: mat4x4f;
112
- #endif
113
- #endif
114
- #endif
115
- `;
116
- // Sideeffect
117
- ShaderStore.IncludesShadersStoreWGSL[name$P] = shader$P;
118
-
119
- // Do not edit.
120
- const name$O = "samplerFragmentDeclaration";
121
- const shader$O = `#ifdef _DEFINENAME_
122
- #if _DEFINENAME_DIRECTUV==1
123
- #define v_VARYINGNAME_UV vMainUV1
124
- #elif _DEFINENAME_DIRECTUV==2
125
- #define v_VARYINGNAME_UV vMainUV2
126
- #elif _DEFINENAME_DIRECTUV==3
127
- #define v_VARYINGNAME_UV vMainUV3
128
- #elif _DEFINENAME_DIRECTUV==4
129
- #define v_VARYINGNAME_UV vMainUV4
130
- #elif _DEFINENAME_DIRECTUV==5
131
- #define v_VARYINGNAME_UV vMainUV5
132
- #elif _DEFINENAME_DIRECTUV==6
133
- #define v_VARYINGNAME_UV vMainUV6
134
- #else
135
- varying v_VARYINGNAME_UV: vec2f;
136
- #endif
137
- var _SAMPLERNAME_SamplerSampler: sampler;var _SAMPLERNAME_Sampler: texture_2d<f32>;
138
- #endif
139
- `;
140
- // Sideeffect
141
- ShaderStore.IncludesShadersStoreWGSL[name$O] = shader$O;
142
-
143
- // Do not edit.
144
- const name$N = "samplerFragmentAlternateDeclaration";
145
- const shader$N = `#ifdef _DEFINENAME_
146
- #if _DEFINENAME_DIRECTUV==1
147
- #define v_VARYINGNAME_UV vMainUV1
148
- #elif _DEFINENAME_DIRECTUV==2
149
- #define v_VARYINGNAME_UV vMainUV2
150
- #elif _DEFINENAME_DIRECTUV==3
151
- #define v_VARYINGNAME_UV vMainUV3
152
- #elif _DEFINENAME_DIRECTUV==4
153
- #define v_VARYINGNAME_UV vMainUV4
154
- #elif _DEFINENAME_DIRECTUV==5
155
- #define v_VARYINGNAME_UV vMainUV5
156
- #elif _DEFINENAME_DIRECTUV==6
157
- #define v_VARYINGNAME_UV vMainUV6
158
- #else
159
- varying v_VARYINGNAME_UV: vec2f;
160
- #endif
161
- #endif
162
- `;
163
- // Sideeffect
164
- ShaderStore.IncludesShadersStoreWGSL[name$N] = shader$N;
165
-
166
- // Do not edit.
167
- const name$M = "pbrFragmentSamplersDeclaration";
168
- const shader$M = `#include<samplerFragmentDeclaration>(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo)
169
- #include<samplerFragmentDeclaration>(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)
170
- #include<samplerFragmentDeclaration>(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)
171
- #include<samplerFragmentDeclaration>(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)
172
- #include<samplerFragmentDeclaration>(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)
173
- #include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity)
174
- #include<samplerFragmentDeclaration>(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface)
175
- #include<samplerFragmentDeclaration>(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance)
176
- #include<samplerFragmentDeclaration>(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance)
177
- #include<samplerFragmentDeclaration>(_DEFINENAME_,DECAL,_VARYINGNAME_,Decal,_SAMPLERNAME_,decal)
178
- #ifdef CLEARCOAT
179
- #include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat)
180
- #include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)
181
- #if defined(CLEARCOAT_TEXTURE_ROUGHNESS)
182
- var clearCoatRoughnessSamplerSampler: sampler;var clearCoatRoughnessSampler: texture_2d<f32>;
183
- #endif
184
- #include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump)
185
- #include<samplerFragmentDeclaration>(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint)
186
- #endif
187
- #ifdef IRIDESCENCE
188
- #include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_TEXTURE,_VARYINGNAME_,Iridescence,_SAMPLERNAME_,iridescence)
189
- #include<samplerFragmentDeclaration>(_DEFINENAME_,IRIDESCENCE_THICKNESS_TEXTURE,_VARYINGNAME_,IridescenceThickness,_SAMPLERNAME_,iridescenceThickness)
190
- #endif
191
- #ifdef SHEEN
192
- #include<samplerFragmentDeclaration>(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen)
193
- #include<samplerFragmentAlternateDeclaration>(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)
194
- #if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS)
195
- var sheenRoughnessSamplerSampler: sampler;var sheenRoughnessSampler: texture_2d<f32>;
196
- #endif
197
- #endif
198
- #ifdef ANISOTROPIC
199
- #include<samplerFragmentDeclaration>(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy)
200
- #endif
201
- #ifdef REFLECTION
202
- #ifdef REFLECTIONMAP_3D
203
- var reflectionSamplerSampler: sampler;var reflectionSampler: texture_cube<f32>;
204
- #ifdef LODBASEDMICROSFURACE
205
- #else
206
- var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_cube<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_cube<f32>;
207
- #endif
208
- #ifdef USEIRRADIANCEMAP
209
- var irradianceSamplerSampler: sampler;var irradianceSampler: texture_cube<f32>;
210
- #endif
211
- #else
212
- var reflectionSamplerSampler: sampler;var reflectionSampler: texture_2d<f32>;
213
- #ifdef LODBASEDMICROSFURACE
214
- #else
215
- var reflectionLowSamplerSampler: sampler;var reflectionLowSampler: texture_2d<f32>;var reflectionHighSamplerSampler: sampler;var reflectionHighSampler: texture_2d<f32>;
216
- #endif
217
- #ifdef USEIRRADIANCEMAP
218
- var irradianceSamplerSampler: sampler;var irradianceSampler: texture_2d<f32>;
219
- #endif
220
- #endif
221
- #ifdef REFLECTIONMAP_SKYBOX
222
- varying vPositionUVW: vec3f;
223
- #else
224
- #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
225
- varying vDirectionW: vec3f;
226
- #endif
227
- #endif
228
- #endif
229
- #ifdef ENVIRONMENTBRDF
230
- var environmentBrdfSamplerSampler: sampler;var environmentBrdfSampler: texture_2d<f32>;
231
- #endif
232
- #ifdef SUBSURFACE
233
- #ifdef SS_REFRACTION
234
- #ifdef SS_REFRACTIONMAP_3D
235
- var refractionSamplerSampler: sampler;var refractionSampler: texture_cube<f32>;
236
- #ifdef LODBASEDMICROSFURACE
237
- #else
238
- var refractionLowSamplerSampler: sampler;var refractionLowSampler: texture_cube<f32>;var refractionHighSamplerSampler: sampler;var refractionHighSampler: texture_cube<f32>;
239
- #endif
240
- #else
241
- var refractionSamplerSampler: sampler;var refractionSampler: texture_2d<f32>;
242
- #ifdef LODBASEDMICROSFURACE
243
- #else
244
- var refractionLowSamplerSampler: sampler;var refractionLowSampler: texture_2d<f32>;var refractionHighSamplerSampler: sampler;var refractionHighSampler: texture_2d<f32>;
245
- #endif
246
- #endif
247
- #endif
248
- #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness)
249
- #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity)
250
- #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity)
251
- #include<samplerFragmentDeclaration>(_DEFINENAME_,SS_TRANSLUCENCYCOLOR_TEXTURE,_VARYINGNAME_,TranslucencyColor,_SAMPLERNAME_,translucencyColor)
252
- #endif
253
- `;
254
- // Sideeffect
255
- ShaderStore.IncludesShadersStoreWGSL[name$M] = shader$M;
256
-
257
- // Do not edit.
258
- const name$L = "imageProcessingDeclaration";
259
- const shader$L = `#ifdef EXPOSURE
260
- uniform exposureLinear: f32;
261
- #endif
262
- #ifdef CONTRAST
263
- uniform contrast: f32;
264
- #endif
265
- #if defined(VIGNETTE) || defined(DITHER)
266
- uniform vInverseScreenSize: vec2f;
267
- #endif
268
- #ifdef VIGNETTE
269
- uniform vignetteSettings1: vec4f;uniform vignetteSettings2: vec4f;
270
- #endif
271
- #ifdef COLORCURVES
272
- uniform vCameraColorCurveNegative: vec4f;uniform vCameraColorCurveNeutral: vec4f;uniform vCameraColorCurvePositive: vec4f;
273
- #endif
274
- #ifdef COLORGRADING
275
- #ifdef COLORGRADING3D
276
- var txColorTransformSampler: sampler;var txColorTransform: texture_3d<f32>;
277
- #else
278
- var txColorTransformSampler: sampler;var txColorTransform: texture_2d<f32>;
279
- #endif
280
- uniform colorTransformSettings: vec4f;
281
- #endif
282
- #ifdef DITHER
283
- uniform ditherIntensity: f32;
284
- #endif
285
- `;
286
- // Sideeffect
287
- ShaderStore.IncludesShadersStoreWGSL[name$L] = shader$L;
288
-
289
- // Do not edit.
290
- const name$K = "clipPlaneFragmentDeclaration";
291
- const shader$K = `#ifdef CLIPPLANE
292
- varying fClipDistance: f32;
293
- #endif
294
- #ifdef CLIPPLANE2
295
- varying fClipDistance2: f32;
296
- #endif
297
- #ifdef CLIPPLANE3
298
- varying fClipDistance3: f32;
299
- #endif
300
- #ifdef CLIPPLANE4
301
- varying fClipDistance4: f32;
302
- #endif
303
- #ifdef CLIPPLANE5
304
- varying fClipDistance5: f32;
305
- #endif
306
- #ifdef CLIPPLANE6
307
- varying fClipDistance6: f32;
308
- #endif
309
- `;
310
- // Sideeffect
311
- ShaderStore.IncludesShadersStoreWGSL[name$K] = shader$K;
312
-
313
- // Do not edit.
314
- const name$J = "fogFragmentDeclaration";
315
- const shader$J = `#ifdef FOG
316
- #define FOGMODE_NONE 0.
317
- #define FOGMODE_EXP 1.
318
- #define FOGMODE_EXP2 2.
319
- #define FOGMODE_LINEAR 3.
320
- const E=2.71828;uniform vFogInfos: vec4f;uniform vFogColor: vec3f;varying vFogDistance: vec3f;fn CalcFogFactor()->f32
321
- {var fogCoeff: f32=1.0;var fogStart: f32=uniforms.vFogInfos.y;var fogEnd: f32=uniforms.vFogInfos.z;var fogDensity: f32=uniforms.vFogInfos.w;var fogDistance: f32=length(fragmentInputs.vFogDistance);if (FOGMODE_LINEAR==uniforms.vFogInfos.x)
322
- {fogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);}
323
- else if (FOGMODE_EXP==uniforms.vFogInfos.x)
324
- {fogCoeff=1.0/pow(E,fogDistance*fogDensity);}
325
- else if (FOGMODE_EXP2==uniforms.vFogInfos.x)
326
- {fogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);}
327
- return clamp(fogCoeff,0.0,1.0);}
328
- #endif
329
- `;
330
- // Sideeffect
331
- ShaderStore.IncludesShadersStoreWGSL[name$J] = shader$J;
332
-
333
- // Do not edit.
334
- const name$I = "subSurfaceScatteringFunctions";
335
- const shader$I = `fn testLightingForSSS(diffusionProfile: f32)->bool
336
- {return diffusionProfile<1.;}`;
337
- // Sideeffect
338
- ShaderStore.IncludesShadersStoreWGSL[name$I] = shader$I;
339
-
340
- // Do not edit.
341
- const name$H = "importanceSampling";
342
- const shader$H = `fn hemisphereCosSample(u: vec2f)->vec3f {var phi: f32=2.*PI*u.x;var cosTheta2: f32=1.-u.y;var cosTheta: f32=sqrt(cosTheta2);var sinTheta: f32=sqrt(1.-cosTheta2);return vec3f(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}
343
- fn hemisphereImportanceSampleDggx(u: vec2f,a: f32)->vec3f {var phi: f32=2.*PI*u.x;var cosTheta2: f32=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));var cosTheta: f32=sqrt(cosTheta2);var sinTheta: f32=sqrt(1.-cosTheta2);return vec3f(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}
344
- fn hemisphereImportanceSampleDCharlie(u: vec2f,a: f32)->vec3f {
345
- var phi: f32=2.*PI*u.x;var sinTheta: f32=pow(u.y,a/(2.*a+1.));var cosTheta: f32=sqrt(1.-sinTheta*sinTheta);return vec3f(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);}`;
346
- // Sideeffect
347
- ShaderStore.IncludesShadersStoreWGSL[name$H] = shader$H;
348
-
349
- // Do not edit.
350
- const name$G = "pbrHelperFunctions";
351
- const shader$G = `#define MINIMUMVARIANCE 0.0005
352
- fn convertRoughnessToAverageSlope(roughness: f32)->f32
353
- {return roughness*roughness+MINIMUMVARIANCE;}
354
- fn fresnelGrazingReflectance(reflectance0: f32)->f32 {var reflectance90: f32=saturate(reflectance0*25.0);return reflectance90;}
355
- fn getAARoughnessFactors(normalVector: vec3f)->vec2f {
356
- #ifdef SPECULARAA
357
- var nDfdx: vec3f=dpdx(normalVector.xyz);var nDfdy: vec3f=dpdy(normalVector.xyz);var slopeSquare: f32=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));var geometricRoughnessFactor: f32=pow(saturate(slopeSquare),0.333);var geometricAlphaGFactor: f32=sqrt(slopeSquare);geometricAlphaGFactor*=0.75;return vec2f(geometricRoughnessFactor,geometricAlphaGFactor);
358
- #else
359
- return vec2f(0.);
360
- #endif
361
- }
362
- #ifdef ANISOTROPIC
363
- #ifdef ANISOTROPIC_LEGACY
364
- fn getAnisotropicRoughness(alphaG: f32,anisotropy: f32)->vec2f {var alphaT: f32=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);var alphaB: f32=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);return vec2f(alphaT,alphaB);}
365
- fn getAnisotropicBentNormals(T: vec3f,B: vec3f,N: vec3f,V: vec3f,anisotropy: f32,roughness: f32)->vec3f {var anisotropicFrameDirection: vec3f=select(T,B,anisotropy>=0.0);var anisotropicFrameTangent: vec3f=cross(normalize(anisotropicFrameDirection),V);var anisotropicFrameNormal: vec3f=cross(anisotropicFrameTangent,anisotropicFrameDirection);var anisotropicNormal: vec3f=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));return anisotropicNormal;}
366
- #else
367
- fn getAnisotropicRoughness(alphaG: f32,anisotropy: f32)->vec2f {var alphaT: f32=max(mix(alphaG,1.0,anisotropy*anisotropy),MINIMUMVARIANCE);var alphaB: f32=max(alphaG,MINIMUMVARIANCE);return vec2f(alphaT,alphaB);}
368
- fn getAnisotropicBentNormals(T: vec3f,B: vec3f,N: vec3f,V: vec3f,anisotropy: f32,roughness: f32)->vec3f {var bentNormal: vec3f=cross(B,V);bentNormal=normalize(cross(bentNormal,B));var sq=1.0-anisotropy*(1.0-roughness);var a: f32=sq*sq*sq*sq;bentNormal=normalize(mix(bentNormal,N,a));return bentNormal;}
369
- #endif
370
- #endif
371
- #if defined(CLEARCOAT) || defined(SS_REFRACTION)
372
- fn cocaLambertVec3(alpha: vec3f,distance: f32)->vec3f {return exp(-alpha*distance);}
373
- fn cocaLambert(NdotVRefract: f32,NdotLRefract: f32,alpha: vec3f,thickness: f32)->vec3f {return cocaLambertVec3(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));}
374
- fn computeColorAtDistanceInMedia(color: vec3f,distance: f32)->vec3f {return -log(color)/distance;}
375
- fn computeClearCoatAbsorption(NdotVRefract: f32,NdotLRefract: f32,clearCoatColor: vec3f,clearCoatThickness: f32,clearCoatIntensity: f32)->vec3f {var clearCoatAbsorption: vec3f=mix( vec3f(1.0),
376
- cocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),
377
- clearCoatIntensity);return clearCoatAbsorption;}
378
- #endif
379
- #ifdef MICROSURFACEAUTOMATIC
380
- fn computeDefaultMicroSurface(microSurface: f32,reflectivityColor: vec3f)->f32
381
- {const kReflectivityNoAlphaWorkflow_SmoothnessMax: f32=0.95;var reflectivityLuminance: f32=getLuminance(reflectivityColor);var reflectivityLuma: f32=sqrt(reflectivityLuminance);var resultMicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;return resultMicroSurface;}
382
- #endif
383
- `;
384
- // Sideeffect
385
- ShaderStore.IncludesShadersStoreWGSL[name$G] = shader$G;
386
-
387
- // Do not edit.
388
- const name$F = "imageProcessingFunctions";
389
- const shader$F = `#if TONEMAPPING==3
390
- const PBRNeutralStartCompression: f32=0.8-0.04;const PBRNeutralDesaturation: f32=0.15;fn PBRNeutralToneMapping( color: vec3f )->vec3f {var x: f32=min(color.r,min(color.g,color.b));var offset: f32=select(0.04,x-6.25*x*x,x<0.08);var result=color;result-=offset;var peak: f32=max(result.r,max(result.g,result.b));if (peak<PBRNeutralStartCompression) {return result;}
391
- var d: f32=1.-PBRNeutralStartCompression;var newPeak: f32=1.-d*d/(peak+d-PBRNeutralStartCompression);result*=newPeak/peak;var g: f32=1.-1./(PBRNeutralDesaturation*(peak-newPeak)+1.);return mix(result,newPeak* vec3f(1,1,1),g);}
392
- #endif
393
- #if TONEMAPPING==2
394
- const ACESInputMat: mat3x3f= mat3x3f(
395
- vec3f(0.59719,0.07600,0.02840),
396
- vec3f(0.35458,0.90834,0.13383),
397
- vec3f(0.04823,0.01566,0.83777)
398
- );const ACESOutputMat: mat3x3f= mat3x3f(
399
- vec3f( 1.60475,-0.10208,-0.00327),
400
- vec3f(-0.53108, 1.10813,-0.07276),
401
- vec3f(-0.07367,-0.00605, 1.07602)
402
- );fn RRTAndODTFit(v: vec3f)->vec3f
403
- {var a: vec3f=v*(v+0.0245786)-0.000090537;var b: vec3f=v*(0.983729*v+0.4329510)+0.238081;return a/b;}
404
- fn ACESFitted(color: vec3f)->vec3f
405
- {var output=ACESInputMat*color;output=RRTAndODTFit(output);output=ACESOutputMat*output;output=saturateVec3(output);return output;}
406
- #endif
407
- #define CUSTOM_IMAGEPROCESSINGFUNCTIONS_DEFINITIONS
408
- fn applyImageProcessing(result: vec4f)->vec4f {
409
- #define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATSTART
410
- var rgb=result.rgb;;
411
- #ifdef EXPOSURE
412
- rgb*=uniforms.exposureLinear;
413
- #endif
414
- #ifdef VIGNETTE
415
- var viewportXY: vec2f=fragmentInputs.position.xy*uniforms.vInverseScreenSize;viewportXY=viewportXY*2.0-1.0;var vignetteXY1: vec3f= vec3f(viewportXY*uniforms.vignetteSettings1.xy+uniforms.vignetteSettings1.zw,1.0);var vignetteTerm: f32=dot(vignetteXY1,vignetteXY1);var vignette: f32=pow(vignetteTerm,uniforms.vignetteSettings2.w);var vignetteColor: vec3f=uniforms.vignetteSettings2.rgb;
416
- #ifdef VIGNETTEBLENDMODEMULTIPLY
417
- var vignetteColorMultiplier: vec3f=mix(vignetteColor, vec3f(1,1,1),vignette);rgb*=vignetteColorMultiplier;
418
- #endif
419
- #ifdef VIGNETTEBLENDMODEOPAQUE
420
- rgb=mix(vignetteColor,rgb,vignette);
421
- #endif
422
- #endif
423
- #if TONEMAPPING==3
424
- rgb=PBRNeutralToneMapping(rgb);
425
- #elif TONEMAPPING==2
426
- rgb=ACESFitted(rgb);
427
- #elif TONEMAPPING==1
428
- const tonemappingCalibration: f32=1.590579;rgb=1.0-exp2(-tonemappingCalibration*rgb);
429
- #endif
430
- rgb=toGammaSpaceVec3(rgb);rgb=saturateVec3(rgb);
431
- #ifdef CONTRAST
432
- var resultHighContrast: vec3f=rgb*rgb*(3.0-2.0*rgb);if (uniforms.contrast<1.0) {rgb=mix( vec3f(0.5,0.5,0.5),rgb,uniforms.contrast);} else {rgb=mix(rgb,resultHighContrast,uniforms.contrast-1.0);}
433
- #endif
434
- #ifdef COLORGRADING
435
- var colorTransformInput: vec3f=rgb*uniforms.colorTransformSettings.xxx+uniforms.colorTransformSettings.yyy;
436
- #ifdef COLORGRADING3D
437
- var colorTransformOutput: vec3f=textureSample(txColorTransform,txColorTransformSampler,colorTransformInput).rgb;
438
- #else
439
- var colorTransformOutput: vec3f=textureSample(txColorTransform,txColorTransformSampler,colorTransformInput,uniforms.colorTransformSettings.yz).rgb;
440
- #endif
441
- rgb=mix(rgb,colorTransformOutput,uniforms.colorTransformSettings.www);
442
- #endif
443
- #ifdef COLORCURVES
444
- var luma: f32=getLuminance(rgb);var curveMix: vec2f=clamp( vec2f(luma*3.0-1.5,luma*-3.0+1.5), vec2f(0.0), vec2f(1.0));var colorCurve: vec4f=uniforms.vCameraColorCurveNeutral+curveMix.x*uniforms.vCameraColorCurvePositive-curveMix.y*uniforms.vCameraColorCurveNegative;rgb*=colorCurve.rgb;rgb=mix( vec3f(luma),rgb,colorCurve.a);
445
- #endif
446
- #ifdef DITHER
447
- var rand: f32=getRand(fragmentInputs.position.xy*uniforms.vInverseScreenSize);var dither: f32=mix(-uniforms.ditherIntensity,uniforms.ditherIntensity,rand);rgb=saturateVec3(rgb+ vec3f(dither));
448
- #endif
449
- #define CUSTOM_IMAGEPROCESSINGFUNCTIONS_UPDATERESULT_ATEND
450
- return vec4f(rgb,result.a);}`;
451
- // Sideeffect
452
- ShaderStore.IncludesShadersStoreWGSL[name$F] = shader$F;
453
-
454
- // Do not edit.
455
- const name$E = "shadowsFragmentFunctions";
456
- const shader$E = `#ifdef SHADOWS
457
- #ifndef SHADOWFLOAT
458
- fn unpack(color: vec4f)->f32
459
- {const bit_shift: vec4f= vec4f(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(color,bit_shift);}
460
- #endif
461
- fn computeFallOff(value: f32,clipSpace: vec2f,frustumEdgeFalloff: f32)->f32
462
- {var mask: f32=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));return mix(value,1.0,mask);}
463
- fn computeShadowCube(worldPos: vec3f,lightPosition: vec3f,shadowTexture: texture_cube<f32>,shadowSampler: sampler,darkness: f32,depthValues: vec2f)->f32
464
- {var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
465
- #ifndef SHADOWFLOAT
466
- var shadow: f32=unpack(textureSample(shadowTexture,shadowSampler,directionToLight));
467
- #else
468
- var shadow: f32=textureSample(shadowTexture,shadowSampler,directionToLight).x;
469
- #endif
470
- return select(darkness,1.0,depth>shadow);}
471
- fn computeShadowWithPoissonSamplingCube(worldPos: vec3f,lightPosition: vec3f,shadowTexture: texture_cube<f32>,shadowSampler: sampler,mapSize: f32,darkness: f32,depthValues: vec2f)->f32
472
- {var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);depth=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;var visibility: f32=1.;var poissonDisk: array<vec3f,4>;poissonDisk[0]= vec3f(-1.0,1.0,-1.0);poissonDisk[1]= vec3f(1.0,-1.0,-1.0);poissonDisk[2]= vec3f(-1.0,-1.0,-1.0);poissonDisk[3]= vec3f(1.0,-1.0,1.0);
473
- #ifndef SHADOWFLOAT
474
- if (unpack(textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) {visibility-=0.25;};if (unpack(textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) {visibility-=0.25;};if (unpack(textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) {visibility-=0.25;};if (unpack(textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) {visibility-=0.25;};
475
- #else
476
- if (textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) {visibility-=0.25;};if (textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) {visibility-=0.25;};if (textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) {visibility-=0.25;};if (textureSample(shadowTexture,shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) {visibility-=0.25;};
477
- #endif
478
- return min(1.0,visibility+darkness);}
479
- fn computeShadowWithESMCube(worldPos: vec3f,lightPosition: vec3f,shadowTexture: texture_cube<f32>,shadowSampler: sampler,darkness: f32,depthScale: f32,depthValues: vec2f)->f32
480
- {var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);var shadowPixelDepth: f32=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
481
- #ifndef SHADOWFLOAT
482
- var shadowMapSample: f32=unpack(textureSample(shadowTexture,shadowSampler,directionToLight));
483
- #else
484
- var shadowMapSample: f32=textureSample(shadowTexture,shadowSampler,directionToLight).x;
485
- #endif
486
- var esm: f32=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return esm;}
487
- fn computeShadowWithCloseESMCube(worldPos: vec3f,lightPosition: vec3f,shadowTexture: texture_cube<f32>,shadowSampler: sampler,darkness: f32,depthScale: f32,depthValues: vec2f)->f32
488
- {var directionToLight: vec3f=worldPos-lightPosition;var depth: f32=length(directionToLight);depth=(depth+depthValues.x)/(depthValues.y);var shadowPixelDepth: f32=clamp(depth,0.,1.0);directionToLight=normalize(directionToLight);directionToLight.y=-directionToLight.y;
489
- #ifndef SHADOWFLOAT
490
- var shadowMapSample: f32=unpack(textureSample(shadowTexture,shadowSampler,directionToLight));
491
- #else
492
- var shadowMapSample: f32=textureSample(shadowTexture,shadowSampler,directionToLight).x;
493
- #endif
494
- var esm: f32=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return esm;}
495
- fn computeShadowCSM(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d_array<f32>,shadowSampler: sampler,darkness: f32,frustumEdgeFalloff: f32)->f32
496
- {var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0);
497
- #ifndef SHADOWFLOAT
498
- var shadow: f32=unpack(textureSample(shadowTexture,shadowSampler,uv,layer));
499
- #else
500
- var shadow: f32=textureSample(shadowTexture,shadowSampler,uv,layer).x;
501
- #endif
502
- return select(1.,computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff),shadowPixelDepth>shadow );}
503
- fn computeShadow(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d<f32>,shadowSampler: sampler,darkness: f32,frustumEdgeFalloff: f32)->f32
504
- {var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
505
- {return 1.0;}
506
- else
507
- {var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0);
508
- #ifndef SHADOWFLOAT
509
- var shadow: f32=unpack(textureSampleLevel(shadowTexture,shadowSampler,uv,0.));
510
- #else
511
- var shadow: f32=textureSampleLevel(shadowTexture,shadowSampler,uv,0.).x;
512
- #endif
513
- return select(1.,computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff),shadowPixelDepth>shadow );}}
514
- fn computeShadowWithPoissonSampling(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d<f32>,shadowSampler: sampler,mapSize: f32,darkness: f32,frustumEdgeFalloff: f32)->f32
515
- {var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
516
- {return 1.0;}
517
- else
518
- {var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0);var visibility: f32=1.;var poissonDisk: array<vec2f,4>;poissonDisk[0]= vec2f(-0.94201624,-0.39906216);poissonDisk[1]= vec2f(0.94558609,-0.76890725);poissonDisk[2]= vec2f(-0.094184101,-0.92938870);poissonDisk[3]= vec2f(0.34495938,0.29387760);
519
- #ifndef SHADOWFLOAT
520
- if (unpack(textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[0]*mapSize,0.))<shadowPixelDepth) {visibility-=0.25;}
521
- if (unpack(textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[1]*mapSize,0.))<shadowPixelDepth) {visibility-=0.25;}
522
- if (unpack(textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[2]*mapSize,0.))<shadowPixelDepth) {visibility-=0.25;}
523
- if (unpack(textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[3]*mapSize,0.))<shadowPixelDepth) {visibility-=0.25;}
524
- #else
525
- if (textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[0]*mapSize,0.).x<shadowPixelDepth) {visibility-=0.25;}
526
- if (textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[1]*mapSize,0.).x<shadowPixelDepth) {visibility-=0.25;}
527
- if (textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[2]*mapSize,0.).x<shadowPixelDepth) {visibility-=0.25;}
528
- if (textureSampleLevel(shadowTexture,shadowSampler,uv+poissonDisk[3]*mapSize,0.).x<shadowPixelDepth) {visibility-=0.25;}
529
- #endif
530
- return computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);}}
531
- fn computeShadowWithESM(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d<f32>,shadowSampler: sampler,darkness: f32,depthScale: f32,frustumEdgeFalloff: f32)->f32
532
- {var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
533
- {return 1.0;}
534
- else
535
- {var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0);
536
- #ifndef SHADOWFLOAT
537
- var shadowMapSample: f32=unpack(textureSampleLevel(shadowTexture,shadowSampler,uv,0.));
538
- #else
539
- var shadowMapSample: f32=textureSampleLevel(shadowTexture,shadowSampler,uv,0.).x;
540
- #endif
541
- var esm: f32=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
542
- fn computeShadowWithCloseESM(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_2d<f32>,shadowSampler: sampler,darkness: f32,depthScale: f32,frustumEdgeFalloff: f32)->f32
543
- {var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uv: vec2f=0.5*clipSpace.xy+ vec2f(0.5);if (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)
544
- {return 1.0;}
545
- else
546
- {var shadowPixelDepth: f32=clamp(depthMetric,0.,1.0);
547
- #ifndef SHADOWFLOAT
548
- var shadowMapSample: f32=unpack(textureSampleLevel(shadowTexture,shadowSampler,uv,0.));
549
- #else
550
- var shadowMapSample: f32=textureSampleLevel(shadowTexture,shadowSampler,uv,0.).x;
551
- #endif
552
- var esm: f32=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);return computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);}}
553
- fn getZInClip(clipSpace: vec3f,uvDepth: vec3f)->f32
554
- {
555
- #ifdef IS_NDC_HALF_ZRANGE
556
- return clipSpace.z;
557
- #else
558
- return uvDepth.z;
559
- #endif
560
- }
561
- const GREATEST_LESS_THAN_ONE: f32=0.99999994;
562
- #define DISABLE_UNIFORMITY_ANALYSIS
563
- fn computeShadowWithCSMPCF1(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,darkness: f32,frustumEdgeFalloff: f32)->f32
564
- {var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var shadow: f32=textureSampleCompare(shadowTexture,shadowSampler,uvDepth.xy,layer,uvDepth.z);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
565
- fn computeShadowWithCSMPCF3(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32
566
- {var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x;
567
- uv+=0.5;
568
- var st: vec2f=fract(uv);
569
- var base_uv: vec2f=floor(uv)-0.5;
570
- base_uv*=shadowMapSizeAndInverse.y;
571
- var uvw0: vec2f=3.-2.*st;var uvw1: vec2f=1.+2.*st;var u: vec2f= vec2f((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;var v: vec2f= vec2f((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),layer,uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),layer,uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),layer,uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),layer,uvDepth.z);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
572
- fn computeShadowWithCSMPCF5(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32
573
- {var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x;
574
- uv+=0.5;
575
- var st: vec2f=fract(uv);
576
- var base_uv: vec2f=floor(uv)-0.5;
577
- base_uv*=shadowMapSizeAndInverse.y;
578
- var uvw0: vec2f=4.-3.*st;var uvw1: vec2f= vec2f(7.);var uvw2: vec2f=1.+3.*st;var u: vec3f= vec3f((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;var v: vec3f= vec3f((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),layer,uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),layer,uvDepth.z);shadow+=uvw2.x*uvw0.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[0]),layer,uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),layer,uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),layer,uvDepth.z);shadow+=uvw2.x*uvw1.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[1]),layer,uvDepth.z);shadow+=uvw0.x*uvw2.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[2]),layer,uvDepth.z);shadow+=uvw1.x*uvw2.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[2]),layer,uvDepth.z);shadow+=uvw2.x*uvw2.y*textureSampleCompare(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[2]),layer,uvDepth.z);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}
579
- fn computeShadowWithPCF1(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,darkness: f32,frustumEdgeFalloff: f32)->f32
580
- {if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
581
- else
582
- {var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);var shadow: f32=textureSampleCompareLevel(shadowTexture,shadowSampler,uvDepth.xy,uvDepth.z);shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
583
- fn computeShadowWithPCF3(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32
584
- {if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
585
- else
586
- {var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x;
587
- uv+=0.5;
588
- var st: vec2f=fract(uv);
589
- var base_uv: vec2f=floor(uv)-0.5;
590
- base_uv*=shadowMapSizeAndInverse.y;
591
- var uvw0: vec2f=3.-2.*st;var uvw1: vec2f=1.+2.*st;var u: vec2f= vec2f((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;var v: vec2f= vec2f((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),uvDepth.z);shadow=shadow/16.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
592
- fn computeShadowWithPCF5(vPositionFromLight: vec4f,depthMetric: f32,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeAndInverse: vec2f,darkness: f32,frustumEdgeFalloff: f32)->f32
593
- {if (depthMetric>1.0 || depthMetric<0.0) {return 1.0;}
594
- else
595
- {var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);var uv: vec2f=uvDepth.xy*shadowMapSizeAndInverse.x;
596
- uv+=0.5;
597
- var st: vec2f=fract(uv);
598
- var base_uv: vec2f=floor(uv)-0.5;
599
- base_uv*=shadowMapSizeAndInverse.y;
600
- var uvw0: vec2f=4.-3.*st;var uvw1: vec2f= vec2f(7.);var uvw2: vec2f=1.+3.*st;var u: vec3f= vec3f((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;var v: vec3f= vec3f((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;var shadow: f32=0.;shadow+=uvw0.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[0]),uvDepth.z);shadow+=uvw1.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[0]),uvDepth.z);shadow+=uvw2.x*uvw0.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[0]),uvDepth.z);shadow+=uvw0.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[1]),uvDepth.z);shadow+=uvw1.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[1]),uvDepth.z);shadow+=uvw2.x*uvw1.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[1]),uvDepth.z);shadow+=uvw0.x*uvw2.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[0],v[2]),uvDepth.z);shadow+=uvw1.x*uvw2.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[1],v[2]),uvDepth.z);shadow+=uvw2.x*uvw2.y*textureSampleCompareLevel(shadowTexture,shadowSampler, base_uv.xy+ vec2f(u[2],v[2]),uvDepth.z);shadow=shadow/144.;shadow=mix(darkness,1.,shadow);return computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);}}
601
- const PoissonSamplers32: array<vec3f,64>=array<vec3f,64> (
602
- vec3f(0.06407013,0.05409927,0.),
603
- vec3f(0.7366577,0.5789394,0.),
604
- vec3f(-0.6270542,-0.5320278,0.),
605
- vec3f(-0.4096107,0.8411095,0.),
606
- vec3f(0.6849564,-0.4990818,0.),
607
- vec3f(-0.874181,-0.04579735,0.),
608
- vec3f(0.9989998,0.0009880066,0.),
609
- vec3f(-0.004920578,-0.9151649,0.),
610
- vec3f(0.1805763,0.9747483,0.),
611
- vec3f(-0.2138451,0.2635818,0.),
612
- vec3f(0.109845,0.3884785,0.),
613
- vec3f(0.06876755,-0.3581074,0.),
614
- vec3f(0.374073,-0.7661266,0.),
615
- vec3f(0.3079132,-0.1216763,0.),
616
- vec3f(-0.3794335,-0.8271583,0.),
617
- vec3f(-0.203878,-0.07715034,0.),
618
- vec3f(0.5912697,0.1469799,0.),
619
- vec3f(-0.88069,0.3031784,0.),
620
- vec3f(0.5040108,0.8283722,0.),
621
- vec3f(-0.5844124,0.5494877,0.),
622
- vec3f(0.6017799,-0.1726654,0.),
623
- vec3f(-0.5554981,0.1559997,0.),
624
- vec3f(-0.3016369,-0.3900928,0.),
625
- vec3f(-0.5550632,-0.1723762,0.),
626
- vec3f(0.925029,0.2995041,0.),
627
- vec3f(-0.2473137,0.5538505,0.),
628
- vec3f(0.9183037,-0.2862392,0.),
629
- vec3f(0.2469421,0.6718712,0.),
630
- vec3f(0.3916397,-0.4328209,0.),
631
- vec3f(-0.03576927,-0.6220032,0.),
632
- vec3f(-0.04661255,0.7995201,0.),
633
- vec3f(0.4402924,0.3640312,0.),
634
- vec3f(0.),
635
- vec3f(0.),
636
- vec3f(0.),
637
- vec3f(0.),
638
- vec3f(0.),
639
- vec3f(0.),
640
- vec3f(0.),
641
- vec3f(0.),
642
- vec3f(0.),
643
- vec3f(0.),
644
- vec3f(0.),
645
- vec3f(0.),
646
- vec3f(0.),
647
- vec3f(0.),
648
- vec3f(0.),
649
- vec3f(0.),
650
- vec3f(0.),
651
- vec3f(0.),
652
- vec3f(0.),
653
- vec3f(0.),
654
- vec3f(0.),
655
- vec3f(0.),
656
- vec3f(0.),
657
- vec3f(0.),
658
- vec3f(0.),
659
- vec3f(0.),
660
- vec3f(0.),
661
- vec3f(0.),
662
- vec3f(0.),
663
- vec3f(0.),
664
- vec3f(0.),
665
- vec3f(0.)
666
- );const PoissonSamplers64: array<vec3f,64>=array<vec3f,64> (
667
- vec3f(-0.613392,0.617481,0.),
668
- vec3f(0.170019,-0.040254,0.),
669
- vec3f(-0.299417,0.791925,0.),
670
- vec3f(0.645680,0.493210,0.),
671
- vec3f(-0.651784,0.717887,0.),
672
- vec3f(0.421003,0.027070,0.),
673
- vec3f(-0.817194,-0.271096,0.),
674
- vec3f(-0.705374,-0.668203,0.),
675
- vec3f(0.977050,-0.108615,0.),
676
- vec3f(0.063326,0.142369,0.),
677
- vec3f(0.203528,0.214331,0.),
678
- vec3f(-0.667531,0.326090,0.),
679
- vec3f(-0.098422,-0.295755,0.),
680
- vec3f(-0.885922,0.215369,0.),
681
- vec3f(0.566637,0.605213,0.),
682
- vec3f(0.039766,-0.396100,0.),
683
- vec3f(0.751946,0.453352,0.),
684
- vec3f(0.078707,-0.715323,0.),
685
- vec3f(-0.075838,-0.529344,0.),
686
- vec3f(0.724479,-0.580798,0.),
687
- vec3f(0.222999,-0.215125,0.),
688
- vec3f(-0.467574,-0.405438,0.),
689
- vec3f(-0.248268,-0.814753,0.),
690
- vec3f(0.354411,-0.887570,0.),
691
- vec3f(0.175817,0.382366,0.),
692
- vec3f(0.487472,-0.063082,0.),
693
- vec3f(-0.084078,0.898312,0.),
694
- vec3f(0.488876,-0.783441,0.),
695
- vec3f(0.470016,0.217933,0.),
696
- vec3f(-0.696890,-0.549791,0.),
697
- vec3f(-0.149693,0.605762,0.),
698
- vec3f(0.034211,0.979980,0.),
699
- vec3f(0.503098,-0.308878,0.),
700
- vec3f(-0.016205,-0.872921,0.),
701
- vec3f(0.385784,-0.393902,0.),
702
- vec3f(-0.146886,-0.859249,0.),
703
- vec3f(0.643361,0.164098,0.),
704
- vec3f(0.634388,-0.049471,0.),
705
- vec3f(-0.688894,0.007843,0.),
706
- vec3f(0.464034,-0.188818,0.),
707
- vec3f(-0.440840,0.137486,0.),
708
- vec3f(0.364483,0.511704,0.),
709
- vec3f(0.034028,0.325968,0.),
710
- vec3f(0.099094,-0.308023,0.),
711
- vec3f(0.693960,-0.366253,0.),
712
- vec3f(0.678884,-0.204688,0.),
713
- vec3f(0.001801,0.780328,0.),
714
- vec3f(0.145177,-0.898984,0.),
715
- vec3f(0.062655,-0.611866,0.),
716
- vec3f(0.315226,-0.604297,0.),
717
- vec3f(-0.780145,0.486251,0.),
718
- vec3f(-0.371868,0.882138,0.),
719
- vec3f(0.200476,0.494430,0.),
720
- vec3f(-0.494552,-0.711051,0.),
721
- vec3f(0.612476,0.705252,0.),
722
- vec3f(-0.578845,-0.768792,0.),
723
- vec3f(-0.772454,-0.090976,0.),
724
- vec3f(0.504440,0.372295,0.),
725
- vec3f(0.155736,0.065157,0.),
726
- vec3f(0.391522,0.849605,0.),
727
- vec3f(-0.620106,-0.328104,0.),
728
- vec3f(0.789239,-0.419965,0.),
729
- vec3f(-0.545396,0.538133,0.),
730
- vec3f(-0.178564,-0.596057,0.)
731
- );fn computeShadowWithCSMPCSS(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d_array<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,searchTapCount: i32,pcfTapCount: i32,poissonSamplers: array<vec3f,64>,lightSizeUVCorrection: vec2f,depthCorrection: f32,penumbraDarkness: f32)->f32
732
- {var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=clamp(getZInClip(clipSpace,uvDepth),0.,GREATEST_LESS_THAN_ONE);var uvDepthLayer: vec4f= vec4f(uvDepth.x,uvDepth.y,f32(layer),uvDepth.z);var blockerDepth: f32=0.0;var sumBlockerDepth: f32=0.0;var numBlocker: f32=0.0;for (var i: i32=0; i<searchTapCount; i ++) {blockerDepth=textureSample(depthTexture,depthSampler, uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer).r;numBlocker+=select(0.,1.,blockerDepth<depthMetric);sumBlockerDepth+=select(0.,blockerDepth,blockerDepth<depthMetric);}
733
- var avgBlockerDepth: f32=sumBlockerDepth/numBlocker;var AAOffset: f32=shadowMapSizeInverse*10.;var penumbraRatio: f32=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);var filterRadius: vec4f= vec4f(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);var random: f32=getRand(vPositionFromLight.xy);var rotationAngle: f32=random*3.1415926;var rotationVector: vec2f= vec2f(cos(rotationAngle),sin(rotationAngle));var shadow: f32=0.;for (var i: i32=0; i<pcfTapCount; i++) {var offset: vec4f= vec4f(poissonSamplers[i],0.);offset= vec4f(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);let coords=uvDepthLayer+offset*filterRadius;shadow+=textureSampleCompare(shadowTexture,shadowSampler,coords.xy,i32(coords.z),coords.w);}
734
- shadow/= f32(pcfTapCount);shadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));shadow=mix(darkness,1.,shadow);return select(computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff),1.0,numBlocker<1.0);}
735
- fn computeShadowWithPCSS(vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,searchTapCount: i32,pcfTapCount: i32,poissonSamplers: array<vec3f,64>)->f32
736
- {var clipSpace: vec3f=vPositionFromLight.xyz/vPositionFromLight.w;var uvDepth: vec3f= vec3f(0.5*clipSpace.xyz+ vec3f(0.5));uvDepth.z=getZInClip(clipSpace,uvDepth);var blockerDepth: f32=0.0;var sumBlockerDepth: f32=0.0;var numBlocker: f32=0.0;var exitCondition: bool=depthMetric>1.0 || depthMetric<0.0;for (var i: i32=0; i<searchTapCount; i ++) {if (exitCondition) {break;}
737
- blockerDepth=textureSampleLevel(depthTexture,depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy),0).r;numBlocker+=select(0.,1.,blockerDepth<depthMetric);sumBlockerDepth+=select(0.,blockerDepth,blockerDepth<depthMetric);}
738
- exitCondition=exitCondition || numBlocker<1.0;var avgBlockerDepth: f32=sumBlockerDepth/numBlocker;var AAOffset: f32=shadowMapSizeInverse*10.;var penumbraRatio: f32=((depthMetric-avgBlockerDepth)+AAOffset);var filterRadius: f32=penumbraRatio*lightSizeUV*shadowMapSizeInverse;var random: f32=getRand(vPositionFromLight.xy);var rotationAngle: f32=random*3.1415926;var rotationVector: vec2f= vec2f(cos(rotationAngle),sin(rotationAngle));var shadow: f32=0.;for (var i: i32=0; i<pcfTapCount; i++) {if (exitCondition) {break;}
739
- var offset: vec3f=poissonSamplers[i];offset= vec3f(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);let coords=uvDepth+offset*filterRadius;shadow+=textureSampleCompareLevel(shadowTexture,shadowSampler,coords.xy,coords.z);}
740
- shadow/= f32(pcfTapCount);shadow=mix(shadow,1.,depthMetric-avgBlockerDepth);shadow=mix(darkness,1.,shadow);return select(computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff),1.0,exitCondition);}
741
- fn computeShadowWithPCSS16(vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32)->f32
742
- {return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);}
743
- fn computeShadowWithPCSS32(vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32)->f32
744
- {return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);}
745
- fn computeShadowWithPCSS64(vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32)->f32
746
- {return computeShadowWithPCSS(vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);}
747
- fn computeShadowWithCSMPCSS16(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d_array<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,lightSizeUVCorrection: vec2f,depthCorrection: f32,penumbraDarkness: f32)->f32
748
- {return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
749
- fn computeShadowWithCSMPCSS32(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d_array<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,lightSizeUVCorrection: vec2f,depthCorrection: f32,penumbraDarkness: f32)->f32
750
- {return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
751
- fn computeShadowWithCSMPCSS64(layer: i32,vPositionFromLight: vec4f,depthMetric: f32,depthTexture: texture_2d_array<f32>,depthSampler: sampler,shadowTexture: texture_depth_2d_array,shadowSampler: sampler_comparison,shadowMapSizeInverse: f32,lightSizeUV: f32,darkness: f32,frustumEdgeFalloff: f32,lightSizeUVCorrection: vec2f,depthCorrection: f32,penumbraDarkness: f32)->f32
752
- {return computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthTexture,depthSampler,shadowTexture,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);}
753
- #endif
754
- `;
755
- // Sideeffect
756
- ShaderStore.IncludesShadersStoreWGSL[name$E] = shader$E;
757
-
758
- // Do not edit.
759
- const name$D = "pbrDirectLightingSetupFunctions";
760
- const shader$D = `struct preLightingInfo
761
- {lightOffset: vec3f,
762
- lightDistanceSquared: f32,
763
- lightDistance: f32,
764
- attenuation: f32,
765
- L: vec3f,
766
- H: vec3f,
767
- NdotV: f32,
768
- NdotLUnclamped: f32,
769
- NdotL: f32,
770
- VdotH: f32,
771
- roughness: f32,
772
- #ifdef IRIDESCENCE
773
- iridescenceIntensity: f32
774
- #endif
775
- };fn computePointAndSpotPreLightingInfo(lightData: vec4f,V: vec3f,N: vec3f,posW: vec3f)->preLightingInfo {var result: preLightingInfo;result.lightOffset=lightData.xyz-posW;result.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);result.lightDistance=sqrt(result.lightDistanceSquared);result.L=normalize(result.lightOffset);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);return result;}
776
- fn computeDirectionalPreLightingInfo(lightData: vec4f,V: vec3f,N: vec3f)->preLightingInfo {var result: preLightingInfo;result.lightDistance=length(-lightData.xyz);result.L=normalize(-lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));result.NdotLUnclamped=dot(N,result.L);result.NdotL=saturateEps(result.NdotLUnclamped);return result;}
777
- fn computeHemisphericPreLightingInfo(lightData: vec4f,V: vec3f,N: vec3f)->preLightingInfo {var result: preLightingInfo;result.NdotL=dot(N,lightData.xyz)*0.5+0.5;result.NdotL=saturateEps(result.NdotL);result.NdotLUnclamped=result.NdotL;
778
- #ifdef SPECULARTERM
779
- result.L=normalize(lightData.xyz);result.H=normalize(V+result.L);result.VdotH=saturate(dot(V,result.H));
780
- #endif
781
- return result;}`;
782
- // Sideeffect
783
- ShaderStore.IncludesShadersStoreWGSL[name$D] = shader$D;
784
-
785
- // Do not edit.
786
- const name$C = "pbrDirectLightingFalloffFunctions";
787
- const shader$C = `fn computeDistanceLightFalloff_Standard(lightOffset: vec3f,range: f32)->f32
788
- {return max(0.,1.0-length(lightOffset)/range);}
789
- fn computeDistanceLightFalloff_Physical(lightDistanceSquared: f32)->f32
790
- {return 1.0/maxEps(lightDistanceSquared);}
791
- fn computeDistanceLightFalloff_GLTF(lightDistanceSquared: f32,inverseSquaredRange: f32)->f32
792
- {var lightDistanceFalloff: f32=1.0/maxEps(lightDistanceSquared);var factor: f32=lightDistanceSquared*inverseSquaredRange;var attenuation: f32=saturate(1.0-factor*factor);attenuation*=attenuation;lightDistanceFalloff*=attenuation;return lightDistanceFalloff;}
793
- fn computeDistanceLightFalloff(lightOffset: vec3f,lightDistanceSquared: f32,range: f32,inverseSquaredRange: f32)->f32
794
- {
795
- #ifdef USEPHYSICALLIGHTFALLOFF
796
- return computeDistanceLightFalloff_Physical(lightDistanceSquared);
797
- #elif defined(USEGLTFLIGHTFALLOFF)
798
- return computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);
799
- #else
800
- return computeDistanceLightFalloff_Standard(lightOffset,range);
801
- #endif
802
- }
803
- fn computeDirectionalLightFalloff_Standard(lightDirection: vec3f,directionToLightCenterW: vec3f,cosHalfAngle: f32,exponent: f32)->f32
804
- {var falloff: f32=0.0;var cosAngle: f32=maxEps(dot(-lightDirection,directionToLightCenterW));if (cosAngle>=cosHalfAngle)
805
- {falloff=max(0.,pow(cosAngle,exponent));}
806
- return falloff;}
807
- fn computeDirectionalLightFalloff_Physical(lightDirection: vec3f,directionToLightCenterW: vec3f,cosHalfAngle: f32)->f32
808
- {const kMinusLog2ConeAngleIntensityRatio: f32=6.64385618977;
809
- var concentrationKappa: f32=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);var lightDirectionSpreadSG: vec4f= vec4f(-lightDirection*concentrationKappa,-concentrationKappa);var falloff: f32=exp2(dot( vec4f(directionToLightCenterW,1.0),lightDirectionSpreadSG));return falloff;}
810
- fn computeDirectionalLightFalloff_GLTF(lightDirection: vec3f,directionToLightCenterW: vec3f,lightAngleScale: f32,lightAngleOffset: f32)->f32
811
- {var cd: f32=dot(-lightDirection,directionToLightCenterW);var falloff: f32=saturate(cd*lightAngleScale+lightAngleOffset);falloff*=falloff;return falloff;}
812
- fn computeDirectionalLightFalloff(lightDirection: vec3f,directionToLightCenterW: vec3f,cosHalfAngle: f32,exponent: f32,lightAngleScale: f32,lightAngleOffset: f32)->f32
813
- {
814
- #ifdef USEPHYSICALLIGHTFALLOFF
815
- return computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);
816
- #elif defined(USEGLTFLIGHTFALLOFF)
817
- return computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);
818
- #else
819
- return computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);
820
- #endif
821
- }`;
822
- // Sideeffect
823
- ShaderStore.IncludesShadersStoreWGSL[name$C] = shader$C;
824
-
825
- // Do not edit.
826
- const name$B = "pbrBRDFFunctions";
827
- const shader$B = `#define FRESNEL_MAXIMUM_ON_ROUGH 0.25
828
- #ifdef MS_BRDF_ENERGY_CONSERVATION
829
- fn getEnergyConservationFactor(specularEnvironmentR0: vec3f,environmentBrdf: vec3f)->vec3f {return 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);}
830
- #endif
831
- #ifdef ENVIRONMENTBRDF
832
- fn getBRDFLookup(NdotV: f32,perceptualRoughness: f32)->vec3f {var UV: vec2f= vec2f(NdotV,perceptualRoughness);var brdfLookup: vec4f= textureSample(environmentBrdfSampler,environmentBrdfSamplerSampler,UV);
833
- #ifdef ENVIRONMENTBRDF_RGBD
834
- brdfLookup=vec4f(fromRGBD(brdfLookup.rgba),brdfLookup.a);
835
- #endif
836
- return brdfLookup.rgb;}
837
- fn getReflectanceFromBRDFWithEnvLookup(specularEnvironmentR0: vec3f,specularEnvironmentR90: vec3f,environmentBrdf: vec3f)->vec3f {
838
- #ifdef BRDF_V_HEIGHT_CORRELATED
839
- var reflectance: vec3f=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;
840
- #else
841
- var reflectance: vec3f=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;
842
- #endif
843
- return reflectance;}
844
- fn getReflectanceFromBRDFLookup(specularEnvironmentR0: vec3f,environmentBrdf: vec3f)->vec3f {
845
- #ifdef BRDF_V_HEIGHT_CORRELATED
846
- var reflectance: vec3f=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);
847
- #else
848
- var reflectance: vec3f=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;
849
- #endif
850
- return reflectance;}
851
- #endif
852
- /* NOT USED
853
- #if defined(SHEEN) && defined(SHEEN_SOFTER)
854
- fn getBRDFLookupCharlieSheen(NdotV: f32,perceptualRoughness: f32)->f32
855
- {var c: f32=1.0-NdotV;var c3: f32=c*c*c;return 0.65584461*c3+1.0/(4.16526551+exp(-7.97291361*perceptualRoughness+6.33516894));}
856
- #endif
857
- */
858
- #if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)
859
- fn getReflectanceFromAnalyticalBRDFLookup_Jones(VdotN: f32,reflectance0: vec3f,reflectance90: vec3f,smoothness: f32)->vec3f
860
- {var weight: f32=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);return reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));}
861
- #endif
862
- #if defined(SHEEN) && defined(ENVIRONMENTBRDF)
863
- /**
864
- * The sheen BRDF not containing F can be easily stored in the blue channel of the BRDF texture.
865
- * The blue channel contains DCharlie*VAshikhmin*NdotL as a lokkup table
866
- */
867
- fn getSheenReflectanceFromBRDFLookup(reflectance0: vec3f,environmentBrdf: vec3f)->vec3f {var sheenEnvironmentReflectance: vec3f=reflectance0*environmentBrdf.b;return sheenEnvironmentReflectance;}
868
- #endif
869
- fn fresnelSchlickGGXVec3(VdotH: f32,reflectance0: vec3f,reflectance90: vec3f)->vec3f
870
- {return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);}
871
- fn fresnelSchlickGGX(VdotH: f32,reflectance0: f32,reflectance90: f32)->f32
872
- {return reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);}
873
- #ifdef CLEARCOAT
874
- fn getR0RemappedForClearCoat(f0: vec3f)->vec3f {
875
- #ifdef CLEARCOAT_DEFAULTIOR
876
- #ifdef MOBILE
877
- return saturateVec3(f0*(f0*0.526868+0.529324)-0.0482256);
878
- #else
879
- return saturateVec3(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);
880
- #endif
881
- #else
882
- var s: vec3f=sqrt(f0);var t: vec3f=(uniforms.vClearCoatRefractionParams.z+uniforms.vClearCoatRefractionParams.w*s)/(uniforms.vClearCoatRefractionParams.w+uniforms.vClearCoatRefractionParams.z*s);return squareVec3(t);
883
- #endif
884
- }
885
- #endif
886
- #ifdef IRIDESCENCE
887
- const XYZ_TO_REC709: mat3x3f= mat3x3f(
888
- 3.2404542,-0.9692660, 0.0556434,
889
- -1.5371385, 1.8760108,-0.2040259,
890
- -0.4985314, 0.0415560, 1.0572252
891
- );fn getIORTfromAirToSurfaceR0(f0: vec3f)->vec3f {var sqrtF0: vec3f=sqrt(f0);return (1.+sqrtF0)/(1.-sqrtF0);}
892
- fn getR0fromIORsVec3(iorT: vec3f,iorI: f32)->vec3f {return squareVec3((iorT- vec3f(iorI))/(iorT+ vec3f(iorI)));}
893
- fn getR0fromIORs(iorT: f32,iorI: f32)->f32 {return square((iorT-iorI)/(iorT+iorI));}
894
- fn evalSensitivity(opd: f32,shift: vec3f)->vec3f {var phase: f32=2.0*PI*opd*1.0e-9;const val: vec3f= vec3f(5.4856e-13,4.4201e-13,5.2481e-13);const pos: vec3f= vec3f(1.6810e+06,1.7953e+06,2.2084e+06);const vr: vec3f= vec3f(4.3278e+09,9.3046e+09,6.6121e+09);var xyz: vec3f=val*sqrt(2.0*PI*vr)*cos(pos*phase+shift)*exp(-square(phase)*vr);xyz.x+=9.7470e-14*sqrt(2.0*PI*4.5282e+09)*cos(2.2399e+06*phase+shift[0])*exp(-4.5282e+09*square(phase));xyz/=1.0685e-7;var srgb: vec3f=XYZ_TO_REC709*xyz;return srgb;}
895
- fn evalIridescence(outsideIOR: f32,eta2: f32,cosTheta1: f32,thinFilmThickness: f32,baseF0: vec3f)->vec3f {var I: vec3f= vec3f(1.0);var iridescenceIOR: f32=mix(outsideIOR,eta2,smoothstep(0.0,0.03,thinFilmThickness));var sinTheta2Sq: f32=square(outsideIOR/iridescenceIOR)*(1.0-square(cosTheta1));var cosTheta2Sq: f32=1.0-sinTheta2Sq;if (cosTheta2Sq<0.0) {return I;}
896
- var cosTheta2: f32=sqrt(cosTheta2Sq);var R0: f32=getR0fromIORs(iridescenceIOR,outsideIOR);var R12: f32=fresnelSchlickGGX(cosTheta1,R0,1.);var R21: f32=R12;var T121: f32=1.0-R12;var phi12: f32=0.0;if (iridescenceIOR<outsideIOR) {phi12=PI;}
897
- var phi21: f32=PI-phi12;var baseIOR: vec3f=getIORTfromAirToSurfaceR0(clamp(baseF0,vec3f(0.0),vec3f(0.9999)));
898
- var R1: vec3f=getR0fromIORsVec3(baseIOR,iridescenceIOR);var R23: vec3f=fresnelSchlickGGXVec3(cosTheta2,R1, vec3f(1.));var phi23: vec3f= vec3f(0.0);if (baseIOR[0]<iridescenceIOR) {phi23[0]=PI;}
899
- if (baseIOR[1]<iridescenceIOR) {phi23[1]=PI;}
900
- if (baseIOR[2]<iridescenceIOR) {phi23[2]=PI;}
901
- var opd: f32=2.0*iridescenceIOR*thinFilmThickness*cosTheta2;var phi: vec3f= vec3f(phi21)+phi23;var R123: vec3f=clamp(R12*R23,vec3f(1e-5),vec3f(0.9999));var r123: vec3f=sqrt(R123);var Rs: vec3f=(T121*T121)*R23/( vec3f(1.0)-R123);var C0: vec3f=R12+Rs;I=C0;var Cm: vec3f=Rs-T121;for (var m: i32=1; m<=2; m++)
902
- {Cm*=r123;var Sm: vec3f=2.0*evalSensitivity( f32(m)*opd, f32(m)*phi);I+=Cm*Sm;}
903
- return max(I, vec3f(0.0));}
904
- #endif
905
- fn normalDistributionFunction_TrowbridgeReitzGGX(NdotH: f32,alphaG: f32)->f32
906
- {var a2: f32=alphaG*alphaG;var d: f32=NdotH*NdotH*(a2-1.0)+1.0;return a2/(PI*d*d);}
907
- #ifdef SHEEN
908
- fn normalDistributionFunction_CharlieSheen(NdotH: f32,alphaG: f32)->f32
909
- {var invR: f32=1./alphaG;var cos2h: f32=NdotH*NdotH;var sin2h: f32=1.-cos2h;return (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);}
910
- #endif
911
- #ifdef ANISOTROPIC
912
- fn normalDistributionFunction_BurleyGGX_Anisotropic(NdotH: f32,TdotH: f32,BdotH: f32,alphaTB: vec2f)->f32 {var a2: f32=alphaTB.x*alphaTB.y;var v: vec3f= vec3f(alphaTB.y*TdotH,alphaTB.x *BdotH,a2*NdotH);var v2: f32=dot(v,v);var w2: f32=a2/v2;return a2*w2*w2*RECIPROCAL_PI;}
913
- #endif
914
- #ifdef BRDF_V_HEIGHT_CORRELATED
915
- fn smithVisibility_GGXCorrelated(NdotL: f32,NdotV: f32,alphaG: f32)->f32 {
916
- #ifdef MOBILE
917
- var GGXV: f32=NdotL*(NdotV*(1.0-alphaG)+alphaG);var GGXL: f32=NdotV*(NdotL*(1.0-alphaG)+alphaG);return 0.5/(GGXV+GGXL);
918
- #else
919
- var a2: f32=alphaG*alphaG;var GGXV: f32=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);var GGXL: f32=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);return 0.5/(GGXV+GGXL);
920
- #endif
921
- }
922
- #else
923
- fn smithVisibilityG1_TrowbridgeReitzGGXFast(dot: f32,alphaG: f32)->f32
924
- {
925
- #ifdef MOBILE
926
- return 1.0/(dot+alphaG+(1.0-alphaG)*dot ));
927
- #else
928
- var alphaSquared: f32=alphaG*alphaG;return 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));
929
- #endif
930
- }
931
- fn smithVisibility_TrowbridgeReitzGGXFast(NdotL: f32,NdotV: f32,alphaG: f32)->f32
932
- {var visibility: f32=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);return visibility;}
933
- #endif
934
- #ifdef ANISOTROPIC
935
- fn smithVisibility_GGXCorrelated_Anisotropic(NdotL: f32,NdotV: f32,TdotV: f32,BdotV: f32,TdotL: f32,BdotL: f32,alphaTB: vec2f)->f32 {var lambdaV: f32=NdotL*length( vec3f(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));var lambdaL: f32=NdotV*length( vec3f(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));var v: f32=0.5/(lambdaV+lambdaL);return v;}
936
- #endif
937
- #ifdef CLEARCOAT
938
- fn visibility_Kelemen(VdotH: f32)->f32 {return 0.25/(VdotH*VdotH); }
939
- #endif
940
- #ifdef SHEEN
941
- fn visibility_Ashikhmin(NdotL: f32,NdotV: f32)->f32
942
- {return 1./(4.*(NdotL+NdotV-NdotL*NdotV));}
943
- /* NOT USED
944
- #ifdef SHEEN_SOFTER
945
- fn l(x: f32,alphaG: f32)->f32
946
- {var oneMinusAlphaSq: f32=(1.0-alphaG)*(1.0-alphaG);var a: f32=mix(21.5473,25.3245,oneMinusAlphaSq);var b: f32=mix(3.82987,3.32435,oneMinusAlphaSq);var c: f32=mix(0.19823,0.16801,oneMinusAlphaSq);var d: f32=mix(-1.97760,-1.27393,oneMinusAlphaSq);var e: f32=mix(-4.32054,-4.85967,oneMinusAlphaSq);return a/(1.0+b*pow(x,c))+d*x+e;}
947
- fn lambdaSheen(cosTheta: f32,alphaG: f32)->f32
948
- {return abs(cosTheta)<0.5 ? exp(l(cosTheta,alphaG)) : exp(2.0*l(0.5,alphaG)-l(1.0-cosTheta,alphaG));}
949
- fn visibility_CharlieSheen(NdotL: f32,NdotV: f32,alphaG: f32)->f32
950
- {var G: f32=1.0/(1.0+lambdaSheen(NdotV,alphaG)+lambdaSheen(NdotL,alphaG));return G/(4.0*NdotV*NdotL);}
951
- #endif
952
- */
953
- #endif
954
- fn diffuseBRDF_Burley(NdotL: f32,NdotV: f32,VdotH: f32,roughness: f32)->f32 {var diffuseFresnelNV: f32=pow5(saturateEps(1.0-NdotL));var diffuseFresnelNL: f32=pow5(saturateEps(1.0-NdotV));var diffuseFresnel90: f32=0.5+2.0*VdotH*VdotH*roughness;var fresnel: f32 =
955
- (1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *
956
- (1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);return fresnel/PI;}
957
- #ifdef SS_TRANSLUCENCY
958
- fn transmittanceBRDF_Burley(tintColor: vec3f,diffusionDistance: vec3f,thickness: f32)->vec3f {var S: vec3f=1./maxEpsVec3(diffusionDistance);var temp: vec3f=exp((-0.333333333*thickness)*S);return tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);}
959
- fn computeWrappedDiffuseNdotL(NdotL: f32,w: f32)->f32 {var t: f32=1.0+w;var invt2: f32=1.0/(t*t);return saturate((NdotL+w)*invt2);}
960
- #endif
961
- `;
962
- // Sideeffect
963
- ShaderStore.IncludesShadersStoreWGSL[name$B] = shader$B;
964
-
965
- // Do not edit.
966
- const name$A = "hdrFilteringFunctions";
967
- const shader$A = `#ifdef NUM_SAMPLES
968
- #if NUM_SAMPLES>0
969
- fn radicalInverse_VdC(value: u32)->f32
970
- {var bits=(value<<16u) | (value>>16u);bits=((bits & 0x55555555u)<<1u) | ((bits & 0xAAAAAAAAu)>>1u);bits=((bits & 0x33333333u)<<2u) | ((bits & 0xCCCCCCCCu)>>2u);bits=((bits & 0x0F0F0F0Fu)<<4u) | ((bits & 0xF0F0F0F0u)>>4u);bits=((bits & 0x00FF00FFu)<<8u) | ((bits & 0xFF00FF00u)>>8u);return f32(bits)*2.3283064365386963e-10; }
971
- fn hammersley(i: u32,N: u32)->vec2f
972
- {return vec2f( f32(i)/ f32(N),radicalInverse_VdC(i));}
973
- fn log4(x: f32)->f32 {return log2(x)/2.;}
974
- const NUM_SAMPLES_FLOAT: f32= f32(NUM_SAMPLES);const NUM_SAMPLES_FLOAT_INVERSED: f32=1./NUM_SAMPLES_FLOAT;const K: f32=4.;fn irradiance(inputTexture: texture_cube<f32>,inputSampler: sampler,inputN: vec3f,filteringInfo: vec2f)->vec3f
975
- {var n: vec3f=normalize(inputN);var result: vec3f= vec3f(0.0);var tangent: vec3f=select(vec3f(1.,0.,0.),vec3f(0.,0.,1.),abs(n.z)<0.999);tangent=normalize(cross(tangent,n));var bitangent: vec3f=cross(n,tangent);var tbn: mat3x3f= mat3x3f(tangent,bitangent,n);var maxLevel: f32=filteringInfo.y;var dim0: f32=filteringInfo.x;var omegaP: f32=(4.*PI)/(6.*dim0*dim0);for(var i: u32=0u; i<NUM_SAMPLES; i++)
976
- {var Xi: vec2f=hammersley(i,NUM_SAMPLES);var Ls: vec3f=hemisphereCosSample(Xi);Ls=normalize(Ls);var Ns: vec3f= vec3f(0.,0.,1.);var NoL: f32=dot(Ns,Ls);if (NoL>0.) {var pdf_inversed: f32=PI/NoL;var omegaS: f32=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;var l: f32=log4(omegaS)-log4(omegaP)+log4(K);var mipLevel: f32=clamp(l,0.0,maxLevel);var c: vec3f=textureSampleLevel(inputTexture,inputSampler,tbn*Ls,mipLevel).rgb;
977
- #ifdef GAMMA_INPUT
978
- c=toLinearSpaceVec3(c);
979
- #endif
980
- result+=c;}}
981
- result=result*NUM_SAMPLES_FLOAT_INVERSED;return result;}
982
- fn radiance(alphaG: f32,inputTexture: texture_cube<f32>,inputSampler: sampler,inputN: vec3f,filteringInfo: vec2f)->vec3f
983
- {var n: vec3f=normalize(inputN);var c: vec3f=textureSample(inputTexture,inputSampler,n).rgb;
984
- if (alphaG==0.) {
985
- #ifdef GAMMA_INPUT
986
- c=toLinearSpace(c);
987
- #endif
988
- return c;} else {var result: vec3f= vec3f(0.);var tangent: vec3f=select(vec3f(1.,0.,0.),vec3f(0.,0.,1.),abs(n.z)<0.999);tangent=normalize(cross(tangent,n));var bitangent: vec3f=cross(n,tangent);var tbn: mat3x3f= mat3x3f(tangent,bitangent,n);var maxLevel: f32=filteringInfo.y;var dim0: f32=filteringInfo.x;var omegaP: f32=(4.*PI)/(6.*dim0*dim0);var weight: f32=0.;for(var i: u32=0u; i<NUM_SAMPLES; i++)
989
- {var Xi: vec2f=hammersley(i,NUM_SAMPLES);var H: vec3f=hemisphereImportanceSampleDggx(Xi,alphaG);var NoV: f32=1.;var NoH: f32=H.z;var NoH2: f32=H.z*H.z;var NoL: f32=2.*NoH2-1.;var L: vec3f= vec3f(2.*NoH*H.x,2.*NoH*H.y,NoL);L=normalize(L);if (NoL>0.) {var pdf_inversed: f32=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);var omegaS: f32=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;var l: f32=log4(omegaS)-log4(omegaP)+log4(K);var mipLevel: f32=clamp( f32(l),0.0,maxLevel);weight+=NoL;var c: vec3f=textureSampleLevel(inputTexture,inputSampler,tbn*L,mipLevel).rgb;
990
- #ifdef GAMMA_INPUT
991
- c=toLinearSpace(c);
992
- #endif
993
- result+=c*NoL;}}
994
- result=result/weight;return result;}}
995
- #endif
996
- #endif
997
- `;
998
- // Sideeffect
999
- ShaderStore.IncludesShadersStoreWGSL[name$A] = shader$A;
1000
-
1001
- // Do not edit.
1002
- const name$z = "pbrDirectLightingFunctions";
1003
- const shader$z = `#define CLEARCOATREFLECTANCE90 1.0
1004
- struct lightingInfo
1005
- {diffuse: vec3f,
1006
- #ifdef SPECULARTERM
1007
- specular: vec3f,
1008
- #endif
1009
- #ifdef CLEARCOAT
1010
- clearCoat: vec4f,
1011
- #endif
1012
- #ifdef SHEEN
1013
- sheen: vec3f
1014
- #endif
1015
- };fn adjustRoughnessFromLightProperties(roughness: f32,lightRadius: f32,lightDistance: f32)->f32 {
1016
- #if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)
1017
- var lightRoughness: f32=lightRadius/lightDistance;var totalRoughness: f32=saturate(lightRoughness+roughness);return totalRoughness;
1018
- #else
1019
- return roughness;
1020
- #endif
1021
- }
1022
- fn computeHemisphericDiffuseLighting(info: preLightingInfo,lightColor: vec3f,groundColor: vec3f)->vec3f {return mix(groundColor,lightColor,info.NdotL);}
1023
- fn computeDiffuseLighting(info: preLightingInfo,lightColor: vec3f)->vec3f {var diffuseTerm: f32=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);return diffuseTerm*info.attenuation*info.NdotL*lightColor;}
1024
- fn computeProjectionTextureDiffuseLighting(projectionLightTexture: texture_2d<f32>,projectionLightSampler: sampler,textureProjectionMatrix: mat4x4f,posW: vec3f)->vec3f{var strq: vec4f=textureProjectionMatrix* vec4f(posW,1.0);strq/=strq.w;var textureColor: vec3f=textureSample(projectionLightTexture,projectionLightSampler,strq.xy).rgb;return toLinearSpaceVec3(textureColor);}
1025
- #ifdef SS_TRANSLUCENCY
1026
- fn computeDiffuseAndTransmittedLighting(info: preLightingInfo,lightColor: vec3f,transmittance: vec3f)->vec3f {var NdotL: f32=absEps(info.NdotLUnclamped);var wrapNdotL: f32=computeWrappedDiffuseNdotL(NdotL,0.02);var trAdapt: f32=step(0.,info.NdotLUnclamped);var transmittanceNdotL: vec3f=mix(transmittance*wrapNdotL, vec3f(wrapNdotL),trAdapt);var diffuseTerm: f32=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);return diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;}
1027
- #endif
1028
- #ifdef SPECULARTERM
1029
- fn computeSpecularLighting(info: preLightingInfo,N: vec3f,reflectance0: vec3f,reflectance90: vec3f,geometricRoughnessFactor: f32,lightColor: vec3f)->vec3f {var NdotH: f32=saturateEps(dot(N,info.H));var roughness: f32=max(info.roughness,geometricRoughnessFactor);var alphaG: f32=convertRoughnessToAverageSlope(roughness);var fresnel: vec3f=fresnelSchlickGGXVec3(info.VdotH,reflectance0,reflectance90);
1030
- #ifdef IRIDESCENCE
1031
- fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity);
1032
- #endif
1033
- var distribution: f32=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);
1034
- #ifdef BRDF_V_HEIGHT_CORRELATED
1035
- var smithVisibility: f32=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);
1036
- #else
1037
- var smithVisibility: f32=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);
1038
- #endif
1039
- var specTerm: vec3f=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;}
1040
- #endif
1041
- #ifdef ANISOTROPIC
1042
- fn computeAnisotropicSpecularLighting(info: preLightingInfo,V: vec3f,N: vec3f,T: vec3f,B: vec3f,anisotropy: f32,reflectance0: vec3f,reflectance90: vec3f,geometricRoughnessFactor: f32,lightColor: vec3f)->vec3f {var NdotH: f32=saturateEps(dot(N,info.H));var TdotH: f32=dot(T,info.H);var BdotH: f32=dot(B,info.H);var TdotV: f32=dot(T,V);var BdotV: f32=dot(B,V);var TdotL: f32=dot(T,info.L);var BdotL: f32=dot(B,info.L);var alphaG: f32=convertRoughnessToAverageSlope(info.roughness);var alphaTB: vec2f=getAnisotropicRoughness(alphaG,anisotropy);alphaTB=max(alphaTB,vec2f(geometricRoughnessFactor*geometricRoughnessFactor));var fresnel: vec3f=fresnelSchlickGGXVec3(info.VdotH,reflectance0,reflectance90);
1043
- #ifdef IRIDESCENCE
1044
- fresnel=mix(fresnel,reflectance0,info.iridescenceIntensity);
1045
- #endif
1046
- var distribution: f32=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);var smithVisibility: f32=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);var specTerm: vec3f=fresnel*distribution*smithVisibility;return specTerm*info.attenuation*info.NdotL*lightColor;}
1047
- #endif
1048
- #ifdef CLEARCOAT
1049
- fn computeClearCoatLighting(info: preLightingInfo,Ncc: vec3f,geometricRoughnessFactor: f32,clearCoatIntensity: f32,lightColor: vec3f)->vec4f {var NccdotL: f32=saturateEps(dot(Ncc,info.L));var NccdotH: f32=saturateEps(dot(Ncc,info.H));var clearCoatRoughness: f32=max(info.roughness,geometricRoughnessFactor);var alphaG: f32=convertRoughnessToAverageSlope(clearCoatRoughness);var fresnel: f32=fresnelSchlickGGX(info.VdotH,uniforms.vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnel*=clearCoatIntensity;var distribution: f32=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);var kelemenVisibility: f32=visibility_Kelemen(info.VdotH);var clearCoatTerm: f32=fresnel*distribution*kelemenVisibility;return vec4f(
1050
- clearCoatTerm*info.attenuation*NccdotL*lightColor,
1051
- 1.0-fresnel
1052
- );}
1053
- fn computeClearCoatLightingAbsorption(NdotVRefract: f32,L: vec3f,Ncc: vec3f,clearCoatColor: vec3f,clearCoatThickness: f32,clearCoatIntensity: f32)->vec3f {var LRefract: vec3f=-refract(L,Ncc,uniforms.vClearCoatRefractionParams.y);var NdotLRefract: f32=saturateEps(dot(Ncc,LRefract));var absorption: vec3f=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);return absorption;}
1054
- #endif
1055
- #ifdef SHEEN
1056
- fn computeSheenLighting(info: preLightingInfo,N: vec3f,reflectance0: vec3f,reflectance90: vec3f,geometricRoughnessFactor: f32,lightColor: vec3f)->vec3f {var NdotH: f32=saturateEps(dot(N,info.H));var roughness: f32=max(info.roughness,geometricRoughnessFactor);var alphaG: f32=convertRoughnessToAverageSlope(roughness);var fresnel: f32=1.;var distribution: f32=normalDistributionFunction_CharlieSheen(NdotH,alphaG);/*#ifdef SHEEN_SOFTER
1057
- var visibility: f32=visibility_CharlieSheen(info.NdotL,info.NdotV,alphaG);
1058
- #else */
1059
- var visibility: f32=visibility_Ashikhmin(info.NdotL,info.NdotV);/* #endif */
1060
- var sheenTerm: f32=fresnel*distribution*visibility;return sheenTerm*info.attenuation*info.NdotL*lightColor;}
1061
- #endif
1062
- `;
1063
- // Sideeffect
1064
- ShaderStore.IncludesShadersStoreWGSL[name$z] = shader$z;
1065
-
1066
- // Do not edit.
1067
- const name$y = "pbrIBLFunctions";
1068
- const shader$y = `#if defined(REFLECTION) || defined(SS_REFRACTION)
1069
- fn getLodFromAlphaG(cubeMapDimensionPixels: f32,microsurfaceAverageSlope: f32)->f32 {var microsurfaceAverageSlopeTexels: f32=cubeMapDimensionPixels*microsurfaceAverageSlope;var lod: f32=log2(microsurfaceAverageSlopeTexels);return lod;}
1070
- fn getLinearLodFromRoughness(cubeMapDimensionPixels: f32,roughness: f32)->f32 {var lod: f32=log2(cubeMapDimensionPixels)*roughness;return lod;}
1071
- #endif
1072
- #if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)
1073
- fn environmentRadianceOcclusion(ambientOcclusion: f32,NdotVUnclamped: f32)->f32 {var temp: f32=NdotVUnclamped+ambientOcclusion;return saturate(temp*temp-1.0+ambientOcclusion);}
1074
- #endif
1075
- #if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)
1076
- fn environmentHorizonOcclusion(view: vec3f,normal: vec3f,geometricNormal: vec3f)->f32 {var reflection: vec3f=reflect(view,normal);var temp: f32=saturate(1.0+1.1*dot(reflection,geometricNormal));return temp*temp;}
1077
- #endif
1078
- #if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)
1079
- fn UNPACK_LOD(x: f32)->f32 {return (1.0-x)*255.0;}
1080
- fn getLodFromAlphaGNdotV(cubeMapDimensionPixels: f32,alphaG: f32,NdotV: f32)->f32 {var microsurfaceAverageSlope: f32=alphaG;microsurfaceAverageSlope*=sqrt(abs(NdotV));return getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);}
1081
- #endif
1082
- `;
1083
- // Sideeffect
1084
- ShaderStore.IncludesShadersStoreWGSL[name$y] = shader$y;
1085
-
1086
- // Do not edit.
1087
- const name$x = "bumpFragmentMainFunctions";
1088
- const shader$x = `#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)
1089
- #if defined(TANGENT) && defined(NORMAL)
1090
- varying vTBN0: vec3f;varying vTBN1: vec3f;varying vTBN2: vec3f;
1091
- #endif
1092
- #ifdef OBJECTSPACE_NORMALMAP
1093
- uniform normalMatrix: mat4x4f;fn toNormalMatrix(m: mat4x4f)->mat4x4f
1094
- {var a00=m[0][0];var a01=m[0][1];var a02=m[0][2];var a03=m[0][3];var a10=m[1][0];var a11=m[1][1];var a12=m[1][2];var a13=m[1][3];var a20=m[2][0];
1095
- var a21=m[2][1];var a22=m[2][2];var a23=m[2][3];var a30=m[3][0];
1096
- var a31=m[3][1];var a32=m[3][2];var a33=m[3][3];var b00=a00*a11-a01*a10;var b01=a00*a12-a02*a10;var b02=a00*a13-a03*a10;var b03=a01*a12-a02*a11;var b04=a01*a13-a03*a11;var b05=a02*a13-a03*a12;var b06=a20*a31-a21*a30;var b07=a20*a32-a22*a30;var b08=a20*a33-a23*a30;var b09=a21*a32-a22*a31;var b10=a21*a33-a23*a31;var b11=a22*a33-a23*a32;var det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;var mi=mat4x4<f32>(
1097
- (a11*b11-a12*b10+a13*b09)/det,
1098
- (a02*b10-a01*b11-a03*b09)/det,
1099
- (a31*b05-a32*b04+a33*b03)/det,
1100
- (a22*b04-a21*b05-a23*b03)/det,
1101
- (a12*b08-a10*b11-a13*b07)/det,
1102
- (a00*b11-a02*b08+a03*b07)/det,
1103
- (a32*b02-a30*b05-a33*b01)/det,
1104
- (a20*b05-a22*b02+a23*b01)/det,
1105
- (a10*b10-a11*b08+a13*b06)/det,
1106
- (a01*b08-a00*b10-a03*b06)/det,
1107
- (a30*b04-a31*b02+a33*b00)/det,
1108
- (a21*b02-a20*b04-a23*b00)/det,
1109
- (a11*b07-a10*b09-a12*b06)/det,
1110
- (a00*b09-a01*b07+a02*b06)/det,
1111
- (a31*b01-a30*b03-a32*b00)/det,
1112
- (a20*b03-a21*b01+a22*b00)/det);return mat4x4<f32>(mi[0][0],mi[1][0],mi[2][0],mi[3][0],
1113
- mi[0][1],mi[1][1],mi[2][1],mi[3][1],
1114
- mi[0][2],mi[1][2],mi[2][2],mi[3][2],
1115
- mi[0][3],mi[1][3],mi[2][3],mi[3][3]);}
1116
- #endif
1117
- fn perturbNormalBase(cotangentFrame: mat3x3f,normal: vec3f,scale: f32)->vec3f
1118
- {var output=normal;
1119
- #ifdef NORMALXYSCALE
1120
- output=normalize(output* vec3f(scale,scale,1.0));
1121
- #endif
1122
- return normalize(cotangentFrame*output);}
1123
- fn perturbNormal(cotangentFrame: mat3x3f,textureSample: vec3f,scale: f32)->vec3f
1124
- {return perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);}
1125
- fn cotangent_frame(normal: vec3f,p: vec3f,uv: vec2f,tangentSpaceParams: vec2f)->mat3x3f
1126
- {var dp1: vec3f=dpdx(p);var dp2: vec3f=dpdy(p);var duv1: vec2f=dpdx(uv);var duv2: vec2f=dpdy(uv);var dp2perp: vec3f=cross(dp2,normal);var dp1perp: vec3f=cross(normal,dp1);var tangent: vec3f=dp2perp*duv1.x+dp1perp*duv2.x;var bitangent: vec3f=dp2perp*duv1.y+dp1perp*duv2.y;tangent*=tangentSpaceParams.x;bitangent*=tangentSpaceParams.y;var det: f32=max(dot(tangent,tangent),dot(bitangent,bitangent));var invmax: f32=select(inverseSqrt(det),0.0,det==0.0);return mat3x3f(tangent*invmax,bitangent*invmax,normal);}
1127
- #endif
1128
- `;
1129
- // Sideeffect
1130
- ShaderStore.IncludesShadersStoreWGSL[name$x] = shader$x;
1131
-
1132
- // Do not edit.
1133
- const name$w = "bumpFragmentFunctions";
1134
- const shader$w = `#if defined(BUMP)
1135
- #include<samplerFragmentDeclaration>(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump)
1136
- #endif
1137
- #if defined(DETAIL)
1138
- #include<samplerFragmentDeclaration>(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)
1139
- #endif
1140
- #if defined(BUMP) && defined(PARALLAX)
1141
- const minSamples: f32=4.;const maxSamples: f32=15.;const iMaxSamples: i32=15;fn parallaxOcclusion(vViewDirCoT: vec3f,vNormalCoT: vec3f,texCoord: vec2f,parallaxScale: f32)->vec2f {var parallaxLimit: f32=length(vViewDirCoT.xy)/vViewDirCoT.z;parallaxLimit*=parallaxScale;var vOffsetDir: vec2f=normalize(vViewDirCoT.xy);var vMaxOffset: vec2f=vOffsetDir*parallaxLimit;var numSamples: f32=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));var stepSize: f32=1.0/numSamples;var currRayHeight: f32=1.0;var vCurrOffset: vec2f= vec2f(0,0);var vLastOffset: vec2f= vec2f(0,0);var lastSampledHeight: f32=1.0;var currSampledHeight: f32=1.0;var keepWorking: bool=true;for (var i: i32=0; i<iMaxSamples; i++)
1142
- {currSampledHeight=textureSample(bumpSampler,bumpSamplerSampler,texCoord+vCurrOffset).w;if (!keepWorking)
1143
- {}
1144
- else if (currSampledHeight>currRayHeight)
1145
- {var delta1: f32=currSampledHeight-currRayHeight;var delta2: f32=(currRayHeight+stepSize)-lastSampledHeight;var ratio: f32=delta1/(delta1+delta2);vCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;keepWorking=false;}
1146
- else
1147
- {currRayHeight-=stepSize;vLastOffset=vCurrOffset;
1148
- #ifdef PARALLAX_RHS
1149
- vCurrOffset-=stepSize*vMaxOffset;
1150
- #else
1151
- vCurrOffset+=stepSize*vMaxOffset;
1152
- #endif
1153
- lastSampledHeight=currSampledHeight;}}
1154
- return vCurrOffset;}
1155
- fn parallaxOffset(viewDir: vec3f,heightScale: f32)->vec2f
1156
- {var height: f32=textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).w;var texCoordOffset: vec2f=heightScale*viewDir.xy*height;
1157
- #ifdef PARALLAX_RHS
1158
- return texCoordOffset;
1159
- #else
1160
- return -texCoordOffset;
1161
- #endif
1162
- }
1163
- #endif
1164
- `;
1165
- // Sideeffect
1166
- ShaderStore.IncludesShadersStoreWGSL[name$w] = shader$w;
1167
-
1168
- // Do not edit.
1169
- const name$v = "reflectionFunction";
1170
- const shader$v = `fn computeFixedEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,direction: vec3f)->vec3f
1171
- {var lon: f32=atan2(direction.z,direction.x);var lat: f32=acos(direction.y);var sphereCoords: vec2f= vec2f(lon,lat)*RECIPROCAL_PI2*2.0;var s: f32=sphereCoords.x*0.5+0.5;var t: f32=sphereCoords.y;return vec3f(s,t,0); }
1172
- fn computeMirroredFixedEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,direction: vec3f)->vec3f
1173
- {var lon: f32=atan2(direction.z,direction.x);var lat: f32=acos(direction.y);var sphereCoords: vec2f= vec2f(lon,lat)*RECIPROCAL_PI2*2.0;var s: f32=sphereCoords.x*0.5+0.5;var t: f32=sphereCoords.y;return vec3f(1.0-s,t,0); }
1174
- fn computeEquirectangularCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
1175
- {var cameraToVertex: vec3f=normalize(worldPos.xyz-eyePosition);var r: vec3f=normalize(reflect(cameraToVertex,worldNormal));r= (reflectionMatrix* vec4f(r,0)).xyz;var lon: f32=atan2(r.z,r.x);var lat: f32=acos(r.y);var sphereCoords: vec2f= vec2f(lon,lat)*RECIPROCAL_PI2*2.0;var s: f32=sphereCoords.x*0.5+0.5;var t: f32=sphereCoords.y;return vec3f(s,t,0);}
1176
- fn computeSphericalCoords(worldPos: vec4f,worldNormal: vec3f,view: mat4x4f,reflectionMatrix: mat4x4f)->vec3f
1177
- {var viewDir: vec3f=normalize((view*worldPos).xyz);var viewNormal: vec3f=normalize((view* vec4f(worldNormal,0.0)).xyz);var r: vec3f=reflect(viewDir,viewNormal);r= (reflectionMatrix* vec4f(r,0)).xyz;r.z=r.z-1.0;var m: f32=2.0*length(r);return vec3f(r.x/m+0.5,1.0-r.y/m-0.5,0);}
1178
- fn computePlanarCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
1179
- {var viewDir: vec3f=worldPos.xyz-eyePosition;var coords: vec3f=normalize(reflect(viewDir,worldNormal));return (reflectionMatrix* vec4f(coords,1)).xyz;}
1180
- fn computeCubicCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f)->vec3f
1181
- {var viewDir: vec3f=normalize(worldPos.xyz-eyePosition);var coords: vec3f=reflect(viewDir,worldNormal);coords= (reflectionMatrix* vec4f(coords,0)).xyz;
1182
- #ifdef INVERTCUBICMAP
1183
- coords.y*=-1.0;
1184
- #endif
1185
- return coords;}
1186
- fn computeCubicLocalCoords(worldPos: vec4f,worldNormal: vec3f,eyePosition: vec3f,reflectionMatrix: mat4x4f,reflectionSize: vec3f,reflectionPosition: vec3f)->vec3f
1187
- {var viewDir: vec3f=normalize(worldPos.xyz-eyePosition);var coords: vec3f=reflect(viewDir,worldNormal);coords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);coords=(reflectionMatrix* vec4f(coords,0)).xyz;
1188
- #ifdef INVERTCUBICMAP
1189
- coords.y*=-1.0;
1190
- #endif
1191
- return coords;}
1192
- fn computeProjectionCoords(worldPos: vec4f,view: mat4x4f,reflectionMatrix: mat4x4f)->vec3f
1193
- {return (reflectionMatrix*(view*worldPos)).xyz;}
1194
- fn computeSkyBoxCoords(positionW: vec3f,reflectionMatrix: mat4x4f)->vec3f
1195
- {return (reflectionMatrix* vec4f(positionW,1.)).xyz;}
1196
- #ifdef REFLECTION
1197
- fn computeReflectionCoords(worldPos: vec4f,worldNormal: vec3f)->vec3f
1198
- {
1199
- #ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED
1200
- var direction: vec3f=normalize(fragmentInputs.vDirectionW);return computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);
1201
- #endif
1202
- #ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
1203
- var direction: vec3f=normalize(fragmentInputs.vDirectionW);return computeFixedEquirectangularCoords(worldPos,worldNormal,direction);
1204
- #endif
1205
- #ifdef REFLECTIONMAP_EQUIRECTANGULAR
1206
- return computeEquirectangularCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
1207
- #endif
1208
- #ifdef REFLECTIONMAP_SPHERICAL
1209
- return computeSphericalCoords(worldPos,worldNormal,scene.view,uniforms.reflectionMatrix);
1210
- #endif
1211
- #ifdef REFLECTIONMAP_PLANAR
1212
- return computePlanarCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
1213
- #endif
1214
- #ifdef REFLECTIONMAP_CUBIC
1215
- #ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
1216
- return computeCubicLocalCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix,uniforms.vReflectionSize,uniforms.vReflectionPosition);
1217
- #else
1218
- return computeCubicCoords(worldPos,worldNormal,scene.vEyePosition.xyz,uniforms.reflectionMatrix);
1219
- #endif
1220
- #endif
1221
- #ifdef REFLECTIONMAP_PROJECTION
1222
- return computeProjectionCoords(worldPos,scene.view,uniforms.reflectionMatrix);
1223
- #endif
1224
- #ifndef REFLECTIONMAP_CUBIC
1225
- #ifdef REFLECTIONMAP_SKYBOX
1226
- return computeSkyBoxCoords(fragmentInputs.vPositionUVW,uniforms.reflectionMatrix);
1227
- #endif
1228
- #endif
1229
- #ifdef REFLECTIONMAP_EXPLICIT
1230
- return vec3f(0,0,0);
1231
- #endif
1232
- }
1233
- #endif
1234
- `;
1235
- // Sideeffect
1236
- ShaderStore.IncludesShadersStoreWGSL[name$v] = shader$v;
1237
-
1238
- // Do not edit.
1239
- const name$u = "decalFragment";
1240
- const shader$u = `#ifdef DECAL
1241
- var decalTempColor=decalColor.rgb;var decalTempAlpha=decalColor.a;
1242
- #ifdef GAMMADECAL
1243
- decalTempColor=toLinearSpaceVec3(decalColor.rgb);
1244
- #endif
1245
- #ifdef DECAL_SMOOTHALPHA
1246
- decalTempAlpha=decalColor.a*decalColor.a;
1247
- #endif
1248
- surfaceAlbedo=mix(surfaceAlbedo.rgb,decalTempColor,decalTempAlpha);
1249
- #endif
1250
- `;
1251
- // Sideeffect
1252
- ShaderStore.IncludesShadersStoreWGSL[name$u] = shader$u;
1253
-
1254
- // Do not edit.
1255
- const name$t = "pbrBlockAlbedoOpacity";
1256
- const shader$t = `struct albedoOpacityOutParams
1257
- {surfaceAlbedo: vec3f,
1258
- alpha: f32};
1259
- #define pbr_inline
1260
- fn albedoOpacityBlock(
1261
- vAlbedoColor: vec4f
1262
- #ifdef ALBEDO
1263
- ,albedoTexture: vec4f
1264
- ,albedoInfos: vec2f
1265
- #endif
1266
- #ifdef OPACITY
1267
- ,opacityMap: vec4f
1268
- ,vOpacityInfos: vec2f
1269
- #endif
1270
- #ifdef DETAIL
1271
- ,detailColor: vec4f
1272
- ,vDetailInfos: vec4f
1273
- #endif
1274
- #ifdef DECAL
1275
- ,decalColor: vec4f
1276
- ,vDecalInfos: vec4f
1277
- #endif
1278
- )->albedoOpacityOutParams
1279
- {var outParams: albedoOpacityOutParams;var surfaceAlbedo: vec3f=vAlbedoColor.rgb;var alpha: f32=vAlbedoColor.a;
1280
- #ifdef ALBEDO
1281
- #if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)
1282
- alpha*=albedoTexture.a;
1283
- #endif
1284
- #ifdef GAMMAALBEDO
1285
- surfaceAlbedo*=toLinearSpaceVec3(albedoTexture.rgb);
1286
- #else
1287
- surfaceAlbedo*=albedoTexture.rgb;
1288
- #endif
1289
- surfaceAlbedo*=albedoInfos.y;
1290
- #endif
1291
- #ifndef DECAL_AFTER_DETAIL
1292
- #include<decalFragment>
1293
- #endif
1294
- #if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR) && defined(INSTANCES)
1295
- surfaceAlbedo*=fragmentInputs.vColor.rgb;
1296
- #endif
1297
- #ifdef DETAIL
1298
- var detailAlbedo: f32=2.0*mix(0.5,detailColor.r,vDetailInfos.y);surfaceAlbedo=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo;
1299
- #endif
1300
- #ifdef DECAL_AFTER_DETAIL
1301
- #include<decalFragment>
1302
- #endif
1303
- #define CUSTOM_FRAGMENT_UPDATE_ALBEDO
1304
- #ifdef OPACITY
1305
- #ifdef OPACITYRGB
1306
- alpha=getLuminance(opacityMap.rgb);
1307
- #else
1308
- alpha*=opacityMap.a;
1309
- #endif
1310
- alpha*=vOpacityInfos.y;
1311
- #endif
1312
- #if defined(VERTEXALPHA) || defined(INSTANCESCOLOR) && defined(INSTANCES)
1313
- alpha*=fragmentInputs.vColor.a;
1314
- #endif
1315
- #if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)
1316
- #ifdef ALPHATEST
1317
- #if DEBUGMODE != 88
1318
- if (alpha<ALPHATESTVALUE) {discard;}
1319
- #endif
1320
- #ifndef ALPHABLEND
1321
- alpha=1.0;
1322
- #endif
1323
- #endif
1324
- #endif
1325
- outParams.surfaceAlbedo=surfaceAlbedo;outParams.alpha=alpha;return outParams;}
1326
- `;
1327
- // Sideeffect
1328
- ShaderStore.IncludesShadersStoreWGSL[name$t] = shader$t;
1329
-
1330
- // Do not edit.
1331
- const name$s = "pbrBlockReflectivity";
1332
- const shader$s = `struct reflectivityOutParams
1333
- {microSurface: f32,
1334
- roughness: f32,
1335
- surfaceReflectivityColor: vec3f,
1336
- #ifdef METALLICWORKFLOW
1337
- surfaceAlbedo: vec3f,
1338
- #endif
1339
- #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
1340
- ambientOcclusionColor: vec3f,
1341
- #endif
1342
- #if DEBUGMODE>0
1343
- #ifdef METALLICWORKFLOW
1344
- metallicRoughness: vec2f,
1345
- #ifdef REFLECTIVITY
1346
- surfaceMetallicColorMap: vec4f,
1347
- #endif
1348
- #ifndef FROSTBITE_REFLECTANCE
1349
- metallicF0: vec3f,
1350
- #endif
1351
- #else
1352
- #ifdef REFLECTIVITY
1353
- surfaceReflectivityColorMap: vec4f,
1354
- #endif
1355
- #endif
1356
- #endif
1357
- };
1358
- #define pbr_inline
1359
- fn reflectivityBlock(
1360
- vReflectivityColor: vec4f
1361
- #ifdef METALLICWORKFLOW
1362
- ,surfaceAlbedo: vec3f
1363
- ,metallicReflectanceFactors: vec4f
1364
- #endif
1365
- #ifdef REFLECTIVITY
1366
- ,reflectivityInfos: vec3f
1367
- ,surfaceMetallicOrReflectivityColorMap: vec4f
1368
- #endif
1369
- #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
1370
- ,ambientOcclusionColorIn: vec3f
1371
- #endif
1372
- #ifdef MICROSURFACEMAP
1373
- ,microSurfaceTexel: vec4f
1374
- #endif
1375
- #ifdef DETAIL
1376
- ,detailColor: vec4f
1377
- ,vDetailInfos: vec4f
1378
- #endif
1379
- )->reflectivityOutParams
1380
- {var outParams: reflectivityOutParams;var microSurface: f32=vReflectivityColor.a;var surfaceReflectivityColor: vec3f=vReflectivityColor.rgb;
1381
- #ifdef METALLICWORKFLOW
1382
- var metallicRoughness: vec2f=surfaceReflectivityColor.rg;
1383
- #ifdef REFLECTIVITY
1384
- #if DEBUGMODE>0
1385
- outParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;
1386
- #endif
1387
- #ifdef AOSTOREINMETALMAPRED
1388
- var aoStoreInMetalMap: vec3f= vec3f(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);outParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);
1389
- #endif
1390
- #ifdef METALLNESSSTOREINMETALMAPBLUE
1391
- metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;
1392
- #else
1393
- metallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;
1394
- #endif
1395
- #ifdef ROUGHNESSSTOREINMETALMAPALPHA
1396
- metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;
1397
- #else
1398
- #ifdef ROUGHNESSSTOREINMETALMAPGREEN
1399
- metallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;
1400
- #endif
1401
- #endif
1402
- #endif
1403
- #ifdef DETAIL
1404
- var detailRoughness: f32=mix(0.5,detailColor.b,vDetailInfos.w);var loLerp: f32=mix(0.,metallicRoughness.g,detailRoughness*2.);var hiLerp: f32=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);metallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));
1405
- #endif
1406
- #ifdef MICROSURFACEMAP
1407
- metallicRoughness.g*=microSurfaceTexel.r;
1408
- #endif
1409
- #if DEBUGMODE>0
1410
- outParams.metallicRoughness=metallicRoughness;
1411
- #endif
1412
- #define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS
1413
- microSurface=1.0-metallicRoughness.g;var baseColor: vec3f=surfaceAlbedo;
1414
- #ifdef FROSTBITE_REFLECTANCE
1415
- outParams.surfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);surfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);
1416
- #else
1417
- var metallicF0: vec3f=metallicReflectanceFactors.rgb;
1418
- #if DEBUGMODE>0
1419
- outParams.metallicF0=metallicF0;
1420
- #endif
1421
- outParams.surfaceAlbedo=mix(baseColor.rgb*(1.0-metallicF0), vec3f(0.,0.,0.),metallicRoughness.r);surfaceReflectivityColor=mix(metallicF0,baseColor,metallicRoughness.r);
1422
- #endif
1423
- #else
1424
- #ifdef REFLECTIVITY
1425
- surfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;
1426
- #if DEBUGMODE>0
1427
- outParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;
1428
- #endif
1429
- #ifdef MICROSURFACEFROMREFLECTIVITYMAP
1430
- microSurface*=surfaceMetallicOrReflectivityColorMap.a;microSurface*=reflectivityInfos.z;
1431
- #else
1432
- #ifdef MICROSURFACEAUTOMATIC
1433
- microSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);
1434
- #endif
1435
- #ifdef MICROSURFACEMAP
1436
- microSurface*=microSurfaceTexel.r;
1437
- #endif
1438
- #define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE
1439
- #endif
1440
- #endif
1441
- #endif
1442
- microSurface=saturate(microSurface);var roughness: f32=1.-microSurface;outParams.microSurface=microSurface;outParams.roughness=roughness;outParams.surfaceReflectivityColor=surfaceReflectivityColor;return outParams;}
1443
- `;
1444
- // Sideeffect
1445
- ShaderStore.IncludesShadersStoreWGSL[name$s] = shader$s;
1446
-
1447
- // Do not edit.
1448
- const name$r = "pbrBlockAmbientOcclusion";
1449
- const shader$r = `struct ambientOcclusionOutParams
1450
- {ambientOcclusionColor: vec3f,
1451
- #if DEBUGMODE>0 && defined(AMBIENT)
1452
- ambientOcclusionColorMap: vec3f
1453
- #endif
1454
- };
1455
- #define pbr_inline
1456
- fn ambientOcclusionBlock(
1457
- #ifdef AMBIENT
1458
- ambientOcclusionColorMap_: vec3f,
1459
- vAmbientInfos: vec4f
1460
- #endif
1461
- )->ambientOcclusionOutParams
1462
- {
1463
- var outParams: ambientOcclusionOutParams;var ambientOcclusionColor: vec3f= vec3f(1.,1.,1.);
1464
- #ifdef AMBIENT
1465
- var ambientOcclusionColorMap: vec3f=ambientOcclusionColorMap_*vAmbientInfos.y;
1466
- #ifdef AMBIENTINGRAYSCALE
1467
- ambientOcclusionColorMap= vec3f(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);
1468
- #endif
1469
- ambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);
1470
- #if DEBUGMODE>0
1471
- outParams.ambientOcclusionColorMap=ambientOcclusionColorMap;
1472
- #endif
1473
- #endif
1474
- outParams.ambientOcclusionColor=ambientOcclusionColor;return outParams;}
1475
- `;
1476
- // Sideeffect
1477
- ShaderStore.IncludesShadersStoreWGSL[name$r] = shader$r;
1478
-
1479
- // Do not edit.
1480
- const name$q = "pbrBlockAlphaFresnel";
1481
- const shader$q = `#ifdef ALPHAFRESNEL
1482
- #if defined(ALPHATEST) || defined(ALPHABLEND)
1483
- struct alphaFresnelOutParams
1484
- {alpha: f32};fn faceforward(N: vec3<f32>,I: vec3<f32>,Nref: vec3<f32>)->vec3<f32> {return select(N,-N,dot(Nref,I)>0.0);}
1485
- #define pbr_inline
1486
- fn alphaFresnelBlock(
1487
- normalW: vec3f,
1488
- viewDirectionW: vec3f,
1489
- alpha: f32,
1490
- microSurface: f32
1491
- )->alphaFresnelOutParams
1492
- {var outParams: alphaFresnelOutParams;var opacityPerceptual: f32=alpha;
1493
- #ifdef LINEARALPHAFRESNEL
1494
- var opacity0: f32=opacityPerceptual;
1495
- #else
1496
- var opacity0: f32=opacityPerceptual*opacityPerceptual;
1497
- #endif
1498
- var opacity90: f32=fresnelGrazingReflectance(opacity0);var normalForward: vec3f=faceforward(normalW,-viewDirectionW,normalW);outParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)), vec3f(opacity0), vec3f(opacity90),sqrt(microSurface)).x;
1499
- #ifdef ALPHATEST
1500
- if (outParams.alpha<ALPHATESTVALUE) {discard;}
1501
- #ifndef ALPHABLEND
1502
- outParams.alpha=1.0;
1503
- #endif
1504
- #endif
1505
- return outParams;}
1506
- #endif
1507
- #endif
1508
- `;
1509
- // Sideeffect
1510
- ShaderStore.IncludesShadersStoreWGSL[name$q] = shader$q;
1511
-
1512
- // Do not edit.
1513
- const name$p = "pbrBlockAnisotropic";
1514
- const shader$p = `#ifdef ANISOTROPIC
1515
- struct anisotropicOutParams
1516
- {anisotropy: f32,
1517
- anisotropicTangent: vec3f,
1518
- anisotropicBitangent: vec3f,
1519
- anisotropicNormal: vec3f,
1520
- #if DEBUGMODE>0 && defined(ANISOTROPIC_TEXTURE)
1521
- anisotropyMapData: vec3f
1522
- #endif
1523
- };
1524
- #define pbr_inline
1525
- fn anisotropicBlock(
1526
- vAnisotropy: vec3f,
1527
- roughness: f32,
1528
- #ifdef ANISOTROPIC_TEXTURE
1529
- anisotropyMapData: vec3f,
1530
- #endif
1531
- TBN: mat3x3f,
1532
- normalW: vec3f,
1533
- viewDirectionW: vec3f
1534
- )->anisotropicOutParams
1535
- {
1536
- var outParams: anisotropicOutParams;var anisotropy: f32=vAnisotropy.b;var anisotropyDirection: vec3f= vec3f(vAnisotropy.xy,0.);
1537
- #ifdef ANISOTROPIC_TEXTURE
1538
- var amd=anisotropyMapData.rg;anisotropy*=anisotropyMapData.b;
1539
- #if DEBUGMODE>0
1540
- outParams.anisotropyMapData=anisotropyMapData;
1541
- #endif
1542
- amd=amd*2.0-1.0;
1543
- #ifdef ANISOTROPIC_LEGACY
1544
- anisotropyDirection=vec3f(anisotropyDirection.xy*amd,anisotropyDirection.z);
1545
- #else
1546
- anisotropyDirection=vec3f(mat2x2f(anisotropyDirection.x,anisotropyDirection.y,-anisotropyDirection.y,anisotropyDirection.x)*normalize(amd),anisotropyDirection.z);
1547
- #endif
1548
- #endif
1549
- var anisoTBN: mat3x3f= mat3x3f(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));var anisotropicTangent: vec3f=normalize(anisoTBN*anisotropyDirection);var anisotropicBitangent: vec3f=normalize(cross(anisoTBN[2],anisotropicTangent));outParams.anisotropy=anisotropy;outParams.anisotropicTangent=anisotropicTangent;outParams.anisotropicBitangent=anisotropicBitangent;outParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy,roughness);return outParams;}
1550
- #endif
1551
- `;
1552
- // Sideeffect
1553
- ShaderStore.IncludesShadersStoreWGSL[name$p] = shader$p;
1554
-
1555
- // Do not edit.
1556
- const name$o = "pbrBlockReflection";
1557
- const shader$o = `#ifdef REFLECTION
1558
- struct reflectionOutParams
1559
- {environmentRadiance: vec4f
1560
- ,environmentIrradiance: vec3f
1561
- #ifdef REFLECTIONMAP_3D
1562
- ,reflectionCoords: vec3f
1563
- #else
1564
- ,reflectionCoords: vec2f
1565
- #endif
1566
- #ifdef SS_TRANSLUCENCY
1567
- #ifdef USESPHERICALFROMREFLECTIONMAP
1568
- #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
1569
- ,irradianceVector: vec3f
1570
- #endif
1571
- #endif
1572
- #endif
1573
- };
1574
- #define pbr_inline
1575
- #ifdef REFLECTIONMAP_3D
1576
- fn createReflectionCoords(
1577
- vPositionW: vec3f,
1578
- normalW: vec3f,
1579
- #ifdef ANISOTROPIC
1580
- anisotropicOut: anisotropicOutParams,
1581
- #endif
1582
- )->vec3f
1583
- {var reflectionCoords: vec3f;
1584
- #else
1585
- fn createReflectionCoords(
1586
- vPositionW: vec3f,
1587
- normalW: vec3f,
1588
- #ifdef ANISOTROPIC
1589
- anisotropicOut: anisotropicOutParams,
1590
- #endif
1591
- )->vec2f
1592
- {
1593
- var reflectionCoords: vec2f;
1594
- #endif
1595
- #ifdef ANISOTROPIC
1596
- var reflectionVector: vec3f=computeReflectionCoords( vec4f(vPositionW,1.0),anisotropicOut.anisotropicNormal);
1597
- #else
1598
- var reflectionVector: vec3f=computeReflectionCoords( vec4f(vPositionW,1.0),normalW);
1599
- #endif
1600
- #ifdef REFLECTIONMAP_OPPOSITEZ
1601
- reflectionVector.z*=-1.0;
1602
- #endif
1603
- #ifdef REFLECTIONMAP_3D
1604
- reflectionCoords=reflectionVector;
1605
- #else
1606
- reflectionCoords=reflectionVector.xy;
1607
- #ifdef REFLECTIONMAP_PROJECTION
1608
- reflectionCoords/=reflectionVector.z;
1609
- #endif
1610
- reflectionCoords.y=1.0-reflectionCoords.y;
1611
- #endif
1612
- return reflectionCoords;}
1613
- #define pbr_inline
1614
- fn sampleReflectionTexture(
1615
- alphaG: f32
1616
- ,vReflectionMicrosurfaceInfos: vec3f
1617
- ,vReflectionInfos: vec2f
1618
- ,vReflectionColor: vec3f
1619
- #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
1620
- ,NdotVUnclamped: f32
1621
- #endif
1622
- #ifdef LINEARSPECULARREFLECTION
1623
- ,roughness: f32
1624
- #endif
1625
- #ifdef REFLECTIONMAP_3D
1626
- ,reflectionSampler: texture_cube<f32>
1627
- ,reflectionSamplerSampler: sampler
1628
- ,reflectionCoords: vec3f
1629
- #else
1630
- ,reflectionSampler: texture_2d<f32>
1631
- ,reflectionSamplerSampler: sampler
1632
- ,reflectionCoords: vec2f
1633
- #endif
1634
- #ifndef LODBASEDMICROSFURACE
1635
- #ifdef REFLECTIONMAP_3D
1636
- ,reflectionLowSampler: texture_cube<f32>
1637
- ,reflectionLowSamplerSampler: sampler
1638
- ,reflectionHighSampler: texture_cube<f32>
1639
- ,reflectionHighSamplerSampler: sampler
1640
- #else
1641
- ,reflectionLowSampler: texture_2d<f32>
1642
- ,reflectionLowSamplerSampler: sampler
1643
- ,reflectionHighSampler: texture_2d<f32>
1644
- ,reflectionHighSamplerSampler: sampler
1645
- #endif
1646
- #endif
1647
- #ifdef REALTIME_FILTERING
1648
- ,vReflectionFilteringInfo: vec2f
1649
- #endif
1650
- )->vec4f
1651
- {var environmentRadiance: vec4f;
1652
- #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
1653
- var reflectionLOD: f32=getLodFromAlphaGNdotV(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);
1654
- #elif defined(LINEARSPECULARREFLECTION)
1655
- var reflectionLOD: f32=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);
1656
- #else
1657
- var reflectionLOD: f32=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);
1658
- #endif
1659
- #ifdef LODBASEDMICROSFURACE
1660
- reflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;
1661
- #ifdef LODINREFLECTIONALPHA
1662
- var automaticReflectionLOD: f32=UNPACK_LOD(textureSample(reflectionSampler,reflectionSamplerSampler,reflectionCoords).a);var requestedReflectionLOD: f32=max(automaticReflectionLOD,reflectionLOD);
1663
- #else
1664
- var requestedReflectionLOD: f32=reflectionLOD;
1665
- #endif
1666
- #ifdef REALTIME_FILTERING
1667
- environmentRadiance= vec4f(radiance(alphaG,reflectionSampler,reflectionSamplerSampler,reflectionCoords,vReflectionFilteringInfo),1.0);
1668
- #else
1669
- environmentRadiance=textureSampleLevel(reflectionSampler,reflectionSamplerSampler,reflectionCoords,reflectionLOD);
1670
- #endif
1671
- #else
1672
- var lodReflectionNormalized: f32=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));var lodReflectionNormalizedDoubled: f32=lodReflectionNormalized*2.0;var environmentMid: vec4f=textureSample(reflectionSampler,reflectionSamplerSampler,reflectionCoords);if (lodReflectionNormalizedDoubled<1.0){environmentRadiance=mix(
1673
- textureSample(reflectionHighSampler,reflectionHighSamplerSampler,reflectionCoords),
1674
- environmentMid,
1675
- lodReflectionNormalizedDoubled
1676
- );} else {environmentRadiance=mix(
1677
- environmentMid,
1678
- textureSample(reflectionLowSampler,reflectionLowSamplerSampler,reflectionCoords),
1679
- lodReflectionNormalizedDoubled-1.0
1680
- );}
1681
- #endif
1682
- var envRadiance=environmentRadiance.rgb;
1683
- #ifdef RGBDREFLECTION
1684
- envRadiance=fromRGBD(environmentRadiance);
1685
- #endif
1686
- #ifdef GAMMAREFLECTION
1687
- envRadiance=toLinearSpaceVec3(environmentRadiance.rgb);
1688
- #endif
1689
- envRadiance*=vReflectionInfos.x;envRadiance*=vReflectionColor.rgb;return vec4f(envRadiance,environmentRadiance.a);}
1690
- #define pbr_inline
1691
- fn reflectionBlock(
1692
- vPositionW: vec3f
1693
- ,normalW: vec3f
1694
- ,alphaG: f32
1695
- ,vReflectionMicrosurfaceInfos: vec3f
1696
- ,vReflectionInfos: vec2f
1697
- ,vReflectionColor: vec3f
1698
- #ifdef ANISOTROPIC
1699
- ,anisotropicOut: anisotropicOutParams
1700
- #endif
1701
- #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
1702
- ,NdotVUnclamped: f32
1703
- #endif
1704
- #ifdef LINEARSPECULARREFLECTION
1705
- ,roughness: f32
1706
- #endif
1707
- #ifdef REFLECTIONMAP_3D
1708
- ,reflectionSampler: texture_cube<f32>
1709
- ,reflectionSamplerSampler: sampler
1710
- #else
1711
- ,reflectionSampler: texture_2d<f32>
1712
- ,reflectionSamplerSampler: sampler
1713
- #endif
1714
- #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
1715
- ,vEnvironmentIrradiance: vec3f
1716
- #endif
1717
- #ifdef USESPHERICALFROMREFLECTIONMAP
1718
- #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
1719
- ,reflectionMatrix: mat4x4f
1720
- #endif
1721
- #endif
1722
- #ifdef USEIRRADIANCEMAP
1723
- #ifdef REFLECTIONMAP_3D
1724
- ,irradianceSampler: texture_cube<f32>
1725
- ,irradianceSamplerSampler: sampler
1726
- #else
1727
- ,irradianceSampler: texture_2d<f32>
1728
- ,irradianceSamplerSampler: sampler
1729
- #endif
1730
- #endif
1731
- #ifndef LODBASEDMICROSFURACE
1732
- #ifdef REFLECTIONMAP_3D
1733
- ,reflectionLowSampler: texture_cube<f32>
1734
- ,reflectionLowSamplerSampler: sampler
1735
- ,reflectionHighSampler: texture_cube<f32>
1736
- ,reflectionHighSamplerSampler: sampler
1737
- #else
1738
- ,reflectionLowSampler: texture_2d<f32>
1739
- ,reflectionLowSamplerSampler: sampler
1740
- ,reflectionHighSampler: texture_2d<f32>
1741
- ,reflectionHighSamplerSampler: sampler
1742
- #endif
1743
- #endif
1744
- #ifdef REALTIME_FILTERING
1745
- ,vReflectionFilteringInfo: vec2f
1746
- #endif
1747
- )->reflectionOutParams
1748
- {var outParams: reflectionOutParams;var environmentRadiance: vec4f= vec4f(0.,0.,0.,0.);
1749
- #ifdef REFLECTIONMAP_3D
1750
- var reflectionCoords: vec3f= vec3f(0.);
1751
- #else
1752
- var reflectionCoords: vec2f= vec2f(0.);
1753
- #endif
1754
- reflectionCoords=createReflectionCoords(
1755
- vPositionW,
1756
- normalW,
1757
- #ifdef ANISOTROPIC
1758
- anisotropicOut,
1759
- #endif
1760
- );environmentRadiance=sampleReflectionTexture(
1761
- alphaG
1762
- ,vReflectionMicrosurfaceInfos
1763
- ,vReflectionInfos
1764
- ,vReflectionColor
1765
- #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
1766
- ,NdotVUnclamped
1767
- #endif
1768
- #ifdef LINEARSPECULARREFLECTION
1769
- ,roughness
1770
- #endif
1771
- #ifdef REFLECTIONMAP_3D
1772
- ,reflectionSampler
1773
- ,reflectionSamplerSampler
1774
- ,reflectionCoords
1775
- #else
1776
- ,reflectionSampler
1777
- ,reflectionSamplerSampler
1778
- ,reflectionCoords
1779
- #endif
1780
- #ifndef LODBASEDMICROSFURACE
1781
- ,reflectionLowSampler
1782
- ,reflectionLowSamplerSampler
1783
- ,reflectionHighSampler
1784
- ,reflectionHighSamplerSampler
1785
- #endif
1786
- #ifdef REALTIME_FILTERING
1787
- ,vReflectionFilteringInfo
1788
- #endif
1789
- );var environmentIrradiance: vec3f= vec3f(0.,0.,0.);
1790
- #ifdef USESPHERICALFROMREFLECTIONMAP
1791
- #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
1792
- environmentIrradiance=vEnvironmentIrradiance;
1793
- #else
1794
- #ifdef ANISOTROPIC
1795
- var irradianceVector: vec3f= (reflectionMatrix* vec4f(anisotropicOut.anisotropicNormal,0)).xyz;
1796
- #else
1797
- var irradianceVector: vec3f= (reflectionMatrix* vec4f(normalW,0)).xyz;
1798
- #endif
1799
- #ifdef REFLECTIONMAP_OPPOSITEZ
1800
- irradianceVector.z*=-1.0;
1801
- #endif
1802
- #ifdef INVERTCUBICMAP
1803
- irradianceVector.y*=-1.0;
1804
- #endif
1805
- #if defined(REALTIME_FILTERING)
1806
- environmentIrradiance=irradiance(reflectionSampler,reflectionSamplerSampler,irradianceVector,vReflectionFilteringInfo);
1807
- #else
1808
- environmentIrradiance=computeEnvironmentIrradiance(irradianceVector);
1809
- #endif
1810
- #ifdef SS_TRANSLUCENCY
1811
- outParams.irradianceVector=irradianceVector;
1812
- #endif
1813
- #endif
1814
- #elif defined(USEIRRADIANCEMAP)
1815
- var environmentIrradiance4: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,reflectionCoords);environmentIrradiance=environmentIrradiance4.rgb;
1816
- #ifdef RGBDREFLECTION
1817
- environmentIrradiance=fromRGBD(environmentIrradiance4);
1818
- #endif
1819
- #ifdef GAMMAREFLECTION
1820
- environmentIrradiance=toLinearSpaceVec3(environmentIrradiance.rgb);
1821
- #endif
1822
- #endif
1823
- environmentIrradiance*=vReflectionColor.rgb;outParams.environmentRadiance=environmentRadiance;outParams.environmentIrradiance=environmentIrradiance;outParams.reflectionCoords=reflectionCoords;return outParams;}
1824
- #endif
1825
- `;
1826
- // Sideeffect
1827
- ShaderStore.IncludesShadersStoreWGSL[name$o] = shader$o;
1828
-
1829
- // Do not edit.
1830
- const name$n = "pbrBlockSheen";
1831
- const shader$n = `#ifdef SHEEN
1832
- struct sheenOutParams
1833
- {sheenIntensity: f32
1834
- ,sheenColor: vec3f
1835
- ,sheenRoughness: f32
1836
- #ifdef SHEEN_LINKWITHALBEDO
1837
- ,surfaceAlbedo: vec3f
1838
- #endif
1839
- #if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
1840
- ,sheenAlbedoScaling: f32
1841
- #endif
1842
- #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
1843
- ,finalSheenRadianceScaled: vec3f
1844
- #endif
1845
- #if DEBUGMODE>0
1846
- #ifdef SHEEN_TEXTURE
1847
- ,sheenMapData: vec4f
1848
- #endif
1849
- #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
1850
- ,sheenEnvironmentReflectance: vec3f
1851
- #endif
1852
- #endif
1853
- };
1854
- #define pbr_inline
1855
- fn sheenBlock(
1856
- vSheenColor: vec4f
1857
- #ifdef SHEEN_ROUGHNESS
1858
- ,vSheenRoughness: f32
1859
- #if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
1860
- ,sheenMapRoughnessData: vec4f
1861
- #endif
1862
- #endif
1863
- ,roughness: f32
1864
- #ifdef SHEEN_TEXTURE
1865
- ,sheenMapData: vec4f
1866
- ,sheenMapLevel: f32
1867
- #endif
1868
- ,reflectance: f32
1869
- #ifdef SHEEN_LINKWITHALBEDO
1870
- ,baseColor: vec3f
1871
- ,surfaceAlbedo: vec3f
1872
- #endif
1873
- #ifdef ENVIRONMENTBRDF
1874
- ,NdotV: f32
1875
- ,environmentBrdf: vec3f
1876
- #endif
1877
- #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
1878
- ,AARoughnessFactors: vec2f
1879
- ,vReflectionMicrosurfaceInfos: vec3f
1880
- ,vReflectionInfos: vec2f
1881
- ,vReflectionColor: vec3f
1882
- ,vLightingIntensity: vec4f
1883
- #ifdef REFLECTIONMAP_3D
1884
- ,reflectionSampler: texture_cube<f32>
1885
- ,reflectionSamplerSampler: sampler
1886
- ,reflectionCoords: vec3f
1887
- #else
1888
- ,reflectionSampler: texture_2d<f32>
1889
- ,reflectionSamplerSampler: sampler
1890
- ,reflectionCoords: vec2f
1891
- #endif
1892
- ,NdotVUnclamped: f32
1893
- #ifndef LODBASEDMICROSFURACE
1894
- #ifdef REFLECTIONMAP_3D
1895
- ,reflectionLowSampler: texture_cube<f32>
1896
- ,reflectionLowSamplerSampler: sampler
1897
- ,reflectionHighSampler: texture_cube<f32>
1898
- ,reflectionHighSamplerSampler: sampler
1899
- #else
1900
- ,reflectionLowSampler: texture_2d<f32>
1901
- ,reflectionLowSamplerSampler: sampler
1902
- ,reflectionHighSampler: texture_2d<f32>
1903
- ,reflectionHighSamplerSampler: sampler
1904
- #endif
1905
- #endif
1906
- #ifdef REALTIME_FILTERING
1907
- ,vReflectionFilteringInfo: vec2f
1908
- #endif
1909
- #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
1910
- ,seo: f32
1911
- #endif
1912
- #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
1913
- ,eho: f32
1914
- #endif
1915
- #endif
1916
- )->sheenOutParams
1917
- {var outParams: sheenOutParams;var sheenIntensity: f32=vSheenColor.a;
1918
- #ifdef SHEEN_TEXTURE
1919
- #if DEBUGMODE>0
1920
- outParams.sheenMapData=sheenMapData;
1921
- #endif
1922
- #endif
1923
- #ifdef SHEEN_LINKWITHALBEDO
1924
- var sheenFactor: f32=pow5(1.0-sheenIntensity);var sheenColor: vec3f=baseColor.rgb*(1.0-sheenFactor);var sheenRoughness: f32=sheenIntensity;outParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;
1925
- #ifdef SHEEN_TEXTURE
1926
- sheenIntensity*=sheenMapData.a;
1927
- #endif
1928
- #else
1929
- var sheenColor: vec3f=vSheenColor.rgb;
1930
- #ifdef SHEEN_TEXTURE
1931
- #ifdef SHEEN_GAMMATEXTURE
1932
- sheenColor*=toLinearSpaceVec3(sheenMapData.rgb);
1933
- #else
1934
- sheenColor*=sheenMapData.rgb;
1935
- #endif
1936
- sheenColor*=sheenMapLevel;
1937
- #endif
1938
- #ifdef SHEEN_ROUGHNESS
1939
- var sheenRoughness: f32=vSheenRoughness;
1940
- #ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE
1941
- #if defined(SHEEN_TEXTURE)
1942
- sheenRoughness*=sheenMapData.a;
1943
- #endif
1944
- #elif defined(SHEEN_TEXTURE_ROUGHNESS)
1945
- sheenRoughness*=sheenMapRoughnessData.a;
1946
- #endif
1947
- #else
1948
- var sheenRoughness: f32=roughness;
1949
- #ifdef SHEEN_TEXTURE
1950
- sheenIntensity*=sheenMapData.a;
1951
- #endif
1952
- #endif
1953
- #if !defined(SHEEN_ALBEDOSCALING)
1954
- sheenIntensity*=(1.-reflectance);
1955
- #endif
1956
- sheenColor*=sheenIntensity;
1957
- #endif
1958
- #ifdef ENVIRONMENTBRDF
1959
- /*#ifdef SHEEN_SOFTER
1960
- var environmentSheenBrdf: vec3f= vec3f(0.,0.,getBRDFLookupCharlieSheen(NdotV,sheenRoughness));
1961
- #else*/
1962
- #ifdef SHEEN_ROUGHNESS
1963
- var environmentSheenBrdf: vec3f=getBRDFLookup(NdotV,sheenRoughness);
1964
- #else
1965
- var environmentSheenBrdf: vec3f=environmentBrdf;
1966
- #endif
1967
- /*#endif*/
1968
- #endif
1969
- #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
1970
- var sheenAlphaG: f32=convertRoughnessToAverageSlope(sheenRoughness);
1971
- #ifdef SPECULARAA
1972
- sheenAlphaG+=AARoughnessFactors.y;
1973
- #endif
1974
- var environmentSheenRadiance: vec4f= vec4f(0.,0.,0.,0.);environmentSheenRadiance=sampleReflectionTexture(
1975
- sheenAlphaG
1976
- ,vReflectionMicrosurfaceInfos
1977
- ,vReflectionInfos
1978
- ,vReflectionColor
1979
- #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
1980
- ,NdotVUnclamped
1981
- #endif
1982
- #ifdef LINEARSPECULARREFLECTION
1983
- ,sheenRoughness
1984
- #endif
1985
- ,reflectionSampler
1986
- ,reflectionSamplerSampler
1987
- ,reflectionCoords
1988
- #ifndef LODBASEDMICROSFURACE
1989
- ,reflectionLowSampler
1990
- ,reflectionLowSamplerSampler
1991
- ,reflectionHighSampler
1992
- ,reflectionHighSamplerSampler
1993
- #endif
1994
- #ifdef REALTIME_FILTERING
1995
- ,vReflectionFilteringInfo
1996
- #endif
1997
- );var sheenEnvironmentReflectance: vec3f=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);
1998
- #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
1999
- sheenEnvironmentReflectance*=seo;
2000
- #endif
2001
- #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
2002
- sheenEnvironmentReflectance*=eho;
2003
- #endif
2004
- #if DEBUGMODE>0
2005
- outParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;
2006
- #endif
2007
- outParams.finalSheenRadianceScaled=
2008
- environmentSheenRadiance.rgb *
2009
- sheenEnvironmentReflectance *
2010
- vLightingIntensity.z;
2011
- #endif
2012
- #if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
2013
- outParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;
2014
- #endif
2015
- outParams.sheenIntensity=sheenIntensity;outParams.sheenColor=sheenColor;outParams.sheenRoughness=sheenRoughness;return outParams;}
2016
- #endif
2017
- `;
2018
- // Sideeffect
2019
- ShaderStore.IncludesShadersStoreWGSL[name$n] = shader$n;
2020
-
2021
- // Do not edit.
2022
- const name$m = "pbrBlockClearcoat";
2023
- const shader$m = `struct clearcoatOutParams
2024
- {specularEnvironmentR0: vec3f,
2025
- conservationFactor: f32,
2026
- clearCoatNormalW: vec3f,
2027
- clearCoatAARoughnessFactors: vec2f,
2028
- clearCoatIntensity: f32,
2029
- clearCoatRoughness: f32,
2030
- #ifdef REFLECTION
2031
- finalClearCoatRadianceScaled: vec3f,
2032
- #endif
2033
- #ifdef CLEARCOAT_TINT
2034
- absorption: vec3f,
2035
- clearCoatNdotVRefract: f32,
2036
- clearCoatColor: vec3f,
2037
- clearCoatThickness: f32,
2038
- #endif
2039
- #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
2040
- energyConservationFactorClearCoat: vec3f,
2041
- #endif
2042
- #if DEBUGMODE>0
2043
- #ifdef CLEARCOAT_BUMP
2044
- TBNClearCoat: mat3x3f,
2045
- #endif
2046
- #ifdef CLEARCOAT_TEXTURE
2047
- clearCoatMapData: vec2f,
2048
- #endif
2049
- #if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
2050
- clearCoatTintMapData: vec4f,
2051
- #endif
2052
- #ifdef REFLECTION
2053
- environmentClearCoatRadiance: vec4f,
2054
- clearCoatEnvironmentReflectance: vec3f,
2055
- #endif
2056
- clearCoatNdotV: f32
2057
- #endif
2058
- };
2059
- #ifdef CLEARCOAT
2060
- #define pbr_inline
2061
- fn clearcoatBlock(
2062
- vPositionW: vec3f
2063
- ,geometricNormalW: vec3f
2064
- ,viewDirectionW: vec3f
2065
- ,vClearCoatParams: vec2f
2066
- #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
2067
- ,clearCoatMapRoughnessData: vec4f
2068
- #endif
2069
- ,specularEnvironmentR0: vec3f
2070
- #ifdef CLEARCOAT_TEXTURE
2071
- ,clearCoatMapData: vec2f
2072
- #endif
2073
- #ifdef CLEARCOAT_TINT
2074
- ,vClearCoatTintParams: vec4f
2075
- ,clearCoatColorAtDistance: f32
2076
- ,vClearCoatRefractionParams: vec4f
2077
- #ifdef CLEARCOAT_TINT_TEXTURE
2078
- ,clearCoatTintMapData: vec4f
2079
- #endif
2080
- #endif
2081
- #ifdef CLEARCOAT_BUMP
2082
- ,vClearCoatBumpInfos: vec2f
2083
- ,clearCoatBumpMapData: vec4f
2084
- ,vClearCoatBumpUV: vec2f
2085
- #if defined(TANGENT) && defined(NORMAL)
2086
- ,vTBN: mat3x3f
2087
- #else
2088
- ,vClearCoatTangentSpaceParams: vec2f
2089
- #endif
2090
- #ifdef OBJECTSPACE_NORMALMAP
2091
- ,normalMatrix: mat4x4f
2092
- #endif
2093
- #endif
2094
- #if defined(FORCENORMALFORWARD) && defined(NORMAL)
2095
- ,faceNormal: vec3f
2096
- #endif
2097
- #ifdef REFLECTION
2098
- ,vReflectionMicrosurfaceInfos: vec3f
2099
- ,vReflectionInfos: vec2f
2100
- ,vReflectionColor: vec3f
2101
- ,vLightingIntensity: vec4f
2102
- #ifdef REFLECTIONMAP_3D
2103
- ,reflectionSampler: texture_cube<f32>
2104
- ,reflectionSamplerSampler: sampler
2105
- #else
2106
- ,reflectionSampler: texture_2d<f32>
2107
- ,reflectionSamplerSampler: sampler
2108
- #endif
2109
- #ifndef LODBASEDMICROSFURACE
2110
- #ifdef REFLECTIONMAP_3D
2111
- ,reflectionLowSampler: texture_cube<f32>
2112
- ,reflectionLowSamplerSampler: sampler
2113
- ,reflectionHighSampler: texture_cube<f32>
2114
- ,reflectionHighSamplerSampler: sampler
2115
- #else
2116
- ,reflectionLowSampler: texture_2d<f32>
2117
- ,reflectionLowSamplerSampler: sampler
2118
- ,reflectionHighSampler: texture_2d<f32>
2119
- ,reflectionHighSamplerSampler: sampler
2120
- #endif
2121
- #endif
2122
- #ifdef REALTIME_FILTERING
2123
- ,vReflectionFilteringInfo: vec2f
2124
- #endif
2125
- #endif
2126
- #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
2127
- #ifdef RADIANCEOCCLUSION
2128
- ,ambientMonochrome: f32
2129
- #endif
2130
- #endif
2131
- #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
2132
- ,frontFacingMultiplier: f32
2133
- #endif
2134
- )->clearcoatOutParams
2135
- {var outParams: clearcoatOutParams;var clearCoatIntensity: f32=vClearCoatParams.x;var clearCoatRoughness: f32=vClearCoatParams.y;
2136
- #ifdef CLEARCOAT_TEXTURE
2137
- clearCoatIntensity*=clearCoatMapData.x;
2138
- #ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE
2139
- clearCoatRoughness*=clearCoatMapData.y;
2140
- #endif
2141
- #if DEBUGMODE>0
2142
- outParams.clearCoatMapData=clearCoatMapData;
2143
- #endif
2144
- #endif
2145
- #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
2146
- clearCoatRoughness*=clearCoatMapRoughnessData.y;
2147
- #endif
2148
- outParams.clearCoatIntensity=clearCoatIntensity;outParams.clearCoatRoughness=clearCoatRoughness;
2149
- #ifdef CLEARCOAT_TINT
2150
- var clearCoatColor: vec3f=vClearCoatTintParams.rgb;var clearCoatThickness: f32=vClearCoatTintParams.a;
2151
- #ifdef CLEARCOAT_TINT_TEXTURE
2152
- #ifdef CLEARCOAT_TINT_GAMMATEXTURE
2153
- clearCoatColor*=toLinearSpaceVec3(clearCoatTintMapData.rgb);
2154
- #else
2155
- clearCoatColor*=clearCoatTintMapData.rgb;
2156
- #endif
2157
- clearCoatThickness*=clearCoatTintMapData.a;
2158
- #if DEBUGMODE>0
2159
- outParams.clearCoatTintMapData=clearCoatTintMapData;
2160
- #endif
2161
- #endif
2162
- outParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);outParams.clearCoatThickness=clearCoatThickness;
2163
- #endif
2164
- #ifdef CLEARCOAT_REMAP_F0
2165
- var specularEnvironmentR0Updated: vec3f=getR0RemappedForClearCoat(specularEnvironmentR0);
2166
- #else
2167
- var specularEnvironmentR0Updated: vec3f=specularEnvironmentR0;
2168
- #endif
2169
- outParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);var clearCoatNormalW: vec3f=geometricNormalW;
2170
- #ifdef CLEARCOAT_BUMP
2171
- #ifdef NORMALXYSCALE
2172
- var clearCoatNormalScale: f32=1.0;
2173
- #else
2174
- var clearCoatNormalScale: f32=vClearCoatBumpInfos.y;
2175
- #endif
2176
- #if defined(TANGENT) && defined(NORMAL)
2177
- var TBNClearCoat: mat3x3f=vTBN;
2178
- #else
2179
- var TBNClearCoatUV: vec2f=vClearCoatBumpUV*frontFacingMultiplier;var TBNClearCoat: mat3x3f=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,TBNClearCoatUV,vClearCoatTangentSpaceParams);
2180
- #endif
2181
- #if DEBUGMODE>0
2182
- outParams.TBNClearCoat=TBNClearCoat;
2183
- #endif
2184
- #ifdef OBJECTSPACE_NORMALMAP
2185
- clearCoatNormalW=normalize(clearCoatBumpMapData.xyz *2.0-1.0);clearCoatNormalW=normalize( mat3x3f(normalMatrix[0].xyz,normalMatrix[1].xyz,normalMatrix[2].xyz)*clearCoatNormalW);
2186
- #else
2187
- clearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);
2188
- #endif
2189
- #endif
2190
- #if defined(FORCENORMALFORWARD) && defined(NORMAL)
2191
- clearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));
2192
- #endif
2193
- #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
2194
- clearCoatNormalW=clearCoatNormalW*frontFacingMultiplier;
2195
- #endif
2196
- outParams.clearCoatNormalW=clearCoatNormalW;outParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);var clearCoatNdotVUnclamped: f32=dot(clearCoatNormalW,viewDirectionW);var clearCoatNdotV: f32=absEps(clearCoatNdotVUnclamped);
2197
- #if DEBUGMODE>0
2198
- outParams.clearCoatNdotV=clearCoatNdotV;
2199
- #endif
2200
- #ifdef CLEARCOAT_TINT
2201
- var clearCoatVRefract: vec3f=refract(-viewDirectionW,clearCoatNormalW,vClearCoatRefractionParams.y);outParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));
2202
- #endif
2203
- #if defined(ENVIRONMENTBRDF) && (!defined(REFLECTIONMAP_SKYBOX) || defined(MS_BRDF_ENERGY_CONSERVATION))
2204
- var environmentClearCoatBrdf: vec3f=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);
2205
- #endif
2206
- #if defined(REFLECTION)
2207
- var clearCoatAlphaG: f32=convertRoughnessToAverageSlope(clearCoatRoughness);
2208
- #ifdef SPECULARAA
2209
- clearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;
2210
- #endif
2211
- var environmentClearCoatRadiance: vec4f= vec4f(0.,0.,0.,0.);var clearCoatReflectionVector: vec3f=computeReflectionCoords( vec4f(vPositionW,1.0),clearCoatNormalW);
2212
- #ifdef REFLECTIONMAP_OPPOSITEZ
2213
- clearCoatReflectionVector.z*=-1.0;
2214
- #endif
2215
- #ifdef REFLECTIONMAP_3D
2216
- var clearCoatReflectionCoords: vec3f=clearCoatReflectionVector;
2217
- #else
2218
- var clearCoatReflectionCoords: vec2f=clearCoatReflectionVector.xy;
2219
- #ifdef REFLECTIONMAP_PROJECTION
2220
- clearCoatReflectionCoords/=clearCoatReflectionVector.z;
2221
- #endif
2222
- clearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;
2223
- #endif
2224
- environmentClearCoatRadiance=sampleReflectionTexture(
2225
- clearCoatAlphaG
2226
- ,vReflectionMicrosurfaceInfos
2227
- ,vReflectionInfos
2228
- ,vReflectionColor
2229
- #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
2230
- ,clearCoatNdotVUnclamped
2231
- #endif
2232
- #ifdef LINEARSPECULARREFLECTION
2233
- ,clearCoatRoughness
2234
- #endif
2235
- ,reflectionSampler
2236
- ,reflectionSamplerSampler
2237
- ,clearCoatReflectionCoords
2238
- #ifndef LODBASEDMICROSFURACE
2239
- ,reflectionLowSampler
2240
- ,reflectionLowSamplerSampler
2241
- ,reflectionHighSampler
2242
- ,reflectionHighSamplerSampler
2243
- #endif
2244
- #ifdef REALTIME_FILTERING
2245
- ,vReflectionFilteringInfo
2246
- #endif
2247
- );
2248
- #if DEBUGMODE>0
2249
- outParams.environmentClearCoatRadiance=environmentClearCoatRadiance;
2250
- #endif
2251
- #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
2252
- var clearCoatEnvironmentReflectance: vec3f=getReflectanceFromBRDFLookup(vec3f(uniforms.vClearCoatRefractionParams.x),environmentClearCoatBrdf);
2253
- #ifdef HORIZONOCCLUSION
2254
- #ifdef BUMP
2255
- #ifdef REFLECTIONMAP_3D
2256
- var clearCoatEho: f32=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);clearCoatEnvironmentReflectance*=clearCoatEho;
2257
- #endif
2258
- #endif
2259
- #endif
2260
- #else
2261
- var clearCoatEnvironmentReflectance: vec3f=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV, vec3f(1.), vec3f(1.),sqrt(1.-clearCoatRoughness));
2262
- #endif
2263
- clearCoatEnvironmentReflectance*=clearCoatIntensity;
2264
- #if DEBUGMODE>0
2265
- outParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;
2266
- #endif
2267
- outParams.finalClearCoatRadianceScaled=
2268
- environmentClearCoatRadiance.rgb *
2269
- clearCoatEnvironmentReflectance *
2270
- vLightingIntensity.z;
2271
- #endif
2272
- #if defined(CLEARCOAT_TINT)
2273
- outParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);
2274
- #endif
2275
- var fresnelIBLClearCoat: f32=fresnelSchlickGGX(clearCoatNdotV,uniforms.vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);fresnelIBLClearCoat*=clearCoatIntensity;outParams.conservationFactor=(1.-fresnelIBLClearCoat);
2276
- #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
2277
- outParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);
2278
- #endif
2279
- return outParams;}
2280
- #endif
2281
- `;
2282
- // Sideeffect
2283
- ShaderStore.IncludesShadersStoreWGSL[name$m] = shader$m;
2284
-
2285
- // Do not edit.
2286
- const name$l = "pbrBlockIridescence";
2287
- const shader$l = `struct iridescenceOutParams
2288
- {iridescenceIntensity: f32,
2289
- iridescenceIOR: f32,
2290
- iridescenceThickness: f32,
2291
- specularEnvironmentR0: vec3f};
2292
- #ifdef IRIDESCENCE
2293
- fn iridescenceBlock(
2294
- vIridescenceParams: vec4f
2295
- ,viewAngle: f32
2296
- ,specularEnvironmentR0: vec3f
2297
- #ifdef IRIDESCENCE_TEXTURE
2298
- ,iridescenceMapData: vec2f
2299
- #endif
2300
- #ifdef IRIDESCENCE_THICKNESS_TEXTURE
2301
- ,iridescenceThicknessMapData: vec2f
2302
- #endif
2303
- #ifdef CLEARCOAT
2304
- ,NdotVUnclamped: f32
2305
- #ifdef CLEARCOAT_TEXTURE
2306
- ,clearCoatMapData: vec2f
2307
- #endif
2308
- #endif
2309
- )->iridescenceOutParams
2310
- {var outParams: iridescenceOutParams;var iridescenceIntensity: f32=vIridescenceParams.x;var iridescenceIOR: f32=vIridescenceParams.y;var iridescenceThicknessMin: f32=vIridescenceParams.z;var iridescenceThicknessMax: f32=vIridescenceParams.w;var iridescenceThicknessWeight: f32=1.;
2311
- #ifdef IRIDESCENCE_TEXTURE
2312
- iridescenceIntensity*=iridescenceMapData.x;
2313
- #endif
2314
- #if defined(IRIDESCENCE_THICKNESS_TEXTURE)
2315
- iridescenceThicknessWeight=iridescenceThicknessMapData.g;
2316
- #endif
2317
- var iridescenceThickness: f32=mix(iridescenceThicknessMin,iridescenceThicknessMax,iridescenceThicknessWeight);var topIor: f32=1.;
2318
- #ifdef CLEARCOAT
2319
- var clearCoatIntensity: f32=vClearCoatParams.x;
2320
- #ifdef CLEARCOAT_TEXTURE
2321
- clearCoatIntensity*=clearCoatMapData.x;
2322
- #endif
2323
- topIor=mix(1.0,uniforms.vClearCoatRefractionParams.w-1.,clearCoatIntensity);viewAngle=sqrt(1.0+((1.0/topIor)*(1.0/topIor))*((NdotVUnclamped*NdotVUnclamped)-1.0));
2324
- #endif
2325
- var iridescenceFresnel: vec3f=evalIridescence(topIor,iridescenceIOR,viewAngle,iridescenceThickness,specularEnvironmentR0);outParams.specularEnvironmentR0=mix(specularEnvironmentR0,iridescenceFresnel,iridescenceIntensity);outParams.iridescenceIntensity=iridescenceIntensity;outParams.iridescenceThickness=iridescenceThickness;outParams.iridescenceIOR=iridescenceIOR;return outParams;}
2326
- #endif
2327
- `;
2328
- // Sideeffect
2329
- ShaderStore.IncludesShadersStoreWGSL[name$l] = shader$l;
2330
-
2331
- // Do not edit.
2332
- const name$k = "pbrBlockSubSurface";
2333
- const shader$k = `struct subSurfaceOutParams
2334
- {specularEnvironmentReflectance: vec3f,
2335
- #ifdef SS_REFRACTION
2336
- finalRefraction: vec3f,
2337
- surfaceAlbedo: vec3f,
2338
- #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
2339
- alpha: f32,
2340
- #endif
2341
- #ifdef REFLECTION
2342
- refractionFactorForIrradiance: f32,
2343
- #endif
2344
- #endif
2345
- #ifdef SS_TRANSLUCENCY
2346
- transmittance: vec3f,
2347
- translucencyIntensity: f32,
2348
- #ifdef REFLECTION
2349
- refractionIrradiance: vec3f,
2350
- #endif
2351
- #endif
2352
- #if DEBUGMODE>0
2353
- #ifdef SS_THICKNESSANDMASK_TEXTURE
2354
- thicknessMap: vec4f,
2355
- #endif
2356
- #ifdef SS_REFRACTION
2357
- environmentRefraction: vec4f,
2358
- refractionTransmittance: vec3f
2359
- #endif
2360
- #endif
2361
- };
2362
- #ifdef SUBSURFACE
2363
- #ifdef SS_REFRACTION
2364
- #define pbr_inline
2365
- fn sampleEnvironmentRefraction(
2366
- ior: f32
2367
- ,thickness: f32
2368
- ,refractionLOD: f32
2369
- ,normalW: vec3f
2370
- ,vPositionW: vec3f
2371
- ,viewDirectionW: vec3f
2372
- ,view: mat4x4f
2373
- ,vRefractionInfos: vec4f
2374
- ,refractionMatrix: mat4x4f
2375
- ,vRefractionMicrosurfaceInfos: vec4f
2376
- ,alphaG: f32
2377
- #ifdef SS_REFRACTIONMAP_3D
2378
- ,refractionSampler: texture_cube<f32>
2379
- ,refractionSamplerSampler: sampler
2380
- #ifndef LODBASEDMICROSFURACE
2381
- ,refractionLowSampler: texture_cube<f32>
2382
- ,refractionLowSamplerSampler: sampler
2383
- ,refractionHighSampler: texture_cube<f32>
2384
- ,refractionHighSamplerSampler: sampler
2385
- #endif
2386
- #else
2387
- ,refractionSampler: texture_2d<f32>
2388
- ,refractionSamplerSampler: sampler
2389
- #ifndef LODBASEDMICROSFURACE
2390
- ,refractionLowSampler: texture_2d<f32>
2391
- ,refractionLowSamplerSampler: sampler
2392
- ,refractionHighSampler: texture_2d<f32>
2393
- ,refractionHighSamplerSampler: sampler
2394
- #endif
2395
- #endif
2396
- #ifdef ANISOTROPIC
2397
- ,anisotropicOut: anisotropicOutParams
2398
- #endif
2399
- #ifdef REALTIME_FILTERING
2400
- ,vRefractionFilteringInfo: vec2f
2401
- #endif
2402
- #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
2403
- ,refractionPosition: vec3f
2404
- ,refractionSize: vec3f
2405
- #endif
2406
- )->vec4f {var environmentRefraction: vec4f= vec4f(0.,0.,0.,0.);
2407
- #ifdef ANISOTROPIC
2408
- var refractionVector: vec3f=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,ior);
2409
- #else
2410
- var refractionVector: vec3f=refract(-viewDirectionW,normalW,ior);
2411
- #endif
2412
- #ifdef SS_REFRACTIONMAP_OPPOSITEZ
2413
- refractionVector.z*=-1.0;
2414
- #endif
2415
- #ifdef SS_REFRACTIONMAP_3D
2416
- #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
2417
- refractionVector=parallaxCorrectNormal(vPositionW,refractionVector,refractionSize,refractionPosition);
2418
- #endif
2419
- refractionVector.y=refractionVector.y*vRefractionInfos.w;var refractionCoords: vec3f=refractionVector;refractionCoords= (refractionMatrix* vec4f(refractionCoords,0)).xyz;
2420
- #else
2421
- #ifdef SS_USE_THICKNESS_AS_DEPTH
2422
- var vRefractionUVW: vec3f= (refractionMatrix*(view* vec4f(vPositionW+refractionVector*thickness,1.0))).xyz;
2423
- #else
2424
- var vRefractionUVW: vec3f= (refractionMatrix*(view* vec4f(vPositionW+refractionVector*vRefractionInfos.z,1.0))).xyz;
2425
- #endif
2426
- var refractionCoords: vec2f=vRefractionUVW.xy/vRefractionUVW.z;refractionCoords.y=1.0-refractionCoords.y;
2427
- #endif
2428
- #ifdef LODBASEDMICROSFURACE
2429
- var lod=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;
2430
- #ifdef SS_LODINREFRACTIONALPHA
2431
- var automaticRefractionLOD: f32=UNPACK_LOD(textureSample(refractionSampler,refractionSamplerSampler,refractionCoords).a);var requestedRefractionLOD: f32=max(automaticRefractionLOD,lod);
2432
- #else
2433
- var requestedRefractionLOD: f32=lod;
2434
- #endif
2435
- #if defined(REALTIME_FILTERING) && defined(SS_REFRACTIONMAP_3D)
2436
- environmentRefraction= vec4f(radiance(alphaG,refractionSampler,refractionSamplerSampler,refractionCoords,vRefractionFilteringInfo),1.0);
2437
- #else
2438
- environmentRefraction=textureSampleLevel(refractionSampler,refractionSamplerSampler,refractionCoords,requestedRefractionLOD);
2439
- #endif
2440
- #else
2441
- var lodRefractionNormalized: f32=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));var lodRefractionNormalizedDoubled: f32=lodRefractionNormalized*2.0;var environmentRefractionMid: vec4f=textureSample(refractionSampler,refractionSamplerSampler,refractionCoords);if (lodRefractionNormalizedDoubled<1.0){environmentRefraction=mix(
2442
- textureSample(refractionHighSampler,refractionHighSamplerSampler,refractionCoords),
2443
- environmentRefractionMid,
2444
- lodRefractionNormalizedDoubled
2445
- );} else {environmentRefraction=mix(
2446
- environmentRefractionMid,
2447
- textureSample(refractionLowSampler,refractionLowSamplerSampler,refractionCoords),
2448
- lodRefractionNormalizedDoubled-1.0
2449
- );}
2450
- #endif
2451
- var refraction=environmentRefraction.rgb;
2452
- #ifdef SS_RGBDREFRACTION
2453
- refraction=fromRGBD(environmentRefraction);
2454
- #endif
2455
- #ifdef SS_GAMMAREFRACTION
2456
- refraction=toLinearSpaceVec3(environmentRefraction.rgb);
2457
- #endif
2458
- return vec4f(refraction,environmentRefraction.a);}
2459
- #endif
2460
- #define pbr_inline
2461
- fn subSurfaceBlock(
2462
- vSubSurfaceIntensity: vec3f
2463
- ,vThicknessParam: vec2f
2464
- ,vTintColor: vec4f
2465
- ,normalW: vec3f
2466
- ,specularEnvironmentReflectance: vec3f
2467
- #ifdef SS_THICKNESSANDMASK_TEXTURE
2468
- ,thicknessMap: vec4f
2469
- #endif
2470
- #ifdef SS_REFRACTIONINTENSITY_TEXTURE
2471
- ,refractionIntensityMap: vec4f
2472
- #endif
2473
- #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
2474
- ,translucencyIntensityMap: vec4f
2475
- #endif
2476
- #ifdef REFLECTION
2477
- #ifdef SS_TRANSLUCENCY
2478
- ,reflectionMatrix: mat4x4f
2479
- #ifdef USESPHERICALFROMREFLECTIONMAP
2480
- #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
2481
- ,irradianceVector_: vec3f
2482
- #endif
2483
- #if defined(REALTIME_FILTERING)
2484
- ,reflectionSampler: texture_cube<f32>
2485
- ,reflectionSamplerSampler: sampler
2486
- ,vReflectionFilteringInfo: vec2f
2487
- #endif
2488
- #endif
2489
- #ifdef USEIRRADIANCEMAP
2490
- #ifdef REFLECTIONMAP_3D
2491
- ,irradianceSampler: texture_cube<f32>
2492
- ,irradianceSamplerSampler: sampler
2493
- #else
2494
- ,irradianceSampler: texture_2d<f32>
2495
- ,irradianceSamplerSampler: sampler
2496
- #endif
2497
- #endif
2498
- #endif
2499
- #endif
2500
- #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
2501
- ,surfaceAlbedo: vec3f
2502
- #endif
2503
- #ifdef SS_REFRACTION
2504
- ,vPositionW: vec3f
2505
- ,viewDirectionW: vec3f
2506
- ,view: mat4x4f
2507
- ,vRefractionInfos: vec4f
2508
- ,refractionMatrix: mat4x4f
2509
- ,vRefractionMicrosurfaceInfos: vec4f
2510
- ,vLightingIntensity: vec4f
2511
- #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
2512
- ,alpha: f32
2513
- #endif
2514
- #ifdef SS_LODINREFRACTIONALPHA
2515
- ,NdotVUnclamped: f32
2516
- #endif
2517
- #ifdef SS_LINEARSPECULARREFRACTION
2518
- ,roughness: f32
2519
- #endif
2520
- ,alphaG: f32
2521
- #ifdef SS_REFRACTIONMAP_3D
2522
- ,refractionSampler: texture_cube<f32>
2523
- ,refractionSamplerSampler: sampler
2524
- #ifndef LODBASEDMICROSFURACE
2525
- ,refractionLowSampler: texture_cube<f32>
2526
- ,refractionLowSamplerSampler: sampler
2527
- ,refractionHighSampler: texture_cube<f32>
2528
- ,refractionHighSamplerSampler: sampler
2529
- #endif
2530
- #else
2531
- ,refractionSampler: texture_2d<f32>
2532
- ,refractionSamplerSampler: sampler
2533
- #ifndef LODBASEDMICROSFURACE
2534
- ,refractionLowSampler: texture_2d<f32>
2535
- ,refractionLowSamplerSampler: sampler
2536
- ,refractionHighSampler: texture_2d<f32>
2537
- ,refractionHighSamplerSampler: sampler
2538
- #endif
2539
- #endif
2540
- #ifdef ANISOTROPIC
2541
- ,anisotropicOut: anisotropicOutParams
2542
- #endif
2543
- #ifdef REALTIME_FILTERING
2544
- ,vRefractionFilteringInfo: vec2f
2545
- #endif
2546
- #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
2547
- ,refractionPosition: vec3f
2548
- ,refractionSize: vec3f
2549
- #endif
2550
- #ifdef SS_DISPERSION
2551
- ,dispersion: f32
2552
- #endif
2553
- #endif
2554
- #ifdef SS_TRANSLUCENCY
2555
- ,vDiffusionDistance: vec3f
2556
- ,vTranslucencyColor: vec4f
2557
- #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
2558
- ,translucencyColorMap: vec4f
2559
- #endif
2560
- #endif
2561
- )->subSurfaceOutParams
2562
- {var outParams: subSurfaceOutParams;outParams.specularEnvironmentReflectance=specularEnvironmentReflectance;
2563
- #ifdef SS_REFRACTION
2564
- var refractionIntensity: f32=vSubSurfaceIntensity.x;
2565
- #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
2566
- refractionIntensity*=(1.0-alpha);outParams.alpha=1.0;
2567
- #endif
2568
- #endif
2569
- #ifdef SS_TRANSLUCENCY
2570
- var translucencyIntensity: f32=vSubSurfaceIntensity.y;
2571
- #endif
2572
- #ifdef SS_THICKNESSANDMASK_TEXTURE
2573
- #ifdef SS_USE_GLTF_TEXTURES
2574
- var thickness: f32=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;
2575
- #else
2576
- var thickness: f32=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;
2577
- #endif
2578
- #if DEBUGMODE>0
2579
- outParams.thicknessMap=thicknessMap;
2580
- #endif
2581
- #if defined(SS_REFRACTION) && defined(SS_REFRACTION_USE_INTENSITY_FROM_THICKNESS)
2582
- #ifdef SS_USE_GLTF_TEXTURES
2583
- refractionIntensity*=thicknessMap.r;
2584
- #else
2585
- refractionIntensity*=thicknessMap.g;
2586
- #endif
2587
- #endif
2588
- #if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCY_USE_INTENSITY_FROM_THICKNESS)
2589
- #ifdef SS_USE_GLTF_TEXTURES
2590
- translucencyIntensity*=thicknessMap.a;
2591
- #else
2592
- translucencyIntensity*=thicknessMap.b;
2593
- #endif
2594
- #endif
2595
- #else
2596
- var thickness: f32=vThicknessParam.y;
2597
- #endif
2598
- #if defined(SS_REFRACTION) && defined(SS_REFRACTIONINTENSITY_TEXTURE)
2599
- #ifdef SS_USE_GLTF_TEXTURES
2600
- refractionIntensity*=refractionIntensityMap.r;
2601
- #else
2602
- refractionIntensity*=refractionIntensityMap.g;
2603
- #endif
2604
- #endif
2605
- #if defined(SS_TRANSLUCENCY) && defined(SS_TRANSLUCENCYINTENSITY_TEXTURE)
2606
- #ifdef SS_USE_GLTF_TEXTURES
2607
- translucencyIntensity*=translucencyIntensityMap.a;
2608
- #else
2609
- translucencyIntensity*=translucencyIntensityMap.b;
2610
- #endif
2611
- #endif
2612
- #ifdef SS_TRANSLUCENCY
2613
- thickness=maxEps(thickness);var translucencyColor: vec4f=vTranslucencyColor;
2614
- #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
2615
- translucencyColor*=translucencyColorMap;
2616
- #endif
2617
- var transmittance: vec3f=transmittanceBRDF_Burley(translucencyColor.rgb,vDiffusionDistance,thickness);transmittance*=translucencyIntensity;outParams.transmittance=transmittance;outParams.translucencyIntensity=translucencyIntensity;
2618
- #endif
2619
- #ifdef SS_REFRACTION
2620
- var environmentRefraction: vec4f= vec4f(0.,0.,0.,0.);
2621
- #ifdef SS_HAS_THICKNESS
2622
- var ior: f32=vRefractionInfos.y;
2623
- #else
2624
- var ior: f32=vRefractionMicrosurfaceInfos.w;
2625
- #endif
2626
- #ifdef SS_LODINREFRACTIONALPHA
2627
- var refractionAlphaG: f32=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));var refractionLOD: f32=getLodFromAlphaGNdotV(vRefractionMicrosurfaceInfos.x,refractionAlphaG,NdotVUnclamped);
2628
- #elif defined(SS_LINEARSPECULARREFRACTION)
2629
- var refractionRoughness: f32=alphaG;refractionRoughness=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));var refractionLOD: f32=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,refractionRoughness);
2630
- #else
2631
- var refractionAlphaG: f32=alphaG;refractionAlphaG=mix(alphaG,0.0,clamp(ior*3.0-2.0,0.0,1.0));var refractionLOD: f32=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,refractionAlphaG);
2632
- #endif
2633
- var refraction_ior: f32=vRefractionInfos.y;
2634
- #ifdef SS_DISPERSION
2635
- var realIOR: f32=1.0/refraction_ior;var iorDispersionSpread: f32=0.04*dispersion*(realIOR-1.0);var iors: vec3f= vec3f(1.0/(realIOR-iorDispersionSpread),refraction_ior,1.0/(realIOR+iorDispersionSpread));for (var i: i32=0; i<3; i++) {refraction_ior=iors[i];
2636
- #endif
2637
- var envSample: vec4f=sampleEnvironmentRefraction(refraction_ior,thickness,refractionLOD,normalW,vPositionW,viewDirectionW,view,vRefractionInfos,refractionMatrix,vRefractionMicrosurfaceInfos,alphaG
2638
- #ifdef SS_REFRACTIONMAP_3D
2639
- ,refractionSampler
2640
- ,refractionSamplerSampler
2641
- #ifndef LODBASEDMICROSFURACE
2642
- ,refractionLowSampler
2643
- ,refractionLowSamplerSampler
2644
- ,refractionHighSampler
2645
- ,refractionHighSamplerSampler
2646
- #endif
2647
- #else
2648
- ,refractionSampler
2649
- ,refractionSamplerSampler
2650
- #ifndef LODBASEDMICROSFURACE
2651
- ,refractionLowSampler
2652
- ,refractionLowSamplerSampler
2653
- ,refractionHighSampler
2654
- ,refractionHighSamplerSampler
2655
- #endif
2656
- #endif
2657
- #ifdef ANISOTROPIC
2658
- ,anisotropicOut
2659
- #endif
2660
- #ifdef REALTIME_FILTERING
2661
- ,vRefractionFilteringInfo
2662
- #endif
2663
- #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
2664
- ,refractionPosition
2665
- ,refractionSize
2666
- #endif
2667
- );
2668
- #ifdef SS_DISPERSION
2669
- environmentRefraction[i]=envSample[i];}
2670
- #else
2671
- environmentRefraction=envSample;
2672
- #endif
2673
- environmentRefraction=vec4f(environmentRefraction.rgb*vRefractionInfos.x,environmentRefraction.a);
2674
- #endif
2675
- #ifdef SS_REFRACTION
2676
- var refractionTransmittance: vec3f= vec3f(refractionIntensity);
2677
- #ifdef SS_THICKNESSANDMASK_TEXTURE
2678
- var volumeAlbedo: vec3f=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambertVec3(volumeAlbedo,thickness);
2679
- #elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)
2680
- var maxChannel: f32=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);var volumeAlbedo: vec3f=saturateVec3(maxChannel*surfaceAlbedo);environmentRefraction=vec4f(environmentRefraction.rgb*volumeAlbedo,environmentRefraction.a);
2681
- #else
2682
- var volumeAlbedo: vec3f=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);refractionTransmittance*=cocaLambertVec3(volumeAlbedo,vThicknessParam.y);
2683
- #endif
2684
- #ifdef SS_ALBEDOFORREFRACTIONTINT
2685
- environmentRefraction=vec4f(environmentRefraction.rgb*surfaceAlbedo.rgb,environmentRefraction.a);
2686
- #endif
2687
- outParams.surfaceAlbedo=surfaceAlbedo*(1.-refractionIntensity);
2688
- #ifdef REFLECTION
2689
- outParams.refractionFactorForIrradiance=(1.-refractionIntensity);
2690
- #endif
2691
- #ifdef UNUSED_MULTIPLEBOUNCES
2692
- var bounceSpecularEnvironmentReflectance: vec3f=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);outParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);
2693
- #endif
2694
- refractionTransmittance*=1.0-outParams.specularEnvironmentReflectance;
2695
- #if DEBUGMODE>0
2696
- outParams.refractionTransmittance=refractionTransmittance;
2697
- #endif
2698
- outParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;
2699
- #if DEBUGMODE>0
2700
- outParams.environmentRefraction=environmentRefraction;
2701
- #endif
2702
- #endif
2703
- #if defined(REFLECTION) && defined(SS_TRANSLUCENCY)
2704
- #if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)
2705
- var irradianceVector: vec3f= (reflectionMatrix* vec4f(normalW,0)).xyz;
2706
- #ifdef REFLECTIONMAP_OPPOSITEZ
2707
- irradianceVector.z*=-1.0;
2708
- #endif
2709
- #ifdef INVERTCUBICMAP
2710
- irradianceVector.y*=-1.0;
2711
- #endif
2712
- #else
2713
- var irradianceVector: vec3f=irradianceVector_;
2714
- #endif
2715
- #if defined(USESPHERICALFROMREFLECTIONMAP)
2716
- #if defined(REALTIME_FILTERING)
2717
- var refractionIrradiance: vec3f=irradiance(reflectionSampler,reflectionSamplerSampler,-irradianceVector,vReflectionFilteringInfo);
2718
- #else
2719
- var refractionIrradiance: vec3f=computeEnvironmentIrradiance(-irradianceVector);
2720
- #endif
2721
- #elif defined(USEIRRADIANCEMAP)
2722
- #ifdef REFLECTIONMAP_3D
2723
- var irradianceCoords: vec3f=irradianceVector;
2724
- #else
2725
- var irradianceCoords: vec2f=irradianceVector.xy;
2726
- #ifdef REFLECTIONMAP_PROJECTION
2727
- irradianceCoords/=irradianceVector.z;
2728
- #endif
2729
- irradianceCoords.y=1.0-irradianceCoords.y;
2730
- #endif
2731
- var temp: vec4f=textureSample(irradianceSampler,irradianceSamplerSampler,-irradianceCoords);var refractionIrradiance=temp.rgb;
2732
- #ifdef RGBDREFLECTION
2733
- refractionIrradiance=fromRGBD(temp).rgb;
2734
- #endif
2735
- #ifdef GAMMAREFLECTION
2736
- refractionIrradiance=toLinearSpaceVec3(refractionIrradiance);
2737
- #endif
2738
- #else
2739
- var refractionIrradiance: vec3f= vec3f(0.);
2740
- #endif
2741
- refractionIrradiance*=transmittance;
2742
- #ifdef SS_ALBEDOFORTRANSLUCENCYTINT
2743
- refractionIrradiance*=surfaceAlbedo.rgb;
2744
- #endif
2745
- outParams.refractionIrradiance=refractionIrradiance;
2746
- #endif
2747
- return outParams;}
2748
- #endif
2749
- `;
2750
- // Sideeffect
2751
- ShaderStore.IncludesShadersStoreWGSL[name$k] = shader$k;
2752
-
2753
- // Do not edit.
2754
- const name$j = "clipPlaneFragment";
2755
- const shader$j = `#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
2756
- if (false) {}
2757
- #endif
2758
- #ifdef CLIPPLANE
2759
- else if (fragmentInputs.fClipDistance>0.0)
2760
- {discard;}
2761
- #endif
2762
- #ifdef CLIPPLANE2
2763
- else if (fragmentInputs.fClipDistance2>0.0)
2764
- {discard;}
2765
- #endif
2766
- #ifdef CLIPPLANE3
2767
- else if (fragmentInputs.fClipDistance3>0.0)
2768
- {discard;}
2769
- #endif
2770
- #ifdef CLIPPLANE4
2771
- else if (fragmentInputs.fClipDistance4>0.0)
2772
- {discard;}
2773
- #endif
2774
- #ifdef CLIPPLANE5
2775
- else if (fragmentInputs.fClipDistance5>0.0)
2776
- {discard;}
2777
- #endif
2778
- #ifdef CLIPPLANE6
2779
- else if (fragmentInputs.fClipDistance6>0.0)
2780
- {discard;}
2781
- #endif
2782
- `;
2783
- // Sideeffect
2784
- ShaderStore.IncludesShadersStoreWGSL[name$j] = shader$j;
2785
-
2786
- // Do not edit.
2787
- const name$i = "pbrBlockNormalGeometric";
2788
- const shader$i = `var viewDirectionW: vec3f=normalize(scene.vEyePosition.xyz-input.vPositionW);
2789
- #ifdef NORMAL
2790
- var normalW: vec3f=normalize(input.vNormalW);
2791
- #else
2792
- var normalW: vec3f=normalize(cross(dpdx(input.vPositionW),dpdy(input.vPositionW)))*scene.vEyePosition.w;
2793
- #endif
2794
- var geometricNormalW: vec3f=normalW;
2795
- #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
2796
- geometricNormalW=select(-geometricNormalW,geometricNormalW,fragmentInputs.frontFacing);
2797
- #endif
2798
- `;
2799
- // Sideeffect
2800
- ShaderStore.IncludesShadersStoreWGSL[name$i] = shader$i;
2801
-
2802
- // Do not edit.
2803
- const name$h = "bumpFragment";
2804
- const shader$h = `var uvOffset: vec2f= vec2f(0.0,0.0);
2805
- #if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)
2806
- #ifdef NORMALXYSCALE
2807
- var normalScale: f32=1.0;
2808
- #elif defined(BUMP)
2809
- var normalScale: f32=uniforms.vBumpInfos.y;
2810
- #else
2811
- var normalScale: f32=1.0;
2812
- #endif
2813
- #if defined(TANGENT) && defined(NORMAL)
2814
- var TBN: mat3x3f=mat3x3<f32>(input.vTBN0,input.vTBN1,input.vTBN2);
2815
- #elif defined(BUMP)
2816
- var TBNUV: vec2f=select(-fragmentInputs.vBumpUV,fragmentInputs.vBumpUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV,uniforms.vTangentSpaceParams);
2817
- #else
2818
- var TBNUV: vec2f=select(-fragmentInputs.vDetailUV,fragmentInputs.vDetailUV,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW*normalScale,input.vPositionW,TBNUV, vec2f(1.,1.));
2819
- #endif
2820
- #elif defined(ANISOTROPIC)
2821
- #if defined(TANGENT) && defined(NORMAL)
2822
- var TBN: mat3x3f=mat3x3<f32>(input.vTBN0,input.vTBN1,input.vTBN2);
2823
- #else
2824
- var TBNUV: vec2f=select( -fragmentInputs.vMainUV1,fragmentInputs.vMainUV1,fragmentInputs.frontFacing);var TBN: mat3x3f=cotangent_frame(normalW,input.vPositionW,TBNUV, vec2f(1.,1.));
2825
- #endif
2826
- #endif
2827
- #ifdef PARALLAX
2828
- var invTBN: mat3x3f=transposeMat3(TBN);
2829
- #ifdef PARALLAXOCCLUSION
2830
- uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,fragmentInputs.vBumpUV,uniforms.vBumpInfos.z);
2831
- #else
2832
- uvOffset=parallaxOffset(invTBN*viewDirectionW,uniforms.vBumpInfos.z);
2833
- #endif
2834
- #endif
2835
- #ifdef DETAIL
2836
- var detailColor: vec4f=textureSample(detailSampler,detailSamplerSampler,fragmentInputs.vDetailUV+uvOffset);var detailNormalRG: vec2f=detailColor.wy*2.0-1.0;var detailNormalB: f32=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));var detailNormal: vec3f= vec3f(detailNormalRG,detailNormalB);
2837
- #endif
2838
- #ifdef BUMP
2839
- #ifdef OBJECTSPACE_NORMALMAP
2840
- #define CUSTOM_FRAGMENT_BUMP_FRAGMENT
2841
- normalW=normalize(textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).xyz *2.0-1.0);normalW=normalize(mat3x3f(uniforms.normalMatrix[0].xyz,uniforms.normalMatrix[1].xyz,uniforms.normalMatrix[2].xyz)*normalW);
2842
- #elif !defined(DETAIL)
2843
- normalW=perturbNormal(TBN,textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV+uvOffset).xyz,uniforms.vBumpInfos.y);
2844
- #else
2845
- var bumpNormal: vec3f=textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV+uvOffset).xyz*2.0-1.0;
2846
- #if DETAIL_NORMALBLENDMETHOD==0
2847
- detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);var blendedNormal: vec3f=normalize( vec3f(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));
2848
- #elif DETAIL_NORMALBLENDMETHOD==1
2849
- detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);bumpNormal+= vec3f(0.0,0.0,1.0);detailNormal*= vec3f(-1.0,-1.0,1.0);var blendedNormal: vec3f=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;
2850
- #endif
2851
- normalW=perturbNormalBase(TBN,blendedNormal,uniforms.vBumpInfos.y);
2852
- #endif
2853
- #elif defined(DETAIL)
2854
- detailNormal=vec3f(detailNormal.xy*uniforms.vDetailInfos.z,detailNormal.z);normalW=perturbNormalBase(TBN,detailNormal,uniforms.vDetailInfos.z);
2855
- #endif
2856
- `;
2857
- // Sideeffect
2858
- ShaderStore.IncludesShadersStoreWGSL[name$h] = shader$h;
2859
-
2860
- // Do not edit.
2861
- const name$g = "pbrBlockNormalFinal";
2862
- const shader$g = `#if defined(FORCENORMALFORWARD) && defined(NORMAL)
2863
- var faceNormal: vec3f=normalize(cross(dpdx(fragmentInputs.vPositionW),dpdy(fragmentInputs.vPositionW)))*scene.vEyePosition.w;
2864
- #if defined(TWOSIDEDLIGHTING)
2865
- faceNormal=select(-faceNormal,faceNormal,fragmentInputs.frontFacing);
2866
- #endif
2867
- normalW*=sign(dot(normalW,faceNormal));
2868
- #endif
2869
- #if defined(TWOSIDEDLIGHTING) && defined(NORMAL)
2870
- normalW=select(-normalW,normalW,fragmentInputs.frontFacing);
2871
- #endif
2872
- `;
2873
- // Sideeffect
2874
- ShaderStore.IncludesShadersStoreWGSL[name$g] = shader$g;
2875
-
2876
- // Do not edit.
2877
- const name$f = "depthPrePass";
2878
- const shader$f = `#ifdef DEPTHPREPASS
2879
- fragmentOutputs.color= vec4f(0.,0.,0.,1.0);return fragmentOutputs;
2880
- #endif
2881
- `;
2882
- // Sideeffect
2883
- ShaderStore.IncludesShadersStoreWGSL[name$f] = shader$f;
2884
-
2885
- // Do not edit.
2886
- const name$e = "pbrBlockLightmapInit";
2887
- const shader$e = `#ifdef LIGHTMAP
2888
- var lightmapColor: vec4f=textureSample(lightmapSampler,lightmapSamplerSampler,fragmentInputs.vLightmapUV+uvOffset);
2889
- #ifdef RGBDLIGHTMAP
2890
- lightmapColor=vec4f(fromRGBD(lightmapColor),lightmapColor.a);
2891
- #endif
2892
- #ifdef GAMMALIGHTMAP
2893
- lightmapColor=vec4f(toLinearSpaceVec3(lightmapColor.rgb),lightmapColor.a);
2894
- #endif
2895
- lightmapColor=vec4f(lightmapColor.rgb*uniforms.vLightmapInfos.y,lightmapColor.a);
2896
- #endif
2897
- `;
2898
- // Sideeffect
2899
- ShaderStore.IncludesShadersStoreWGSL[name$e] = shader$e;
2900
-
2901
- // Do not edit.
2902
- const name$d = "pbrBlockGeometryInfo";
2903
- const shader$d = `var NdotVUnclamped: f32=dot(normalW,viewDirectionW);var NdotV: f32=absEps(NdotVUnclamped);var alphaG: f32=convertRoughnessToAverageSlope(roughness);var AARoughnessFactors: vec2f=getAARoughnessFactors(normalW.xyz);
2904
- #ifdef SPECULARAA
2905
- alphaG+=AARoughnessFactors.y;
2906
- #endif
2907
- #if defined(ENVIRONMENTBRDF)
2908
- var environmentBrdf: vec3f=getBRDFLookup(NdotV,roughness);
2909
- #endif
2910
- #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
2911
- #ifdef RADIANCEOCCLUSION
2912
- #ifdef AMBIENTINGRAYSCALE
2913
- var ambientMonochrome: f32=aoOut.ambientOcclusionColor.r;
2914
- #else
2915
- var ambientMonochrome: f32=getLuminance(aoOut.ambientOcclusionColor);
2916
- #endif
2917
- var seo: f32=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);
2918
- #endif
2919
- #ifdef HORIZONOCCLUSION
2920
- #ifdef BUMP
2921
- #ifdef REFLECTIONMAP_3D
2922
- var eho: f32=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);
2923
- #endif
2924
- #endif
2925
- #endif
2926
- #endif
2927
- `;
2928
- // Sideeffect
2929
- ShaderStore.IncludesShadersStoreWGSL[name$d] = shader$d;
2930
-
2931
- // Do not edit.
2932
- const name$c = "pbrBlockReflectance0";
2933
- const shader$c = `var reflectance: f32=max(max(reflectivityOut.surfaceReflectivityColor.r,reflectivityOut.surfaceReflectivityColor.g),reflectivityOut.surfaceReflectivityColor.b);var specularEnvironmentR0: vec3f=reflectivityOut.surfaceReflectivityColor.rgb;
2934
- #ifdef METALLICWORKFLOW
2935
- var specularEnvironmentR90: vec3f= vec3f(metallicReflectanceFactors.a);
2936
- #else
2937
- var specularEnvironmentR90: vec3f= vec3f(1.0,1.0,1.0);
2938
- #endif
2939
- #ifdef ALPHAFRESNEL
2940
- var reflectance90: f32=fresnelGrazingReflectance(reflectance);specularEnvironmentR90=specularEnvironmentR90*reflectance90;
2941
- #endif
2942
- `;
2943
- // Sideeffect
2944
- ShaderStore.IncludesShadersStoreWGSL[name$c] = shader$c;
2945
-
2946
- // Do not edit.
2947
- const name$b = "pbrBlockReflectance";
2948
- const shader$b = `#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
2949
- var specularEnvironmentReflectance: vec3f=getReflectanceFromBRDFWithEnvLookup(clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,environmentBrdf);
2950
- #ifdef RADIANCEOCCLUSION
2951
- specularEnvironmentReflectance*=seo;
2952
- #endif
2953
- #ifdef HORIZONOCCLUSION
2954
- #ifdef BUMP
2955
- #ifdef REFLECTIONMAP_3D
2956
- specularEnvironmentReflectance*=eho;
2957
- #endif
2958
- #endif
2959
- #endif
2960
- #else
2961
- var specularEnvironmentReflectance: vec3f=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));
2962
- #endif
2963
- #ifdef CLEARCOAT
2964
- specularEnvironmentReflectance*=clearcoatOut.conservationFactor;
2965
- #if defined(CLEARCOAT_TINT)
2966
- specularEnvironmentReflectance*=clearcoatOut.absorption;
2967
- #endif
2968
- #endif
2969
- `;
2970
- // Sideeffect
2971
- ShaderStore.IncludesShadersStoreWGSL[name$b] = shader$b;
2972
-
2973
- // Do not edit.
2974
- const name$a = "pbrBlockDirectLighting";
2975
- const shader$a = `var diffuseBase: vec3f=vec3f(0.,0.,0.);
2976
- #ifdef SPECULARTERM
2977
- var specularBase: vec3f=vec3f(0.,0.,0.);
2978
- #endif
2979
- #ifdef CLEARCOAT
2980
- var clearCoatBase: vec3f=vec3f(0.,0.,0.);
2981
- #endif
2982
- #ifdef SHEEN
2983
- var sheenBase: vec3f=vec3f(0.,0.,0.);
2984
- #endif
2985
- var preInfo: preLightingInfo;var info: lightingInfo;var shadow: f32=1.;
2986
- var aggShadow: f32=0.;var numLights: f32=0.;
2987
- #if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
2988
- var absorption: vec3f=vec3f(0.);
2989
- #endif
2990
- `;
2991
- // Sideeffect
2992
- ShaderStore.IncludesShadersStoreWGSL[name$a] = shader$a;
2993
-
2994
- // Do not edit.
2995
- const name$9 = "lightFragment";
2996
- const shader$9 = `#ifdef LIGHT{X}
2997
- #if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})
2998
- #else
2999
- #ifdef PBR
3000
- #ifdef SPOTLIGHT{X}
3001
- preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,input.vPositionW);
3002
- #elif defined(POINTLIGHT{X})
3003
- preInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW,input.vPositionW);
3004
- #elif defined(HEMILIGHT{X})
3005
- preInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
3006
- #elif defined(DIRLIGHT{X})
3007
- preInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);
3008
- #endif
3009
- preInfo.NdotV=NdotV;
3010
- #ifdef SPOTLIGHT{X}
3011
- #ifdef LIGHT_FALLOFF_GLTF{X}
3012
- preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);preInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
3013
- #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
3014
- preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);preInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);
3015
- #elif defined(LIGHT_FALLOFF_STANDARD{X})
3016
- preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);preInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);
3017
- #else
3018
- preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);preInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);
3019
- #endif
3020
- #elif defined(POINTLIGHT{X})
3021
- #ifdef LIGHT_FALLOFF_GLTF{X}
3022
- preInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);
3023
- #elif defined(LIGHT_FALLOFF_PHYSICAL{X})
3024
- preInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);
3025
- #elif defined(LIGHT_FALLOFF_STANDARD{X})
3026
- preInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);
3027
- #else
3028
- preInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);
3029
- #endif
3030
- #else
3031
- preInfo.attenuation=1.0;
3032
- #endif
3033
- #ifdef HEMILIGHT{X}
3034
- preInfo.roughness=roughness;
3035
- #else
3036
- preInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
3037
- #endif
3038
- #ifdef IRIDESCENCE
3039
- preInfo.iridescenceIntensity=iridescenceIntensity;
3040
- #endif
3041
- #ifdef HEMILIGHT{X}
3042
- info.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);
3043
- #elif defined(SS_TRANSLUCENCY)
3044
- info.diffuse=computeDiffuseAndTransmittedLighting(preInfo,light{X}.vLightDiffuse.rgb,subSurfaceOut.transmittance);
3045
- #else
3046
- info.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);
3047
- #endif
3048
- #ifdef SPECULARTERM
3049
- #ifdef ANISOTROPIC
3050
- info.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
3051
- #else
3052
- info.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
3053
- #endif
3054
- #endif
3055
- #ifdef SHEEN
3056
- #ifdef SHEEN_LINKWITHALBEDO
3057
- preInfo.roughness=sheenOut.sheenIntensity;
3058
- #else
3059
- #ifdef HEMILIGHT{X}
3060
- preInfo.roughness=sheenOut.sheenRoughness;
3061
- #else
3062
- preInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
3063
- #endif
3064
- #endif
3065
- info.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);
3066
- #endif
3067
- #ifdef CLEARCOAT
3068
- #ifdef HEMILIGHT{X}
3069
- preInfo.roughness=clearcoatOut.clearCoatRoughness;
3070
- #else
3071
- preInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);
3072
- #endif
3073
- info.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light{X}.vLightDiffuse.rgb);
3074
- #ifdef CLEARCOAT_TINT
3075
- absorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);info.diffuse*=absorption;
3076
- #ifdef SPECULARTERM
3077
- info.specular*=absorption;
3078
- #endif
3079
- #endif
3080
- info.diffuse*=info.clearCoat.w;
3081
- #ifdef SPECULARTERM
3082
- info.specular*=info.clearCoat.w;
3083
- #endif
3084
- #ifdef SHEEN
3085
- info.sheen*=info.clearCoat.w;
3086
- #endif
3087
- #endif
3088
- #else
3089
- #ifdef SPOTLIGHT{X}
3090
- info=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);
3091
- #elif defined(HEMILIGHT{X})
3092
- info=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightGround,glossiness);
3093
- #elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})
3094
- info=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,light{X}.vLightDiffuse.a,glossiness);
3095
- #endif
3096
- #endif
3097
- #ifdef PROJECTEDLIGHTTEXTURE{X}
3098
- info.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightTexture{X},projectionLightTexture{X}Sampler,uniforms.textureProjectionMatrix{X},input.vPositionW);
3099
- #endif
3100
- #endif
3101
- #ifdef SHADOW{X}
3102
- #ifdef SHADOWCSMDEBUG{X}
3103
- var shadowDebug{X}: vec3f;
3104
- #endif
3105
- #ifdef SHADOWCSM{X}
3106
- #ifdef SHADOWCSMUSESHADOWMAXZ{X}
3107
- var index{X}: i32=-1;
3108
- #else
3109
- var index{X}: i32=SHADOWCSMNUM_CASCADES{X}-1;
3110
- #endif
3111
- var diff{X}: f32=0.;vPositionFromLight{X}[0]=fragmentInputs.vPositionFromLight{X}_0;vPositionFromLight{X}[1]=fragmentInputs.vPositionFromLight{X}_1;vPositionFromLight{X}[2]=fragmentInputs.vPositionFromLight{X}_2;vPositionFromLight{X}[3]=fragmentInputs.vPositionFromLight{X}_3;vDepthMetric{X}[0]=fragmentInputs.vDepthMetric{X}_0;vDepthMetric{X}[1]=fragmentInputs.vDepthMetric{X}_1;vDepthMetric{X}[2]=fragmentInputs.vDepthMetric{X}_2;vDepthMetric{X}[3]=fragmentInputs.vDepthMetric{X}_3;for (var i:i32=0; i<SHADOWCSMNUM_CASCADES{X}; i++)
3112
- {
3113
- #ifdef SHADOWCSM_RIGHTHANDED{X}
3114
- diff{X}=uniforms.viewFrustumZ{X}[i]+fragmentInputs.vPositionFromCamera{X}.z;
3115
- #else
3116
- diff{X}=uniforms.viewFrustumZ{X}[i]-fragmentInputs.vPositionFromCamera{X}.z;
3117
- #endif
3118
- if (diff{X}>=0.) {index{X}=i;break;}}
3119
- #ifdef SHADOWCSMUSESHADOWMAXZ{X}
3120
- if (index{X}>=0)
3121
- #endif
3122
- {
3123
- #if defined(SHADOWPCF{X})
3124
- #if defined(SHADOWLOWQUALITY{X})
3125
- shadow=computeShadowWithCSMPCF1(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3126
- #elif defined(SHADOWMEDIUMQUALITY{X})
3127
- shadow=computeShadowWithCSMPCF3(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3128
- #else
3129
- shadow=computeShadowWithCSMPCF5(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3130
- #endif
3131
- #elif defined(SHADOWPCSS{X})
3132
- #if defined(SHADOWLOWQUALITY{X})
3133
- shadow=computeShadowWithCSMPCSS16(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
3134
- #elif defined(SHADOWMEDIUMQUALITY{X})
3135
- shadow=computeShadowWithCSMPCSS32(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
3136
- #else
3137
- shadow=computeShadowWithCSMPCSS64(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
3138
- #endif
3139
- #else
3140
- shadow=computeShadowCSM(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3141
- #endif
3142
- #ifdef SHADOWCSMDEBUG{X}
3143
- shadowDebug{X}=vec3f(shadow)*vCascadeColorsMultiplier{X}[index{X}];
3144
- #endif
3145
- #ifndef SHADOWCSMNOBLEND{X}
3146
- var frustumLength:f32=uniforms.frustumLengths{X}[index{X}];var diffRatio:f32=clamp(diff{X}/frustumLength,0.,1.)*uniforms.cascadeBlendFactor{X};if (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)
3147
- {index{X}+=1;var nextShadow: f32=0.;
3148
- #if defined(SHADOWPCF{X})
3149
- #if defined(SHADOWLOWQUALITY{X})
3150
- nextShadow=computeShadowWithCSMPCF1(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],,shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3151
- #elif defined(SHADOWMEDIUMQUALITY{X})
3152
- nextShadow=computeShadowWithCSMPCF3(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3153
- #else
3154
- nextShadow=computeShadowWithCSMPCF5(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3155
- #endif
3156
- #elif defined(SHADOWPCSS{X})
3157
- #if defined(SHADOWLOWQUALITY{X})
3158
- nextShadow=computeShadowWithCSMPCSS16(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
3159
- #elif defined(SHADOWMEDIUMQUALITY{X})
3160
- nextShadow=computeShadowWithCSMPCSS32(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
3161
- #else
3162
- nextShadow=computeShadowWithCSMPCSS64(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,uniforms.lightSizeUVCorrection{X}[index{X}],uniforms.depthCorrection{X}[index{X}],uniforms.penumbraDarkness{X});
3163
- #endif
3164
- #else
3165
- nextShadow=computeShadowCSM(index{X},vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3166
- #endif
3167
- shadow=mix(nextShadow,shadow,diffRatio);
3168
- #ifdef SHADOWCSMDEBUG{X}
3169
- shadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);
3170
- #endif
3171
- }
3172
- #endif
3173
- }
3174
- #elif defined(SHADOWCLOSEESM{X})
3175
- #if defined(SHADOWCUBE{X})
3176
- shadow=computeShadowWithCloseESMCube(input.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
3177
- #else
3178
- shadow=computeShadowWithCloseESM(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
3179
- #endif
3180
- #elif defined(SHADOWESM{X})
3181
- #if defined(SHADOWCUBE{X})
3182
- shadow=computeShadowWithESMCube(input.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);
3183
- #else
3184
- shadow=computeShadowWithESM(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);
3185
- #endif
3186
- #elif defined(SHADOWPOISSON{X})
3187
- #if defined(SHADOWCUBE{X})
3188
- shadow=computeShadowWithPoissonSamplingCube(input.vPositionW,light{X}.vLightData.xyz,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);
3189
- #else
3190
- shadow=computeShadowWithPoissonSampling(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3191
- #endif
3192
- #elif defined(SHADOWPCF{X})
3193
- #if defined(SHADOWLOWQUALITY{X})
3194
- shadow=computeShadowWithPCF1(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3195
- #elif defined(SHADOWMEDIUMQUALITY{X})
3196
- shadow=computeShadowWithPCF3(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3197
- #else
3198
- shadow=computeShadowWithPCF5(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3199
- #endif
3200
- #elif defined(SHADOWPCSS{X})
3201
- #if defined(SHADOWLOWQUALITY{X})
3202
- shadow=computeShadowWithPCSS16(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3203
- #elif defined(SHADOWMEDIUMQUALITY{X})
3204
- shadow=computeShadowWithPCSS32(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3205
- #else
3206
- shadow=computeShadowWithPCSS64(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},depthTexture{X},depthTexture{X}Sampler,shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3207
- #endif
3208
- #else
3209
- #if defined(SHADOWCUBE{X})
3210
- shadow=computeShadowCube(input.vPositionW,light{X}.vLightData.xyz,shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.depthValues);
3211
- #else
3212
- shadow=computeShadow(fragmentInputs.vPositionFromLight{X},fragmentInputs.vDepthMetric{X},shadowTexture{X},shadowTexture{X}Sampler,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);
3213
- #endif
3214
- #endif
3215
- #ifdef SHADOWONLY
3216
- #ifndef SHADOWINUSE
3217
- #define SHADOWINUSE
3218
- #endif
3219
- globalShadow+=shadow;shadowLightCount+=1.0;
3220
- #endif
3221
- #else
3222
- shadow=1.;
3223
- #endif
3224
- aggShadow+=shadow;numLights+=1.0;
3225
- #ifndef SHADOWONLY
3226
- #ifdef CUSTOMUSERLIGHTING
3227
- diffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);
3228
- #ifdef SPECULARTERM
3229
- specularBase+=computeCustomSpecularLighting(info,specularBase,shadow);
3230
- #endif
3231
- #elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})
3232
- diffuseBase+=lightmapColor.rgb*shadow;
3233
- #ifdef SPECULARTERM
3234
- #ifndef LIGHTMAPNOSPECULAR{X}
3235
- specularBase+=info.specular*shadow*lightmapColor.rgb;
3236
- #endif
3237
- #endif
3238
- #ifdef CLEARCOAT
3239
- #ifndef LIGHTMAPNOSPECULAR{X}
3240
- clearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;
3241
- #endif
3242
- #endif
3243
- #ifdef SHEEN
3244
- #ifndef LIGHTMAPNOSPECULAR{X}
3245
- sheenBase+=info.sheen.rgb*shadow;
3246
- #endif
3247
- #endif
3248
- #else
3249
- #ifdef SHADOWCSMDEBUG{X}
3250
- diffuseBase+=info.diffuse*shadowDebug{X};
3251
- #else
3252
- diffuseBase+=info.diffuse*shadow;
3253
- #endif
3254
- #ifdef SPECULARTERM
3255
- specularBase+=info.specular*shadow;
3256
- #endif
3257
- #ifdef CLEARCOAT
3258
- clearCoatBase+=info.clearCoat.rgb*shadow;
3259
- #endif
3260
- #ifdef SHEEN
3261
- sheenBase+=info.sheen.rgb*shadow;
3262
- #endif
3263
- #endif
3264
- #endif
3265
- #endif
3266
- `;
3267
- // Sideeffect
3268
- ShaderStore.IncludesShadersStoreWGSL[name$9] = shader$9;
3269
-
3270
- // Do not edit.
3271
- const name$8 = "pbrBlockFinalLitComponents";
3272
- const shader$8 = `aggShadow=aggShadow/numLights;
3273
- #if defined(ENVIRONMENTBRDF)
3274
- #ifdef MS_BRDF_ENERGY_CONSERVATION
3275
- var energyConservationFactor: vec3f=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);
3276
- #endif
3277
- #endif
3278
- #ifndef METALLICWORKFLOW
3279
- #ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION
3280
- surfaceAlbedo=(1.-reflectance)*surfaceAlbedo.rgb;
3281
- #endif
3282
- #endif
3283
- #if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)
3284
- surfaceAlbedo=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;
3285
- #endif
3286
- #ifdef REFLECTION
3287
- var finalIrradiance: vec3f=reflectionOut.environmentIrradiance;
3288
- #if defined(CLEARCOAT)
3289
- finalIrradiance*=clearcoatOut.conservationFactor;
3290
- #if defined(CLEARCOAT_TINT)
3291
- finalIrradiance*=clearcoatOut.absorption;
3292
- #endif
3293
- #endif
3294
- #if defined(SS_REFRACTION)
3295
- finalIrradiance*=subSurfaceOut.refractionFactorForIrradiance;
3296
- #endif
3297
- #if defined(SS_TRANSLUCENCY)
3298
- finalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);finalIrradiance+=subSurfaceOut.refractionIrradiance;
3299
- #endif
3300
- finalIrradiance*=surfaceAlbedo.rgb;finalIrradiance*=uniforms.vLightingIntensity.z;finalIrradiance*=aoOut.ambientOcclusionColor;
3301
- #endif
3302
- #ifdef SPECULARTERM
3303
- var finalSpecular: vec3f=specularBase;finalSpecular=max(finalSpecular,vec3f(0.0));var finalSpecularScaled: vec3f=finalSpecular*uniforms.vLightingIntensity.x*uniforms.vLightingIntensity.w;
3304
- #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
3305
- finalSpecularScaled*=energyConservationFactor;
3306
- #endif
3307
- #if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
3308
- finalSpecularScaled*=sheenOut.sheenAlbedoScaling;
3309
- #endif
3310
- #endif
3311
- #ifdef REFLECTION
3312
- var finalRadiance: vec3f=reflectionOut.environmentRadiance.rgb;finalRadiance*=subSurfaceOut.specularEnvironmentReflectance;var finalRadianceScaled: vec3f=finalRadiance*uniforms.vLightingIntensity.z;
3313
- #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
3314
- finalRadianceScaled*=energyConservationFactor;
3315
- #endif
3316
- #if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)
3317
- finalRadianceScaled*=sheenOut.sheenAlbedoScaling;
3318
- #endif
3319
- #endif
3320
- #ifdef SHEEN
3321
- var finalSheen: vec3f=sheenBase*sheenOut.sheenColor;finalSheen=max(finalSheen,vec3f(0.0));var finalSheenScaled: vec3f=finalSheen*uniforms.vLightingIntensity.x*uniforms.vLightingIntensity.w;
3322
- #if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)
3323
- sheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;
3324
- #if defined(CLEARCOAT_TINT)
3325
- sheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;
3326
- #endif
3327
- #endif
3328
- #endif
3329
- #ifdef CLEARCOAT
3330
- var finalClearCoat: vec3f=clearCoatBase;finalClearCoat=max(finalClearCoat,vec3f(0.0));var finalClearCoatScaled: vec3f=finalClearCoat*uniforms.vLightingIntensity.x*uniforms.vLightingIntensity.w;
3331
- #if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)
3332
- finalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;
3333
- #endif
3334
- #ifdef SS_REFRACTION
3335
- subSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;
3336
- #ifdef CLEARCOAT_TINT
3337
- subSurfaceOut.finalRefraction*=clearcoatOut.absorption;
3338
- #endif
3339
- #endif
3340
- #endif
3341
- #ifdef ALPHABLEND
3342
- var luminanceOverAlpha: f32=0.0;
3343
- #if defined(REFLECTION) && defined(RADIANCEOVERALPHA)
3344
- luminanceOverAlpha+=getLuminance(finalRadianceScaled);
3345
- #if defined(CLEARCOAT)
3346
- luminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);
3347
- #endif
3348
- #endif
3349
- #if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)
3350
- luminanceOverAlpha+=getLuminance(finalSpecularScaled);
3351
- #endif
3352
- #if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)
3353
- luminanceOverAlpha+=getLuminance(finalClearCoatScaled);
3354
- #endif
3355
- #if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)
3356
- alpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);
3357
- #endif
3358
- #endif
3359
- `;
3360
- // Sideeffect
3361
- ShaderStore.IncludesShadersStoreWGSL[name$8] = shader$8;
3362
-
3363
- // Do not edit.
3364
- const name$7 = "pbrBlockFinalUnlitComponents";
3365
- const shader$7 = `var finalDiffuse: vec3f=diffuseBase;finalDiffuse*=surfaceAlbedo.rgb;finalDiffuse=max(finalDiffuse,vec3f(0.0));finalDiffuse*=uniforms.vLightingIntensity.x;var finalAmbient: vec3f=uniforms.vAmbientColor;finalAmbient*=surfaceAlbedo.rgb;var finalEmissive: vec3f=uniforms.vEmissiveColor;
3366
- #ifdef EMISSIVE
3367
- var emissiveColorTex: vec3f=textureSample(emissiveSampler,emissiveSamplerSampler,fragmentInputs.vEmissiveUV+uvOffset).rgb;
3368
- #ifdef GAMMAEMISSIVE
3369
- finalEmissive*=toLinearSpaceVec3(emissiveColorTex.rgb);
3370
- #else
3371
- finalEmissive*=emissiveColorTex.rgb;
3372
- #endif
3373
- finalEmissive*= uniforms.vEmissiveInfos.y;
3374
- #endif
3375
- finalEmissive*=uniforms.vLightingIntensity.y;
3376
- #ifdef AMBIENT
3377
- var ambientOcclusionForDirectDiffuse: vec3f=mix( vec3f(1.),aoOut.ambientOcclusionColor,uniforms.vAmbientInfos.w);
3378
- #else
3379
- var ambientOcclusionForDirectDiffuse: vec3f=aoOut.ambientOcclusionColor;
3380
- #endif
3381
- finalAmbient*=aoOut.ambientOcclusionColor;finalDiffuse*=ambientOcclusionForDirectDiffuse;
3382
- `;
3383
- // Sideeffect
3384
- ShaderStore.IncludesShadersStoreWGSL[name$7] = shader$7;
3385
-
3386
- // Do not edit.
3387
- const name$6 = "pbrBlockFinalColorComposition";
3388
- const shader$6 = `var finalColor: vec4f= vec4f(
3389
- #ifndef UNLIT
3390
- #ifdef REFLECTION
3391
- finalIrradiance +
3392
- #endif
3393
- #ifdef SPECULARTERM
3394
- finalSpecularScaled +
3395
- #endif
3396
- #ifdef SHEEN
3397
- finalSheenScaled +
3398
- #endif
3399
- #ifdef CLEARCOAT
3400
- finalClearCoatScaled +
3401
- #endif
3402
- #ifdef REFLECTION
3403
- finalRadianceScaled +
3404
- #if defined(SHEEN) && defined(ENVIRONMENTBRDF)
3405
- sheenOut.finalSheenRadianceScaled +
3406
- #endif
3407
- #ifdef CLEARCOAT
3408
- clearcoatOut.finalClearCoatRadianceScaled +
3409
- #endif
3410
- #endif
3411
- #ifdef SS_REFRACTION
3412
- subSurfaceOut.finalRefraction +
3413
- #endif
3414
- #endif
3415
- finalAmbient +
3416
- finalDiffuse,
3417
- alpha);
3418
- #ifdef LIGHTMAP
3419
- #ifndef LIGHTMAPEXCLUDED
3420
- #ifdef USELIGHTMAPASSHADOWMAP
3421
- finalColor=vec4f(finalColor.rgb*lightmapColor.rgb,finalColor.a);
3422
- #else
3423
- finalColor=vec4f(finalColor.rgb+lightmapColor.rgb,finalColor.a);
3424
- #endif
3425
- #endif
3426
- #endif
3427
- finalColor=vec4f(finalColor.rgb+finalEmissive,finalColor.a);
3428
- #define CUSTOM_FRAGMENT_BEFORE_FOG
3429
- finalColor=max(finalColor,vec4f(0.0));
3430
- `;
3431
- // Sideeffect
3432
- ShaderStore.IncludesShadersStoreWGSL[name$6] = shader$6;
3433
-
3434
- // Do not edit.
3435
- const name$5 = "logDepthFragment";
3436
- const shader$5 = `#ifdef LOGARITHMICDEPTH
3437
- fragmentOutputs.fragDepth=log2(fragmentInputs.vFragmentDepth)*uniforms.logarithmicDepthConstant*0.5;
3438
- #endif
3439
- `;
3440
- // Sideeffect
3441
- ShaderStore.IncludesShadersStoreWGSL[name$5] = shader$5;
3442
-
3443
- // Do not edit.
3444
- const name$4 = "fogFragment";
3445
- const shader$4 = `#ifdef FOG
3446
- var fog: f32=CalcFogFactor();
3447
- #ifdef PBR
3448
- fog=toLinearSpace(fog);
3449
- #endif
3450
- color= vec4f(mix(uniforms.vFogColor,color.rgb,fog),color.a);
3451
- #endif
3452
- `;
3453
- // Sideeffect
3454
- ShaderStore.IncludesShadersStoreWGSL[name$4] = shader$4;
3455
-
3456
- // Do not edit.
3457
- const name$3 = "pbrBlockImageProcessing";
3458
- const shader$3 = `#if defined(IMAGEPROCESSINGPOSTPROCESS) || defined(SS_SCATTERING)
3459
- #if !defined(SKIPFINALCOLORCLAMP)
3460
- finalColor=vec4f(clamp(finalColor.rgb,vec3f(0.),vec3f(30.0)),finalColor.a);
3461
- #endif
3462
- #else
3463
- finalColor=applyImageProcessing(finalColor);
3464
- #endif
3465
- finalColor=vec4f(finalColor.rgb,finalColor.a*mesh.visibility);
3466
- #ifdef PREMULTIPLYALPHA
3467
- finalColor=vec4f(finalColor.rgb*finalColor.a,finalColor.a);;
3468
- #endif
3469
- `;
3470
- // Sideeffect
3471
- ShaderStore.IncludesShadersStoreWGSL[name$3] = shader$3;
3472
-
3473
- // Do not edit.
3474
- const name$2 = "oitFragment";
3475
- const shader$2 = `#ifdef ORDER_INDEPENDENT_TRANSPARENCY
3476
- var fragDepth: f32=fragmentInputs.position.z;
3477
- #ifdef ORDER_INDEPENDENT_TRANSPARENCY_16BITS
3478
- var halfFloat: i32=packHalf2x16( vec2f(fragDepth));var full: vec2f=unpackHalf2x16(halfFloat);fragDepth=full.x;
3479
- #endif
3480
- var fragCoord: vec2i=vec2i(fragmentInputs.position.xy);var lastDepth: vec2f=textureLoad(oitDepthSampler,fragCoord,0).rg;var lastFrontColor: vec4f=textureLoad(oitFrontColorSampler,fragCoord,0);fragmentOutputs.depth=vec2f(-MAX_DEPTH);fragmentOutputs.frontColor=lastFrontColor;fragmentOutputs.backColor= vec4f(0.0);
3481
- #ifdef USE_REVERSE_DEPTHBUFFER
3482
- var furthestDepth: f32=-lastDepth.x;var nearestDepth: f32=lastDepth.y;
3483
- #else
3484
- var nearestDepth: f32=-lastDepth.x;var furthestDepth: f32=lastDepth.y;
3485
- #endif
3486
- var alphaMultiplier: f32=1.0-lastFrontColor.a;
3487
- #ifdef USE_REVERSE_DEPTHBUFFER
3488
- if (fragDepth>nearestDepth || fragDepth<furthestDepth) {
3489
- #else
3490
- if (fragDepth<nearestDepth || fragDepth>furthestDepth) {
3491
- #endif
3492
- return fragmentOutputs;}
3493
- #ifdef USE_REVERSE_DEPTHBUFFER
3494
- if (fragDepth<nearestDepth && fragDepth>furthestDepth) {
3495
- #else
3496
- if (fragDepth>nearestDepth && fragDepth<furthestDepth) {
3497
- #endif
3498
- fragmentOutputs.depth=vec2f(-fragDepth,fragDepth);return fragmentOutputs;}
3499
- #endif
3500
- `;
3501
- // Sideeffect
3502
- ShaderStore.IncludesShadersStoreWGSL[name$2] = shader$2;
3503
-
3504
- // Do not edit.
3505
- const name$1 = "pbrDebug";
3506
- const shader$1 = `#if DEBUGMODE>0
3507
- if (input.vClipSpacePosition.x/input.vClipSpacePosition.w>=uniforms.vDebugMode.x) {var color: vec3f;
3508
- #if DEBUGMODE==1
3509
- color=fragmentInputs.vPositionW.rgb;
3510
- #define DEBUGMODE_NORMALIZE
3511
- #elif DEBUGMODE==2 && defined(NORMAL)
3512
- color=fragmentInputs.vNormalW.rgb;
3513
- #define DEBUGMODE_NORMALIZE
3514
- #elif DEBUGMODE==3 && defined(BUMP) || DEBUGMODE==3 && defined(PARALLAX) || DEBUGMODE==3 && defined(ANISOTROPIC)
3515
- color=TBN[0];
3516
- #define DEBUGMODE_NORMALIZE
3517
- #elif DEBUGMODE==4 && defined(BUMP) || DEBUGMODE==4 && defined(PARALLAX) || DEBUGMODE==4 && defined(ANISOTROPIC)
3518
- color=TBN[1];
3519
- #define DEBUGMODE_NORMALIZE
3520
- #elif DEBUGMODE==5
3521
- color=normalW;
3522
- #define DEBUGMODE_NORMALIZE
3523
- #elif DEBUGMODE==6 && defined(MAINUV1)
3524
- color= vec3f(input.vMainUV1,0.0);
3525
- #elif DEBUGMODE==7 && defined(MAINUV2)
3526
- color= vec3f(input.vMainUV2,0.0);
3527
- #elif DEBUGMODE==8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
3528
- color=clearcoatOut.TBNClearCoat[0];
3529
- #define DEBUGMODE_NORMALIZE
3530
- #elif DEBUGMODE==9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)
3531
- color=clearcoatOut.TBNClearCoat[1];
3532
- #define DEBUGMODE_NORMALIZE
3533
- #elif DEBUGMODE==10 && defined(CLEARCOAT)
3534
- color=clearcoatOut.clearCoatNormalW;
3535
- #define DEBUGMODE_NORMALIZE
3536
- #elif DEBUGMODE==11 && defined(ANISOTROPIC)
3537
- color=anisotropicOut.anisotropicNormal;
3538
- #define DEBUGMODE_NORMALIZE
3539
- #elif DEBUGMODE==12 && defined(ANISOTROPIC)
3540
- color=anisotropicOut.anisotropicTangent;
3541
- #define DEBUGMODE_NORMALIZE
3542
- #elif DEBUGMODE==13 && defined(ANISOTROPIC)
3543
- color=anisotropicOut.anisotropicBitangent;
3544
- #define DEBUGMODE_NORMALIZE
3545
- #elif DEBUGMODE==20 && defined(ALBEDO)
3546
- color=albedoTexture.rgb;
3547
- #ifndef GAMMAALBEDO
3548
- #define DEBUGMODE_GAMMA
3549
- #endif
3550
- #elif DEBUGMODE==21 && defined(AMBIENT)
3551
- color=aoOut.ambientOcclusionColorMap.rgb;
3552
- #elif DEBUGMODE==22 && defined(OPACITY)
3553
- color=opacityMap.rgb;
3554
- #elif DEBUGMODE==23 && defined(EMISSIVE)
3555
- color=emissiveColorTex.rgb;
3556
- #ifndef GAMMAEMISSIVE
3557
- #define DEBUGMODE_GAMMA
3558
- #endif
3559
- #elif DEBUGMODE==24 && defined(LIGHTMAP)
3560
- color=lightmapColor;
3561
- #ifndef GAMMALIGHTMAP
3562
- #define DEBUGMODE_GAMMA
3563
- #endif
3564
- #elif DEBUGMODE==25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)
3565
- color=reflectivityOut.surfaceMetallicColorMap.rgb;
3566
- #elif DEBUGMODE==26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)
3567
- color=reflectivityOut.surfaceReflectivityColorMap.rgb;
3568
- #define DEBUGMODE_GAMMA
3569
- #elif DEBUGMODE==27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)
3570
- color= vec3f(clearcoatOut.clearCoatMapData.rg,0.0);
3571
- #elif DEBUGMODE==28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
3572
- color=clearcoatOut.clearCoatTintMapData.rgb;
3573
- #elif DEBUGMODE==29 && defined(SHEEN) && defined(SHEEN_TEXTURE)
3574
- color=sheenOut.sheenMapData.rgb;
3575
- #elif DEBUGMODE==30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)
3576
- color=anisotropicOut.anisotropyMapData.rgb;
3577
- #elif DEBUGMODE==31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)
3578
- color=subSurfaceOut.thicknessMap.rgb;
3579
- #elif DEBUGMODE==32 && defined(BUMP)
3580
- color=textureSample(bumpSampler,bumpSamplerSampler,fragmentInputs.vBumpUV).rgb;
3581
- #elif DEBUGMODE==40 && defined(SS_REFRACTION)
3582
- color=subSurfaceOut.environmentRefraction.rgb;
3583
- #define DEBUGMODE_GAMMA
3584
- #elif DEBUGMODE==41 && defined(REFLECTION)
3585
- color=reflectionOut.environmentRadiance.rgb;
3586
- #ifndef GAMMAREFLECTION
3587
- #define DEBUGMODE_GAMMA
3588
- #endif
3589
- #elif DEBUGMODE==42 && defined(CLEARCOAT) && defined(REFLECTION)
3590
- color=clearcoatOut.environmentClearCoatRadiance.rgb;
3591
- #define DEBUGMODE_GAMMA
3592
- #elif DEBUGMODE==50
3593
- color=diffuseBase.rgb;
3594
- #define DEBUGMODE_GAMMA
3595
- #elif DEBUGMODE==51 && defined(SPECULARTERM)
3596
- color=specularBase.rgb;
3597
- #define DEBUGMODE_GAMMA
3598
- #elif DEBUGMODE==52 && defined(CLEARCOAT)
3599
- color=clearCoatBase.rgb;
3600
- #define DEBUGMODE_GAMMA
3601
- #elif DEBUGMODE==53 && defined(SHEEN)
3602
- color=sheenBase.rgb;
3603
- #define DEBUGMODE_GAMMA
3604
- #elif DEBUGMODE==54 && defined(REFLECTION)
3605
- color=reflectionOut.environmentIrradiance.rgb;
3606
- #ifndef GAMMAREFLECTION
3607
- #define DEBUGMODE_GAMMA
3608
- #endif
3609
- #elif DEBUGMODE==60
3610
- color=surfaceAlbedo.rgb;
3611
- #define DEBUGMODE_GAMMA
3612
- #elif DEBUGMODE==61
3613
- color=clearcoatOut.specularEnvironmentR0;
3614
- #define DEBUGMODE_GAMMA
3615
- #elif DEBUGMODE==62 && defined(METALLICWORKFLOW)
3616
- color= vec3f(reflectivityOut.metallicRoughness.r);
3617
- #elif DEBUGMODE==71 && defined(METALLICWORKFLOW)
3618
- color=reflectivityOut.metallicF0;
3619
- #elif DEBUGMODE==63
3620
- color= vec3f(roughness);
3621
- #elif DEBUGMODE==64
3622
- color= vec3f(alphaG);
3623
- #elif DEBUGMODE==65
3624
- color= vec3f(NdotV);
3625
- #elif DEBUGMODE==66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)
3626
- color=clearcoatOut.clearCoatColor;
3627
- #define DEBUGMODE_GAMMA
3628
- #elif DEBUGMODE==67 && defined(CLEARCOAT)
3629
- color= vec3f(clearcoatOut.clearCoatRoughness);
3630
- #elif DEBUGMODE==68 && defined(CLEARCOAT)
3631
- color= vec3f(clearcoatOut.clearCoatNdotV);
3632
- #elif DEBUGMODE==69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)
3633
- color=subSurfaceOut.transmittance;
3634
- #elif DEBUGMODE==70 && defined(SUBSURFACE) && defined(SS_REFRACTION)
3635
- color=subSurfaceOut.refractionTransmittance;
3636
- #elif DEBUGMODE==72
3637
- color= vec3f(microSurface);
3638
- #elif DEBUGMODE==73
3639
- color=uniforms.vAlbedoColor.rgb;
3640
- #define DEBUGMODE_GAMMA
3641
- #elif DEBUGMODE==74 && !defined(METALLICWORKFLOW)
3642
- color=uniforms.vReflectivityColor.rgb;
3643
- #define DEBUGMODE_GAMMA
3644
- #elif DEBUGMODE==75
3645
- color=uniforms.vEmissiveColor;
3646
- #define DEBUGMODE_GAMMA
3647
- #elif DEBUGMODE==80 && defined(RADIANCEOCCLUSION)
3648
- color= vec3f(seo);
3649
- #elif DEBUGMODE==81 && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
3650
- color= vec3f(eho);
3651
- #elif DEBUGMODE==82 && defined(MS_BRDF_ENERGY_CONSERVATION)
3652
- color= vec3f(energyConservationFactor);
3653
- #elif DEBUGMODE==83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
3654
- color=specularEnvironmentReflectance;
3655
- #define DEBUGMODE_GAMMA
3656
- #elif DEBUGMODE==84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
3657
- color=clearcoatOut.clearCoatEnvironmentReflectance;
3658
- #define DEBUGMODE_GAMMA
3659
- #elif DEBUGMODE==85 && defined(SHEEN) && defined(REFLECTION)
3660
- color=sheenOut.sheenEnvironmentReflectance;
3661
- #define DEBUGMODE_GAMMA
3662
- #elif DEBUGMODE==86 && defined(ALPHABLEND)
3663
- color= vec3f(luminanceOverAlpha);
3664
- #elif DEBUGMODE==87
3665
- color= vec3f(alpha);
3666
- #elif DEBUGMODE==88 && defined(ALBEDO)
3667
- color= vec3f(albedoTexture.a);
3668
- #elif DEBUGMODE==89
3669
- color=aoOut.ambientOcclusionColor;
3670
- #else
3671
- var stripeWidth: f32=30.;var stripePos: f32=abs(floor(input.position.x/stripeWidth));var whichColor: f32=((stripePos)%(2.));var color1: vec3f= vec3f(.6,.2,.2);var color2: vec3f= vec3f(.3,.1,.1);color=mix(color1,color2,whichColor);
3672
- #endif
3673
- color*=uniforms.vDebugMode.y;
3674
- #ifdef DEBUGMODE_NORMALIZE
3675
- color=normalize(color)*0.5+0.5;
3676
- #endif
3677
- #ifdef DEBUGMODE_GAMMA
3678
- color=toGammaSpaceVec3(color);
3679
- #endif
3680
- fragmentOutputs.color=vec4f(color,1.0);
3681
- #ifdef PREPASS
3682
- fragmentOutputs.fragData0=toLinearSpaceVec3(color);
3683
- fragmentOutputs.fragData1=vec4f(0.,0.,0.,0.);
3684
- #endif
3685
- #ifdef DEBUGMODE_FORCERETURN
3686
- return fragmentOutputs;
3687
- #endif
3688
- }
3689
- #endif
3690
- `;
3691
- // Sideeffect
3692
- ShaderStore.IncludesShadersStoreWGSL[name$1] = shader$1;
3693
-
3694
- // Do not edit.
3695
- const name = "pbrPixelShader";
3696
- const shader = `#define CUSTOM_FRAGMENT_BEGIN
3697
- #include<prePassDeclaration>[SCENE_MRT_COUNT]
3698
- #include<oitDeclaration>
3699
- #ifndef FROMLINEARSPACE
3700
- #define FROMLINEARSPACE
3701
- #endif
3702
- #include<pbrUboDeclaration>
3703
- #include<pbrFragmentExtraDeclaration>
3704
- #include<lightUboDeclaration>[0..maxSimultaneousLights]
3705
- #include<pbrFragmentSamplersDeclaration>
3706
- #include<imageProcessingDeclaration>
3707
- #include<clipPlaneFragmentDeclaration>
3708
- #include<logDepthDeclaration>
3709
- #include<fogFragmentDeclaration>
3710
- #include<helperFunctions>
3711
- #include<subSurfaceScatteringFunctions>
3712
- #include<importanceSampling>
3713
- #include<pbrHelperFunctions>
3714
- #include<imageProcessingFunctions>
3715
- #include<shadowsFragmentFunctions>
3716
- #include<harmonicsFunctions>
3717
- #include<pbrDirectLightingSetupFunctions>
3718
- #include<pbrDirectLightingFalloffFunctions>
3719
- #include<pbrBRDFFunctions>
3720
- #include<hdrFilteringFunctions>
3721
- #include<pbrDirectLightingFunctions>
3722
- #include<pbrIBLFunctions>
3723
- #include<bumpFragmentMainFunctions>
3724
- #include<bumpFragmentFunctions>
3725
- #ifdef REFLECTION
3726
- #include<reflectionFunction>
3727
- #endif
3728
- #define CUSTOM_FRAGMENT_DEFINITIONS
3729
- #include<pbrBlockAlbedoOpacity>
3730
- #include<pbrBlockReflectivity>
3731
- #include<pbrBlockAmbientOcclusion>
3732
- #include<pbrBlockAlphaFresnel>
3733
- #include<pbrBlockAnisotropic>
3734
- #include<pbrBlockReflection>
3735
- #include<pbrBlockSheen>
3736
- #include<pbrBlockClearcoat>
3737
- #include<pbrBlockIridescence>
3738
- #include<pbrBlockSubSurface>
3739
- @fragment
3740
- fn main(input: FragmentInputs)->FragmentOutputs {
3741
- #define CUSTOM_FRAGMENT_MAIN_BEGIN
3742
- #include<clipPlaneFragment>
3743
- #include<pbrBlockNormalGeometric>
3744
- #include<bumpFragment>
3745
- #include<pbrBlockNormalFinal>
3746
- var albedoOpacityOut: albedoOpacityOutParams;
3747
- #ifdef ALBEDO
3748
- var albedoTexture: vec4f=textureSample(albedoSampler,albedoSamplerSampler,fragmentInputs.vAlbedoUV+uvOffset);
3749
- #endif
3750
- #ifdef OPACITY
3751
- var opacityMap: vec4f=textureSample(opacitySampler,opacitySamplerSampler,fragmentInputs.vOpacityUV+uvOffset);
3752
- #endif
3753
- #ifdef DECAL
3754
- var decalColor: vec4f=textureSample(decalSampler,decalSamplerSampler,fragmentInputs.vDecalUV+uvOffset);
3755
- #endif
3756
- albedoOpacityOut=albedoOpacityBlock(
3757
- uniforms.vAlbedoColor
3758
- #ifdef ALBEDO
3759
- ,albedoTexture
3760
- ,uniforms.vAlbedoInfos
3761
- #endif
3762
- #ifdef OPACITY
3763
- ,opacityMap
3764
- ,uniforms.vOpacityInfos
3765
- #endif
3766
- #ifdef DETAIL
3767
- ,detailColor
3768
- ,uniforms.vDetailInfos
3769
- #endif
3770
- #ifdef DECAL
3771
- ,decalColor
3772
- ,uniforms.vDecalInfos
3773
- #endif
3774
- );var surfaceAlbedo: vec3f=albedoOpacityOut.surfaceAlbedo;var alpha: f32=albedoOpacityOut.alpha;
3775
- #define CUSTOM_FRAGMENT_UPDATE_ALPHA
3776
- #include<depthPrePass>
3777
- #define CUSTOM_FRAGMENT_BEFORE_LIGHTS
3778
- var aoOut: ambientOcclusionOutParams;
3779
- #ifdef AMBIENT
3780
- var ambientOcclusionColorMap: vec3f=textureSample(ambientSampler,ambientSamplerSampler,fragmentInputs.vAmbientUV+uvOffset).rgb;
3781
- #endif
3782
- aoOut=ambientOcclusionBlock(
3783
- #ifdef AMBIENT
3784
- ambientOcclusionColorMap,
3785
- uniforms.vAmbientInfos
3786
- #endif
3787
- );
3788
- #include<pbrBlockLightmapInit>
3789
- #ifdef UNLIT
3790
- var diffuseBase: vec3f= vec3f(1.,1.,1.);
3791
- #else
3792
- var baseColor: vec3f=surfaceAlbedo;var reflectivityOut: reflectivityOutParams;
3793
- #if defined(REFLECTIVITY)
3794
- var surfaceMetallicOrReflectivityColorMap: vec4f=textureSample(reflectivitySampler,reflectivitySamplerSampler,fragmentInputs.vReflectivityUV+uvOffset);var baseReflectivity: vec4f=surfaceMetallicOrReflectivityColorMap;
3795
- #ifndef METALLICWORKFLOW
3796
- #ifdef REFLECTIVITY_GAMMA
3797
- surfaceMetallicOrReflectivityColorMap=toLinearSpaceVec4(surfaceMetallicOrReflectivityColorMap);
3798
- #endif
3799
- surfaceMetallicOrReflectivityColorMap=vec4f(surfaceMetallicOrReflectivityColorMap.rgb*uniforms.vReflectivityInfos.y,surfaceMetallicOrReflectivityColorMap.a);
3800
- #endif
3801
- #endif
3802
- #if defined(MICROSURFACEMAP)
3803
- var microSurfaceTexel: vec4f=textureSample(microSurfaceSampler,microSurfaceSamplerSampler,fragmentInputs.vMicroSurfaceSamplerUV+uvOffset)*uniforms.vMicroSurfaceSamplerInfos.y;
3804
- #endif
3805
- #ifdef METALLICWORKFLOW
3806
- var metallicReflectanceFactors: vec4f=uniforms.vMetallicReflectanceFactors;
3807
- #ifdef REFLECTANCE
3808
- var reflectanceFactorsMap: vec4f=textureSample(reflectanceSampler,reflectanceSamplerSampler,fragmentInputs.vReflectanceUV+uvOffset);
3809
- #ifdef REFLECTANCE_GAMMA
3810
- reflectanceFactorsMap=toLinearSpaceVec4(reflectanceFactorsMap);
3811
- #endif
3812
- metallicReflectanceFactors=vec4f(metallicReflectanceFactors.rgb*reflectanceFactorsMap.rgb,metallicReflectanceFactors.a);
3813
- #endif
3814
- #ifdef METALLIC_REFLECTANCE
3815
- var metallicReflectanceFactorsMap: vec4f=textureSample(metallicReflectanceSampler,metallicReflectanceSamplerSampler,fragmentInputs.vMetallicReflectanceUV+uvOffset);
3816
- #ifdef METALLIC_REFLECTANCE_GAMMA
3817
- metallicReflectanceFactorsMap=toLinearSpaceVec4(metallicReflectanceFactorsMap);
3818
- #endif
3819
- #ifndef METALLIC_REFLECTANCE_USE_ALPHA_ONLY
3820
- metallicReflectanceFactors=vec4f(metallicReflectanceFactors.rgb*reflectanceFactorsMap.rgb,metallicReflectanceFactors.a);
3821
- #endif
3822
- metallicReflectanceFactors*=metallicReflectanceFactorsMap.a;
3823
- #endif
3824
- #endif
3825
- reflectivityOut=reflectivityBlock(
3826
- uniforms.vReflectivityColor
3827
- #ifdef METALLICWORKFLOW
3828
- ,surfaceAlbedo
3829
- ,metallicReflectanceFactors
3830
- #endif
3831
- #ifdef REFLECTIVITY
3832
- ,uniforms.vReflectivityInfos
3833
- ,surfaceMetallicOrReflectivityColorMap
3834
- #endif
3835
- #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
3836
- ,aoOut.ambientOcclusionColor
3837
- #endif
3838
- #ifdef MICROSURFACEMAP
3839
- ,microSurfaceTexel
3840
- #endif
3841
- #ifdef DETAIL
3842
- ,detailColor
3843
- ,uniforms.vDetailInfos
3844
- #endif
3845
- );var microSurface: f32=reflectivityOut.microSurface;var roughness: f32=reflectivityOut.roughness;
3846
- #ifdef METALLICWORKFLOW
3847
- surfaceAlbedo=reflectivityOut.surfaceAlbedo;
3848
- #endif
3849
- #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)
3850
- aoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;
3851
- #endif
3852
- #ifdef ALPHAFRESNEL
3853
- #if defined(ALPHATEST) || defined(ALPHABLEND)
3854
- var alphaFresnelOut: alphaFresnelOutParams;alphaFresnelOut=alphaFresnelBlock(
3855
- normalW,
3856
- viewDirectionW,
3857
- alpha,
3858
- microSurface
3859
- );alpha=alphaFresnelOut.alpha;
3860
- #endif
3861
- #endif
3862
- #include<pbrBlockGeometryInfo>
3863
- #ifdef ANISOTROPIC
3864
- var anisotropicOut: anisotropicOutParams;
3865
- #ifdef ANISOTROPIC_TEXTURE
3866
- var anisotropyMapData: vec3f=textureSample(anisotropySampler,anisotropySamplerSampler,fragmentInputs.vAnisotropyUV+uvOffset).rgb*uniforms.vAnisotropyInfos.y;
3867
- #endif
3868
- anisotropicOut=anisotropicBlock(
3869
- uniforms.vAnisotropy,
3870
- roughness,
3871
- #ifdef ANISOTROPIC_TEXTURE
3872
- anisotropyMapData,
3873
- #endif
3874
- TBN,
3875
- normalW,
3876
- viewDirectionW
3877
- );
3878
- #endif
3879
- #ifdef REFLECTION
3880
- var reflectionOut: reflectionOutParams;
3881
- #ifndef USE_CUSTOM_REFLECTION
3882
- reflectionOut=reflectionBlock(
3883
- input.vPositionW
3884
- ,normalW
3885
- ,alphaG
3886
- ,uniforms.vReflectionMicrosurfaceInfos
3887
- ,uniforms.vReflectionInfos
3888
- ,uniforms.vReflectionColor
3889
- #ifdef ANISOTROPIC
3890
- ,anisotropicOut
3891
- #endif
3892
- #if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)
3893
- ,NdotVUnclamped
3894
- #endif
3895
- #ifdef LINEARSPECULARREFLECTION
3896
- ,roughness
3897
- #endif
3898
- ,reflectionSampler
3899
- ,reflectionSamplerSampler
3900
- #if defined(NORMAL) && defined(USESPHERICALINVERTEX)
3901
- ,input.vEnvironmentIrradiance
3902
- #endif
3903
- #ifdef USESPHERICALFROMREFLECTIONMAP
3904
- #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
3905
- ,uniforms.reflectionMatrix
3906
- #endif
3907
- #endif
3908
- #ifdef USEIRRADIANCEMAP
3909
- ,irradianceSampler
3910
- ,irradianceSamplerSampler
3911
- #endif
3912
- #ifndef LODBASEDMICROSFURACE
3913
- ,reflectionLowSampler
3914
- ,reflectionLowSamplerSampler
3915
- ,reflectionHighSampler
3916
- ,reflectionHighSamplerSampler
3917
- #endif
3918
- #ifdef REALTIME_FILTERING
3919
- ,uniforms.vReflectionFilteringInfo
3920
- #endif
3921
- );
3922
- #else
3923
- #define CUSTOM_REFLECTION
3924
- #endif
3925
- #endif
3926
- #include<pbrBlockReflectance0>
3927
- #ifdef SHEEN
3928
- var sheenOut: sheenOutParams;
3929
- #ifdef SHEEN_TEXTURE
3930
- var sheenMapData: vec4f=textureSample(sheenSampler,sheenSamplerSampler,fragmentInputs.vSheenUV+uvOffset);
3931
- #endif
3932
- #if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
3933
- var sheenMapRoughnessData: vec4f=textureSample(sheenRoughnessSampler,sheenRoughnessSamplerSampler,fragmentInputs.vSheenRoughnessUV+uvOffset)*uniforms.vSheenInfos.w;
3934
- #endif
3935
- sheenOut=sheenBlock(
3936
- uniforms.vSheenColor
3937
- #ifdef SHEEN_ROUGHNESS
3938
- ,uniforms.vSheenRoughness
3939
- #if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)
3940
- ,sheenMapRoughnessData
3941
- #endif
3942
- #endif
3943
- ,roughness
3944
- #ifdef SHEEN_TEXTURE
3945
- ,sheenMapData
3946
- ,uniforms.vSheenInfos.y
3947
- #endif
3948
- ,reflectance
3949
- #ifdef SHEEN_LINKWITHALBEDO
3950
- ,baseColor
3951
- ,surfaceAlbedo
3952
- #endif
3953
- #ifdef ENVIRONMENTBRDF
3954
- ,NdotV
3955
- ,environmentBrdf
3956
- #endif
3957
- #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)
3958
- ,AARoughnessFactors
3959
- ,uniforms.vReflectionMicrosurfaceInfos
3960
- ,uniforms.vReflectionInfos
3961
- ,uniforms.vReflectionColor
3962
- ,uniforms.vLightingIntensity
3963
- ,reflectionSampler
3964
- ,reflectionSamplerSampler
3965
- ,reflectionOut.reflectionCoords
3966
- ,NdotVUnclamped
3967
- #ifndef LODBASEDMICROSFURACE
3968
- ,reflectionLowSampler
3969
- ,reflectionLowSamplerSampler
3970
- ,reflectionHighSampler
3971
- ,reflectionHighSamplerSampler
3972
- #endif
3973
- #ifdef REALTIME_FILTERING
3974
- ,vReflectionFilteringInfo
3975
- #endif
3976
- #if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)
3977
- ,seo
3978
- #endif
3979
- #if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)
3980
- ,eho
3981
- #endif
3982
- #endif
3983
- );
3984
- #ifdef SHEEN_LINKWITHALBEDO
3985
- surfaceAlbedo=sheenOut.surfaceAlbedo;
3986
- #endif
3987
- #endif
3988
- #ifdef CLEARCOAT
3989
- #ifdef CLEARCOAT_TEXTURE
3990
- var clearCoatMapData: vec2f=textureSample(clearCoatSampler,clearCoatSamplerSampler,fragmentInputs.vClearCoatUV+uvOffset).rg*uniforms.vClearCoatInfos.y;
3991
- #endif
3992
- #endif
3993
- #ifdef IRIDESCENCE
3994
- var iridescenceOut: iridescenceOutParams;
3995
- #ifdef IRIDESCENCE_TEXTURE
3996
- var iridescenceMapData: vec2f=textureSample(iridescenceSampler,iridescenceSamplerSampler,fragmentInputs.vIridescenceUV+uvOffset).rg*vIridescenceInfos.y;
3997
- #endif
3998
- #ifdef IRIDESCENCE_THICKNESS_TEXTURE
3999
- var iridescenceThicknessMapData: vec2f=textureSample(iridescenceThicknessSampler,iridescenceThicknessSamplerSampler,fragmentInputs.vIridescenceThicknessUV+uvOffset).rg*vIridescenceInfos.w;
4000
- #endif
4001
- iridescenceOut=iridescenceBlock(
4002
- uniforms.vIridescenceParams
4003
- ,NdotV
4004
- ,specularEnvironmentR0
4005
- #ifdef IRIDESCENCE_TEXTURE
4006
- ,iridescenceMapData
4007
- #endif
4008
- #ifdef IRIDESCENCE_THICKNESS_TEXTURE
4009
- ,iridescenceThicknessMapData
4010
- #endif
4011
- #ifdef CLEARCOAT
4012
- ,NdotVUnclamped
4013
- #ifdef CLEARCOAT_TEXTURE
4014
- ,clearCoatMapData
4015
- #endif
4016
- #endif
4017
- );var iridescenceIntensity: f32=iridescenceOut.iridescenceIntensity;specularEnvironmentR0=iridescenceOut.specularEnvironmentR0;
4018
- #endif
4019
- var clearcoatOut: clearcoatOutParams;
4020
- #ifdef CLEARCOAT
4021
- #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
4022
- var clearCoatMapRoughnessData: vec4f=textureSample(clearCoatRoughnessSampler,clearCoatRoughnessSamplerSampler,fragmentInputs.vClearCoatRoughnessUV+uvOffset)*uniforms.vClearCoatInfos.w;
4023
- #endif
4024
- #if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)
4025
- var clearCoatTintMapData: vec4f=textureSample(clearCoatTintSampler,clearCoatTintSamplerSampler,fragmentInputs.vClearCoatTintUV+uvOffset);
4026
- #endif
4027
- #ifdef CLEARCOAT_BUMP
4028
- var clearCoatBumpMapData: vec4f=textureSample(clearCoatBumpSampler,clearCoatBumpSamplerSampler,fragmentInputs.vClearCoatBumpUV+uvOffset);
4029
- #endif
4030
- clearcoatOut=clearcoatBlock(
4031
- input.vPositionW
4032
- ,geometricNormalW
4033
- ,viewDirectionW
4034
- ,uniforms.vClearCoatParams
4035
- #if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)
4036
- ,clearCoatMapRoughnessData
4037
- #endif
4038
- ,specularEnvironmentR0
4039
- #ifdef CLEARCOAT_TEXTURE
4040
- ,clearCoatMapData
4041
- #endif
4042
- #ifdef CLEARCOAT_TINT
4043
- ,uniforms.vClearCoatTintParams
4044
- ,uniforms.clearCoatColorAtDistance
4045
- ,uniforms.vClearCoatRefractionParams
4046
- #ifdef CLEARCOAT_TINT_TEXTURE
4047
- ,clearCoatTintMapData
4048
- #endif
4049
- #endif
4050
- #ifdef CLEARCOAT_BUMP
4051
- ,uniforms.vClearCoatBumpInfos
4052
- ,clearCoatBumpMapData
4053
- ,fragmentInputs.vClearCoatBumpUV
4054
- #if defined(TANGENT) && defined(NORMAL)
4055
- ,vTBN
4056
- #else
4057
- ,uniforms.vClearCoatTangentSpaceParams
4058
- #endif
4059
- #ifdef OBJECTSPACE_NORMALMAP
4060
- ,uniforms.normalMatrix
4061
- #endif
4062
- #endif
4063
- #if defined(FORCENORMALFORWARD) && defined(NORMAL)
4064
- ,faceNormal
4065
- #endif
4066
- #ifdef REFLECTION
4067
- ,uniforms.vReflectionMicrosurfaceInfos
4068
- ,uniforms.vReflectionInfos
4069
- ,uniforms.vReflectionColor
4070
- ,uniforms.vLightingIntensity
4071
- ,reflectionSampler
4072
- ,reflectionSamplerSampler
4073
- #ifndef LODBASEDMICROSFURACE
4074
- ,reflectionLowSampler
4075
- ,reflectionLowSamplerSampler
4076
- ,reflectionHighSampler
4077
- ,reflectionHighSamplerSampler
4078
- #endif
4079
- #ifdef REALTIME_FILTERING
4080
- ,uniforms.vReflectionFilteringInfo
4081
- #endif
4082
- #endif
4083
- #if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)
4084
- #ifdef RADIANCEOCCLUSION
4085
- ,ambientMonochrome
4086
- #endif
4087
- #endif
4088
- #if defined(CLEARCOAT_BUMP) || defined(TWOSIDEDLIGHTING)
4089
- ,select(-1.,1.,fragmentInputs.frontFacing)
4090
- #endif
4091
- );
4092
- #else
4093
- clearcoatOut.specularEnvironmentR0=specularEnvironmentR0;
4094
- #endif
4095
- #include<pbrBlockReflectance>
4096
- var subSurfaceOut: subSurfaceOutParams;
4097
- #ifdef SUBSURFACE
4098
- #ifdef SS_THICKNESSANDMASK_TEXTURE
4099
- var thicknessMap: vec4f=textureSample(thicknessSampler,thicknessSamplerSampler,fragmentInputs.vThicknessUV+uvOffset);
4100
- #endif
4101
- #ifdef SS_REFRACTIONINTENSITY_TEXTURE
4102
- var refractionIntensityMap: vec4f=textureSample(refractionIntensitySampler,refractionIntensitySamplerSampler,fragmentInputs.vRefractionIntensityUV+uvOffset);
4103
- #endif
4104
- #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
4105
- var translucencyIntensityMap: vec4f=textureSample(translucencyIntensitySampler,translucencyIntensitySamplerSampler,fragmentInputs.vTranslucencyIntensityUV+uvOffset);
4106
- #endif
4107
- #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
4108
- var translucencyColorMap: vec4f=textureSample(translucencyColorSampler,translucencyColorSamplerSampler,fragmentInputs.vTranslucencyColorUV+uvOffset);
4109
- #endif
4110
- subSurfaceOut=subSurfaceBlock(
4111
- uniforms.vSubSurfaceIntensity
4112
- ,uniforms.vThicknessParam
4113
- ,uniforms.vTintColor
4114
- ,normalW
4115
- ,specularEnvironmentReflectance
4116
- #ifdef SS_THICKNESSANDMASK_TEXTURE
4117
- ,thicknessMap
4118
- #endif
4119
- #ifdef SS_REFRACTIONINTENSITY_TEXTURE
4120
- ,refractionIntensityMap
4121
- #endif
4122
- #ifdef SS_TRANSLUCENCYINTENSITY_TEXTURE
4123
- ,translucencyIntensityMap
4124
- #endif
4125
- #ifdef REFLECTION
4126
- #ifdef SS_TRANSLUCENCY
4127
- ,uniforms.reflectionMatrix
4128
- #ifdef USESPHERICALFROMREFLECTIONMAP
4129
- #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)
4130
- ,reflectionOut.irradianceVector
4131
- #endif
4132
- #if defined(REALTIME_FILTERING)
4133
- ,reflectionSampler
4134
- ,reflectionSamplerSampler
4135
- ,vReflectionFilteringInfo
4136
- #endif
4137
- #endif
4138
- #ifdef USEIRRADIANCEMAP
4139
- ,irradianceSampler
4140
- ,irradianceSamplerSampler
4141
- #endif
4142
- #endif
4143
- #endif
4144
- #if defined(SS_REFRACTION) || defined(SS_TRANSLUCENCY)
4145
- ,surfaceAlbedo
4146
- #endif
4147
- #ifdef SS_REFRACTION
4148
- ,input.vPositionW
4149
- ,viewDirectionW
4150
- ,scene.view
4151
- ,uniforms.vRefractionInfos
4152
- ,uniforms.refractionMatrix
4153
- ,uniforms.vRefractionMicrosurfaceInfos
4154
- ,uniforms.vLightingIntensity
4155
- #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
4156
- ,alpha
4157
- #endif
4158
- #ifdef SS_LODINREFRACTIONALPHA
4159
- ,NdotVUnclamped
4160
- #endif
4161
- #ifdef SS_LINEARSPECULARREFRACTION
4162
- ,roughness
4163
- #endif
4164
- ,alphaG
4165
- ,refractionSampler
4166
- ,refractionSamplerSampler
4167
- #ifndef LODBASEDMICROSFURACE
4168
- ,refractionLowSampler
4169
- ,refractionLowSamplerSampler
4170
- ,refractionHighSampler
4171
- ,refractionHighSamplerSampler
4172
- #endif
4173
- #ifdef ANISOTROPIC
4174
- ,anisotropicOut
4175
- #endif
4176
- #ifdef REALTIME_FILTERING
4177
- ,uniforms.vRefractionFilteringInfo
4178
- #endif
4179
- #ifdef SS_USE_LOCAL_REFRACTIONMAP_CUBIC
4180
- ,uniforms.vRefractionPosition
4181
- ,uniforms.vRefractionSize
4182
- #endif
4183
- #ifdef SS_DISPERSION
4184
- ,dispersion
4185
- #endif
4186
- #endif
4187
- #ifdef SS_TRANSLUCENCY
4188
- ,uniforms.vDiffusionDistance
4189
- ,uniforms.vTranslucencyColor
4190
- #ifdef SS_TRANSLUCENCYCOLOR_TEXTURE
4191
- ,translucencyColorMap
4192
- #endif
4193
- #endif
4194
- );
4195
- #ifdef SS_REFRACTION
4196
- surfaceAlbedo=subSurfaceOut.surfaceAlbedo;
4197
- #ifdef SS_LINKREFRACTIONTOTRANSPARENCY
4198
- alpha=subSurfaceOut.alpha;
4199
- #endif
4200
- #endif
4201
- #else
4202
- subSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;
4203
- #endif
4204
- #include<pbrBlockDirectLighting>
4205
- #include<lightFragment>[0..maxSimultaneousLights]
4206
- #include<pbrBlockFinalLitComponents>
4207
- #endif
4208
- #include<pbrBlockFinalUnlitComponents>
4209
- #define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION
4210
- #include<pbrBlockFinalColorComposition>
4211
- #include<logDepthFragment>
4212
- #include<fogFragment>(color,finalColor)
4213
- #include<pbrBlockImageProcessing>
4214
- #define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR
4215
- #ifdef PREPASS
4216
- var writeGeometryInfo: f32=select(0.0,1.0,finalColor.a>0.4);var fragData: array<vec4<f32>,SCENE_MRT_COUNT>;
4217
- #ifdef PREPASS_POSITION
4218
- fragData[PREPASS_POSITION_INDEX]= vec4f(input.vPositionW,writeGeometryInfo);
4219
- #endif
4220
- #ifdef PREPASS_VELOCITY
4221
- var a: vec2f=(fragmentInputs.vCurrentPosition.xy/fragmentInputs.vCurrentPosition.w)*0.5+0.5;var b: vec2f=(fragmentInputs.vPreviousPosition.xy/fragmentInputs.vPreviousPosition.w)*0.5+0.5;var velocity: vec2f=abs(a-b);velocity= vec2f(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;fragData[PREPASS_VELOCITY_INDEX]= vec4f(velocity,0.0,writeGeometryInfo);
4222
- #elif defined(PREPASS_VELOCITY_LINEAR)
4223
- var velocity : vec2f=vec2f(0.5)*((fragmentInputs.vPreviousPosition.xy /
4224
- fragmentInputs.vPreviousPosition.w) -
4225
- (fragmentInputs.vCurrentPosition.xy /
4226
- fragmentInputs.vCurrentPosition.w));fragData[PREPASS_VELOCITY_LINEAR_INDEX] =
4227
- vec4f(velocity,0.0,writeGeometryInfo);
4228
- #endif
4229
- #ifdef PREPASS_ALBEDO_SQRT
4230
- var sqAlbedo : vec3f=sqrt(surfaceAlbedo);
4231
- #endif
4232
- #ifdef PREPASS_IRRADIANCE
4233
- var irradiance : vec3f=finalDiffuse;
4234
- #ifndef UNLIT
4235
- #ifdef REFLECTION
4236
- irradiance+=finalIrradiance;
4237
- #endif
4238
- #endif
4239
- #ifdef SS_SCATTERING
4240
- fragData[0]=vec4f(finalColor.rgb-irradiance,
4241
- finalColor.a);
4242
- irradiance/=sqAlbedo;
4243
- #else
4244
- fragData[0]=finalColor;
4245
- var scatteringDiffusionProfile : f32=255.;
4246
- #endif
4247
- fragData[PREPASS_IRRADIANCE_INDEX] =
4248
- vec4f(clamp(irradiance,vec3f(0.),vec3f(1.)),
4249
- writeGeometryInfo*scatteringDiffusionProfile /
4250
- 255.);
4251
- #else
4252
- fragData[0]=vec4f(finalColor.rgb,finalColor.a);
4253
- #endif
4254
- #ifdef PREPASS_DEPTH
4255
- fragData[PREPASS_DEPTH_INDEX]=vec4f(fragmentInputs.vViewPos.z,0.0,0.0,
4256
- writeGeometryInfo);
4257
- #endif
4258
- #ifdef PREPASS_NORMAL
4259
- #ifdef PREPASS_NORMAL_WORLDSPACE
4260
- fragData[PREPASS_NORMAL_INDEX] =
4261
- vec4f(normalW,writeGeometryInfo);
4262
- #else
4263
- fragData[PREPASS_NORMAL_INDEX] =
4264
- vec4f(normalize((scene.view*vec4f(normalW,0.0)).rgb),
4265
- writeGeometryInfo);
4266
- #endif
4267
- #endif
4268
- #ifdef PREPASS_ALBEDO_SQRT
4269
- fragData[PREPASS_ALBEDO_SQRT_INDEX] =
4270
- vec4f(sqAlbedo,writeGeometryInfo);
4271
- #endif
4272
- #ifdef PREPASS_REFLECTIVITY
4273
- #ifndef UNLIT
4274
- fragData[PREPASS_REFLECTIVITY_INDEX] =
4275
- vec4f(specularEnvironmentR0,microSurface)*writeGeometryInfo;
4276
- #else
4277
- fragData[PREPASS_REFLECTIVITY_INDEX] =
4278
- vec4f(0.0,0.0,0.0,1.0)*writeGeometryInfo;
4279
- #endif
4280
- #endif
4281
- #if SCENE_MRT_COUNT>0
4282
- fragmentOutputs.fragData0=fragData[0];
4283
- #endif
4284
- #if SCENE_MRT_COUNT>1
4285
- fragmentOutputs.fragData1=fragData[1];
4286
- #endif
4287
- #if SCENE_MRT_COUNT>2
4288
- fragmentOutputs.fragData2=fragData[2];
4289
- #endif
4290
- #if SCENE_MRT_COUNT>3
4291
- fragmentOutputs.fragData3=fragData[3];
4292
- #endif
4293
- #if SCENE_MRT_COUNT>4
4294
- fragmentOutputs.fragData4=fragData[4];
4295
- #endif
4296
- #if SCENE_MRT_COUNT>5
4297
- fragmentOutputs.fragData5=fragData[5];
4298
- #endif
4299
- #if SCENE_MRT_COUNT>6
4300
- fragmentOutputs.fragData6=fragData[6];
4301
- #endif
4302
- #if SCENE_MRT_COUNT>7
4303
- fragmentOutputs.fragData7=fragData[7];
4304
- #endif
4305
- #endif
4306
- #if !defined(PREPASS) && !defined(ORDER_INDEPENDENT_TRANSPARENCY)
4307
- fragmentOutputs.color=finalColor;
4308
- #endif
4309
- #include<oitFragment>
4310
- #if ORDER_INDEPENDENT_TRANSPARENCY
4311
- if (fragDepth==nearestDepth) {fragmentOutputs.frontColor=vec4f(fragmentOutputs.frontColor.rgb+finalColor.rgb*finalColor.a*alphaMultiplier,1.0-alphaMultiplier*(1.0-finalColor.a));} else {fragmentOutputs.backColor+=finalColor;}
4312
- #endif
4313
- #include<pbrDebug>
4314
- #define CUSTOM_FRAGMENT_MAIN_END
4315
- }
4316
- `;
4317
- // Sideeffect
4318
- ShaderStore.ShadersStoreWGSL[name] = shader;
4319
- /** @internal */
4320
- const pbrPixelShaderWGSL = { name, shader };
4321
-
4322
- export { pbrPixelShaderWGSL };
4323
- //# sourceMappingURL=pbr.fragment-QxF1RFoh.esm.js.map