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