@zephyr3d/scene 0.9.5 → 0.9.7

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 (621) hide show
  1. package/dist/animation/joint_dynamics/controller.js +92 -32
  2. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  3. package/dist/animation/joint_dynamics/convex_collider.js +320 -0
  4. package/dist/animation/joint_dynamics/convex_collider.js.map +1 -0
  5. package/dist/animation/joint_dynamics/joint_dynamics_system.js +57 -19
  6. package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
  7. package/dist/animation/joint_dynamics/solver.js +71 -27
  8. package/dist/animation/joint_dynamics/solver.js.map +1 -1
  9. package/dist/animation/joint_dynamics_modifier.js +21 -20
  10. package/dist/animation/joint_dynamics_modifier.js.map +1 -1
  11. package/dist/animation/skeleton.js +7 -10
  12. package/dist/animation/skeleton.js.map +1 -1
  13. package/dist/app/engine.js +134 -140
  14. package/dist/app/engine.js.map +1 -1
  15. package/dist/app/scriptregistry.js +47 -16
  16. package/dist/app/scriptregistry.js.map +1 -1
  17. package/dist/asset/assetmanager.js +3 -1
  18. package/dist/asset/assetmanager.js.map +1 -1
  19. package/dist/asset/model.js +346 -7
  20. package/dist/asset/model.js.map +1 -1
  21. package/dist/avatar/wardrobe.js +20 -16
  22. package/dist/avatar/wardrobe.js.map +1 -1
  23. package/dist/camera/camera.js +416 -210
  24. package/dist/camera/camera.js.map +1 -1
  25. package/dist/index.d.ts +1350 -621
  26. package/dist/index.js +6 -11
  27. package/dist/index.js.map +1 -1
  28. package/dist/material/blinn.js +1 -1
  29. package/dist/material/blinn.js.map +1 -1
  30. package/dist/material/lambert.js +1 -1
  31. package/dist/material/lambert.js.map +1 -1
  32. package/dist/material/material.js +23 -1
  33. package/dist/material/material.js.map +1 -1
  34. package/dist/material/meshmaterial.js +178 -23
  35. package/dist/material/meshmaterial.js.map +1 -1
  36. package/dist/material/mixins/albedocolor.js +4 -4
  37. package/dist/material/mixins/albedocolor.js.map +1 -1
  38. package/dist/material/mixins/lightmodel/blinnphong.js +2 -1
  39. package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
  40. package/dist/material/mixins/lightmodel/lambert.js +2 -1
  41. package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
  42. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +63 -16
  43. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
  44. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +105 -32
  45. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  46. package/dist/material/mixins/lightmodel/pbrspecularglossness.js +16 -6
  47. package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
  48. package/dist/material/mixins/lit.js +1 -1
  49. package/dist/material/mixins/lit.js.map +1 -1
  50. package/dist/material/mixins/pbr/common.js +276 -65
  51. package/dist/material/mixins/pbr/common.js.map +1 -1
  52. package/dist/material/mixins/texture.js +3 -3
  53. package/dist/material/mixins/texture.js.map +1 -1
  54. package/dist/material/mixins/vertexcolor.js +2 -2
  55. package/dist/material/mixins/vertexcolor.js.map +1 -1
  56. package/dist/material/msdf_text.js +3 -3
  57. package/dist/material/msdf_text.js.map +1 -1
  58. package/dist/material/mtoon.js +574 -0
  59. package/dist/material/mtoon.js.map +1 -0
  60. package/dist/material/pbrblueprint.js +499 -336
  61. package/dist/material/pbrblueprint.js.map +1 -1
  62. package/dist/material/pbrmr.js +118 -100
  63. package/dist/material/pbrmr.js.map +1 -1
  64. package/dist/material/pbrsg.js +1 -1
  65. package/dist/material/pbrsg.js.map +1 -1
  66. package/dist/material/shader/helper.js +324 -294
  67. package/dist/material/shader/helper.js.map +1 -1
  68. package/dist/material/subsurfaceprofile.js +812 -0
  69. package/dist/material/subsurfaceprofile.js.map +1 -0
  70. package/dist/material/unlit.js +1 -1
  71. package/dist/material/unlit.js.map +1 -1
  72. package/dist/posteffect/compositor.js +46 -11
  73. package/dist/posteffect/compositor.js.map +1 -1
  74. package/dist/posteffect/ssr.js +422 -96
  75. package/dist/posteffect/ssr.js.map +1 -1
  76. package/dist/posteffect/sss.js +1053 -0
  77. package/dist/posteffect/sss.js.map +1 -0
  78. package/dist/posteffect/taa.js +61 -60
  79. package/dist/posteffect/taa.js.map +1 -1
  80. package/dist/render/abuffer_oit.js +63 -12
  81. package/dist/render/abuffer_oit.js.map +1 -1
  82. package/dist/render/cluster_light.js +6 -5
  83. package/dist/render/cluster_light.js.map +1 -1
  84. package/dist/render/drawable.js +1 -5
  85. package/dist/render/drawable.js.map +1 -1
  86. package/dist/render/drawable_mixin.js +2 -1
  87. package/dist/render/drawable_mixin.js.map +1 -1
  88. package/dist/render/fbm_wavegenerator.js +2 -1
  89. package/dist/render/fbm_wavegenerator.js.map +1 -1
  90. package/dist/render/gerstner_wavegenerator.js +2 -1
  91. package/dist/render/gerstner_wavegenerator.js.map +1 -1
  92. package/dist/render/globalbindgroup_allocator.js +2 -1
  93. package/dist/render/globalbindgroup_allocator.js.map +1 -1
  94. package/dist/render/lightpass.js +110 -23
  95. package/dist/render/lightpass.js.map +1 -1
  96. package/dist/render/render_queue.js +51 -8
  97. package/dist/render/render_queue.js.map +1 -1
  98. package/dist/render/renderer.js +80 -66
  99. package/dist/render/renderer.js.map +1 -1
  100. package/dist/render/rendergraph/device_pool_allocator.js +8 -0
  101. package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
  102. package/dist/render/rendergraph/forward_plus_builder.js +481 -95
  103. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
  104. package/dist/render/rendergraph/history_resource_manager.js +55 -0
  105. package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
  106. package/dist/render/rendergraph/history_resources.js +3 -1
  107. package/dist/render/rendergraph/history_resources.js.map +1 -1
  108. package/dist/render/rendergraph/types.js.map +1 -1
  109. package/dist/render/renderpass.js +10 -4
  110. package/dist/render/renderpass.js.map +1 -1
  111. package/dist/render/sky.js +31 -1
  112. package/dist/render/sky.js.map +1 -1
  113. package/dist/render/weightedblended_oit.js +23 -5
  114. package/dist/render/weightedblended_oit.js.map +1 -1
  115. package/dist/scene/basesprite.js +4 -2
  116. package/dist/scene/basesprite.js.map +1 -1
  117. package/dist/scene/batchgroup.js +3 -1
  118. package/dist/scene/batchgroup.js.map +1 -1
  119. package/dist/scene/environment.js +11 -1
  120. package/dist/scene/environment.js.map +1 -1
  121. package/dist/scene/light.js +21 -3
  122. package/dist/scene/light.js.map +1 -1
  123. package/dist/scene/mesh.js +29 -14
  124. package/dist/scene/mesh.js.map +1 -1
  125. package/dist/scene/meshdrawable.js +6 -0
  126. package/dist/scene/meshdrawable.js.map +1 -1
  127. package/dist/scene/msdftext.js +5 -2
  128. package/dist/scene/msdftext.js.map +1 -1
  129. package/dist/scene/msdftextsprite.js +5 -3
  130. package/dist/scene/msdftextsprite.js.map +1 -1
  131. package/dist/scene/particlesys.js +3 -1
  132. package/dist/scene/particlesys.js.map +1 -1
  133. package/dist/scene/scene.js +6 -5
  134. package/dist/scene/scene.js.map +1 -1
  135. package/dist/scene/terrain-cm/grass.js +4 -2
  136. package/dist/scene/terrain-cm/grass.js.map +1 -1
  137. package/dist/scene/terrain-cm/grassmaterial.js +2 -1
  138. package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
  139. package/dist/scene/terrain-cm/terrain-cm.js +4 -2
  140. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  141. package/dist/scene/water.js +4 -2
  142. package/dist/scene/water.js.map +1 -1
  143. package/dist/shaders/shadow.js +26 -393
  144. package/dist/shaders/shadow.js.map +1 -1
  145. package/dist/shadow/esm.js +112 -12
  146. package/dist/shadow/esm.js.map +1 -1
  147. package/dist/shadow/pcf_opt.js +2 -2
  148. package/dist/shadow/pcf_opt.js.map +1 -1
  149. package/dist/shadow/pcf_pd.js +19 -10
  150. package/dist/shadow/pcf_pd.js.map +1 -1
  151. package/dist/shadow/shader.js +58 -7
  152. package/dist/shadow/shader.js.map +1 -1
  153. package/dist/shadow/shadow_impl.js +6 -0
  154. package/dist/shadow/shadow_impl.js.map +1 -1
  155. package/dist/shadow/shadow_region.js +229 -0
  156. package/dist/shadow/shadow_region.js.map +1 -0
  157. package/dist/shadow/shadowmapper.js +67 -59
  158. package/dist/shadow/shadowmapper.js.map +1 -1
  159. package/dist/shadow/vsm.js +45 -19
  160. package/dist/shadow/vsm.js.map +1 -1
  161. package/dist/text/font/cff_font.js +890 -0
  162. package/dist/text/font/cff_font.js.map +1 -0
  163. package/dist/text/font/font_asset.js +17 -3
  164. package/dist/text/font/font_asset.js.map +1 -1
  165. package/dist/utility/blueprint/common/constants.js +8 -8
  166. package/dist/utility/blueprint/common/constants.js.map +1 -1
  167. package/dist/utility/blueprint/material/pbr.js +31 -4
  168. package/dist/utility/blueprint/material/pbr.js.map +1 -1
  169. package/dist/utility/blueprint/material/texture.js +1 -17
  170. package/dist/utility/blueprint/material/texture.js.map +1 -1
  171. package/dist/utility/serialization/manager.js +327 -359
  172. package/dist/utility/serialization/manager.js.map +1 -1
  173. package/dist/utility/serialization/scene/animation.js +5 -2
  174. package/dist/utility/serialization/scene/animation.js.map +1 -1
  175. package/dist/utility/serialization/scene/batch.js +4 -1
  176. package/dist/utility/serialization/scene/batch.js.map +1 -1
  177. package/dist/utility/serialization/scene/camera.js +249 -54
  178. package/dist/utility/serialization/scene/camera.js.map +1 -1
  179. package/dist/utility/serialization/scene/common.js +37 -1
  180. package/dist/utility/serialization/scene/common.js.map +1 -1
  181. package/dist/utility/serialization/scene/light.js +42 -3
  182. package/dist/utility/serialization/scene/light.js.map +1 -1
  183. package/dist/utility/serialization/scene/material.js +1112 -646
  184. package/dist/utility/serialization/scene/material.js.map +1 -1
  185. package/dist/utility/serialization/scene/mesh.js +7 -4
  186. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  187. package/dist/utility/serialization/scene/node.js +31 -12
  188. package/dist/utility/serialization/scene/node.js.map +1 -1
  189. package/dist/utility/serialization/scene/particle.js +4 -1
  190. package/dist/utility/serialization/scene/particle.js.map +1 -1
  191. package/dist/utility/serialization/scene/primitive.js +3 -1
  192. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  193. package/dist/utility/serialization/scene/scene.js +18 -0
  194. package/dist/utility/serialization/scene/scene.js.map +1 -1
  195. package/dist/utility/serialization/scene/sprite.js +6 -3
  196. package/dist/utility/serialization/scene/sprite.js.map +1 -1
  197. package/dist/utility/serialization/scene/terrain.js +5 -2
  198. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  199. package/dist/utility/serialization/scene/text.js +3 -1
  200. package/dist/utility/serialization/scene/text.js.map +1 -1
  201. package/dist/utility/serialization/scene/water.js +4 -1
  202. package/dist/utility/serialization/scene/water.js.map +1 -1
  203. package/dist/utility/textures/ltcdata.js +6 -0
  204. package/dist/utility/textures/ltcdata.js.map +1 -0
  205. package/dist/utility/textures/ltclut.js +61 -0
  206. package/dist/utility/textures/ltclut.js.map +1 -0
  207. package/dist/values.js +9 -1
  208. package/dist/values.js.map +1 -1
  209. package/package.json +3 -3
  210. package/dist/animation/ik/ik_chain_builder.js +0 -68
  211. package/dist/animation/ik/ik_chain_builder.js.map +0 -1
  212. package/dist/animation/ik/ik_pole_constraint.js +0 -123
  213. package/dist/animation/ik/ik_pole_constraint.js.map +0 -1
  214. package/dist/animation/ik/ik_track.js +0 -96
  215. package/dist/animation/ik/ik_track.js.map +0 -1
  216. package/dist/animation/ik_postprocessor.js +0 -71
  217. package/dist/animation/ik_postprocessor.js.map +0 -1
  218. package/dist/animation/joint_dynamics/math.js +0 -16
  219. package/dist/animation/joint_dynamics/math.js.map +0 -1
  220. package/dist/animation/manual_transform_processor.js +0 -156
  221. package/dist/animation/manual_transform_processor.js.map +0 -1
  222. package/dist/animation/skeleton_postprocessor.js +0 -50
  223. package/dist/animation/skeleton_postprocessor.js.map +0 -1
  224. package/dist/animation/spring2/collision.js +0 -469
  225. package/dist/animation/spring2/collision.js.map +0 -1
  226. package/dist/animation/spring2/constraints.js +0 -329
  227. package/dist/animation/spring2/constraints.js.map +0 -1
  228. package/dist/animation/spring2/controller.js +0 -434
  229. package/dist/animation/spring2/controller.js.map +0 -1
  230. package/dist/animation/spring2/math.js +0 -16
  231. package/dist/animation/spring2/math.js.map +0 -1
  232. package/dist/animation/spring2/solver.js +0 -624
  233. package/dist/animation/spring2/solver.js.map +0 -1
  234. package/dist/animation/spring2/spring_system.js +0 -118
  235. package/dist/animation/spring2/spring_system.js.map +0 -1
  236. package/dist/animation/spring2/types.js +0 -19
  237. package/dist/animation/spring2/types.js.map +0 -1
  238. package/dist/animation/spring_postprocessor.js +0 -54
  239. package/dist/animation/spring_postprocessor.js.map +0 -1
  240. package/dist/asset/loaders/gltf/gltf_loader.js +0 -1276
  241. package/dist/asset/loaders/gltf/gltf_loader.js.map +0 -1
  242. package/dist/asset/loaders/gltf/helpers.js +0 -331
  243. package/dist/asset/loaders/gltf/helpers.js.map +0 -1
  244. package/dist/material/sprite3d.js +0 -301
  245. package/dist/material/sprite3d.js.map +0 -1
  246. package/dist/material/sprite3d_std.js +0 -116
  247. package/dist/material/sprite3d_std.js.map +0 -1
  248. package/dist/material/sprite3dblueprint.js +0 -235
  249. package/dist/material/sprite3dblueprint.js.map +0 -1
  250. package/dist/material/sprite_sdf.js +0 -106
  251. package/dist/material/sprite_sdf.js.map +0 -1
  252. package/dist/material/terrainmaterial.js +0 -368
  253. package/dist/material/terrainmaterial.js.map +0 -1
  254. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
  255. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
  256. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
  257. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
  258. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
  259. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
  260. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
  261. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
  262. package/dist/render/deferredlightpass.js +0 -510
  263. package/dist/render/deferredlightpass.js.map +0 -1
  264. package/dist/render/deferredshadowlightpass.js +0 -428
  265. package/dist/render/deferredshadowlightpass.js.map +0 -1
  266. package/dist/render/gbufferpass.js +0 -50
  267. package/dist/render/gbufferpass.js.map +0 -1
  268. package/dist/scene/sdftextsprite.js +0 -322
  269. package/dist/scene/sdftextsprite.js.map +0 -1
  270. package/dist/scene/sprite3d.js +0 -18
  271. package/dist/scene/sprite3d.js.map +0 -1
  272. package/dist/scene/terrain/grass.js +0 -280
  273. package/dist/scene/terrain/grass.js.map +0 -1
  274. package/dist/scene/terrain/heightfield.js +0 -475
  275. package/dist/scene/terrain/heightfield.js.map +0 -1
  276. package/dist/scene/terrain/patch.js +0 -532
  277. package/dist/scene/terrain/patch.js.map +0 -1
  278. package/dist/scene/terrain/quadtree.js +0 -461
  279. package/dist/scene/terrain/quadtree.js.map +0 -1
  280. package/dist/scene/terrain/terrain.js +0 -231
  281. package/dist/scene/terrain/terrain.js.map +0 -1
  282. package/dist/src/animation/animation.js +0 -127
  283. package/dist/src/animation/animation.js.map +0 -1
  284. package/dist/src/animation/animationset.js +0 -255
  285. package/dist/src/animation/animationset.js.map +0 -1
  286. package/dist/src/animation/animationtrack.js +0 -34
  287. package/dist/src/animation/animationtrack.js.map +0 -1
  288. package/dist/src/animation/eulerrotationtrack.js +0 -52
  289. package/dist/src/animation/eulerrotationtrack.js.map +0 -1
  290. package/dist/src/animation/morphtarget.js +0 -93
  291. package/dist/src/animation/morphtarget.js.map +0 -1
  292. package/dist/src/animation/morphtrack.js +0 -70
  293. package/dist/src/animation/morphtrack.js.map +0 -1
  294. package/dist/src/animation/proptrack.js +0 -161
  295. package/dist/src/animation/proptrack.js.map +0 -1
  296. package/dist/src/animation/rotationtrack.js +0 -51
  297. package/dist/src/animation/rotationtrack.js.map +0 -1
  298. package/dist/src/animation/scaletrack.js +0 -50
  299. package/dist/src/animation/scaletrack.js.map +0 -1
  300. package/dist/src/animation/skeleton.js +0 -204
  301. package/dist/src/animation/skeleton.js.map +0 -1
  302. package/dist/src/animation/translationtrack.js +0 -50
  303. package/dist/src/animation/translationtrack.js.map +0 -1
  304. package/dist/src/app/app.js +0 -129
  305. package/dist/src/app/app.js.map +0 -1
  306. package/dist/src/app/inputmgr.js +0 -267
  307. package/dist/src/app/inputmgr.js.map +0 -1
  308. package/dist/src/asset/assetmanager.js +0 -404
  309. package/dist/src/asset/assetmanager.js.map +0 -1
  310. package/dist/src/asset/builtin.js +0 -337
  311. package/dist/src/asset/builtin.js.map +0 -1
  312. package/dist/src/asset/loaders/dds/dds.js +0 -470
  313. package/dist/src/asset/loaders/dds/dds.js.map +0 -1
  314. package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
  315. package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
  316. package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
  317. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
  318. package/dist/src/asset/loaders/gltf/helpers.js +0 -327
  319. package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
  320. package/dist/src/asset/loaders/hdr/hdr.js +0 -180
  321. package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
  322. package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
  323. package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
  324. package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
  325. package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
  326. package/dist/src/asset/loaders/loader.js +0 -45
  327. package/dist/src/asset/loaders/loader.js.map +0 -1
  328. package/dist/src/asset/model.js +0 -414
  329. package/dist/src/asset/model.js.map +0 -1
  330. package/dist/src/blitter/bilateralblur.js +0 -221
  331. package/dist/src/blitter/bilateralblur.js.map +0 -1
  332. package/dist/src/blitter/blitter.js +0 -390
  333. package/dist/src/blitter/blitter.js.map +0 -1
  334. package/dist/src/blitter/box.js +0 -118
  335. package/dist/src/blitter/box.js.map +0 -1
  336. package/dist/src/blitter/copy.js +0 -22
  337. package/dist/src/blitter/copy.js.map +0 -1
  338. package/dist/src/blitter/gaussianblur.js +0 -228
  339. package/dist/src/blitter/gaussianblur.js.map +0 -1
  340. package/dist/src/camera/base.js +0 -92
  341. package/dist/src/camera/base.js.map +0 -1
  342. package/dist/src/camera/camera.js +0 -1005
  343. package/dist/src/camera/camera.js.map +0 -1
  344. package/dist/src/camera/fps.js +0 -238
  345. package/dist/src/camera/fps.js.map +0 -1
  346. package/dist/src/camera/orbit.js +0 -245
  347. package/dist/src/camera/orbit.js.map +0 -1
  348. package/dist/src/camera/orthocamera.js +0 -167
  349. package/dist/src/camera/orthocamera.js.map +0 -1
  350. package/dist/src/camera/perspectivecamera.js +0 -141
  351. package/dist/src/camera/perspectivecamera.js.map +0 -1
  352. package/dist/src/index.js +0 -120
  353. package/dist/src/index.js.map +0 -1
  354. package/dist/src/material/blinn.js +0 -81
  355. package/dist/src/material/blinn.js.map +0 -1
  356. package/dist/src/material/grassmaterial.js +0 -113
  357. package/dist/src/material/grassmaterial.js.map +0 -1
  358. package/dist/src/material/lambert.js +0 -92
  359. package/dist/src/material/lambert.js.map +0 -1
  360. package/dist/src/material/material.js +0 -301
  361. package/dist/src/material/material.js.map +0 -1
  362. package/dist/src/material/meshmaterial.js +0 -704
  363. package/dist/src/material/meshmaterial.js.map +0 -1
  364. package/dist/src/material/mixins/albedocolor.js +0 -76
  365. package/dist/src/material/mixins/albedocolor.js.map +0 -1
  366. package/dist/src/material/mixins/foliage.js +0 -47
  367. package/dist/src/material/mixins/foliage.js.map +0 -1
  368. package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
  369. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
  370. package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
  371. package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
  372. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
  373. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
  374. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
  375. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
  376. package/dist/src/material/mixins/lit.js +0 -476
  377. package/dist/src/material/mixins/lit.js.map +0 -1
  378. package/dist/src/material/mixins/pbr/common.js +0 -918
  379. package/dist/src/material/mixins/pbr/common.js.map +0 -1
  380. package/dist/src/material/mixins/texture.js +0 -172
  381. package/dist/src/material/mixins/texture.js.map +0 -1
  382. package/dist/src/material/mixins/vertexcolor.js +0 -56
  383. package/dist/src/material/mixins/vertexcolor.js.map +0 -1
  384. package/dist/src/material/particle.js +0 -178
  385. package/dist/src/material/particle.js.map +0 -1
  386. package/dist/src/material/pbrmr.js +0 -97
  387. package/dist/src/material/pbrmr.js.map +0 -1
  388. package/dist/src/material/pbrsg.js +0 -97
  389. package/dist/src/material/pbrsg.js.map +0 -1
  390. package/dist/src/material/shader/helper.js +0 -1209
  391. package/dist/src/material/shader/helper.js.map +0 -1
  392. package/dist/src/material/terrain-cm.js +0 -606
  393. package/dist/src/material/terrain-cm.js.map +0 -1
  394. package/dist/src/material/terrainmaterial.js +0 -375
  395. package/dist/src/material/terrainmaterial.js.map +0 -1
  396. package/dist/src/material/unlit.js +0 -41
  397. package/dist/src/material/unlit.js.map +0 -1
  398. package/dist/src/material/water.js +0 -417
  399. package/dist/src/material/water.js.map +0 -1
  400. package/dist/src/posteffect/bloom.js +0 -361
  401. package/dist/src/posteffect/bloom.js.map +0 -1
  402. package/dist/src/posteffect/compositor.js +0 -226
  403. package/dist/src/posteffect/compositor.js.map +0 -1
  404. package/dist/src/posteffect/fxaa.js +0 -273
  405. package/dist/src/posteffect/fxaa.js.map +0 -1
  406. package/dist/src/posteffect/grayscale.js +0 -69
  407. package/dist/src/posteffect/grayscale.js.map +0 -1
  408. package/dist/src/posteffect/motionblur.js +0 -96
  409. package/dist/src/posteffect/motionblur.js.map +0 -1
  410. package/dist/src/posteffect/posteffect.js +0 -126
  411. package/dist/src/posteffect/posteffect.js.map +0 -1
  412. package/dist/src/posteffect/sao.js +0 -324
  413. package/dist/src/posteffect/sao.js.map +0 -1
  414. package/dist/src/posteffect/ssr.js +0 -489
  415. package/dist/src/posteffect/ssr.js.map +0 -1
  416. package/dist/src/posteffect/taa.js +0 -172
  417. package/dist/src/posteffect/taa.js.map +0 -1
  418. package/dist/src/posteffect/tonemap.js +0 -94
  419. package/dist/src/posteffect/tonemap.js.map +0 -1
  420. package/dist/src/render/abuffer_oit.js +0 -361
  421. package/dist/src/render/abuffer_oit.js.map +0 -1
  422. package/dist/src/render/clipmap.js +0 -851
  423. package/dist/src/render/clipmap.js.map +0 -1
  424. package/dist/src/render/cluster_light.js +0 -333
  425. package/dist/src/render/cluster_light.js.map +0 -1
  426. package/dist/src/render/cull_visitor.js +0 -187
  427. package/dist/src/render/cull_visitor.js.map +0 -1
  428. package/dist/src/render/depthpass.js +0 -68
  429. package/dist/src/render/depthpass.js.map +0 -1
  430. package/dist/src/render/drawable_mixin.js +0 -227
  431. package/dist/src/render/drawable_mixin.js.map +0 -1
  432. package/dist/src/render/envlight.js +0 -463
  433. package/dist/src/render/envlight.js.map +0 -1
  434. package/dist/src/render/fbm_wavegenerator.js +0 -251
  435. package/dist/src/render/fbm_wavegenerator.js.map +0 -1
  436. package/dist/src/render/fft_wavegenerator.js +0 -1006
  437. package/dist/src/render/fft_wavegenerator.js.map +0 -1
  438. package/dist/src/render/fullscreenquad.js +0 -38
  439. package/dist/src/render/fullscreenquad.js.map +0 -1
  440. package/dist/src/render/gerstner_wavegenerator.js +0 -314
  441. package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
  442. package/dist/src/render/globalbindgroup_allocator.js +0 -60
  443. package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
  444. package/dist/src/render/hzb.js +0 -273
  445. package/dist/src/render/hzb.js.map +0 -1
  446. package/dist/src/render/lightpass.js +0 -172
  447. package/dist/src/render/lightpass.js.map +0 -1
  448. package/dist/src/render/objectcolorpass.js +0 -51
  449. package/dist/src/render/objectcolorpass.js.map +0 -1
  450. package/dist/src/render/primitive.js +0 -364
  451. package/dist/src/render/primitive.js.map +0 -1
  452. package/dist/src/render/render_queue.js +0 -467
  453. package/dist/src/render/render_queue.js.map +0 -1
  454. package/dist/src/render/renderbundle_wrapper.js +0 -152
  455. package/dist/src/render/renderbundle_wrapper.js.map +0 -1
  456. package/dist/src/render/renderer.js +0 -455
  457. package/dist/src/render/renderer.js.map +0 -1
  458. package/dist/src/render/renderpass.js +0 -200
  459. package/dist/src/render/renderpass.js.map +0 -1
  460. package/dist/src/render/shadowmap_pass.js +0 -56
  461. package/dist/src/render/shadowmap_pass.js.map +0 -1
  462. package/dist/src/render/sky.js +0 -1103
  463. package/dist/src/render/sky.js.map +0 -1
  464. package/dist/src/render/weightedblended_oit.js +0 -168
  465. package/dist/src/render/weightedblended_oit.js.map +0 -1
  466. package/dist/src/scene/batchgroup.js +0 -162
  467. package/dist/src/scene/batchgroup.js.map +0 -1
  468. package/dist/src/scene/environment.js +0 -209
  469. package/dist/src/scene/environment.js.map +0 -1
  470. package/dist/src/scene/graph_node.js +0 -72
  471. package/dist/src/scene/graph_node.js.map +0 -1
  472. package/dist/src/scene/light.js +0 -416
  473. package/dist/src/scene/light.js.map +0 -1
  474. package/dist/src/scene/mesh.js +0 -341
  475. package/dist/src/scene/mesh.js.map +0 -1
  476. package/dist/src/scene/octree.js +0 -649
  477. package/dist/src/scene/octree.js.map +0 -1
  478. package/dist/src/scene/particlesys.js +0 -738
  479. package/dist/src/scene/particlesys.js.map +0 -1
  480. package/dist/src/scene/raycast_visitor.js +0 -103
  481. package/dist/src/scene/raycast_visitor.js.map +0 -1
  482. package/dist/src/scene/scene.js +0 -284
  483. package/dist/src/scene/scene.js.map +0 -1
  484. package/dist/src/scene/scene_node.js +0 -732
  485. package/dist/src/scene/scene_node.js.map +0 -1
  486. package/dist/src/scene/terrain/grass.js +0 -278
  487. package/dist/src/scene/terrain/grass.js.map +0 -1
  488. package/dist/src/scene/terrain/heightfield.js +0 -475
  489. package/dist/src/scene/terrain/heightfield.js.map +0 -1
  490. package/dist/src/scene/terrain/patch.js +0 -530
  491. package/dist/src/scene/terrain/patch.js.map +0 -1
  492. package/dist/src/scene/terrain/quadtree.js +0 -461
  493. package/dist/src/scene/terrain/quadtree.js.map +0 -1
  494. package/dist/src/scene/terrain/terrain.js +0 -246
  495. package/dist/src/scene/terrain/terrain.js.map +0 -1
  496. package/dist/src/scene/terrain-cm/grass.js +0 -594
  497. package/dist/src/scene/terrain-cm/grass.js.map +0 -1
  498. package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
  499. package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
  500. package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
  501. package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
  502. package/dist/src/scene/water.js +0 -374
  503. package/dist/src/scene/water.js.map +0 -1
  504. package/dist/src/shaders/atmosphere.js +0 -957
  505. package/dist/src/shaders/atmosphere.js.map +0 -1
  506. package/dist/src/shaders/fog.js +0 -112
  507. package/dist/src/shaders/fog.js.map +0 -1
  508. package/dist/src/shaders/misc.js +0 -266
  509. package/dist/src/shaders/misc.js.map +0 -1
  510. package/dist/src/shaders/noise.js +0 -222
  511. package/dist/src/shaders/noise.js.map +0 -1
  512. package/dist/src/shaders/pbr.js +0 -51
  513. package/dist/src/shaders/pbr.js.map +0 -1
  514. package/dist/src/shaders/shadow.js +0 -636
  515. package/dist/src/shaders/shadow.js.map +0 -1
  516. package/dist/src/shaders/ssr.js +0 -490
  517. package/dist/src/shaders/ssr.js.map +0 -1
  518. package/dist/src/shaders/temporal.js +0 -215
  519. package/dist/src/shaders/temporal.js.map +0 -1
  520. package/dist/src/shaders/water.js +0 -756
  521. package/dist/src/shaders/water.js.map +0 -1
  522. package/dist/src/shadow/esm.js +0 -237
  523. package/dist/src/shadow/esm.js.map +0 -1
  524. package/dist/src/shadow/pcf_opt.js +0 -181
  525. package/dist/src/shadow/pcf_opt.js.map +0 -1
  526. package/dist/src/shadow/pcf_pd.js +0 -189
  527. package/dist/src/shadow/pcf_pd.js.map +0 -1
  528. package/dist/src/shadow/shader.js +0 -37
  529. package/dist/src/shadow/shader.js.map +0 -1
  530. package/dist/src/shadow/shadow_impl.js +0 -15
  531. package/dist/src/shadow/shadow_impl.js.map +0 -1
  532. package/dist/src/shadow/shadowmapper.js +0 -790
  533. package/dist/src/shadow/shadowmapper.js.map +0 -1
  534. package/dist/src/shadow/ssm.js +0 -159
  535. package/dist/src/shadow/ssm.js.map +0 -1
  536. package/dist/src/shadow/vsm.js +0 -297
  537. package/dist/src/shadow/vsm.js.map +0 -1
  538. package/dist/src/shapes/box.js +0 -386
  539. package/dist/src/shapes/box.js.map +0 -1
  540. package/dist/src/shapes/cylinder.js +0 -125
  541. package/dist/src/shapes/cylinder.js.map +0 -1
  542. package/dist/src/shapes/plane.js +0 -88
  543. package/dist/src/shapes/plane.js.map +0 -1
  544. package/dist/src/shapes/shape.js +0 -87
  545. package/dist/src/shapes/shape.js.map +0 -1
  546. package/dist/src/shapes/sphere.js +0 -114
  547. package/dist/src/shapes/sphere.js.map +0 -1
  548. package/dist/src/shapes/tetrahedron.js +0 -188
  549. package/dist/src/shapes/tetrahedron.js.map +0 -1
  550. package/dist/src/shapes/torus.js +0 -111
  551. package/dist/src/shapes/torus.js.map +0 -1
  552. package/dist/src/utility/aabbtree.js +0 -400
  553. package/dist/src/utility/aabbtree.js.map +0 -1
  554. package/dist/src/utility/bounding_volume.js +0 -29
  555. package/dist/src/utility/bounding_volume.js.map +0 -1
  556. package/dist/src/utility/debug.js +0 -28
  557. package/dist/src/utility/debug.js.map +0 -1
  558. package/dist/src/utility/draco/decoder.js +0 -116
  559. package/dist/src/utility/draco/decoder.js.map +0 -1
  560. package/dist/src/utility/misc.js +0 -105
  561. package/dist/src/utility/misc.js.map +0 -1
  562. package/dist/src/utility/panorama.js +0 -163
  563. package/dist/src/utility/panorama.js.map +0 -1
  564. package/dist/src/utility/pmrem.js +0 -354
  565. package/dist/src/utility/pmrem.js.map +0 -1
  566. package/dist/src/utility/rendermipmap.js +0 -115
  567. package/dist/src/utility/rendermipmap.js.map +0 -1
  568. package/dist/src/utility/serialization/json.js +0 -402
  569. package/dist/src/utility/serialization/json.js.map +0 -1
  570. package/dist/src/utility/serialization/manager.js +0 -623
  571. package/dist/src/utility/serialization/manager.js.map +0 -1
  572. package/dist/src/utility/serialization/scene/animation.js +0 -248
  573. package/dist/src/utility/serialization/scene/animation.js.map +0 -1
  574. package/dist/src/utility/serialization/scene/batch.js +0 -59
  575. package/dist/src/utility/serialization/scene/batch.js.map +0 -1
  576. package/dist/src/utility/serialization/scene/camera.js +0 -790
  577. package/dist/src/utility/serialization/scene/camera.js.map +0 -1
  578. package/dist/src/utility/serialization/scene/common.js +0 -222
  579. package/dist/src/utility/serialization/scene/common.js.map +0 -1
  580. package/dist/src/utility/serialization/scene/light.js +0 -575
  581. package/dist/src/utility/serialization/scene/light.js.map +0 -1
  582. package/dist/src/utility/serialization/scene/material.js +0 -1111
  583. package/dist/src/utility/serialization/scene/material.js.map +0 -1
  584. package/dist/src/utility/serialization/scene/mesh.js +0 -148
  585. package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
  586. package/dist/src/utility/serialization/scene/misc.js +0 -39
  587. package/dist/src/utility/serialization/scene/misc.js.map +0 -1
  588. package/dist/src/utility/serialization/scene/node.js +0 -451
  589. package/dist/src/utility/serialization/scene/node.js.map +0 -1
  590. package/dist/src/utility/serialization/scene/particle.js +0 -425
  591. package/dist/src/utility/serialization/scene/particle.js.map +0 -1
  592. package/dist/src/utility/serialization/scene/primitive.js +0 -692
  593. package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
  594. package/dist/src/utility/serialization/scene/scene.js +0 -704
  595. package/dist/src/utility/serialization/scene/scene.js.map +0 -1
  596. package/dist/src/utility/serialization/scene/terrain.js +0 -488
  597. package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
  598. package/dist/src/utility/serialization/scene/water.js +0 -465
  599. package/dist/src/utility/serialization/scene/water.js.map +0 -1
  600. package/dist/src/utility/shprojector.js +0 -297
  601. package/dist/src/utility/shprojector.js.map +0 -1
  602. package/dist/src/utility/textures/ggxlut.js +0 -213
  603. package/dist/src/utility/textures/ggxlut.js.map +0 -1
  604. package/dist/src/utility/textures/gradientnoise.js +0 -62
  605. package/dist/src/utility/textures/gradientnoise.js.map +0 -1
  606. package/dist/src/utility/textures/randomnoise.js +0 -41
  607. package/dist/src/utility/textures/randomnoise.js.map +0 -1
  608. package/dist/src/values.js +0 -162
  609. package/dist/src/values.js.map +0 -1
  610. package/dist/utility/blueprint/material/common.js +0 -7
  611. package/dist/utility/blueprint/material/common.js.map +0 -1
  612. package/dist/utility/serialization/blueprint/constants.js +0 -255
  613. package/dist/utility/serialization/blueprint/constants.js.map +0 -1
  614. package/dist/utility/serialization/blueprint/material/constants.js +0 -203
  615. package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
  616. package/dist/utility/serialization/blueprint/material/texture.js +0 -165
  617. package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
  618. package/dist/utility/serialization/scene/cloth_script.js +0 -834
  619. package/dist/utility/serialization/scene/cloth_script.js.map +0 -1
  620. package/dist/utility/serialization/scene/spring_script.js +0 -596
  621. package/dist/utility/serialization/scene/spring_script.js.map +0 -1
@@ -1,918 +0,0 @@
1
- import { applyMaterialMixins } from '../../meshmaterial.js';
2
- import { Vector4, Vector3 } from '@zephyr3d/base';
3
- import { getGGXLUT } from '../../../utility/textures/ggxlut.js';
4
- import { mixinTextureProps } from '../texture.js';
5
- import { ShaderHelper } from '../../shader/helper.js';
6
- import { MaterialVaryingFlags, RENDER_PASS_TYPE_LIGHT } from '../../../values.js';
7
-
8
- /**
9
- * PBR common stuff mixin
10
- * @param BaseCls - Class to mix in
11
- * @returns Mixed class
12
- *
13
- * @public
14
- */ function mixinPBRCommon(BaseCls) {
15
- if (BaseCls.pbrCommonMixed) {
16
- return BaseCls;
17
- }
18
- const S = applyMaterialMixins(BaseCls, mixinTextureProps('occlusion'), mixinTextureProps('emissive'), mixinTextureProps('sheenColor'), mixinTextureProps('sheenRoughness'), mixinTextureProps('clearcoatIntensity'), mixinTextureProps('clearcoatRoughness'), mixinTextureProps('clearcoatNormal'), mixinTextureProps('transmission'), mixinTextureProps('thickness'), mixinTextureProps('iridescence'), mixinTextureProps('iridescenceThickness'));
19
- let FEATURE_SHEEN = 0;
20
- let FEATURE_CLEARCOAT = 0;
21
- let FEATURE_TRANSMISSION = 0;
22
- let FEATURE_IRIDESCENCE = 0;
23
- const EMISSIVE_COLOR_UNIFORM = S.defineInstanceUniform('emissiveColor', 'rgb');
24
- const EMISSIVE_STRENGTH_UNIFORM = S.defineInstanceUniform('emissiveStrength', 'float');
25
- const cls = class extends S {
26
- static pbrCommonMixed = true;
27
- _f0;
28
- _emissiveColor;
29
- _emissiveStrength;
30
- _occlusionStrength;
31
- _sheenFactor;
32
- _clearcoatFactor;
33
- _transmissionFactor;
34
- _thicknessFactor;
35
- _attenuationColor;
36
- _attenuationDistance;
37
- _iridescenceFactor;
38
- constructor(){
39
- super();
40
- this._f0 = new Vector4(0.04, 0.04, 0.04, 1.5);
41
- this._occlusionStrength = 1;
42
- this._emissiveColor = new Vector3(0, 0, 0);
43
- this._emissiveStrength = 1;
44
- this._sheenFactor = Vector4.zero();
45
- this._clearcoatFactor = new Vector4(0, 0, 1, 0);
46
- this._transmissionFactor = 0;
47
- this._thicknessFactor = 0;
48
- this._attenuationColor = Vector3.one();
49
- this._attenuationDistance = 99999;
50
- this._iridescenceFactor = new Vector4(0, 1.3, 100, 400);
51
- }
52
- copyFrom(other) {
53
- super.copyFrom(other);
54
- this.ior = other.ior;
55
- this.transmissionFactor = other.transmissionFactor;
56
- this.thicknessFactor = other.thicknessFactor;
57
- this.attenuationColor = other.attenuationColor;
58
- this.attenuationDistance = other.attenuationDistance;
59
- this.iridescenceFactor = other.iridescenceFactor;
60
- this.iridescenceIor = other.iridescenceIor;
61
- this.iridescenceThicknessMin = other.iridescenceThicknessMin;
62
- this.iridescenceThicknessMax = other.iridescenceThicknessMax;
63
- this.occlusionStrength = other.occlusionStrength;
64
- this.emissiveColor = other.emissiveColor;
65
- this.emissiveStrength = other.emissiveStrength;
66
- this.transmission = other.transmission;
67
- this.iridescence = other.iridescence;
68
- this.clearcoat = other.clearcoat;
69
- this.clearcoatIntensity = other.clearcoatIntensity;
70
- this.clearcoatRoughnessFactor = other.clearcoatRoughnessFactor;
71
- this.sheen = other.sheen;
72
- this.sheenColorFactor = other.sheenColorFactor;
73
- this.sheenRoughnessFactor = other.sheenRoughnessFactor;
74
- }
75
- get ior() {
76
- return this._f0.w;
77
- }
78
- set ior(val) {
79
- if (val !== this._f0.w) {
80
- let k = (val - 1) / (val + 1);
81
- k *= k;
82
- this._f0.setXYZW(k, k, k, val);
83
- this.uniformChanged();
84
- }
85
- }
86
- get transmissionFactor() {
87
- return this._transmissionFactor;
88
- }
89
- set transmissionFactor(val) {
90
- if (val !== this._transmissionFactor) {
91
- this._transmissionFactor = val;
92
- this.uniformChanged();
93
- }
94
- }
95
- get thicknessFactor() {
96
- return this._thicknessFactor;
97
- }
98
- set thicknessFactor(val) {
99
- if (this._thicknessFactor !== val) {
100
- this._thicknessFactor = val;
101
- this.uniformChanged();
102
- }
103
- }
104
- get attenuationColor() {
105
- return this._attenuationColor;
106
- }
107
- set attenuationColor(val) {
108
- if (!val.equalsTo(this._attenuationColor)) {
109
- this._attenuationColor.set(val);
110
- this.uniformChanged();
111
- }
112
- }
113
- get attenuationDistance() {
114
- return this._attenuationDistance;
115
- }
116
- set attenuationDistance(val) {
117
- if (val !== this._attenuationDistance) {
118
- this._attenuationDistance = val;
119
- this.uniformChanged();
120
- }
121
- }
122
- get iridescenceFactor() {
123
- return this._iridescenceFactor.x;
124
- }
125
- set iridescenceFactor(val) {
126
- if (this._iridescenceFactor.x !== val) {
127
- this._iridescenceFactor.x = val;
128
- this.uniformChanged();
129
- }
130
- }
131
- get iridescenceIor() {
132
- return this._iridescenceFactor.y;
133
- }
134
- set iridescenceIor(val) {
135
- if (this._iridescenceFactor.y !== val) {
136
- this._iridescenceFactor.y = val;
137
- this.uniformChanged();
138
- }
139
- }
140
- get iridescenceThicknessMin() {
141
- return this._iridescenceFactor.z;
142
- }
143
- set iridescenceThicknessMin(val) {
144
- if (this._iridescenceFactor.z !== val) {
145
- this._iridescenceFactor.z = val;
146
- this.uniformChanged();
147
- }
148
- }
149
- get iridescenceThicknessMax() {
150
- return this._iridescenceFactor.w;
151
- }
152
- set iridescenceThicknessMax(val) {
153
- if (this._iridescenceFactor.w !== val) {
154
- this._iridescenceFactor.w = val;
155
- this.uniformChanged();
156
- }
157
- }
158
- get occlusionStrength() {
159
- return this._occlusionStrength;
160
- }
161
- set occlusionStrength(val) {
162
- if (val !== this._occlusionStrength) {
163
- this._occlusionStrength = val;
164
- this.uniformChanged();
165
- }
166
- }
167
- get emissiveColor() {
168
- return this._emissiveColor;
169
- }
170
- set emissiveColor(val) {
171
- if (val.x !== this._emissiveColor.x || val.y !== this._emissiveColor.y || val.z !== this._emissiveColor.z) {
172
- this._emissiveColor.set(val);
173
- this.uniformChanged();
174
- }
175
- }
176
- get emissiveStrength() {
177
- return this._emissiveStrength;
178
- }
179
- set emissiveStrength(val) {
180
- if (this._emissiveStrength !== val) {
181
- this._emissiveStrength = val;
182
- this.uniformChanged();
183
- }
184
- }
185
- get transmission() {
186
- return this.featureUsed(FEATURE_TRANSMISSION);
187
- }
188
- set transmission(val) {
189
- this.useFeature(FEATURE_TRANSMISSION, !!val);
190
- }
191
- get iridescence() {
192
- return this.featureUsed(FEATURE_IRIDESCENCE);
193
- }
194
- set iridescence(val) {
195
- this.useFeature(FEATURE_IRIDESCENCE, !!val);
196
- }
197
- get clearcoat() {
198
- return this.featureUsed(FEATURE_CLEARCOAT);
199
- }
200
- set clearcoat(val) {
201
- this.useFeature(FEATURE_CLEARCOAT, !!val);
202
- }
203
- get clearcoatIntensity() {
204
- return this._clearcoatFactor.x;
205
- }
206
- set clearcoatIntensity(val) {
207
- if (val !== this._clearcoatFactor.x) {
208
- this._clearcoatFactor.x = val;
209
- this.uniformChanged();
210
- }
211
- }
212
- get clearcoatRoughnessFactor() {
213
- return this._clearcoatFactor.y;
214
- }
215
- set clearcoatRoughnessFactor(val) {
216
- if (val !== this._clearcoatFactor.y) {
217
- this._clearcoatFactor.y = val;
218
- this.uniformChanged();
219
- }
220
- }
221
- get sheen() {
222
- return this.featureUsed(FEATURE_SHEEN);
223
- }
224
- set sheen(val) {
225
- this.useFeature(FEATURE_SHEEN, !!val);
226
- }
227
- get sheenColorFactor() {
228
- return this._sheenFactor.xyz();
229
- }
230
- set sheenColorFactor(val) {
231
- if (val.x !== this._sheenFactor.x || val.y !== this._sheenFactor.y || val.z !== this._sheenFactor.z) {
232
- this._sheenFactor.x = val.x;
233
- this._sheenFactor.y = val.y;
234
- this._sheenFactor.z = val.z;
235
- this.uniformChanged();
236
- }
237
- }
238
- get sheenRoughnessFactor() {
239
- return this._sheenFactor.w;
240
- }
241
- set sheenRoughnessFactor(val) {
242
- if (val !== this._sheenFactor.w) {
243
- this._sheenFactor.w = val;
244
- this.uniformChanged();
245
- }
246
- }
247
- vertexShader(scope) {
248
- super.vertexShader(scope);
249
- if (this.needFragmentColor() && this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {
250
- scope.$outputs.zEmissiveColor = this.getInstancedUniform(scope, EMISSIVE_COLOR_UNIFORM);
251
- scope.$outputs.zEmissiveStrength = this.getInstancedUniform(scope, EMISSIVE_STRENGTH_UNIFORM);
252
- }
253
- }
254
- fragmentShader(scope) {
255
- const pb = scope.$builder;
256
- super.fragmentShader(scope);
257
- if (this.needFragmentColor()) {
258
- scope.zF0 = pb.vec4().uniform(2);
259
- if (!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {
260
- scope.zEmissiveColor = pb.vec3().uniform(2);
261
- scope.zEmissiveStrength = pb.float().uniform(2);
262
- }
263
- if (this.occlusionTexture) {
264
- scope.zOcclusionStrength = pb.float().uniform(2);
265
- }
266
- if (this.sheen) {
267
- scope.zSheenFactor = pb.vec4().uniform(2);
268
- }
269
- if (this.clearcoat) {
270
- scope.zClearcoatFactor = pb.vec4().uniform(2);
271
- }
272
- if (this.transmission && this.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
273
- scope.zTransmissionFactor = pb.float().uniform(2);
274
- scope.zThicknessFactor = pb.float().uniform(2);
275
- scope.zAttenuationColor = pb.vec3().uniform(2);
276
- scope.zAttenuationDistance = pb.float().uniform(2);
277
- }
278
- if (this.iridescence) {
279
- scope.zIridescenceFactor = pb.vec4().uniform(2);
280
- }
281
- if (this.drawContext.drawEnvLight) {
282
- scope.zGGXLut = pb.tex2D().uniform(2);
283
- }
284
- }
285
- }
286
- needSceneColor() {
287
- return this.transmission;
288
- }
289
- applyUniformValues(bindGroup, ctx, pass) {
290
- super.applyUniformValues(bindGroup, ctx, pass);
291
- if (this.needFragmentColor(ctx)) {
292
- bindGroup.setValue('zF0', this._f0);
293
- if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {
294
- bindGroup.setValue('zEmissiveColor', this._emissiveColor);
295
- bindGroup.setValue('zEmissiveStrength', this._emissiveStrength);
296
- }
297
- if (this.occlusionTexture) {
298
- bindGroup.setValue('zOcclusionStrength', this._occlusionStrength);
299
- }
300
- if (this.sheen) {
301
- bindGroup.setValue('zSheenFactor', this._sheenFactor);
302
- }
303
- if (this.clearcoat) {
304
- bindGroup.setValue('zClearcoatFactor', this._clearcoatFactor);
305
- }
306
- if (this.transmission && ctx.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
307
- bindGroup.setValue('zTransmissionFactor', this._transmissionFactor);
308
- bindGroup.setValue('zThicknessFactor', this._thicknessFactor);
309
- bindGroup.setValue('zAttenuationColor', this._attenuationColor);
310
- bindGroup.setValue('zAttenuationDistance', this._attenuationDistance);
311
- }
312
- if (this.iridescence) {
313
- bindGroup.setValue('zIridescenceFactor', this._iridescenceFactor);
314
- }
315
- if (ctx.drawEnvLight) {
316
- bindGroup.setTexture('zGGXLut', getGGXLUT(1024));
317
- }
318
- }
319
- }
320
- getF0(scope) {
321
- return scope.zF0;
322
- }
323
- getCommonDatasStruct(scope) {
324
- const pb = scope.$builder;
325
- return pb.defineStruct([
326
- pb.vec4('f0'),
327
- pb.vec3('f90'),
328
- pb.vec4('diffuse'),
329
- pb.float('metallic'),
330
- pb.float('roughness'),
331
- pb.float('specularWeight'),
332
- ...this.sheen ? [
333
- pb.float('sheenAlbedoScaling'),
334
- pb.vec3('sheenColor'),
335
- pb.float('sheenRoughness')
336
- ] : [],
337
- ...this.clearcoat ? [
338
- pb.vec4('ccFactor'),
339
- pb.vec3('ccNormal'),
340
- pb.float('ccNoV'),
341
- pb.float('ccFresnel')
342
- ] : [],
343
- ...this.transmission && this.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT ? [
344
- pb.float('transmissionFactor'),
345
- pb.float('thicknessFactor'),
346
- pb.vec3('attenuationColor'),
347
- pb.float('attenuationDistance')
348
- ] : [],
349
- ...this.iridescence ? [
350
- pb.vec4('iridescenceFactor'),
351
- pb.vec3('iridescenceFresnel'),
352
- pb.vec3('iridescenceF0')
353
- ] : []
354
- ]);
355
- }
356
- getCommonData(scope, albedo, normal, viewVec, TBN) {
357
- const pb = scope.$builder;
358
- const that = this;
359
- const funcName = 'Z_getCommonData';
360
- pb.func(funcName, [
361
- pb.vec4('albedo'),
362
- pb.vec3('normal'),
363
- pb.vec3('viewVec'),
364
- pb.mat3('TBN')
365
- ], function() {
366
- this.$l.data = that.getCommonDatasStruct(this)();
367
- that.calculateCommonData(this, this.albedo, this.normal, this.viewVec, this.TBN, this.data);
368
- this.$return(this.data);
369
- });
370
- return scope.$g[funcName](albedo, normal, viewVec, TBN);
371
- }
372
- calculateCommonData(scope, albedo, normal, viewVec, TBN, data) {
373
- const pb = scope.$builder;
374
- if (this.sheen) {
375
- if (this.sheenColorTexture) {
376
- data.sheenColor = pb.mul(this.sampleSheenColorTexture(scope).rgb, scope.zSheenFactor.rgb);
377
- } else {
378
- data.sheenColor = scope.zSheenFactor.rgb;
379
- }
380
- if (this.sheenRoughnessTexture) {
381
- data.sheenRoughness = pb.mul(this.sampleSheenRoughnessTexture(scope).a, scope.zSheenFactor.a);
382
- } else {
383
- data.sheenRoughness = scope.zSheenFactor.a;
384
- }
385
- scope.$l.sheenDFG = 0.157;
386
- data.sheenAlbedoScaling = pb.sub(1, pb.mul(pb.max(pb.max(data.sheenColor.r, data.sheenColor.g), data.sheenColor.b), scope.sheenDFG));
387
- }
388
- if (this.clearcoat) {
389
- if (this.clearcoatNormalTexture) {
390
- const ccNormal = pb.mul(pb.sub(pb.mul(this.sampleClearcoatNormalTexture(scope).rgb, 2), pb.vec3(1)), pb.vec3(scope.zClearcoatFactor.zz, 1));
391
- data.ccNormal = pb.normalize(pb.mul(TBN, ccNormal));
392
- } else {
393
- data.ccNormal = TBN[2];
394
- }
395
- data.ccNoV = pb.clamp(pb.dot(data.ccNormal, viewVec), 0.0001, 1);
396
- data.ccFactor = scope.zClearcoatFactor;
397
- if (this.clearcoatIntensityTexture) {
398
- data.ccFactor.x = pb.mul(data.ccFactor.x, this.sampleClearcoatIntensityTexture(scope).r);
399
- }
400
- if (this.clearcoatRoughnessTexture) {
401
- data.ccFactor.y = pb.clamp(pb.mul(data.ccFactor.y, this.sampleClearcoatRoughnessTexture(scope).g), 0, 1);
402
- }
403
- }
404
- if (this.transmission && this.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
405
- if (this.transmissionTexture) {
406
- data.transmissionFactor = pb.mul(this.sampleTransmissionTexture(scope).r, scope.zTransmissionFactor);
407
- } else {
408
- data.transmissionFactor = scope.zTransmissionFactor;
409
- }
410
- if (this.thicknessTexture) {
411
- data.thicknessFactor = pb.mul(this.sampleThicknessTexture(scope).g, scope.zThicknessFactor);
412
- } else {
413
- data.thicknessFactor = scope.zThicknessFactor;
414
- }
415
- data.attenuationColor = scope.zAttenuationColor;
416
- data.attenuationDistance = scope.zAttenuationDistance;
417
- }
418
- if (this.iridescence) {
419
- data.iridescenceFactor = scope.zIridescenceFactor;
420
- if (this.iridescenceTexture) {
421
- data.iridescenceFactor.x = pb.mul(this.sampleIridescenceTexture(scope).r, data.iridescenceFactor.x);
422
- }
423
- if (this.iridescenceThicknessTexture) {
424
- data.iridescenceFactor.w = pb.mix(data.iridescenceFactor.z, data.iridescenceFactor.w, this.sampleIridescenceThicknessTexture(scope).g);
425
- }
426
- data.iridescenceFresnel = this.evalIridescence(scope, 1, data.iridescenceFactor.y, pb.clamp(pb.dot(normal, viewVec), 0, 1), data.iridescenceFactor.w, data.f0.rgb);
427
- data.iridescenceF0 = this.schlickToF0(scope, data.iridescenceFresnel, pb.vec3(1), pb.clamp(pb.dot(normal, viewVec), 0, 1));
428
- }
429
- }
430
- getEmissiveColor(scope) {
431
- const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
432
- return instancing ? scope.$inputs.zEmissiveColor : scope.zEmissiveColor;
433
- }
434
- getEmissiveStrength(scope) {
435
- const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
436
- return instancing ? scope.$inputs.zEmissiveStrength : scope.zEmissiveStrength;
437
- }
438
- calculateEmissiveColor(scope) {
439
- const pb = scope.$builder;
440
- if (this.emissiveTexture) {
441
- return pb.mul(this.sampleEmissiveTexture(scope).rgb, this.getEmissiveColor(scope), this.getEmissiveStrength(scope));
442
- } else {
443
- return pb.mul(this.getEmissiveColor(scope), this.getEmissiveStrength(scope));
444
- }
445
- }
446
- D_Charlie(scope, NdotH, sheenRoughness) {
447
- const funcNameDCharlie = 'Z_DCharlie';
448
- const pb = scope.$builder;
449
- pb.func(funcNameDCharlie, [
450
- pb.float('NdotH'),
451
- pb.float('sheenRoughness')
452
- ], function() {
453
- this.$l.alphaG = pb.mul(this.sheenRoughness, this.sheenRoughness);
454
- this.$l.invR = pb.div(1, this.alphaG);
455
- this.$l.cos2h = pb.mul(this.NdotH, this.NdotH);
456
- this.$l.sin2h = pb.max(pb.sub(1, this.cos2h), 0.0078125);
457
- this.$return(pb.div(pb.mul(pb.add(this.invR, 2), pb.pow(this.sin2h, pb.mul(this.invR, 0.5))), 2 * Math.PI));
458
- });
459
- return scope.$g[funcNameDCharlie](NdotH, sheenRoughness);
460
- }
461
- V_Ashikhmin(scope, NdotL, NdotV) {
462
- const funcNameVAshikhmin = 'Z_VAshikhmin';
463
- const pb = scope.$builder;
464
- pb.func(funcNameVAshikhmin, [
465
- pb.float('NdotL'),
466
- pb.float('NdotV')
467
- ], function() {
468
- this.$return(pb.clamp(pb.div(1, pb.mul(pb.sub(pb.add(this.NdotL, this.NdotV), pb.mul(this.NdotL, this.NdotV)), 4)), 0, 1));
469
- });
470
- return scope.$g[funcNameVAshikhmin](NdotL, NdotV);
471
- }
472
- getVolumeTransmissionRay(scope, normal, viewVec, thickness, ior) {
473
- const pb = scope.$builder;
474
- const funcName = 'getVolumeTransmissionRay';
475
- pb.func(funcName, [
476
- pb.vec3('normal'),
477
- pb.vec3('viewVec'),
478
- pb.float('thickness'),
479
- pb.float('ior')
480
- ], function() {
481
- this.$l.refractionVector = pb.refract(pb.neg(this.viewVec), this.normal, pb.div(1, this.ior));
482
- this.$return(pb.mul(this.refractionVector, this.$inputs.modelScale, this.thickness));
483
- });
484
- return pb.getGlobalScope()[funcName](normal, viewVec, thickness, ior);
485
- }
486
- getTransmissionSample(scope, fragCoord, roughness, ior) {
487
- const pb = scope.$builder;
488
- const funcName = 'getTransmissionSample';
489
- pb.func(funcName, [
490
- pb.vec2('fragCoord'),
491
- pb.float('roughness'),
492
- pb.float('ior')
493
- ], function() {
494
- this.$l.applyIorToRoughness = pb.mul(this.roughness, pb.clamp(pb.sub(pb.mul(this.ior, 2), 2), 0.0, 1.0));
495
- this.$l.framebufferLod = pb.mul(pb.log2(ShaderHelper.getSceneColorTextureSize(this).x), this.applyIorToRoughness);
496
- this.$return(pb.textureSampleLevel(ShaderHelper.getSceneColorTexture(this), this.fragCoord, this.framebufferLod).rgb);
497
- });
498
- return pb.getGlobalScope()[funcName](fragCoord, roughness, ior);
499
- }
500
- getPunctualRadianceTransmission(scope, normal, viewVec, lightDir, alphaRoughness, f0, f90, baseColor, ior) {
501
- const pb = scope.$builder;
502
- const that = this;
503
- const funcName = 'getPunctualRadianceTransmission';
504
- pb.func(funcName, [
505
- pb.vec3('normal'),
506
- pb.vec3('viewVec'),
507
- pb.vec3('L'),
508
- pb.float('alphaRoughness'),
509
- pb.vec3('f0'),
510
- pb.vec3('f90'),
511
- pb.vec3('baseColor'),
512
- pb.float('ior')
513
- ], function() {
514
- this.$l.transmissionRoughness = pb.mul(this.alphaRoughness, pb.clamp(pb.sub(pb.mul(this.ior, 2), 2), 0.0, 1.0));
515
- this.$l.mirrorL = pb.normalize(pb.add(this.L, pb.mul(this.normal, pb.dot(pb.neg(this.L), this.normal), 2)));
516
- this.$l.h = pb.normalize(pb.add(this.viewVec, this.mirrorL));
517
- this.$l.D = that.distributionGGX(this, pb.clamp(pb.dot(this.normal, this.h), 0, 1), this.transmissionRoughness);
518
- this.$l.F = that.fresnelSchlick(this, pb.clamp(pb.dot(this.viewVec, this.h), 0, 1), this.f0, this.f90);
519
- this.$l.V = that.visGGX(this, pb.clamp(pb.dot(this.normal, this.viewVec), 0, 1), pb.clamp(pb.dot(this.normal, this.mirrorL), 0, 1), this.transmissionRoughness);
520
- this.$return(pb.mul(pb.sub(pb.vec3(1), this.F), this.baseColor, this.D, this.V));
521
- });
522
- return pb.getGlobalScope()[funcName](normal, viewVec, lightDir, alphaRoughness, f0, f90, baseColor, ior);
523
- }
524
- applyVolumeAttenuation(scope, radiance, transmissionDistance, attenuationColor, attenuationDistance) {
525
- const pb = scope.$builder;
526
- const funcName = 'applyVolumeAttenuation';
527
- pb.func(funcName, [
528
- pb.vec3('radiance'),
529
- pb.float('transmissionDistance'),
530
- pb.vec3('attenuationColor'),
531
- pb.float('attenuationDistance')
532
- ], function() {
533
- this.$if(pb.equal(this.attenuationDistance, 0), function() {
534
- this.$return(this.radiance);
535
- }).$else(function() {
536
- this.$l.attenuationCoefficient = pb.div(pb.neg(pb.log(this.attenuationColor)), this.attenuationDistance);
537
- this.$l.transmittance = pb.exp(pb.mul(pb.neg(this.attenuationCoefficient), this.transmissionDistance));
538
- this.$return(pb.mul(this.radiance, this.transmittance));
539
- });
540
- });
541
- return pb.getGlobalScope()[funcName](radiance, transmissionDistance, attenuationColor, attenuationDistance);
542
- }
543
- getIBLVolumnRefraction(scope, brdf, normal, viewVec, roughness, baseColor, f0, f90, position, ior, thickness, attenuationColor, attenuationDistance) {
544
- const pb = scope.$builder;
545
- const funcName = 'getIBLVolumeRefraction';
546
- const that = this;
547
- pb.func(funcName, [
548
- pb.vec2('brdf'),
549
- pb.vec3('normal'),
550
- pb.vec3('viewVec'),
551
- pb.float('roughness'),
552
- pb.vec3('baseColor'),
553
- pb.vec3('f0'),
554
- pb.vec3('f90'),
555
- pb.vec3('position'),
556
- pb.float('ior'),
557
- pb.float('thickness'),
558
- pb.vec3('attenuationColor'),
559
- pb.float('attenuationDistance')
560
- ], function() {
561
- this.$l.transmissionRay = that.getVolumeTransmissionRay(this, this.normal, this.viewVec, this.thickness, this.ior);
562
- this.$l.transmissionRayLength = pb.length(this.transmissionRay);
563
- this.$l.refractedRayExit = pb.add(this.position, this.transmissionRay);
564
- this.$l.ndcPos = pb.mul(ShaderHelper.getViewProjectionMatrix(this), pb.vec4(this.refractedRayExit, 1));
565
- this.$l.refractionCoords = pb.add(pb.mul(pb.div(this.ndcPos.xy, this.ndcPos.w), 0.5), pb.vec2(0.5));
566
- this.$l.transmittedLight = that.getTransmissionSample(this, this.refractionCoords, this.roughness, this.ior);
567
- this.$l.attColor = that.applyVolumeAttenuation(this, this.transmittedLight, this.transmissionRayLength, this.attenuationColor, this.attenuationDistance);
568
- this.$l.specularColor = pb.add(pb.mul(this.f0, this.brdf.x), pb.mul(this.f90, this.brdf.y));
569
- this.$return(pb.mul(pb.sub(pb.vec3(1), this.specularColor), this.attColor, this.baseColor));
570
- });
571
- return pb.getGlobalScope()[funcName](brdf, normal, viewVec, roughness, baseColor, f0, f90, position, ior, thickness, attenuationColor, attenuationDistance);
572
- }
573
- directLighting(scope, lightDir, lightColor, normal, viewVec, commonData, outColor) {
574
- const pb = scope.$builder;
575
- const that = this;
576
- const funcName = 'Z_PBRDirectLighting';
577
- pb.func(funcName, [
578
- pb.vec3('L'),
579
- pb.vec3('lightColor'),
580
- pb.vec3('normal'),
581
- pb.vec3('viewVec'),
582
- that.getCommonDatasStruct(scope)('data'),
583
- pb.vec3('outColor').inout()
584
- ], function() {
585
- this.$l.H = pb.normalize(pb.add(this.viewVec, this.L));
586
- this.$l.NoH = pb.clamp(pb.dot(this.normal, this.H), 0, 1);
587
- this.$l.NoL = pb.clamp(pb.dot(this.normal, this.L), 0, 1);
588
- this.$l.NoV = pb.clamp(pb.dot(this.normal, this.viewVec), 0, 1);
589
- this.$if(pb.greaterThan(this.NoL, 0), function() {
590
- this.$l.VoH = pb.clamp(pb.dot(this.viewVec, this.H), 0, 1);
591
- this.$l.schlickFresnel = that.fresnelSchlick(this, this.VoH, this.data.f0.rgb, this.data.f90);
592
- if (that.iridescence) {
593
- this.$l.F = pb.mix(this.schlickFresnel, this.data.iridescenceFresnel, this.data.iridescenceFactor.x);
594
- } else {
595
- this.$l.F = this.schlickFresnel;
596
- }
597
- this.$l.alphaRoughness = pb.mul(this.data.roughness, this.data.roughness);
598
- this.$l.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);
599
- this.$l.V = that.visGGX(this, this.NoV, this.NoL, this.alphaRoughness);
600
- this.$l.specular = pb.mul(this.lightColor, this.D, this.V, this.F, this.data.specularWeight);
601
- if (that.sheen) {
602
- this.specular = pb.mul(this.specular, this.data.sheenAlbedoScaling);
603
- }
604
- this.outColor = pb.add(this.outColor, this.specular);
605
- if (that.iridescence) {
606
- this.$l.iridescenceFresnelMax = pb.vec3(pb.max(pb.max(this.data.iridescenceFresnel.r, this.data.iridescenceFresnel.g), this.data.iridescenceFresnel.b));
607
- this.F = pb.mix(this.schlickFresnel, this.iridescenceFresnelMax, this.data.iridescenceFactor.x);
608
- }
609
- this.$l.diffuseBRDF = pb.mul(pb.sub(pb.vec3(1), pb.mul(this.F, this.data.specularWeight)), pb.div(this.data.diffuse.rgb, Math.PI));
610
- this.$l.diffuse = pb.mul(this.lightColor, pb.max(this.diffuseBRDF, pb.vec3(0)));
611
- if (that.transmission && that.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
612
- this.$l.transmissionRay = that.getVolumeTransmissionRay(this, this.normal, this.viewVec, this.data.thicknessFactor, this.data.f0.a);
613
- this.$l.pointToLight = pb.normalize(pb.sub(this.L, this.transmissionRay));
614
- this.$l.transmittedLight = pb.mul(this.lightColor, that.getPunctualRadianceTransmission(this, this.normal, this.viewVec, this.pointToLight, this.alphaRoughness, this.data.f0.rgb, this.data.f90.rgb, this.data.diffuse.rgb, this.data.f0.a));
615
- this.transmittedLight = that.applyVolumeAttenuation(this, this.transmittedLight, pb.length(this.transmissionRay), this.data.attenuationColor, this.data.attenuationDistance);
616
- this.diffuse = pb.mix(this.diffuse, this.transmittedLight, this.data.transmissionFactor);
617
- }
618
- if (that.sheen) {
619
- this.diffuse = pb.mul(this.diffuse, this.data.sheenAlbedoScaling);
620
- }
621
- this.outColor = pb.add(this.outColor, this.diffuse);
622
- if (that.sheen) {
623
- this.$l.sheenD = that.D_Charlie(this, this.NoH, this.data.sheenRoughness);
624
- this.$l.sheenV = that.V_Ashikhmin(this, this.NoL, this.NoV);
625
- this.outColor = pb.add(this.outColor, pb.mul(this.lightColor, this.data.sheenColor, this.sheenD, this.sheenV));
626
- }
627
- if (that.clearcoat) {
628
- this.alphaRoughness = pb.mul(this.data.ccFactor.y, this.data.ccFactor.y);
629
- this.NoH = pb.clamp(pb.dot(this.data.ccNormal, this.H), 0, 1);
630
- this.NoL = pb.clamp(pb.dot(this.data.ccNormal, this.L), 0, 1);
631
- this.ccF0 = pb.vec3(pb.pow(pb.div(pb.sub(this.data.f0.a, 1), pb.add(this.data.f0.a, 1)), 2));
632
- this.F = that.fresnelSchlick(this, this.VoH, this.ccF0, pb.vec3(1));
633
- this.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);
634
- this.V = that.visGGX(this, this.data.ccNoV, this.NoL, this.alphaRoughness);
635
- this.outColor = pb.add(this.outColor, pb.mul(this.D, this.V, this.F, this.data.ccFactor.x));
636
- }
637
- });
638
- });
639
- scope.$g[funcName](lightDir, lightColor, normal, viewVec, commonData, outColor);
640
- }
641
- fresnel0ToIor(scope, fresnel0) {
642
- const pb = scope.$builder;
643
- const funcName = 'Z_fresnel0ToIor';
644
- pb.func(funcName, [
645
- pb.vec3('fresnel0')
646
- ], function() {
647
- this.$l.sqrtF0 = pb.sqrt(this.fresnel0);
648
- this.$return(pb.div(pb.add(this.sqrtF0, pb.vec3(1)), pb.sub(pb.vec3(1), this.sqrtF0)));
649
- });
650
- return pb.getGlobalScope()[funcName](fresnel0);
651
- }
652
- iorToFresnel0v(scope, transmittedIor, incidentIor) {
653
- const pb = scope.$builder;
654
- const funcName = 'Z_iorToFresnel0v';
655
- pb.func(funcName, [
656
- pb.vec3('transmittedIor'),
657
- pb.float('incidentIor')
658
- ], function() {
659
- this.$l.t = pb.div(pb.sub(this.transmittedIor, pb.vec3(this.incidentIor)), pb.add(this.transmittedIor, pb.vec3(this.incidentIor)));
660
- this.$return(pb.mul(this.t, this.t));
661
- });
662
- return pb.getGlobalScope()[funcName](transmittedIor, incidentIor);
663
- }
664
- iorToFresnel0(scope, transmittedIor, incidentIor) {
665
- const pb = scope.$builder;
666
- const funcName = 'Z_iorToFresnel0';
667
- pb.func(funcName, [
668
- pb.float('transmittedIor'),
669
- pb.float('incidentIor')
670
- ], function() {
671
- this.$l.t = pb.div(pb.sub(this.transmittedIor, this.incidentIor), pb.add(this.transmittedIor, this.incidentIor));
672
- this.$return(pb.mul(this.t, this.t));
673
- });
674
- return pb.getGlobalScope()[funcName](transmittedIor, incidentIor);
675
- }
676
- evalSensitivity(scope, OPD, shift) {
677
- const pb = scope.$builder;
678
- const funcName = 'Z_evalSensitivity';
679
- pb.func(funcName, [
680
- pb.float('OPD'),
681
- pb.vec3('shift')
682
- ], function() {
683
- this.$l.phase = pb.mul(Math.PI * 2, this.OPD, 1e-9);
684
- this.$l.val = pb.vec3(5.4856e-13, 4.4201e-13, 5.2481e-13);
685
- this.$l.pos = pb.vec3(1.681e6, 1.7953e6, 2.2084e6);
686
- this.$l.va = pb.vec3(4.3278e9, 9.3046e9, 6.6121e9);
687
- this.$l.xyz = pb.mul(this.val, pb.sqrt(pb.mul(Math.PI * 2, this.va)), pb.cos(pb.add(pb.mul(this.pos, this.phase), this.shift)), pb.exp(pb.neg(pb.mul(this.phase, this.phase, this.va))));
688
- this.xyz.x = pb.add(this.xyz.x, pb.mul(9.747e-14, Math.sqrt(Math.PI * 2 * 4.5282e9), pb.cos(pb.add(pb.mul(this.phase, 2.2399e6), this.shift.x)), pb.exp(pb.mul(-45282e5, this.phase, this.phase))));
689
- this.xyz = pb.div(this.xyz, 1.0685e-7);
690
- this.$return(pb.mul(pb.mat3(3.2404542, -0.969266, 0.0556434, -1.5371385, 1.8760108, -0.2040259, -0.4985314, 0.041556, 1.0572252), this.xyz));
691
- });
692
- return pb.getGlobalScope()[funcName](OPD, shift);
693
- }
694
- schlickToF0(scope, f, f90, VdotH) {
695
- const pb = scope.$builder;
696
- const funcName = 'Z_schlickToF0';
697
- pb.func(funcName, [
698
- pb.vec3('f'),
699
- pb.vec3('f90'),
700
- pb.float('VdotH')
701
- ], function() {
702
- this.$l.x = pb.clamp(pb.sub(1, this.VdotH), 0, 1);
703
- this.$l.x2 = pb.mul(this.x, this.x);
704
- this.$l.x5 = pb.clamp(pb.mul(this.x, this.x2, this.x2), 0, 0.9999);
705
- this.$return(pb.div(pb.sub(this.f, pb.mul(this.f90, this.x5)), pb.sub(1, this.x5)));
706
- });
707
- return pb.getGlobalScope()[funcName](f, f90, VdotH);
708
- }
709
- evalIridescence(scope, outsideIOR, eta2, cosTheta1, thinFilmThickness, baseF0) {
710
- const pb = scope.$builder;
711
- const that = this;
712
- const funcName = 'Z_evalIridescence';
713
- pb.func(funcName, [
714
- pb.float('outsideIOR'),
715
- pb.float('eta2'),
716
- pb.float('cosTheta1'),
717
- pb.float('thinFilmThickness'),
718
- pb.vec3('baseF0')
719
- ], function() {
720
- this.$l.iridescenceIor = pb.mix(this.outsideIOR, this.eta2, pb.smoothStep(0, 0.03, this.thinFilmThickness));
721
- this.$l.t = pb.div(this.outsideIOR, this.iridescenceIor);
722
- this.$l.sinTheta2Sq = pb.mul(this.t, this.t, pb.sub(1, pb.mul(this.cosTheta1, this.cosTheta1)));
723
- this.$l.cosTheta2Sq = pb.sub(1, this.sinTheta2Sq);
724
- this.$if(pb.lessThan(this.cosTheta2Sq, 0), function() {
725
- this.$return(pb.vec3(1));
726
- });
727
- this.$l.cosTheta2 = pb.sqrt(this.cosTheta2Sq);
728
- this.$l.R0 = that.iorToFresnel0(this, this.iridescenceIor, this.outsideIOR);
729
- this.$l.R12 = that.fresnelSchlick(this, this.cosTheta1, pb.vec3(this.R0), pb.vec3(1)).x;
730
- this.$l.R21 = this.R12;
731
- this.$l.T121 = pb.sub(1, this.R12);
732
- this.$l.phi12 = pb.float(0);
733
- this.$if(pb.lessThan(this.iridescenceIor, this.outsideIOR), function() {
734
- this.phi12 = Math.PI;
735
- });
736
- this.$l.phi21 = pb.sub(Math.PI, this.phi12);
737
- this.$l.baseIOR = that.fresnel0ToIor(this, pb.clamp(this.baseF0, pb.vec3(0), pb.vec3(0.9999)));
738
- this.$l.R1 = that.iorToFresnel0v(this, this.baseIOR, this.iridescenceIor);
739
- this.$l.R23 = that.fresnelSchlick(this, this.cosTheta2, this.R1, pb.vec3(1));
740
- this.$l.phi23 = pb.vec3(0);
741
- this.$if(pb.lessThan(this.baseIOR.x, this.iridescenceIor), function() {
742
- this.phi23.x = Math.PI;
743
- });
744
- this.$if(pb.lessThan(this.baseIOR.y, this.iridescenceIor), function() {
745
- this.phi23.y = Math.PI;
746
- });
747
- this.$if(pb.lessThan(this.baseIOR.z, this.iridescenceIor), function() {
748
- this.phi23.z = Math.PI;
749
- });
750
- this.$l.OPD = pb.mul(this.iridescenceIor, this.thinFilmThickness, this.cosTheta2, 2);
751
- this.$l.phi = pb.add(pb.vec3(this.phi21), this.phi23);
752
- this.$l.R123 = pb.clamp(pb.mul(this.R12, this.R23), pb.vec3(1e-5), pb.vec3(0.9999));
753
- this.$l.r123 = pb.sqrt(this.R123);
754
- this.$l.Rs = pb.div(pb.mul(this.T121, this.T121, this.R23), pb.sub(pb.vec3(1), this.R123));
755
- this.$l.C0 = pb.add(pb.vec3(this.R12), this.Rs);
756
- this.$l.I = this.C0;
757
- this.$l.Cm = pb.sub(this.Rs, pb.vec3(this.T121));
758
- this.$for(pb.int('m'), 1, 3, function() {
759
- this.Cm = pb.mul(this.Cm, this.r123);
760
- this.$l.Sm = pb.mul(that.evalSensitivity(this, pb.mul(this.OPD, pb.float(this.m)), pb.mul(this.phi, pb.float(this.m))), 2);
761
- this.I = pb.add(this.I, pb.mul(this.Cm, this.Sm));
762
- });
763
- this.$return(pb.max(this.I, pb.vec3(0)));
764
- });
765
- return pb.getGlobalScope()[funcName](outsideIOR, eta2, cosTheta1, thinFilmThickness, baseF0);
766
- }
767
- indirectLighting(scope, normal, viewVec, commonData, outColor, outRoughness) {
768
- const pb = scope.$builder;
769
- const that = this;
770
- const ctx = that.drawContext;
771
- const funcName = 'Z_PBRIndirectLighting';
772
- pb.func(funcName, [
773
- pb.vec3('normal'),
774
- pb.vec3('viewVec'),
775
- that.getCommonDatasStruct(scope)('data'),
776
- pb.vec3('outColor').inout(),
777
- ...outRoughness ? [
778
- pb.vec4('outRoughness').out()
779
- ] : []
780
- ], function() {
781
- if (!ctx.drawEnvLight || !ctx.env.light.envLight.hasRadiance() && !ctx.env.light.envLight.hasIrradiance()) {
782
- return;
783
- }
784
- const envLightStrength = ShaderHelper.getEnvLightStrength(this);
785
- if (that.occlusionTexture) {
786
- const occlusionSample = that.sampleOcclusionTexture(this).r;
787
- this.$l.occlusion = pb.mul(pb.add(pb.mul(this.zOcclusionStrength, pb.sub(occlusionSample, 1)), 1), envLightStrength);
788
- } else {
789
- this.$l.occlusion = envLightStrength;
790
- }
791
- this.$l.NoV = pb.clamp(pb.dot(this.normal, this.viewVec), 0.0001, 1);
792
- this.$l.ggxLutSample = pb.clamp(pb.textureSampleLevel(this.zGGXLut, pb.clamp(pb.vec2(this.NoV, this.data.roughness), pb.vec2(0), pb.vec2(1)), 0), pb.vec4(0), pb.vec4(1));
793
- this.$l.f_ab = this.ggxLutSample.rg;
794
- this.$l.Fr = pb.sub(pb.max(pb.vec3(pb.sub(1, this.data.roughness)), this.data.f0.rgb), this.data.f0.rgb);
795
- if (that.iridescence) {
796
- this.$l.k_S = pb.mix(pb.add(this.data.f0.rgb, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5))), this.data.iridescenceFresnel, this.data.iridescenceFactor.x);
797
- } else {
798
- this.$l.k_S = pb.add(this.data.f0.rgb, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));
799
- }
800
- if (outRoughness || ctx.env.light.envLight.hasRadiance()) {
801
- this.$l.FssEss = pb.add(pb.mul(this.k_S, this.f_ab.x), pb.vec3(this.f_ab.y));
802
- this.$l.specularFactor = pb.mul(this.FssEss, this.data.specularWeight, this.occlusion);
803
- if (that.sheen) {
804
- this.specularFactor = pb.mul(this.specularFactor, this.data.sheenAlbedoScaling);
805
- }
806
- if (outRoughness) {
807
- this.outRoughness = pb.vec4(this.specularFactor /*this.data.f0.rgb*/ , this.data.roughness);
808
- } else if (ctx.env.light.envLight.hasRadiance()) {
809
- this.$l.radiance = ctx.env.light.envLight.getRadiance(this, pb.reflect(pb.neg(this.viewVec), this.normal), this.data.roughness);
810
- this.outColor = pb.add(this.outColor, pb.mul(this.radiance, this.specularFactor));
811
- }
812
- }
813
- if (ctx.env.light.envLight.hasIrradiance()) {
814
- this.$l.irradiance = ctx.env.light.envLight.getIrradiance(this, this.normal);
815
- if (that.iridescence) {
816
- this.$l.iridescenceF0Max = pb.vec3(pb.max(pb.max(this.data.iridescenceF0.r, this.data.iridescenceF0.g), this.data.iridescenceF0.b));
817
- this.$l.mixedF0 = pb.mix(this.data.f0.rgb, this.iridescenceF0Max, this.data.iridescenceFactor.x);
818
- this.Fr = pb.sub(pb.max(pb.vec3(pb.sub(1, this.data.roughness)), this.mixedF0), this.mixedF0);
819
- this.k_S = pb.add(this.mixedF0, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));
820
- } else {
821
- this.$l.mixedF0 = this.data.f0.rgb;
822
- }
823
- this.$l.FssEss = pb.add(pb.mul(this.k_S, this.f_ab.x, this.data.specularWeight), pb.vec3(this.f_ab.y));
824
- this.$l.Ems = pb.sub(1, pb.add(this.f_ab.x, this.f_ab.y));
825
- this.$l.F_avg = pb.mul(pb.add(this.mixedF0, pb.div(pb.sub(pb.vec3(1), this.mixedF0), 21)), this.data.specularWeight);
826
- this.$l.FmsEms = pb.div(pb.mul(this.FssEss, this.F_avg, this.Ems), pb.sub(pb.vec3(1), pb.mul(this.F_avg, this.Ems)));
827
- this.$l.k_D = pb.mul(this.data.diffuse.rgb, pb.add(pb.sub(pb.vec3(1), this.FssEss), this.FmsEms));
828
- this.$l.iblDiffuse = pb.mul(pb.add(this.FmsEms, this.k_D), this.irradiance, this.occlusion);
829
- if (that.sheen) {
830
- this.iblDiffuse = pb.mul(this.iblDiffuse, this.data.sheenAlbedoScaling);
831
- }
832
- if (that.transmission && that.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
833
- this.$l.iblTransmission = that.getIBLVolumnRefraction(this, this.ggxLutSample.rg, this.normal, this.viewVec, this.data.roughness, this.data.diffuse.rgb, this.data.f0.rgb, this.data.f90, this.$inputs.worldPos, this.data.f0.a, this.data.thicknessFactor, this.data.attenuationColor, this.data.attenuationDistance);
834
- this.iblDiffuse = pb.mix(this.iblDiffuse, this.iblTransmission, this.data.transmissionFactor);
835
- }
836
- this.outColor = pb.add(this.outColor, this.iblDiffuse);
837
- }
838
- if (that.sheen && ctx.env.light.envLight.hasIrradiance()) {
839
- this.$l.refl = pb.reflect(pb.neg(this.viewVec), this.normal);
840
- this.$l.sheenBRDF = pb.clamp(pb.textureSampleLevel(this.zGGXLut, pb.clamp(pb.vec2(this.NoV, this.data.sheenRoughness), pb.vec2(0), pb.vec2(1)), 0), pb.vec4(0), pb.vec4(1)).b;
841
- this.outColor = pb.add(this.outColor, pb.mul(this.data.sheenColor, this.irradiance.rgb, this.sheenBRDF));
842
- }
843
- if (that.clearcoat && ctx.env.light.envLight.hasRadiance()) {
844
- this.$l.NoV = pb.clamp(pb.dot(this.data.ccNormal, this.viewVec), 0.0001, 1);
845
- this.$l.ggxLutSample = pb.clamp(pb.textureSampleLevel(this.zGGXLut, pb.clamp(pb.vec2(this.NoV, this.data.ccFactor.y), pb.vec2(0), pb.vec2(1)), 0), pb.vec4(0), pb.vec4(1));
846
- this.$l.f_ab = this.ggxLutSample.rg;
847
- this.$l.Fr = pb.sub(pb.max(pb.vec3(pb.sub(1, this.data.ccFactor.y)), this.data.f0.rgb), this.data.f0.rgb);
848
- this.$l.k_S = pb.add(this.data.f0.rgb, pb.mul(this.Fr, pb.pow(pb.sub(1, this.NoV), 5)));
849
- this.$l.radiance = ctx.env.light.envLight.getRadiance(this, pb.reflect(pb.neg(this.viewVec), this.data.ccNormal), this.data.ccFactor.y);
850
- this.$l.FssEss = pb.add(pb.mul(this.k_S, this.f_ab.x), pb.vec3(this.f_ab.y));
851
- this.$l.ccSpecular = pb.mul(this.radiance, this.FssEss, this.data.specularWeight, this.occlusion);
852
- this.outColor = pb.add(this.outColor, pb.mul(this.ccSpecular, this.data.ccFactor.x));
853
- }
854
- });
855
- if (outRoughness) {
856
- scope.$g[funcName](normal, viewVec, commonData, outColor, outRoughness);
857
- } else {
858
- scope.$g[funcName](normal, viewVec, commonData, outColor);
859
- }
860
- }
861
- fresnelSchlick(scope, cosTheta, F0, F90) {
862
- const pb = scope.$builder;
863
- const funcName = 'Z_fresnelSchlick';
864
- pb.func(funcName, [
865
- pb.float('cosTheta'),
866
- pb.vec3('f0'),
867
- pb.vec3('f90')
868
- ], function() {
869
- this.$return(pb.add(this.f0, pb.mul(pb.sub(this.f90, this.f0), pb.pow(pb.clamp(pb.sub(1, this.cosTheta), 0, 1), 5))));
870
- });
871
- return scope.$g[funcName](cosTheta, F0, F90);
872
- }
873
- distributionGGX(scope, NdotH, alphaRoughness) {
874
- const pb = scope.$builder;
875
- const funcName = 'Z_distributionGGX';
876
- pb.func(funcName, [
877
- pb.float('NdotH'),
878
- pb.float('roughness')
879
- ], function() {
880
- this.$l.a2 = pb.mul(this.roughness, this.roughness);
881
- this.$l.NdotH2 = pb.mul(this.NdotH, this.NdotH);
882
- this.$l.num = this.a2;
883
- this.$l.denom = pb.add(pb.mul(this.NdotH2, pb.sub(this.a2, 1)), 1);
884
- this.denom = pb.mul(pb.mul(3.14159265, this.denom), this.denom);
885
- this.$return(pb.div(this.num, this.denom));
886
- });
887
- return scope.$g[funcName](NdotH, alphaRoughness);
888
- }
889
- visGGX(scope, NdotV, NdotL, alphaRoughness) {
890
- const pb = scope.$builder;
891
- const funcName = 'Z_visGGX';
892
- pb.func(funcName, [
893
- pb.float('NdotV'),
894
- pb.float('NdotL'),
895
- pb.float('roughness')
896
- ], function() {
897
- this.$l.a = this.roughness;
898
- this.$l.ggxV = pb.mul(this.NdotL, pb.sqrt(pb.add(pb.mul(this.NdotV, this.NdotV, pb.sub(1, this.a)), this.a)));
899
- this.$l.ggxL = pb.mul(this.NdotV, pb.sqrt(pb.add(pb.mul(this.NdotL, this.NdotL, pb.sub(1, this.a)), this.a)));
900
- this.$l.ggx = pb.add(this.ggxV, this.ggxL, 1e-5);
901
- this.$if(pb.greaterThan(this.ggx, 0), function() {
902
- this.$return(pb.div(0.5, this.ggx));
903
- }).$else(function() {
904
- this.$return(pb.float(0));
905
- });
906
- });
907
- return scope.$g[funcName](NdotV, NdotL, alphaRoughness);
908
- }
909
- };
910
- FEATURE_SHEEN = cls.defineFeature();
911
- FEATURE_CLEARCOAT = cls.defineFeature();
912
- FEATURE_TRANSMISSION = cls.defineFeature();
913
- FEATURE_IRIDESCENCE = cls.defineFeature();
914
- return cls;
915
- }
916
-
917
- export { mixinPBRCommon };
918
- //# sourceMappingURL=common.js.map