@zephyr3d/scene 0.9.1 → 0.9.3

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 (522) hide show
  1. package/dist/animation/animationset.js +2 -0
  2. package/dist/animation/animationset.js.map +1 -1
  3. package/dist/animation/cloth/gpu_cloth_system.js +9 -1
  4. package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
  5. package/dist/animation/fixed_geometry_cache_track.js +5 -1
  6. package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
  7. package/dist/animation/geometry_cache_utils.js +20 -4
  8. package/dist/animation/geometry_cache_utils.js.map +1 -1
  9. package/dist/animation/ik/ik_angle_constraint.js +2 -6
  10. package/dist/animation/ik/ik_angle_constraint.js.map +1 -1
  11. package/dist/animation/ik/ik_chain_builder.js +68 -0
  12. package/dist/animation/ik/ik_chain_builder.js.map +1 -0
  13. package/dist/animation/ik/ik_pole_constraint.js +2 -7
  14. package/dist/animation/ik/ik_pole_constraint.js.map +1 -1
  15. package/dist/animation/ik/two_bone_ik_solver.js +2 -6
  16. package/dist/animation/ik/two_bone_ik_solver.js.map +1 -1
  17. package/dist/animation/joint_dynamics/collision.js +60 -12
  18. package/dist/animation/joint_dynamics/collision.js.map +1 -1
  19. package/dist/animation/joint_dynamics/constraints.js +20 -4
  20. package/dist/animation/joint_dynamics/constraints.js.map +1 -1
  21. package/dist/animation/joint_dynamics/controller.js +94 -46
  22. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  23. package/dist/animation/joint_dynamics/math.js +16 -0
  24. package/dist/animation/joint_dynamics/math.js.map +1 -0
  25. package/dist/animation/joint_dynamics/solver.js +21 -11
  26. package/dist/animation/joint_dynamics/solver.js.map +1 -1
  27. package/dist/animation/joint_dynamics/types.js +15 -3
  28. package/dist/animation/joint_dynamics/types.js.map +1 -1
  29. package/dist/animation/pca_geometry_cache_track.js +5 -1
  30. package/dist/animation/pca_geometry_cache_track.js.map +1 -1
  31. package/dist/animation/skeleton.js +2 -2
  32. package/dist/animation/skeleton.js.map +1 -1
  33. package/dist/animation/skeleton_modifier.js +2 -6
  34. package/dist/animation/skeleton_modifier.js.map +1 -1
  35. package/dist/animation/spring/spring_particle.js +4 -4
  36. package/dist/animation/spring/spring_particle.js.map +1 -1
  37. package/dist/animation/spring/spring_system.js +13 -40
  38. package/dist/animation/spring/spring_system.js.map +1 -1
  39. package/dist/animation/spring2/constraints.js.map +1 -1
  40. package/dist/animation/spring2/controller.js +64 -64
  41. package/dist/animation/spring2/controller.js.map +1 -1
  42. package/dist/animation/spring2/math.js.map +1 -1
  43. package/dist/animation/spring2/spring_system.js +8 -8
  44. package/dist/animation/spring2/spring_system.js.map +1 -1
  45. package/dist/app/app.js.map +1 -1
  46. package/dist/app/engine.js +1 -1
  47. package/dist/app/engine.js.map +1 -1
  48. package/dist/app/screen.js +4 -4
  49. package/dist/app/screen.js.map +1 -1
  50. package/dist/app/scriptingsystem.js +24 -1
  51. package/dist/app/scriptingsystem.js.map +1 -1
  52. package/dist/app/scriptregistry.js +22 -1
  53. package/dist/app/scriptregistry.js.map +1 -1
  54. package/dist/asset/assetmanager.js +2 -2
  55. package/dist/asset/assetmanager.js.map +1 -1
  56. package/dist/asset/model.js +60 -60
  57. package/dist/asset/model.js.map +1 -1
  58. package/dist/camera/camera.js +1 -1
  59. package/dist/camera/camera.js.map +1 -1
  60. package/dist/camera/orbit.js.map +1 -1
  61. package/dist/index.d.ts +795 -266
  62. package/dist/index.js +3 -2
  63. package/dist/index.js.map +1 -1
  64. package/dist/material/material.js +3 -1
  65. package/dist/material/material.js.map +1 -1
  66. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  67. package/dist/material/shader/helper.js +281 -278
  68. package/dist/material/shader/helper.js.map +1 -1
  69. package/dist/material/sprite.js +6 -6
  70. package/dist/material/sprite.js.map +1 -1
  71. package/dist/material/terrain-cm.js +2 -2
  72. package/dist/material/terrain-cm.js.map +1 -1
  73. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +38 -0
  74. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +1 -0
  75. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +10 -0
  76. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +1 -0
  77. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +127 -0
  78. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +1 -0
  79. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +263 -0
  80. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +1 -0
  81. package/dist/posteffect/taa.js +31 -39
  82. package/dist/posteffect/taa.js.map +1 -1
  83. package/dist/render/cluster_light.js +3 -4
  84. package/dist/render/cluster_light.js.map +1 -1
  85. package/dist/render/drawable.js +5 -1
  86. package/dist/render/drawable.js.map +1 -1
  87. package/dist/render/rendergraph/device_pool_allocator.js +29 -3
  88. package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
  89. package/dist/render/rendergraph/executor.js +283 -33
  90. package/dist/render/rendergraph/executor.js.map +1 -1
  91. package/dist/render/rendergraph/forward_plus_builder.js +338 -108
  92. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
  93. package/dist/render/rendergraph/history_resource_manager.js +195 -115
  94. package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
  95. package/dist/render/rendergraph/history_resources.js +10 -0
  96. package/dist/render/rendergraph/history_resources.js.map +1 -0
  97. package/dist/render/rendergraph/rendergraph.js +162 -35
  98. package/dist/render/rendergraph/rendergraph.js.map +1 -1
  99. package/dist/render/rendergraph/types.js +25 -5
  100. package/dist/render/rendergraph/types.js.map +1 -1
  101. package/dist/render/rendertarget.js +5 -1
  102. package/dist/render/rendertarget.js.map +1 -1
  103. package/dist/render/screenrendertarget.js +5 -1
  104. package/dist/render/screenrendertarget.js.map +1 -1
  105. package/dist/render/sky.js +4 -4
  106. package/dist/render/sky.js.map +1 -1
  107. package/dist/scene/basesprite.js +2 -2
  108. package/dist/scene/basesprite.js.map +1 -1
  109. package/dist/scene/graph_node.js +1 -1
  110. package/dist/scene/graph_node.js.map +1 -1
  111. package/dist/scene/mesh.js +81 -97
  112. package/dist/scene/mesh.js.map +1 -1
  113. package/dist/scene/particlesys.js +1 -1
  114. package/dist/scene/particlesys.js.map +1 -1
  115. package/dist/scene/scene_node.js +228 -228
  116. package/dist/scene/scene_node.js.map +1 -1
  117. package/dist/scene/script_attachment.js +15 -3
  118. package/dist/scene/script_attachment.js.map +1 -1
  119. package/dist/scene/terrain-cm/terrain-cm.js +3 -3
  120. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  121. package/dist/shadow/shadowmapper.js.map +1 -1
  122. package/dist/shapes/box.js +1 -1
  123. package/dist/shapes/box.js.map +1 -1
  124. package/dist/shapes/capsule.js +0 -3
  125. package/dist/shapes/capsule.js.map +1 -1
  126. package/dist/shapes/cylinder.js +0 -3
  127. package/dist/shapes/cylinder.js.map +1 -1
  128. package/dist/shapes/plane.js +0 -3
  129. package/dist/shapes/plane.js.map +1 -1
  130. package/dist/shapes/tetrahedron.js +3 -9
  131. package/dist/shapes/tetrahedron.js.map +1 -1
  132. package/dist/shapes/torus.js +94 -66
  133. package/dist/shapes/torus.js.map +1 -1
  134. package/dist/src/animation/animation.js +127 -0
  135. package/dist/src/animation/animation.js.map +1 -0
  136. package/dist/src/animation/animationset.js +255 -0
  137. package/dist/src/animation/animationset.js.map +1 -0
  138. package/dist/src/animation/animationtrack.js +34 -0
  139. package/dist/src/animation/animationtrack.js.map +1 -0
  140. package/dist/src/animation/eulerrotationtrack.js +52 -0
  141. package/dist/src/animation/eulerrotationtrack.js.map +1 -0
  142. package/dist/src/animation/morphtarget.js +93 -0
  143. package/dist/src/animation/morphtarget.js.map +1 -0
  144. package/dist/src/animation/morphtrack.js +70 -0
  145. package/dist/src/animation/morphtrack.js.map +1 -0
  146. package/dist/src/animation/proptrack.js +161 -0
  147. package/dist/src/animation/proptrack.js.map +1 -0
  148. package/dist/src/animation/rotationtrack.js +51 -0
  149. package/dist/src/animation/rotationtrack.js.map +1 -0
  150. package/dist/src/animation/scaletrack.js +50 -0
  151. package/dist/src/animation/scaletrack.js.map +1 -0
  152. package/dist/src/animation/skeleton.js +204 -0
  153. package/dist/src/animation/skeleton.js.map +1 -0
  154. package/dist/src/animation/translationtrack.js +50 -0
  155. package/dist/src/animation/translationtrack.js.map +1 -0
  156. package/dist/src/app/app.js +129 -0
  157. package/dist/src/app/app.js.map +1 -0
  158. package/dist/src/app/inputmgr.js +267 -0
  159. package/dist/src/app/inputmgr.js.map +1 -0
  160. package/dist/src/asset/assetmanager.js +404 -0
  161. package/dist/src/asset/assetmanager.js.map +1 -0
  162. package/dist/src/asset/builtin.js +337 -0
  163. package/dist/src/asset/builtin.js.map +1 -0
  164. package/dist/src/asset/loaders/dds/dds.js +470 -0
  165. package/dist/src/asset/loaders/dds/dds.js.map +1 -0
  166. package/dist/src/asset/loaders/dds/dds_loader.js +28 -0
  167. package/dist/src/asset/loaders/dds/dds_loader.js.map +1 -0
  168. package/dist/src/asset/loaders/gltf/gltf_loader.js +1265 -0
  169. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +1 -0
  170. package/dist/src/asset/loaders/gltf/helpers.js +327 -0
  171. package/dist/src/asset/loaders/gltf/helpers.js.map +1 -0
  172. package/dist/src/asset/loaders/hdr/hdr.js +180 -0
  173. package/dist/src/asset/loaders/hdr/hdr.js.map +1 -0
  174. package/dist/src/asset/loaders/image/tga_Loader.js +116 -0
  175. package/dist/src/asset/loaders/image/tga_Loader.js.map +1 -0
  176. package/dist/src/asset/loaders/image/webimage_loader.js +63 -0
  177. package/dist/src/asset/loaders/image/webimage_loader.js.map +1 -0
  178. package/dist/src/asset/loaders/loader.js +45 -0
  179. package/dist/src/asset/loaders/loader.js.map +1 -0
  180. package/dist/src/asset/model.js +414 -0
  181. package/dist/src/asset/model.js.map +1 -0
  182. package/dist/src/blitter/bilateralblur.js +221 -0
  183. package/dist/src/blitter/bilateralblur.js.map +1 -0
  184. package/dist/src/blitter/blitter.js +390 -0
  185. package/dist/src/blitter/blitter.js.map +1 -0
  186. package/dist/src/blitter/box.js +118 -0
  187. package/dist/src/blitter/box.js.map +1 -0
  188. package/dist/src/blitter/copy.js +22 -0
  189. package/dist/src/blitter/copy.js.map +1 -0
  190. package/dist/src/blitter/gaussianblur.js +228 -0
  191. package/dist/src/blitter/gaussianblur.js.map +1 -0
  192. package/dist/src/camera/base.js +92 -0
  193. package/dist/src/camera/base.js.map +1 -0
  194. package/dist/src/camera/camera.js +1005 -0
  195. package/dist/src/camera/camera.js.map +1 -0
  196. package/dist/src/camera/fps.js +238 -0
  197. package/dist/src/camera/fps.js.map +1 -0
  198. package/dist/src/camera/orbit.js +245 -0
  199. package/dist/src/camera/orbit.js.map +1 -0
  200. package/dist/src/camera/orthocamera.js +167 -0
  201. package/dist/src/camera/orthocamera.js.map +1 -0
  202. package/dist/src/camera/perspectivecamera.js +141 -0
  203. package/dist/src/camera/perspectivecamera.js.map +1 -0
  204. package/dist/src/index.js +120 -0
  205. package/dist/src/index.js.map +1 -0
  206. package/dist/src/material/blinn.js +81 -0
  207. package/dist/src/material/blinn.js.map +1 -0
  208. package/dist/src/material/grassmaterial.js +113 -0
  209. package/dist/src/material/grassmaterial.js.map +1 -0
  210. package/dist/src/material/lambert.js +92 -0
  211. package/dist/src/material/lambert.js.map +1 -0
  212. package/dist/src/material/material.js +301 -0
  213. package/dist/src/material/material.js.map +1 -0
  214. package/dist/src/material/meshmaterial.js +704 -0
  215. package/dist/src/material/meshmaterial.js.map +1 -0
  216. package/dist/src/material/mixins/albedocolor.js +76 -0
  217. package/dist/src/material/mixins/albedocolor.js.map +1 -0
  218. package/dist/src/material/mixins/foliage.js +47 -0
  219. package/dist/src/material/mixins/foliage.js.map +1 -0
  220. package/dist/src/material/mixins/lightmodel/blinnphong.js +112 -0
  221. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +1 -0
  222. package/dist/src/material/mixins/lightmodel/lambert.js +58 -0
  223. package/dist/src/material/mixins/lightmodel/lambert.js.map +1 -0
  224. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +178 -0
  225. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -0
  226. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +139 -0
  227. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -0
  228. package/dist/src/material/mixins/lit.js +476 -0
  229. package/dist/src/material/mixins/lit.js.map +1 -0
  230. package/dist/src/material/mixins/pbr/common.js +918 -0
  231. package/dist/src/material/mixins/pbr/common.js.map +1 -0
  232. package/dist/src/material/mixins/texture.js +172 -0
  233. package/dist/src/material/mixins/texture.js.map +1 -0
  234. package/dist/src/material/mixins/vertexcolor.js +56 -0
  235. package/dist/src/material/mixins/vertexcolor.js.map +1 -0
  236. package/dist/src/material/particle.js +178 -0
  237. package/dist/src/material/particle.js.map +1 -0
  238. package/dist/src/material/pbrmr.js +97 -0
  239. package/dist/src/material/pbrmr.js.map +1 -0
  240. package/dist/src/material/pbrsg.js +97 -0
  241. package/dist/src/material/pbrsg.js.map +1 -0
  242. package/dist/src/material/shader/helper.js +1209 -0
  243. package/dist/src/material/shader/helper.js.map +1 -0
  244. package/dist/src/material/terrain-cm.js +606 -0
  245. package/dist/src/material/terrain-cm.js.map +1 -0
  246. package/dist/src/material/terrainmaterial.js +375 -0
  247. package/dist/src/material/terrainmaterial.js.map +1 -0
  248. package/dist/src/material/unlit.js +41 -0
  249. package/dist/src/material/unlit.js.map +1 -0
  250. package/dist/src/material/water.js +417 -0
  251. package/dist/src/material/water.js.map +1 -0
  252. package/dist/src/posteffect/bloom.js +361 -0
  253. package/dist/src/posteffect/bloom.js.map +1 -0
  254. package/dist/src/posteffect/compositor.js +226 -0
  255. package/dist/src/posteffect/compositor.js.map +1 -0
  256. package/dist/src/posteffect/fxaa.js +273 -0
  257. package/dist/src/posteffect/fxaa.js.map +1 -0
  258. package/dist/src/posteffect/grayscale.js +69 -0
  259. package/dist/src/posteffect/grayscale.js.map +1 -0
  260. package/dist/src/posteffect/motionblur.js +96 -0
  261. package/dist/src/posteffect/motionblur.js.map +1 -0
  262. package/dist/src/posteffect/posteffect.js +126 -0
  263. package/dist/src/posteffect/posteffect.js.map +1 -0
  264. package/dist/src/posteffect/sao.js +324 -0
  265. package/dist/src/posteffect/sao.js.map +1 -0
  266. package/dist/src/posteffect/ssr.js +489 -0
  267. package/dist/src/posteffect/ssr.js.map +1 -0
  268. package/dist/src/posteffect/taa.js +172 -0
  269. package/dist/src/posteffect/taa.js.map +1 -0
  270. package/dist/src/posteffect/tonemap.js +94 -0
  271. package/dist/src/posteffect/tonemap.js.map +1 -0
  272. package/dist/src/render/abuffer_oit.js +361 -0
  273. package/dist/src/render/abuffer_oit.js.map +1 -0
  274. package/dist/src/render/clipmap.js +851 -0
  275. package/dist/src/render/clipmap.js.map +1 -0
  276. package/dist/src/render/cluster_light.js +333 -0
  277. package/dist/src/render/cluster_light.js.map +1 -0
  278. package/dist/src/render/cull_visitor.js +187 -0
  279. package/dist/src/render/cull_visitor.js.map +1 -0
  280. package/dist/src/render/depthpass.js +68 -0
  281. package/dist/src/render/depthpass.js.map +1 -0
  282. package/dist/src/render/drawable_mixin.js +227 -0
  283. package/dist/src/render/drawable_mixin.js.map +1 -0
  284. package/dist/src/render/envlight.js +463 -0
  285. package/dist/src/render/envlight.js.map +1 -0
  286. package/dist/src/render/fbm_wavegenerator.js +251 -0
  287. package/dist/src/render/fbm_wavegenerator.js.map +1 -0
  288. package/dist/src/render/fft_wavegenerator.js +1006 -0
  289. package/dist/src/render/fft_wavegenerator.js.map +1 -0
  290. package/dist/src/render/fullscreenquad.js +38 -0
  291. package/dist/src/render/fullscreenquad.js.map +1 -0
  292. package/dist/src/render/gerstner_wavegenerator.js +314 -0
  293. package/dist/src/render/gerstner_wavegenerator.js.map +1 -0
  294. package/dist/src/render/globalbindgroup_allocator.js +60 -0
  295. package/dist/src/render/globalbindgroup_allocator.js.map +1 -0
  296. package/dist/src/render/hzb.js +273 -0
  297. package/dist/src/render/hzb.js.map +1 -0
  298. package/dist/src/render/lightpass.js +172 -0
  299. package/dist/src/render/lightpass.js.map +1 -0
  300. package/dist/src/render/objectcolorpass.js +51 -0
  301. package/dist/src/render/objectcolorpass.js.map +1 -0
  302. package/dist/src/render/primitive.js +364 -0
  303. package/dist/src/render/primitive.js.map +1 -0
  304. package/dist/src/render/render_queue.js +467 -0
  305. package/dist/src/render/render_queue.js.map +1 -0
  306. package/dist/src/render/renderbundle_wrapper.js +152 -0
  307. package/dist/src/render/renderbundle_wrapper.js.map +1 -0
  308. package/dist/src/render/renderer.js +455 -0
  309. package/dist/src/render/renderer.js.map +1 -0
  310. package/dist/src/render/renderpass.js +200 -0
  311. package/dist/src/render/renderpass.js.map +1 -0
  312. package/dist/src/render/shadowmap_pass.js +56 -0
  313. package/dist/src/render/shadowmap_pass.js.map +1 -0
  314. package/dist/src/render/sky.js +1103 -0
  315. package/dist/src/render/sky.js.map +1 -0
  316. package/dist/src/render/weightedblended_oit.js +168 -0
  317. package/dist/src/render/weightedblended_oit.js.map +1 -0
  318. package/dist/src/scene/batchgroup.js +162 -0
  319. package/dist/src/scene/batchgroup.js.map +1 -0
  320. package/dist/src/scene/environment.js +209 -0
  321. package/dist/src/scene/environment.js.map +1 -0
  322. package/dist/src/scene/graph_node.js +72 -0
  323. package/dist/src/scene/graph_node.js.map +1 -0
  324. package/dist/src/scene/light.js +416 -0
  325. package/dist/src/scene/light.js.map +1 -0
  326. package/dist/src/scene/mesh.js +341 -0
  327. package/dist/src/scene/mesh.js.map +1 -0
  328. package/dist/src/scene/octree.js +649 -0
  329. package/dist/src/scene/octree.js.map +1 -0
  330. package/dist/src/scene/particlesys.js +738 -0
  331. package/dist/src/scene/particlesys.js.map +1 -0
  332. package/dist/src/scene/raycast_visitor.js +103 -0
  333. package/dist/src/scene/raycast_visitor.js.map +1 -0
  334. package/dist/src/scene/scene.js +284 -0
  335. package/dist/src/scene/scene.js.map +1 -0
  336. package/dist/src/scene/scene_node.js +732 -0
  337. package/dist/src/scene/scene_node.js.map +1 -0
  338. package/dist/src/scene/terrain/grass.js +278 -0
  339. package/dist/src/scene/terrain/grass.js.map +1 -0
  340. package/dist/src/scene/terrain/heightfield.js +475 -0
  341. package/dist/src/scene/terrain/heightfield.js.map +1 -0
  342. package/dist/src/scene/terrain/patch.js +530 -0
  343. package/dist/src/scene/terrain/patch.js.map +1 -0
  344. package/dist/src/scene/terrain/quadtree.js +461 -0
  345. package/dist/src/scene/terrain/quadtree.js.map +1 -0
  346. package/dist/src/scene/terrain/terrain.js +246 -0
  347. package/dist/src/scene/terrain/terrain.js.map +1 -0
  348. package/dist/src/scene/terrain-cm/grass.js +594 -0
  349. package/dist/src/scene/terrain-cm/grass.js.map +1 -0
  350. package/dist/src/scene/terrain-cm/grassmaterial.js +159 -0
  351. package/dist/src/scene/terrain-cm/grassmaterial.js.map +1 -0
  352. package/dist/src/scene/terrain-cm/terrain-cm.js +538 -0
  353. package/dist/src/scene/terrain-cm/terrain-cm.js.map +1 -0
  354. package/dist/src/scene/water.js +374 -0
  355. package/dist/src/scene/water.js.map +1 -0
  356. package/dist/src/shaders/atmosphere.js +957 -0
  357. package/dist/src/shaders/atmosphere.js.map +1 -0
  358. package/dist/src/shaders/fog.js +112 -0
  359. package/dist/src/shaders/fog.js.map +1 -0
  360. package/dist/src/shaders/misc.js +266 -0
  361. package/dist/src/shaders/misc.js.map +1 -0
  362. package/dist/src/shaders/noise.js +222 -0
  363. package/dist/src/shaders/noise.js.map +1 -0
  364. package/dist/src/shaders/pbr.js +51 -0
  365. package/dist/src/shaders/pbr.js.map +1 -0
  366. package/dist/src/shaders/shadow.js +636 -0
  367. package/dist/src/shaders/shadow.js.map +1 -0
  368. package/dist/src/shaders/ssr.js +490 -0
  369. package/dist/src/shaders/ssr.js.map +1 -0
  370. package/dist/src/shaders/temporal.js +215 -0
  371. package/dist/src/shaders/temporal.js.map +1 -0
  372. package/dist/src/shaders/water.js +756 -0
  373. package/dist/src/shaders/water.js.map +1 -0
  374. package/dist/src/shadow/esm.js +237 -0
  375. package/dist/src/shadow/esm.js.map +1 -0
  376. package/dist/src/shadow/pcf_opt.js +181 -0
  377. package/dist/src/shadow/pcf_opt.js.map +1 -0
  378. package/dist/src/shadow/pcf_pd.js +189 -0
  379. package/dist/src/shadow/pcf_pd.js.map +1 -0
  380. package/dist/src/shadow/shader.js +37 -0
  381. package/dist/src/shadow/shader.js.map +1 -0
  382. package/dist/src/shadow/shadow_impl.js +15 -0
  383. package/dist/src/shadow/shadow_impl.js.map +1 -0
  384. package/dist/src/shadow/shadowmapper.js +790 -0
  385. package/dist/src/shadow/shadowmapper.js.map +1 -0
  386. package/dist/src/shadow/ssm.js +159 -0
  387. package/dist/src/shadow/ssm.js.map +1 -0
  388. package/dist/src/shadow/vsm.js +297 -0
  389. package/dist/src/shadow/vsm.js.map +1 -0
  390. package/dist/src/shapes/box.js +386 -0
  391. package/dist/src/shapes/box.js.map +1 -0
  392. package/dist/src/shapes/cylinder.js +125 -0
  393. package/dist/src/shapes/cylinder.js.map +1 -0
  394. package/dist/src/shapes/plane.js +88 -0
  395. package/dist/src/shapes/plane.js.map +1 -0
  396. package/dist/src/shapes/shape.js +87 -0
  397. package/dist/src/shapes/shape.js.map +1 -0
  398. package/dist/src/shapes/sphere.js +114 -0
  399. package/dist/src/shapes/sphere.js.map +1 -0
  400. package/dist/src/shapes/tetrahedron.js +188 -0
  401. package/dist/src/shapes/tetrahedron.js.map +1 -0
  402. package/dist/src/shapes/torus.js +111 -0
  403. package/dist/src/shapes/torus.js.map +1 -0
  404. package/dist/src/utility/aabbtree.js +400 -0
  405. package/dist/src/utility/aabbtree.js.map +1 -0
  406. package/dist/src/utility/bounding_volume.js +29 -0
  407. package/dist/src/utility/bounding_volume.js.map +1 -0
  408. package/dist/src/utility/debug.js +28 -0
  409. package/dist/src/utility/debug.js.map +1 -0
  410. package/dist/src/utility/draco/decoder.js +116 -0
  411. package/dist/src/utility/draco/decoder.js.map +1 -0
  412. package/dist/src/utility/misc.js +105 -0
  413. package/dist/src/utility/misc.js.map +1 -0
  414. package/dist/src/utility/panorama.js +163 -0
  415. package/dist/src/utility/panorama.js.map +1 -0
  416. package/dist/src/utility/pmrem.js +354 -0
  417. package/dist/src/utility/pmrem.js.map +1 -0
  418. package/dist/src/utility/rendermipmap.js +115 -0
  419. package/dist/src/utility/rendermipmap.js.map +1 -0
  420. package/dist/src/utility/serialization/json.js +402 -0
  421. package/dist/src/utility/serialization/json.js.map +1 -0
  422. package/dist/src/utility/serialization/manager.js +623 -0
  423. package/dist/src/utility/serialization/manager.js.map +1 -0
  424. package/dist/src/utility/serialization/scene/animation.js +248 -0
  425. package/dist/src/utility/serialization/scene/animation.js.map +1 -0
  426. package/dist/src/utility/serialization/scene/batch.js +59 -0
  427. package/dist/src/utility/serialization/scene/batch.js.map +1 -0
  428. package/dist/src/utility/serialization/scene/camera.js +790 -0
  429. package/dist/src/utility/serialization/scene/camera.js.map +1 -0
  430. package/dist/src/utility/serialization/scene/common.js +222 -0
  431. package/dist/src/utility/serialization/scene/common.js.map +1 -0
  432. package/dist/src/utility/serialization/scene/light.js +575 -0
  433. package/dist/src/utility/serialization/scene/light.js.map +1 -0
  434. package/dist/src/utility/serialization/scene/material.js +1111 -0
  435. package/dist/src/utility/serialization/scene/material.js.map +1 -0
  436. package/dist/src/utility/serialization/scene/mesh.js +148 -0
  437. package/dist/src/utility/serialization/scene/mesh.js.map +1 -0
  438. package/dist/src/utility/serialization/scene/misc.js +39 -0
  439. package/dist/src/utility/serialization/scene/misc.js.map +1 -0
  440. package/dist/src/utility/serialization/scene/node.js +451 -0
  441. package/dist/src/utility/serialization/scene/node.js.map +1 -0
  442. package/dist/src/utility/serialization/scene/particle.js +425 -0
  443. package/dist/src/utility/serialization/scene/particle.js.map +1 -0
  444. package/dist/src/utility/serialization/scene/primitive.js +692 -0
  445. package/dist/src/utility/serialization/scene/primitive.js.map +1 -0
  446. package/dist/src/utility/serialization/scene/scene.js +704 -0
  447. package/dist/src/utility/serialization/scene/scene.js.map +1 -0
  448. package/dist/src/utility/serialization/scene/terrain.js +488 -0
  449. package/dist/src/utility/serialization/scene/terrain.js.map +1 -0
  450. package/dist/src/utility/serialization/scene/water.js +465 -0
  451. package/dist/src/utility/serialization/scene/water.js.map +1 -0
  452. package/dist/src/utility/shprojector.js +297 -0
  453. package/dist/src/utility/shprojector.js.map +1 -0
  454. package/dist/src/utility/textures/ggxlut.js +213 -0
  455. package/dist/src/utility/textures/ggxlut.js.map +1 -0
  456. package/dist/src/utility/textures/gradientnoise.js +62 -0
  457. package/dist/src/utility/textures/gradientnoise.js.map +1 -0
  458. package/dist/src/utility/textures/randomnoise.js +41 -0
  459. package/dist/src/utility/textures/randomnoise.js.map +1 -0
  460. package/dist/src/values.js +162 -0
  461. package/dist/src/values.js.map +1 -0
  462. package/dist/utility/blueprint/material/common.js +7 -0
  463. package/dist/utility/blueprint/material/common.js.map +1 -0
  464. package/dist/utility/blueprint/material/inputs.js +3 -3
  465. package/dist/utility/blueprint/material/inputs.js.map +1 -1
  466. package/dist/utility/blueprint/material/ir.js +4 -4
  467. package/dist/utility/blueprint/material/ir.js.map +1 -1
  468. package/dist/utility/serialization/blueprint/constants.js +255 -0
  469. package/dist/utility/serialization/blueprint/constants.js.map +1 -0
  470. package/dist/utility/serialization/blueprint/material/constants.js +203 -0
  471. package/dist/utility/serialization/blueprint/material/constants.js.map +1 -0
  472. package/dist/utility/serialization/blueprint/material/texture.js +165 -0
  473. package/dist/utility/serialization/blueprint/material/texture.js.map +1 -0
  474. package/dist/utility/serialization/manager.js +299 -268
  475. package/dist/utility/serialization/manager.js.map +1 -1
  476. package/dist/utility/serialization/scene/animation.js +45 -0
  477. package/dist/utility/serialization/scene/animation.js.map +1 -1
  478. package/dist/utility/serialization/scene/camera.js +53 -0
  479. package/dist/utility/serialization/scene/camera.js.map +1 -1
  480. package/dist/utility/serialization/scene/common.js +10 -0
  481. package/dist/utility/serialization/scene/common.js.map +1 -1
  482. package/dist/utility/serialization/scene/light.js +30 -0
  483. package/dist/utility/serialization/scene/light.js.map +1 -1
  484. package/dist/utility/serialization/scene/material.js +63 -0
  485. package/dist/utility/serialization/scene/material.js.map +1 -1
  486. package/dist/utility/serialization/scene/mesh.js +11 -0
  487. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  488. package/dist/utility/serialization/scene/misc.js +2 -0
  489. package/dist/utility/serialization/scene/misc.js.map +1 -1
  490. package/dist/utility/serialization/scene/node.js +19 -0
  491. package/dist/utility/serialization/scene/node.js.map +1 -1
  492. package/dist/utility/serialization/scene/particle.js +22 -0
  493. package/dist/utility/serialization/scene/particle.js.map +1 -1
  494. package/dist/utility/serialization/scene/primitive.js +33 -0
  495. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  496. package/dist/utility/serialization/scene/scene.js +39 -0
  497. package/dist/utility/serialization/scene/scene.js.map +1 -1
  498. package/dist/utility/serialization/scene/script.js +2 -0
  499. package/dist/utility/serialization/scene/script.js.map +1 -1
  500. package/dist/utility/serialization/scene/sprite.js +6 -0
  501. package/dist/utility/serialization/scene/sprite.js.map +1 -1
  502. package/dist/utility/serialization/scene/terrain.js +9 -0
  503. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  504. package/dist/utility/serialization/scene/water.js +21 -0
  505. package/dist/utility/serialization/scene/water.js.map +1 -1
  506. package/dist/utility/serialization/types.js +5 -1
  507. package/dist/utility/serialization/types.js.map +1 -1
  508. package/dist/values.js +49 -53
  509. package/dist/values.js.map +1 -1
  510. package/package.json +2 -2
  511. package/dist/animation/joint_dynamics/vrm_spring_bone.js +0 -46
  512. package/dist/animation/joint_dynamics/vrm_spring_bone.js.map +0 -1
  513. package/dist/animation/spring/spring_bone.js +0 -240
  514. package/dist/animation/spring/spring_bone.js.map +0 -1
  515. package/dist/animation/spring/spring_bone_collider.js +0 -198
  516. package/dist/animation/spring/spring_bone_collider.js.map +0 -1
  517. package/dist/animation/spring/spring_bone_constraint.js +0 -170
  518. package/dist/animation/spring/spring_bone_constraint.js.map +0 -1
  519. package/dist/animation/spring/spring_bone_system.js +0 -328
  520. package/dist/animation/spring/spring_bone_system.js.map +0 -1
  521. package/dist/render/sky_motion_vector.js +0 -85
  522. package/dist/render/sky_motion_vector.js.map +0 -1
package/dist/index.js CHANGED
@@ -51,11 +51,12 @@ export { GerstnerWaveGenerator } from './render/gerstner_wavegenerator.js';
51
51
  export { FBMWaveGenerator } from './render/fbm_wavegenerator.js';
52
52
  export { RenderTarget } from './render/rendertarget.js';
53
53
  export { ScreenRenderTarget } from './render/screenrendertarget.js';
54
- export { RGHandle } from './render/rendergraph/types.js';
54
+ export { RGHandle, RGSubpass } from './render/rendergraph/types.js';
55
55
  export { RenderGraph } from './render/rendergraph/rendergraph.js';
56
56
  export { RenderGraphExecutor } from './render/rendergraph/executor.js';
57
57
  export { DevicePoolAllocator } from './render/rendergraph/device_pool_allocator.js';
58
58
  export { HistoryResourceManager } from './render/rendergraph/history_resource_manager.js';
59
+ export { RGHistoryResources } from './render/rendergraph/history_resources.js';
59
60
  export { buildForwardPlusGraph, executeForwardPlusGraph } from './render/rendergraph/forward_plus_builder.js';
60
61
  export { ShaderHelper } from './material/shader/helper.js';
61
62
  export { LambertMaterial } from './material/lambert.js';
@@ -158,7 +159,7 @@ export { Blitter } from './blitter/blitter.js';
158
159
  export { GaussianBlurBlitter } from './blitter/gaussianblur.js';
159
160
  export { BoxFilterBlitter } from './blitter/box.js';
160
161
  export { CopyBlitter } from './blitter/copy.js';
161
- export { ATMOSPHERIC_FOG_BIT, BUILTIN_ASSET_TEST_CUBEMAP, BUILTIN_ASSET_TEXTURE_SHEEN_LUT, Fog, HEIGHT_FOG_BIT, LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_NONE, LIGHT_TYPE_POINT, LIGHT_TYPE_RECT, LIGHT_TYPE_SPOT, MAX_CLUSTERED_LIGHTS, MAX_GERSTNER_WAVE_COUNT, MAX_MORPH_ATTRIBUTES, MAX_MORPH_TARGETS, MAX_TERRAIN_MIPMAP_LEVELS, MORPH_ATTRIBUTE_VECTOR_COUNT, MORPH_TARGET_COLOR, MORPH_TARGET_NORMAL, MORPH_TARGET_POSITION, MORPH_TARGET_TANGENT, MORPH_TARGET_TEX0, MORPH_TARGET_TEX1, MORPH_TARGET_TEX2, MORPH_TARGET_TEX3, MORPH_WEIGHTS_VECTOR_COUNT, MaterialVaryingFlags, QUEUE_OPAQUE, QUEUE_TRANSPARENT, RENDER_PASS_TYPE_DEPTH, RENDER_PASS_TYPE_LIGHT, RENDER_PASS_TYPE_OBJECT_COLOR, RENDER_PASS_TYPE_SHADOWMAP, uniformSphereSamples } from './values.js';
162
+ export { ATMOSPHERIC_FOG_BIT, BUILTIN_ASSET_TEST_CUBEMAP, BUILTIN_ASSET_TEXTURE_SHEEN_LUT, Fog, HEIGHT_FOG_BIT, LIGHT_TYPE_DIRECTIONAL, LIGHT_TYPE_NONE, LIGHT_TYPE_POINT, LIGHT_TYPE_RECT, LIGHT_TYPE_SPOT, MAX_GERSTNER_WAVE_COUNT, MAX_MORPH_ATTRIBUTES, MAX_MORPH_TARGETS, MAX_TERRAIN_MIPMAP_LEVELS, MORPH_ATTRIBUTE_VECTOR_COUNT, MORPH_TARGET_COLOR, MORPH_TARGET_NORMAL, MORPH_TARGET_POSITION, MORPH_TARGET_TANGENT, MORPH_TARGET_TEX0, MORPH_TARGET_TEX1, MORPH_TARGET_TEX2, MORPH_TARGET_TEX3, MORPH_WEIGHTS_VECTOR_COUNT, MaterialVaryingFlags, QUEUE_OPAQUE, QUEUE_TRANSPARENT, RENDER_PASS_TYPE_DEPTH, RENDER_PASS_TYPE_LIGHT, RENDER_PASS_TYPE_OBJECT_COLOR, RENDER_PASS_TYPE_SHADOWMAP, uniformSphereSamples } from './values.js';
162
163
  export { AbstractPostEffect, PostEffectLayer } from './posteffect/posteffect.js';
163
164
  export { Grayscale } from './posteffect/grayscale.js';
164
165
  export { ColorAdjust } from './posteffect/coloradjust.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -222,7 +222,7 @@ import { getEngine } from '../app/api.js';
222
222
  * Returns the core material that owns GPU state.
223
223
  *
224
224
  * Instances may delegate to a shared core to reuse compiled programs and caches.
225
- * @internal
225
+ * @public
226
226
  */ get coreMaterial() {
227
227
  return this;
228
228
  }
@@ -369,6 +369,8 @@ import { getEngine } from '../app/api.js';
369
369
  clearCache() {
370
370
  for(const k in this._states){
371
371
  this._states[k]?.bindGroup?.dispose();
372
+ Material._programCache[k]?.dispose();
373
+ delete Material._programCache[k];
372
374
  }
373
375
  this._states = {};
374
376
  }
@@ -1 +1 @@
1
- {"version":3,"file":"material.js","sources":["../../src/material/material.ts"],"sourcesContent":["import type { AbstractDevice, BindGroup, GPUProgram, RenderStateSet } from '@zephyr3d/device';\r\nimport { ProgramBuilder } from '@zephyr3d/device';\r\nimport type { Primitive } from '../render/primitive';\r\nimport type { DrawContext } from '../render/drawable';\r\nimport { QUEUE_OPAQUE } from '../values';\r\nimport { RenderBundleWrapper } from '../render/renderbundle_wrapper';\r\nimport { Disposable } from '@zephyr3d/base';\r\nimport type { Clonable, IDisposable, Nullable } from '@zephyr3d/base';\r\nimport { getEngine } from '../app/api';\r\n\r\ntype MaterialState = {\r\n program: GPUProgram;\r\n bindGroup: Nullable<BindGroup>;\r\n bindGroupTag: string;\r\n renderStateSet: RenderStateSet;\r\n materialTag: number;\r\n};\r\n\r\n/**\r\n * Base class for all materials.\r\n *\r\n * Responsibilities:\r\n * - Defines a multi-pass rendering interface (`numPasses`, `apply`, `bind`, `draw`, `drawPrimitive`).\r\n * - Builds and caches GPU shader programs per pass and per-render-context hash.\r\n * - Manages a per-material bind group (typically at index 2) for uniforms and resources.\r\n * - Updates render states per pass (`updateRenderStates`) and uploads uniforms (`_applyUniforms`).\r\n * - Tracks \"option\" changes that affect shader variant hashing and render bundles.\r\n *\r\n * Caching and hashing:\r\n * - `createHash(pass)` produces a stable hash representing shader variant options for a pass.\r\n * Override `_createHash()` in subclasses to encode feature toggles (defines, keywords, macros).\r\n * - The global hash used to key `MaterialState` also includes `ctx.materialFlags` and\r\n * `ctx.renderPassHash`, allowing context-sensitive variants (e.g., MSAA, MRT layout).\r\n * - GPU programs are additionally memoized in a global static `_programCache` across materials\r\n * by `constructor.name` + hash, to avoid recompilation of identical variants.\r\n *\r\n * Bind groups and uniforms:\r\n * - If a program declares a bind group layout at index 2 (i.e., `bindGroupLayouts.length > 2`),\r\n * `apply()` will allocate the group and keep it in the state. Subclasses should fill it in\r\n * `_applyUniforms()`.\r\n * - `applyUniforms()` only calls `_applyUniforms()` when `needUpdate` is true, based on\r\n * `_optionTag` changes (see `optionChanged()`).\r\n *\r\n * Lifecycle:\r\n * - Constructed materials register a persistent ID into a global registry for serialization.\r\n * - `apply(ctx)` prepares all passes: creates/gets state, programs, bind groups, render states,\r\n * and uploads uniforms as needed.\r\n * - `bind(device, pass)` binds the program, bind group (index 2), and render states.\r\n * - `draw(primitive, ctx, numInstances)` runs all passes, calling `bind()` and `drawPrimitive()`.\r\n * - `onDispose()` releases bind groups and registry entries.\r\n *\r\n * Extending:\r\n * - Override `_createProgram(pb, ctx, pass)` to build a shader.\r\n * - Override `_applyUniforms(bindGroup, ctx, pass)` to upload uniforms and resources.\r\n * - Override `updateRenderStates(pass, renderStates, ctx)` to set depth, blend, cull, etc.\r\n * - Override `_createHash()` to encode options that affect program compilation.\r\n * - Override `supportLighting`, `supportInstancing`, `isTransparentPass`, `getQueueType`, etc.\r\n *\r\n * Thread-safety:\r\n * - Intended for main-thread use in a renderer driving WebGPU/WebGL-like devices.\r\n *\r\n * @public\r\n */\r\nexport class Material extends Disposable implements Clonable<Material>, IDisposable {\r\n /**\r\n * Monotonic instance ID counter.\r\n * @internal\r\n */\r\n private static _nextId = 0;\r\n /**\r\n * Global program cache keyed by global hash\r\n */\r\n private static _programCache: { [hash: string]: GPUProgram } = {};\r\n /**\r\n * Per-material state cache keyed by global hash (material + context + pass).\r\n * @internal\r\n */\r\n private _states: { [hash: string]: MaterialState };\r\n /**\r\n * Number of rendering passes.\r\n * Subclasses can increase this to implement multi-pass rendering.\r\n * @internal\r\n */\r\n protected _numPasses: number;\r\n /**\r\n * Per-pass hash cached results. Length scales with `numPasses`.\r\n * @internal\r\n */\r\n protected _hash: Nullable<string>[];\r\n /**\r\n * Incremented each time options change (via `optionChanged`), used to decide whether\r\n * uniforms need update on next `apply()`.\r\n * @internal\r\n */\r\n private _optionTag: number;\r\n /**\r\n * Unique runtime instance ID.\r\n * @internal\r\n */\r\n protected readonly _id: number;\r\n /**\r\n * Latest computed global hash per pass, set during `apply()`, read in `bind()`.\r\n * @internal\r\n */\r\n private _currentHash: string[];\r\n /**\r\n * Incremented when material states affecting render bundles change (e.g., bind group id changes\r\n * or `optionChanged(true)`), used to trigger re-recording of render bundles.\r\n * @internal\r\n */\r\n private _changeTag: number;\r\n /**\r\n * Unique program id counter for naming compiled programs.\r\n * @internal\r\n */\r\n private _nextProgramId = 0;\r\n /**\r\n * Create a new material instance.\r\n *\r\n * - Initializes one pass by default.\r\n * - Prepares per-pass hash storage and change tracking.\r\n * - Registers a persistent ID in the global registry.\r\n */\r\n constructor() {\r\n super();\r\n this._id = ++Material._nextId;\r\n this._nextProgramId = 0;\r\n this._states = {};\r\n this._numPasses = 1;\r\n this._hash = [null];\r\n this._optionTag = 0;\r\n this._changeTag = 0;\r\n this._currentHash = [];\r\n }\r\n /**\r\n * Create a shallow clone of this material.\r\n *\r\n * Note: The base implementation returns a base `Material`. Subclasses should\r\n * override to return their own type and copy custom fields.\r\n */\r\n clone() {\r\n const other = new Material();\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n /**\r\n * Copy basic properties from another material.\r\n *\r\n * Disposes existing bind groups/states, copies `numPasses`. Subclasses should\r\n * extend this to copy their own fields and call `optionChanged(true)` if\r\n * shader-affecting options differ.\r\n *\r\n * @param other - Source material.\r\n */\r\n copyFrom(other: this) {\r\n this.clearCache();\r\n this._numPasses = other._numPasses;\r\n getEngine().resourceManager.setAssetId(this, getEngine().resourceManager.getAssetId(other.coreMaterial));\r\n }\r\n /**\r\n * Incremented when the material’s GPU-relevant state changes and render bundles\r\n * may need to be rebuilt.\r\n */\r\n get changeTag() {\r\n return this._changeTag;\r\n }\r\n /**\r\n * Runtime-unique numeric identifier for the material instance.\r\n */\r\n get instanceId() {\r\n return this._id;\r\n }\r\n /**\r\n * Number of rendering passes this material uses.\r\n *\r\n * Increasing this will expand the per-pass hash cache; make sure to implement\r\n * `createHash(pass)`, `_createProgram(pb, ctx, pass)`, and `updateRenderStates(pass, ...)`\r\n * accordingly for each pass.\r\n */\r\n get numPasses() {\r\n return this._numPasses;\r\n }\r\n set numPasses(val) {\r\n while (this._hash.length < val) {\r\n this._hash.push(null);\r\n }\r\n this._numPasses = val;\r\n }\r\n /**\r\n * Get or compute the per-pass shader hash used for program caching.\r\n *\r\n * Calls `createHash(pass)` lazily and caches the result.\r\n * @internal\r\n */\r\n protected getHash(pass: number) {\r\n if (this._hash[pass] === null) {\r\n this._hash[pass] = this.createHash(pass);\r\n }\r\n return this._hash[pass];\r\n }\r\n /**\r\n * Return the queue type to which this material belongs.\r\n *\r\n * Override this in transparent or special materials (e.g., post-process).\r\n */\r\n getQueueType(): number {\r\n return QUEUE_OPAQUE;\r\n }\r\n /**\r\n * Whether the given pass is transparent.\r\n *\r\n * Used to place draw calls into appropriate render queues and set blending states.\r\n */\r\n isTransparentPass(_pass: number): boolean {\r\n return false;\r\n }\r\n /**\r\n * Whether this material's shading is affected by scene lights.\r\n *\r\n * Override and return `false` for unlit materials.\r\n */\r\n supportLighting(): boolean {\r\n return true;\r\n }\r\n /**\r\n * Whether this material supports hardware instancing.\r\n *\r\n * Override and return `false` if per-instance data is not supported in the shader.\r\n */\r\n supportInstancing(): boolean {\r\n return true;\r\n }\r\n /** Returns true if this is a instance of material */\r\n isBatchable(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Whether this material requires the scene color texture (e.g., for refraction).\r\n */\r\n needSceneColor(): boolean {\r\n return false;\r\n }\r\n /**\r\n * Whether this material requires the linear scene depth texture (e.g., for depth-aware effects).\r\n */\r\n needSceneDepth(): boolean {\r\n return false;\r\n }\r\n /**\r\n * Create a material instance (instance-uniform-driven variant).\r\n *\r\n * Base returns `null`. Subclasses that support instancing can return a lightweight instance.\r\n */\r\n createInstance(): this {\r\n throw new Error('Abstract function call');\r\n }\r\n /**\r\n * Returns the core material that owns GPU state.\r\n *\r\n * Instances may delegate to a shared core to reuse compiled programs and caches.\r\n * @internal\r\n */\r\n get coreMaterial(): this {\r\n return this;\r\n }\r\n /**\r\n * Prepare the material for drawing across all passes for the given draw context.\r\n *\r\n * Steps per pass:\r\n * - Compute global hash (material variant + context).\r\n * - Retrieve or build the GPU program, cache in `_programCache`.\r\n * - Create per-material bind group (index 2) if the program exposes it.\r\n * - Update uniforms if `_optionTag` indicates changes since last apply.\r\n * - Update and cache render states for the pass.\r\n * - Detect bind group GPU ID changes to bump `changeTag` and notify `RenderBundleWrapper`.\r\n *\r\n * @param ctx - Draw context (device, flags, pass hash, instance data, etc.).\r\n * @returns `true` if successful; `false` if any pass lacks a valid program.\r\n */\r\n apply(ctx: DrawContext) {\r\n for (let pass = 0; pass < this._numPasses; pass++) {\r\n const hash = this.calcGlobalHash(ctx, pass);\r\n let state = this._states[hash];\r\n if (!state) {\r\n let program = Material._programCache[hash];\r\n if (!program) {\r\n program = this.createProgram(ctx, pass) ?? null;\r\n program.name = `@${this.constructor.name}_program_${this._nextProgramId++}`;\r\n Material._programCache[hash] = program;\r\n }\r\n const bindGroup =\r\n program.bindGroupLayouts.length > 2\r\n ? ctx.device.createBindGroup(program.bindGroupLayouts[2])\r\n : null;\r\n state = {\r\n program,\r\n bindGroup,\r\n bindGroupTag: bindGroup?.getGPUId() ?? '',\r\n renderStateSet: ctx.device.createRenderStateSet(),\r\n materialTag: -1\r\n };\r\n this._states[hash] = state;\r\n }\r\n if (!state.program) {\r\n return false;\r\n }\r\n if (state.bindGroup) {\r\n this.applyUniforms(state.bindGroup, ctx, state.materialTag !== this._optionTag, pass);\r\n }\r\n state.materialTag = this._optionTag;\r\n this.updateRenderStates(pass, state.renderStateSet, ctx);\r\n this._currentHash[pass] = hash;\r\n if (state.bindGroup) {\r\n const id = state.bindGroup.getGPUId();\r\n if (id !== state.bindGroupTag) {\r\n state.bindGroupTag = id;\r\n this._changeTag++;\r\n RenderBundleWrapper.materialChanged(this.coreMaterial);\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n /**\r\n * Bind the program, bind group, and render states for the specified pass.\r\n *\r\n * Must be called after `apply(ctx)` for the same pass.\r\n *\r\n * @param device - Rendering device.\r\n * @param pass - Pass index to bind.\r\n * @returns `true` on success; `false` if state or program missing.\r\n * @internal\r\n */\r\n bind(device: AbstractDevice, pass: number) {\r\n const hash = this._currentHash[pass];\r\n const state = this._states[hash];\r\n if (!state) {\r\n console.error('Material.bind() failed: state not found');\r\n return false;\r\n }\r\n if (!state.program) {\r\n return false;\r\n }\r\n device.setProgram(state.program);\r\n if (state.bindGroup) {\r\n device.setBindGroup(2, state.bindGroup);\r\n }\r\n device.setRenderStates(state.renderStateSet);\r\n return true;\r\n }\r\n /**\r\n * Compute the global hash for the given pass and draw context.\r\n *\r\n * Includes:\r\n * - Per-pass material hash from `getHash(pass)`.\r\n * - `ctx.materialFlags` for context-dependent toggles.\r\n * - `ctx.renderPassHash` for framebuffer/attachment layout variants.\r\n * @internal\r\n */\r\n private calcGlobalHash(ctx: DrawContext, pass: number) {\r\n return `${this.getHash(pass)}:${ctx.materialFlags}:${ctx.renderPassHash}`;\r\n }\r\n /**\r\n * Draw a primitive for all passes using this material.\r\n *\r\n * Calls `bind()` then `drawPrimitive()` per pass. If `numInstances` is zero,\r\n * and `ctx.instanceData` exists, uses `ctx.instanceData.numInstances`.\r\n *\r\n * @param primitive - Geometry to draw.\r\n * @param ctx - Draw context.\r\n * @param numInstances - Instance count; 0 means auto-detect from context.\r\n * @internal\r\n */\r\n draw(primitive: Primitive, ctx: DrawContext, numInstances = 0) {\r\n for (let pass = 0; pass < this._numPasses; pass++) {\r\n this.bind(ctx.device, pass);\r\n this.drawPrimitive(pass, primitive, ctx, numInstances);\r\n }\r\n }\r\n /**\r\n * Conditionally update uniforms/resources into the material bind group.\r\n *\r\n * Delegates to `_applyUniforms()` when `needUpdate` is true (based on `_optionTag` check).\r\n *\r\n * @param bindGroup - Material bind group at index 2 (may be `null` if program has no layout).\r\n * @param ctx - Draw context.\r\n * @param needUpdate - Whether uniforms need to be refreshed.\r\n * @param pass - Pass index.\r\n */\r\n applyUniforms(bindGroup: BindGroup, ctx: DrawContext, needUpdate: boolean, pass: number) {\r\n if (needUpdate) {\r\n this._applyUniforms(bindGroup, ctx, pass);\r\n }\r\n }\r\n /**\r\n * Notify the material that some option changed.\r\n *\r\n * - Always increments `_optionTag`. This will trigger uniforms update on next `apply()`.\r\n * - If `changeHash` is true, clears per-pass hashes so programs/states will be rebuilt,\r\n * increments `_changeTag`, and notifies `RenderBundleWrapper` to regenerate recorded bundles.\r\n *\r\n * @param changeHash - Set true if the change affects shader compilation or render states.\r\n * @internal\r\n */\r\n optionChanged(changeHash: boolean) {\r\n this._optionTag++;\r\n if (changeHash) {\r\n for (let i = 0; i < this._numPasses; i++) {\r\n this._hash[i] = null;\r\n }\r\n this._changeTag++;\r\n RenderBundleWrapper.materialChanged(this.coreMaterial);\r\n }\r\n }\r\n clearCache() {\r\n for (const k in this._states) {\r\n this._states[k]?.bindGroup?.dispose();\r\n }\r\n this._states = {};\r\n }\r\n /**\r\n * Convert a pass index to a hash seed string.\r\n *\r\n * Subclasses may override to encode per-pass role (e.g., \"depth\", \"forward\", \"shadow\").\r\n *\r\n * @param pass - Pass number.\r\n * @returns String used when building full hash.\r\n */\r\n passToHash(pass: number) {\r\n return String(pass);\r\n }\r\n /**\r\n * Build the material hash for a pass (excluding context-dependent parts).\r\n *\r\n * Default formula: `${constructor.name}|${pass}|${_createHash()}`\r\n *\r\n * @param pass - Pass number.\r\n * @returns Hash string used in program caching.\r\n * @internal\r\n */\r\n createHash(pass: number) {\r\n return `${this.constructor.name}|${pass}|${this._createHash()}`;\r\n }\r\n /**\r\n * Issue the actual draw call for a pass.\r\n *\r\n * Override for custom per-pass draw behavior if necessary. The default implementation:\r\n * - Draws instanced if `numInstances > 0`.\r\n * - Else uses `ctx.instanceData.numInstances` if available.\r\n * - Else issues a non-instanced draw.\r\n *\r\n * @param pass - Pass number.\r\n * @param primitive - Primitive to draw.\r\n * @param ctx - Draw context.\r\n * @param numInstances - Explicit instance count (0 = auto).\r\n */\r\n drawPrimitive(pass: number, primitive: Primitive, ctx: DrawContext, numInstances: number) {\r\n if (numInstances > 0) {\r\n primitive.drawInstanced(numInstances);\r\n } else if (ctx.instanceData) {\r\n primitive.drawInstanced(ctx.instanceData.numInstances);\r\n } else {\r\n primitive.draw();\r\n }\r\n }\r\n /**\r\n * Dispose the material and release GPU-side resource references.\r\n *\r\n * - Unregisters from the global registry.\r\n * - Disposes the per-material bind groups kept in `_states`.\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n this.clearCache();\r\n }\r\n /**\r\n * Build the GPU program for a pass.\r\n *\r\n * Default creates a `ProgramBuilder` and calls `_createProgram(pb, ctx, pass)`.\r\n * Subclasses should override `_createProgram` instead of this method unless\r\n * they need to replace builder instantiation.\r\n *\r\n * @param ctx - Draw context.\r\n * @param pass - Pass number.\r\n * @returns The compiled `GPUProgram`, or `null` on failure.\r\n * @internal\r\n */\r\n protected createProgram(ctx: DrawContext, pass: number) {\r\n const pb = new ProgramBuilder(ctx.device);\r\n return this._createProgram(pb, ctx, pass);\r\n }\r\n /**\r\n * Create and compile the shader program for this material/pass.\r\n *\r\n * Implement in subclasses:\r\n * - Define shader stages, entry points, macros/defines, and resource layouts.\r\n * - Return a compiled `GPUProgram`.\r\n *\r\n * @param pb - Program builder.\r\n * @param ctx - Draw context.\r\n * @param _pass - Pass number.\r\n * @returns The created program, or `null` on failure.\r\n */\r\n protected _createProgram(_pb: ProgramBuilder, _ctx: DrawContext, _pass: number): GPUProgram {\r\n throw new Error('Abstract function call');\r\n }\r\n /**\r\n * Upload uniforms and bind resources to the per-material bind group (index 2).\r\n *\r\n * Implement in subclasses to:\r\n * - Write uniform buffers/textures/samplers to the `bindGroup`.\r\n * - Respect the current `pass` and `ctx`.\r\n *\r\n * @param _bindGroup - The bind group to populate.\r\n * @param _ctx - Draw context.\r\n * @param _pass - Pass number.\r\n */\r\n protected _applyUniforms(_bindGroup: BindGroup, _ctx: DrawContext, _pass: number) {}\r\n /**\r\n * Update render states (depth/stencil, blending, rasterization) for the pass.\r\n *\r\n * Implement in subclasses based on transparency, double-sidedness, depth writes/tests,\r\n * color mask, stencil ops, etc., and any context flags in `ctx`.\r\n *\r\n * @param _pass - Current pass index.\r\n * @param _renderStates - Render state set to mutate.\r\n * @param _ctx - Draw context.\r\n */\r\n protected updateRenderStates(_pass: number, _renderStates: RenderStateSet, _ctx: DrawContext) {}\r\n /**\r\n * Compute the material-specific portion of the shader hash for the current options.\r\n *\r\n * Subclasses should override to include macro/define sets that influence program compilation.\r\n * Example return: `\"USE_NORMALMAP=1;ALPHA_MODE=BLEND;RECEIVE_SHADOWS=1\"`.\r\n *\r\n * @returns Hash fragment string (no context/pass info).\r\n */\r\n protected _createHash() {\r\n return '';\r\n }\r\n /**\r\n * Whether this is a lightweight instance of a core material.\r\n *\r\n * Instances typically share GPU programs with a core and only override instance uniforms.\r\n * @internal\r\n */\r\n get $isInstance(): boolean {\r\n return false;\r\n }\r\n /**\r\n * Instance-uniform buffer for material instances, if supported.\r\n *\r\n * Returned as a typed Float32 view over a backing ArrayBuffer.\r\n * @internal\r\n */\r\n get $instanceUniforms(): Float32Array<ArrayBuffer> {\r\n throw new Error('Abstract function call');\r\n }\r\n}\r\n"],"names":["Material","Disposable","_nextId","_programCache","_nextProgramId","_id","_states","_numPasses","_hash","_optionTag","_changeTag","_currentHash","clone","other","copyFrom","clearCache","getEngine","resourceManager","setAssetId","getAssetId","coreMaterial","changeTag","instanceId","numPasses","val","length","push","getHash","pass","createHash","getQueueType","QUEUE_OPAQUE","isTransparentPass","_pass","supportLighting","supportInstancing","isBatchable","needSceneColor","needSceneDepth","createInstance","Error","apply","ctx","hash","calcGlobalHash","state","program","createProgram","name","bindGroup","bindGroupLayouts","device","createBindGroup","bindGroupTag","getGPUId","renderStateSet","createRenderStateSet","materialTag","applyUniforms","updateRenderStates","id","RenderBundleWrapper","materialChanged","bind","console","error","setProgram","setBindGroup","setRenderStates","materialFlags","renderPassHash","draw","primitive","numInstances","drawPrimitive","needUpdate","_applyUniforms","optionChanged","changeHash","i","k","dispose","passToHash","String","_createHash","drawInstanced","instanceData","onDispose","pb","ProgramBuilder","_createProgram","_pb","_ctx","_bindGroup","_renderStates","$isInstance","$instanceUniforms"],"mappings":";;;;;;AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AAKC,MACD,SAAsB,GAAA;AACpB,QAAA,KAAK,CAACgB,SAAAA,EAAAA;AACN,QAAA,IAAI,CAACxE,UAAU,EAAA;AACjB;AACA;;;;;;;;;;;AAWC,MACD,aAAUgC,CAAcL,GAAgB,EAAEd,IAAY,EAAE;AACtD,QAAA,MAAM4D,EAAK,GAAA,IAAIC,cAAe/C,CAAAA,GAAAA,CAAIS,MAAM,CAAA;AACxC,QAAA,OAAO,IAAI,CAACuC,cAAc,CAACF,IAAI9C,GAAKd,EAAAA,IAAAA,CAAAA;AACtC;AACA;;;;;;;;;;;AAWC,MACD,cAAyB+D,CAAAA,GAAmB,EAAEC,IAAiB,EAAE3D,KAAa,EAAc;AAC1F,QAAA,MAAM,IAAIO,KAAM,CAAA,wBAAA,CAAA;AAClB;AACA;;;;;;;;;;MAWUoC,eAAeiB,UAAqB,EAAED,IAAiB,EAAE3D,KAAa,EAAE;AAClF;;;;;;;;;MAUU0B,mBAAmB1B,KAAa,EAAE6D,aAA6B,EAAEF,IAAiB,EAAE;AAC9F;;;;;;;AAOC,MACD,WAAwB,GAAA;QACtB,OAAO,EAAA;AACT;AACA;;;;;AAKC,MACD,IAAIG,WAAuB,GAAA;QACzB,OAAO,KAAA;AACT;AACA;;;;;AAKC,MACD,IAAIC,iBAA+C,GAAA;AACjD,QAAA,MAAM,IAAIxD,KAAM,CAAA,wBAAA,CAAA;AAClB;AACF;;;;"}
1
+ {"version":3,"file":"material.js","sources":["../../src/material/material.ts"],"sourcesContent":["import type { AbstractDevice, BindGroup, GPUProgram, RenderStateSet } from '@zephyr3d/device';\r\nimport { ProgramBuilder } from '@zephyr3d/device';\r\nimport type { Primitive } from '../render/primitive';\r\nimport type { DrawContext } from '../render/drawable';\r\nimport { QUEUE_OPAQUE } from '../values';\r\nimport { RenderBundleWrapper } from '../render/renderbundle_wrapper';\r\nimport { Disposable } from '@zephyr3d/base';\r\nimport type { Clonable, IDisposable, Nullable } from '@zephyr3d/base';\r\nimport { getEngine } from '../app/api';\r\n\r\ntype MaterialState = {\r\n program: GPUProgram;\r\n bindGroup: Nullable<BindGroup>;\r\n bindGroupTag: string;\r\n renderStateSet: RenderStateSet;\r\n materialTag: number;\r\n};\r\n\r\n/**\r\n * Base class for all materials.\r\n *\r\n * Responsibilities:\r\n * - Defines a multi-pass rendering interface (`numPasses`, `apply`, `bind`, `draw`, `drawPrimitive`).\r\n * - Builds and caches GPU shader programs per pass and per-render-context hash.\r\n * - Manages a per-material bind group (typically at index 2) for uniforms and resources.\r\n * - Updates render states per pass (`updateRenderStates`) and uploads uniforms (`_applyUniforms`).\r\n * - Tracks \"option\" changes that affect shader variant hashing and render bundles.\r\n *\r\n * Caching and hashing:\r\n * - `createHash(pass)` produces a stable hash representing shader variant options for a pass.\r\n * Override `_createHash()` in subclasses to encode feature toggles (defines, keywords, macros).\r\n * - The global hash used to key `MaterialState` also includes `ctx.materialFlags` and\r\n * `ctx.renderPassHash`, allowing context-sensitive variants (e.g., MSAA, MRT layout).\r\n * - GPU programs are additionally memoized in a global static `_programCache` across materials\r\n * by `constructor.name` + hash, to avoid recompilation of identical variants.\r\n *\r\n * Bind groups and uniforms:\r\n * - If a program declares a bind group layout at index 2 (i.e., `bindGroupLayouts.length > 2`),\r\n * `apply()` will allocate the group and keep it in the state. Subclasses should fill it in\r\n * `_applyUniforms()`.\r\n * - `applyUniforms()` only calls `_applyUniforms()` when `needUpdate` is true, based on\r\n * `_optionTag` changes (see `optionChanged()`).\r\n *\r\n * Lifecycle:\r\n * - Constructed materials register a persistent ID into a global registry for serialization.\r\n * - `apply(ctx)` prepares all passes: creates/gets state, programs, bind groups, render states,\r\n * and uploads uniforms as needed.\r\n * - `bind(device, pass)` binds the program, bind group (index 2), and render states.\r\n * - `draw(primitive, ctx, numInstances)` runs all passes, calling `bind()` and `drawPrimitive()`.\r\n * - `onDispose()` releases bind groups and registry entries.\r\n *\r\n * Extending:\r\n * - Override `_createProgram(pb, ctx, pass)` to build a shader.\r\n * - Override `_applyUniforms(bindGroup, ctx, pass)` to upload uniforms and resources.\r\n * - Override `updateRenderStates(pass, renderStates, ctx)` to set depth, blend, cull, etc.\r\n * - Override `_createHash()` to encode options that affect program compilation.\r\n * - Override `supportLighting`, `supportInstancing`, `isTransparentPass`, `getQueueType`, etc.\r\n *\r\n * Thread-safety:\r\n * - Intended for main-thread use in a renderer driving WebGPU/WebGL-like devices.\r\n *\r\n * @public\r\n */\r\nexport class Material extends Disposable implements Clonable<Material>, IDisposable {\r\n /**\r\n * Monotonic instance ID counter.\r\n * @internal\r\n */\r\n private static _nextId = 0;\r\n /**\r\n * Global program cache keyed by global hash\r\n */\r\n private static _programCache: { [hash: string]: GPUProgram } = {};\r\n /**\r\n * Per-material state cache keyed by global hash (material + context + pass).\r\n * @internal\r\n */\r\n private _states: { [hash: string]: MaterialState };\r\n /**\r\n * Number of rendering passes.\r\n * Subclasses can increase this to implement multi-pass rendering.\r\n * @internal\r\n */\r\n protected _numPasses: number;\r\n /**\r\n * Per-pass hash cached results. Length scales with `numPasses`.\r\n * @internal\r\n */\r\n protected _hash: Nullable<string>[];\r\n /**\r\n * Incremented each time options change (via `optionChanged`), used to decide whether\r\n * uniforms need update on next `apply()`.\r\n * @internal\r\n */\r\n private _optionTag: number;\r\n /**\r\n * Unique runtime instance ID.\r\n * @internal\r\n */\r\n protected readonly _id: number;\r\n /**\r\n * Latest computed global hash per pass, set during `apply()`, read in `bind()`.\r\n * @internal\r\n */\r\n private _currentHash: string[];\r\n /**\r\n * Incremented when material states affecting render bundles change (e.g., bind group id changes\r\n * or `optionChanged(true)`), used to trigger re-recording of render bundles.\r\n * @internal\r\n */\r\n private _changeTag: number;\r\n /**\r\n * Unique program id counter for naming compiled programs.\r\n * @internal\r\n */\r\n private _nextProgramId = 0;\r\n /**\r\n * Create a new material instance.\r\n *\r\n * - Initializes one pass by default.\r\n * - Prepares per-pass hash storage and change tracking.\r\n * - Registers a persistent ID in the global registry.\r\n */\r\n constructor() {\r\n super();\r\n this._id = ++Material._nextId;\r\n this._nextProgramId = 0;\r\n this._states = {};\r\n this._numPasses = 1;\r\n this._hash = [null];\r\n this._optionTag = 0;\r\n this._changeTag = 0;\r\n this._currentHash = [];\r\n }\r\n /**\r\n * Create a shallow clone of this material.\r\n *\r\n * Note: The base implementation returns a base `Material`. Subclasses should\r\n * override to return their own type and copy custom fields.\r\n */\r\n clone() {\r\n const other = new Material();\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n /**\r\n * Copy basic properties from another material.\r\n *\r\n * Disposes existing bind groups/states, copies `numPasses`. Subclasses should\r\n * extend this to copy their own fields and call `optionChanged(true)` if\r\n * shader-affecting options differ.\r\n *\r\n * @param other - Source material.\r\n */\r\n copyFrom(other: this) {\r\n this.clearCache();\r\n this._numPasses = other._numPasses;\r\n getEngine().resourceManager.setAssetId(this, getEngine().resourceManager.getAssetId(other.coreMaterial));\r\n }\r\n /**\r\n * Incremented when the material’s GPU-relevant state changes and render bundles\r\n * may need to be rebuilt.\r\n */\r\n get changeTag() {\r\n return this._changeTag;\r\n }\r\n /**\r\n * Runtime-unique numeric identifier for the material instance.\r\n */\r\n get instanceId() {\r\n return this._id;\r\n }\r\n /**\r\n * Number of rendering passes this material uses.\r\n *\r\n * Increasing this will expand the per-pass hash cache; make sure to implement\r\n * `createHash(pass)`, `_createProgram(pb, ctx, pass)`, and `updateRenderStates(pass, ...)`\r\n * accordingly for each pass.\r\n */\r\n get numPasses() {\r\n return this._numPasses;\r\n }\r\n set numPasses(val) {\r\n while (this._hash.length < val) {\r\n this._hash.push(null);\r\n }\r\n this._numPasses = val;\r\n }\r\n /**\r\n * Get or compute the per-pass shader hash used for program caching.\r\n *\r\n * Calls `createHash(pass)` lazily and caches the result.\r\n * @internal\r\n */\r\n protected getHash(pass: number) {\r\n if (this._hash[pass] === null) {\r\n this._hash[pass] = this.createHash(pass);\r\n }\r\n return this._hash[pass];\r\n }\r\n /**\r\n * Return the queue type to which this material belongs.\r\n *\r\n * Override this in transparent or special materials (e.g., post-process).\r\n */\r\n getQueueType(): number {\r\n return QUEUE_OPAQUE;\r\n }\r\n /**\r\n * Whether the given pass is transparent.\r\n *\r\n * Used to place draw calls into appropriate render queues and set blending states.\r\n */\r\n isTransparentPass(_pass: number): boolean {\r\n return false;\r\n }\r\n /**\r\n * Whether this material's shading is affected by scene lights.\r\n *\r\n * Override and return `false` for unlit materials.\r\n */\r\n supportLighting(): boolean {\r\n return true;\r\n }\r\n /**\r\n * Whether this material supports hardware instancing.\r\n *\r\n * Override and return `false` if per-instance data is not supported in the shader.\r\n */\r\n supportInstancing(): boolean {\r\n return true;\r\n }\r\n /** Returns true if this is a instance of material */\r\n isBatchable(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Whether this material requires the scene color texture (e.g., for refraction).\r\n */\r\n needSceneColor(): boolean {\r\n return false;\r\n }\r\n /**\r\n * Whether this material requires the linear scene depth texture (e.g., for depth-aware effects).\r\n */\r\n needSceneDepth(): boolean {\r\n return false;\r\n }\r\n /**\r\n * Create a material instance (instance-uniform-driven variant).\r\n *\r\n * Base returns `null`. Subclasses that support instancing can return a lightweight instance.\r\n */\r\n createInstance(): this {\r\n throw new Error('Abstract function call');\r\n }\r\n /**\r\n * Returns the core material that owns GPU state.\r\n *\r\n * Instances may delegate to a shared core to reuse compiled programs and caches.\r\n * @public\r\n */\r\n get coreMaterial(): this {\r\n return this;\r\n }\r\n /**\r\n * Prepare the material for drawing across all passes for the given draw context.\r\n *\r\n * Steps per pass:\r\n * - Compute global hash (material variant + context).\r\n * - Retrieve or build the GPU program, cache in `_programCache`.\r\n * - Create per-material bind group (index 2) if the program exposes it.\r\n * - Update uniforms if `_optionTag` indicates changes since last apply.\r\n * - Update and cache render states for the pass.\r\n * - Detect bind group GPU ID changes to bump `changeTag` and notify `RenderBundleWrapper`.\r\n *\r\n * @param ctx - Draw context (device, flags, pass hash, instance data, etc.).\r\n * @returns `true` if successful; `false` if any pass lacks a valid program.\r\n */\r\n apply(ctx: DrawContext) {\r\n for (let pass = 0; pass < this._numPasses; pass++) {\r\n const hash = this.calcGlobalHash(ctx, pass);\r\n let state = this._states[hash];\r\n if (!state) {\r\n let program = Material._programCache[hash];\r\n if (!program) {\r\n program = this.createProgram(ctx, pass) ?? null;\r\n program.name = `@${this.constructor.name}_program_${this._nextProgramId++}`;\r\n Material._programCache[hash] = program;\r\n }\r\n const bindGroup =\r\n program.bindGroupLayouts.length > 2\r\n ? ctx.device.createBindGroup(program.bindGroupLayouts[2])\r\n : null;\r\n state = {\r\n program,\r\n bindGroup,\r\n bindGroupTag: bindGroup?.getGPUId() ?? '',\r\n renderStateSet: ctx.device.createRenderStateSet(),\r\n materialTag: -1\r\n };\r\n this._states[hash] = state;\r\n }\r\n if (!state.program) {\r\n return false;\r\n }\r\n if (state.bindGroup) {\r\n this.applyUniforms(state.bindGroup, ctx, state.materialTag !== this._optionTag, pass);\r\n }\r\n state.materialTag = this._optionTag;\r\n this.updateRenderStates(pass, state.renderStateSet, ctx);\r\n this._currentHash[pass] = hash;\r\n if (state.bindGroup) {\r\n const id = state.bindGroup.getGPUId();\r\n if (id !== state.bindGroupTag) {\r\n state.bindGroupTag = id;\r\n this._changeTag++;\r\n RenderBundleWrapper.materialChanged(this.coreMaterial);\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n /**\r\n * Bind the program, bind group, and render states for the specified pass.\r\n *\r\n * Must be called after `apply(ctx)` for the same pass.\r\n *\r\n * @param device - Rendering device.\r\n * @param pass - Pass index to bind.\r\n * @returns `true` on success; `false` if state or program missing.\r\n * @internal\r\n */\r\n bind(device: AbstractDevice, pass: number) {\r\n const hash = this._currentHash[pass];\r\n const state = this._states[hash];\r\n if (!state) {\r\n console.error('Material.bind() failed: state not found');\r\n return false;\r\n }\r\n if (!state.program) {\r\n return false;\r\n }\r\n device.setProgram(state.program);\r\n if (state.bindGroup) {\r\n device.setBindGroup(2, state.bindGroup);\r\n }\r\n device.setRenderStates(state.renderStateSet);\r\n return true;\r\n }\r\n /**\r\n * Compute the global hash for the given pass and draw context.\r\n *\r\n * Includes:\r\n * - Per-pass material hash from `getHash(pass)`.\r\n * - `ctx.materialFlags` for context-dependent toggles.\r\n * - `ctx.renderPassHash` for framebuffer/attachment layout variants.\r\n * @internal\r\n */\r\n private calcGlobalHash(ctx: DrawContext, pass: number) {\r\n return `${this.getHash(pass)}:${ctx.materialFlags}:${ctx.renderPassHash}`;\r\n }\r\n /**\r\n * Draw a primitive for all passes using this material.\r\n *\r\n * Calls `bind()` then `drawPrimitive()` per pass. If `numInstances` is zero,\r\n * and `ctx.instanceData` exists, uses `ctx.instanceData.numInstances`.\r\n *\r\n * @param primitive - Geometry to draw.\r\n * @param ctx - Draw context.\r\n * @param numInstances - Instance count; 0 means auto-detect from context.\r\n * @internal\r\n */\r\n draw(primitive: Primitive, ctx: DrawContext, numInstances = 0) {\r\n for (let pass = 0; pass < this._numPasses; pass++) {\r\n this.bind(ctx.device, pass);\r\n this.drawPrimitive(pass, primitive, ctx, numInstances);\r\n }\r\n }\r\n /**\r\n * Conditionally update uniforms/resources into the material bind group.\r\n *\r\n * Delegates to `_applyUniforms()` when `needUpdate` is true (based on `_optionTag` check).\r\n *\r\n * @param bindGroup - Material bind group at index 2 (may be `null` if program has no layout).\r\n * @param ctx - Draw context.\r\n * @param needUpdate - Whether uniforms need to be refreshed.\r\n * @param pass - Pass index.\r\n */\r\n applyUniforms(bindGroup: BindGroup, ctx: DrawContext, needUpdate: boolean, pass: number) {\r\n if (needUpdate) {\r\n this._applyUniforms(bindGroup, ctx, pass);\r\n }\r\n }\r\n /**\r\n * Notify the material that some option changed.\r\n *\r\n * - Always increments `_optionTag`. This will trigger uniforms update on next `apply()`.\r\n * - If `changeHash` is true, clears per-pass hashes so programs/states will be rebuilt,\r\n * increments `_changeTag`, and notifies `RenderBundleWrapper` to regenerate recorded bundles.\r\n *\r\n * @param changeHash - Set true if the change affects shader compilation or render states.\r\n * @internal\r\n */\r\n optionChanged(changeHash: boolean) {\r\n this._optionTag++;\r\n if (changeHash) {\r\n for (let i = 0; i < this._numPasses; i++) {\r\n this._hash[i] = null;\r\n }\r\n this._changeTag++;\r\n RenderBundleWrapper.materialChanged(this.coreMaterial);\r\n }\r\n }\r\n clearCache() {\r\n for (const k in this._states) {\r\n this._states[k]?.bindGroup?.dispose();\r\n Material._programCache[k]?.dispose();\r\n delete Material._programCache[k];\r\n }\r\n this._states = {};\r\n }\r\n /**\r\n * Convert a pass index to a hash seed string.\r\n *\r\n * Subclasses may override to encode per-pass role (e.g., \"depth\", \"forward\", \"shadow\").\r\n *\r\n * @param pass - Pass number.\r\n * @returns String used when building full hash.\r\n */\r\n passToHash(pass: number) {\r\n return String(pass);\r\n }\r\n /**\r\n * Build the material hash for a pass (excluding context-dependent parts).\r\n *\r\n * Default formula: `${constructor.name}|${pass}|${_createHash()}`\r\n *\r\n * @param pass - Pass number.\r\n * @returns Hash string used in program caching.\r\n * @internal\r\n */\r\n createHash(pass: number) {\r\n return `${this.constructor.name}|${pass}|${this._createHash()}`;\r\n }\r\n /**\r\n * Issue the actual draw call for a pass.\r\n *\r\n * Override for custom per-pass draw behavior if necessary. The default implementation:\r\n * - Draws instanced if `numInstances > 0`.\r\n * - Else uses `ctx.instanceData.numInstances` if available.\r\n * - Else issues a non-instanced draw.\r\n *\r\n * @param pass - Pass number.\r\n * @param primitive - Primitive to draw.\r\n * @param ctx - Draw context.\r\n * @param numInstances - Explicit instance count (0 = auto).\r\n */\r\n drawPrimitive(pass: number, primitive: Primitive, ctx: DrawContext, numInstances: number) {\r\n if (numInstances > 0) {\r\n primitive.drawInstanced(numInstances);\r\n } else if (ctx.instanceData) {\r\n primitive.drawInstanced(ctx.instanceData.numInstances);\r\n } else {\r\n primitive.draw();\r\n }\r\n }\r\n /**\r\n * Dispose the material and release GPU-side resource references.\r\n *\r\n * - Unregisters from the global registry.\r\n * - Disposes the per-material bind groups kept in `_states`.\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n this.clearCache();\r\n }\r\n /**\r\n * Build the GPU program for a pass.\r\n *\r\n * Default creates a `ProgramBuilder` and calls `_createProgram(pb, ctx, pass)`.\r\n * Subclasses should override `_createProgram` instead of this method unless\r\n * they need to replace builder instantiation.\r\n *\r\n * @param ctx - Draw context.\r\n * @param pass - Pass number.\r\n * @returns The compiled `GPUProgram`, or `null` on failure.\r\n * @internal\r\n */\r\n protected createProgram(ctx: DrawContext, pass: number) {\r\n const pb = new ProgramBuilder(ctx.device);\r\n return this._createProgram(pb, ctx, pass);\r\n }\r\n /**\r\n * Create and compile the shader program for this material/pass.\r\n *\r\n * Implement in subclasses:\r\n * - Define shader stages, entry points, macros/defines, and resource layouts.\r\n * - Return a compiled `GPUProgram`.\r\n *\r\n * @param pb - Program builder.\r\n * @param ctx - Draw context.\r\n * @param _pass - Pass number.\r\n * @returns The created program, or `null` on failure.\r\n */\r\n protected _createProgram(_pb: ProgramBuilder, _ctx: DrawContext, _pass: number): GPUProgram {\r\n throw new Error('Abstract function call');\r\n }\r\n /**\r\n * Upload uniforms and bind resources to the per-material bind group (index 2).\r\n *\r\n * Implement in subclasses to:\r\n * - Write uniform buffers/textures/samplers to the `bindGroup`.\r\n * - Respect the current `pass` and `ctx`.\r\n *\r\n * @param _bindGroup - The bind group to populate.\r\n * @param _ctx - Draw context.\r\n * @param _pass - Pass number.\r\n */\r\n protected _applyUniforms(_bindGroup: BindGroup, _ctx: DrawContext, _pass: number) {}\r\n /**\r\n * Update render states (depth/stencil, blending, rasterization) for the pass.\r\n *\r\n * Implement in subclasses based on transparency, double-sidedness, depth writes/tests,\r\n * color mask, stencil ops, etc., and any context flags in `ctx`.\r\n *\r\n * @param _pass - Current pass index.\r\n * @param _renderStates - Render state set to mutate.\r\n * @param _ctx - Draw context.\r\n */\r\n protected updateRenderStates(_pass: number, _renderStates: RenderStateSet, _ctx: DrawContext) {}\r\n /**\r\n * Compute the material-specific portion of the shader hash for the current options.\r\n *\r\n * Subclasses should override to include macro/define sets that influence program compilation.\r\n * Example return: `\"USE_NORMALMAP=1;ALPHA_MODE=BLEND;RECEIVE_SHADOWS=1\"`.\r\n *\r\n * @returns Hash fragment string (no context/pass info).\r\n */\r\n protected _createHash() {\r\n return '';\r\n }\r\n /**\r\n * Whether this is a lightweight instance of a core material.\r\n *\r\n * Instances typically share GPU programs with a core and only override instance uniforms.\r\n * @internal\r\n */\r\n get $isInstance(): boolean {\r\n return false;\r\n }\r\n /**\r\n * Instance-uniform buffer for material instances, if supported.\r\n *\r\n * Returned as a typed Float32 view over a backing ArrayBuffer.\r\n * @internal\r\n */\r\n get $instanceUniforms(): Float32Array<ArrayBuffer> {\r\n throw new Error('Abstract function call');\r\n }\r\n}\r\n"],"names":["Material","Disposable","_nextId","_programCache","_nextProgramId","_id","_states","_numPasses","_hash","_optionTag","_changeTag","_currentHash","clone","other","copyFrom","clearCache","getEngine","resourceManager","setAssetId","getAssetId","coreMaterial","changeTag","instanceId","numPasses","val","length","push","getHash","pass","createHash","getQueueType","QUEUE_OPAQUE","isTransparentPass","_pass","supportLighting","supportInstancing","isBatchable","needSceneColor","needSceneDepth","createInstance","Error","apply","ctx","hash","calcGlobalHash","state","program","createProgram","name","bindGroup","bindGroupLayouts","device","createBindGroup","bindGroupTag","getGPUId","renderStateSet","createRenderStateSet","materialTag","applyUniforms","updateRenderStates","id","RenderBundleWrapper","materialChanged","bind","console","error","setProgram","setBindGroup","setRenderStates","materialFlags","renderPassHash","draw","primitive","numInstances","drawPrimitive","needUpdate","_applyUniforms","optionChanged","changeHash","i","k","dispose","passToHash","String","_createHash","drawInstanced","instanceData","onDispose","pb","ProgramBuilder","_createProgram","_pb","_ctx","_bindGroup","_renderStates","$isInstance","$instanceUniforms"],"mappings":";;;;;;AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6CO,MAAMA,QAAiBC,SAAAA,UAAAA,CAAAA;AAC5B;;;MAIA,OAAeC,UAAU,CAAE;AAC3B;;MAGA,OAAeC,aAAgD,GAAA,EAAG;AAClE;;;AAG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ACD,SAAsB,GAAA;AACpB,QAAA,KAAK,CAACgB,SAAAA,EAAAA;AACN,QAAA,IAAI,CAACxE,UAAU,EAAA;AACjB;AACA;;;;;;;;;;;AAWC,MACD,aAAUgC,CAAcL,GAAgB,EAAEd,IAAY,EAAE;AACtD,QAAA,MAAM4D,EAAK,GAAA,IAAIC,cAAe/C,CAAAA,GAAAA,CAAIS,MAAM,CAAA;AACxC,QAAA,OAAO,IAAI,CAACuC,cAAc,CAACF,IAAI9C,GAAKd,EAAAA,IAAAA,CAAAA;AACtC;AACA;;;;;;;;;;;AAWC,MACD,cAAyB+D,CAAAA,GAAmB,EAAEC,IAAiB,EAAE3D,KAAa,EAAc;AAC1F,QAAA,MAAM,IAAIO,KAAM,CAAA,wBAAA,CAAA;AAClB;AACA;;;;;;;;;;MAWUoC,eAAeiB,UAAqB,EAAED,IAAiB,EAAE3D,KAAa,EAAE;AAClF;;;;;;;;;MAUU0B,mBAAmB1B,KAAa,EAAE6D,aAA6B,EAAEF,IAAiB,EAAE;AAC9F;;;;;;;AAOC,MACD,WAAwB,GAAA;QACtB,OAAO,EAAA;AACT;AACA;;;;;AAKC,MACD,IAAIG,WAAuB,GAAA;QACzB,OAAO,KAAA;AACT;AACA;;;;;AAKC,MACD,IAAIC,iBAA+C,GAAA;AACjD,QAAA,MAAM,IAAIxD,KAAM,CAAA,wBAAA,CAAA;AAClB;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"pbrmetallicroughness.js","sources":["../../../../src/material/mixins/lightmodel/pbrmetallicroughness.ts"],"sourcesContent":["import type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport type { MeshMaterial } from '../../meshmaterial';\r\nimport { applyMaterialMixins } from '../../meshmaterial';\r\nimport type { TextureMixinInstanceTypes } from '../texture';\r\nimport { mixinTextureProps } from '../texture';\r\nimport type { IMixinPBRCommon } from '../pbr/common';\r\nimport { mixinPBRCommon } from '../pbr/common';\r\nimport type { DrawContext } from '../../../render';\r\nimport type { Immutable } from '@zephyr3d/base';\r\nimport { Vector2, Vector4 } from '@zephyr3d/base';\r\nimport type { IMixinLight } from '../lit';\r\nimport { mixinLight } from '../lit';\r\nimport { ShaderHelper } from '../../shader/helper';\r\nimport {\r\n LIGHT_TYPE_POINT,\r\n LIGHT_TYPE_RECT,\r\n MaterialVaryingFlags,\r\n RENDER_PASS_TYPE_LIGHT\r\n} from '../../../values';\r\n\r\nexport type PBRReflectionMode = 'none' | 'ggx' | 'anisotropic' | 'glint';\r\n\r\nconst PBR_REFLECTION_MODE: Record<PBRReflectionMode, number> = {\r\n none: 0,\r\n ggx: 1,\r\n anisotropic: 2,\r\n glint: 3\r\n};\r\n\r\n/**\r\n * Interface for PBRMetallicRoughness lighting model mixin\r\n * @public\r\n */\r\nexport type IMixinPBRMetallicRoughness = {\r\n metallic: number;\r\n roughness: number;\r\n specularFactor: Vector4;\r\n reflectionMode: PBRReflectionMode;\r\n anisotropy: number;\r\n anisotropyDirection: number;\r\n anisotropyDirectionScaleBias: Vector2;\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ): PBShaderExp;\r\n calculateMetallic(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateRoughness(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateSpecularFactor(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp\r\n ): PBShaderExp;\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ): void;\r\n} & IMixinPBRCommon &\r\n IMixinLight &\r\n TextureMixinInstanceTypes<\r\n ['metallicRoughness', 'occlusion', 'specular', 'specularColor', 'anisotropyDirection']\r\n >;\r\n\r\n/**\r\n * PBRMetallicRoughness lighting model mixin\r\n * @param BaseCls - Class to mix in\r\n * @returns Mixed class\r\n * @public\r\n */\r\nexport function mixinPBRMetallicRoughness<T extends typeof MeshMaterial>(BaseCls: T) {\r\n if ((BaseCls as any).pbrMetallicRoughnessMixed) {\r\n return BaseCls as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n }\r\n const S = applyMaterialMixins(\r\n BaseCls,\r\n mixinPBRCommon,\r\n mixinLight,\r\n mixinTextureProps('metallicRoughness'),\r\n mixinTextureProps('specular'),\r\n mixinTextureProps('specularColor'),\r\n mixinTextureProps('anisotropyDirection')\r\n );\r\n const METALLIC_UNIFORM = S.defineInstanceUniform('metallic', 'float', 'Metallic');\r\n const ROUGHNESS_UNIFORM = S.defineInstanceUniform('roughness', 'float', 'Roughness');\r\n const SPECULAR_FACTOR_UNFORM = S.defineInstanceUniform('specularFactor', 'rgba', 'SpecularFactor');\r\n\r\n return class extends S {\r\n static readonly pbrMetallicRoughnessMixed = true;\r\n private _metallic: number;\r\n private _roughness: number;\r\n private readonly _specularFactor: Vector4;\r\n private _reflectionMode: PBRReflectionMode;\r\n private _anisotropy: number;\r\n private _anisotropyDirection: number;\r\n private readonly _anisotropyDirectionScaleBias: Vector2;\r\n constructor() {\r\n super();\r\n this._metallic = 1;\r\n this._roughness = 1;\r\n this._specularFactor = Vector4.one();\r\n this._reflectionMode = 'ggx';\r\n this._anisotropy = 0.75;\r\n this._anisotropyDirection = 0;\r\n this._anisotropyDirectionScaleBias = new Vector2(1, 0);\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.metallic = other.metallic;\r\n this.roughness = other.roughness;\r\n this.specularFactor = other.specularFactor;\r\n this.reflectionMode = other.reflectionMode;\r\n this.anisotropy = other.anisotropy;\r\n this.anisotropyDirection = other.anisotropyDirection;\r\n this.anisotropyDirectionScaleBias = other.anisotropyDirectionScaleBias;\r\n }\r\n get metallic() {\r\n return this._metallic;\r\n }\r\n set metallic(val) {\r\n if (val !== this._metallic) {\r\n this._metallic = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get roughness() {\r\n return this._roughness;\r\n }\r\n set roughness(val) {\r\n if (val !== this._roughness) {\r\n this._roughness = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get specularFactor(): Immutable<Vector4> {\r\n return this._specularFactor;\r\n }\r\n set specularFactor(val: Immutable<Vector4>) {\r\n if (!val.equalsTo(this._specularFactor)) {\r\n this._specularFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n directLighting(\r\n scope: PBInsideFunctionScope,\r\n lightDir: PBShaderExp,\r\n lightColor: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n commonData: PBShaderExp,\r\n diffuseScale: PBShaderExp,\r\n specularScale: PBShaderExp,\r\n sourceRadiusFactor: PBShaderExp,\r\n outColor: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const that = this as any;\r\n const funcName = 'Z_PBRMR_DirectLighting';\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('L'),\r\n pb.vec3('lightColor'),\r\n pb.vec3('normal'),\r\n pb.vec3('viewVec'),\r\n that.getCommonDatasStruct(scope)('data'),\r\n pb.float('diffuseScale'),\r\n pb.float('specularScale'),\r\n pb.float('sourceRadiusFactor'),\r\n pb.vec3('outColor').inout()\r\n ],\r\n function () {\r\n this.$l.reflectionMode = this.zReflectionMode;\r\n this.$l.anisotropy = this.zAnisotropy;\r\n this.$l.anisotropyDirection = this.zAnisotropyDirection;\r\n this.$l.anisotropyDirectionScaleBias = this.zAnisotropyDirectionScaleBias;\r\n this.$l.H = pb.normalize(pb.add(this.viewVec, this.L));\r\n this.$l.NoH = pb.clamp(pb.dot(this.normal, this.H), 0, 1);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.L), 0, 1);\r\n this.$l.NoV = pb.clamp(pb.dot(this.normal, this.viewVec), 0, 1);\r\n this.$if(pb.greaterThan(this.NoL, 0), function () {\r\n this.$l.VoH = pb.clamp(pb.dot(this.viewVec, this.H), 0, 1);\r\n this.$l.schlickFresnel = that.fresnelSchlick(this, this.VoH, this.data.f0.rgb, this.data.f90);\r\n if (that.iridescence) {\r\n this.$l.F = pb.mix(\r\n this.schlickFresnel,\r\n this.data.iridescenceFresnel,\r\n this.data.iridescenceFactor.x\r\n );\r\n } else {\r\n this.$l.F = this.schlickFresnel;\r\n }\r\n this.$l.specularRoughness = pb.clamp(pb.add(this.data.roughness, this.sourceRadiusFactor), 0, 1);\r\n this.$l.alphaRoughness = pb.mul(this.specularRoughness, this.specularRoughness);\r\n this.$l.Dggx = that.distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.$l.D = this.Dggx;\r\n this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.anisotropic), function () {\r\n this.$l.dirAngle = pb.mul(this.anisotropyDirection, Math.PI / 180);\r\n if (that.anisotropyDirectionTexture) {\r\n this.$l.dirSample = that.sampleAnisotropyDirectionTexture(this);\r\n this.$l.dirAngle = pb.mul(\r\n pb.add(\r\n pb.mul(this.dirSample.r, this.anisotropyDirectionScaleBias.x),\r\n this.anisotropyDirectionScaleBias.y\r\n ),\r\n Math.PI / 180\r\n );\r\n }\r\n this.$l.anisoAngle = this.dirAngle;\r\n this.$l.up = pb.vec3(0, 1, 0);\r\n this.$l.t0 = pb.normalize(pb.cross(this.up, this.normal));\r\n this.$if(pb.lessThan(pb.length(this.t0), 0.001), function () {\r\n this.t0 = pb.normalize(pb.cross(pb.vec3(1, 0, 0), this.normal));\r\n });\r\n this.$l.b0 = pb.normalize(pb.cross(this.normal, this.t0));\r\n this.$l.tangent = pb.normalize(\r\n pb.add(pb.mul(this.t0, pb.cos(this.anisoAngle)), pb.mul(this.b0, pb.sin(this.anisoAngle)))\r\n );\r\n this.$l.bitangent = pb.normalize(pb.cross(this.normal, this.tangent));\r\n this.$l.ToH = pb.dot(this.tangent, this.H);\r\n this.$l.BoH = pb.dot(this.bitangent, this.H);\r\n this.$l.at = pb.max(pb.mul(this.alphaRoughness, pb.add(1, this.anisotropy)), 0.0001);\r\n this.$l.ab = pb.max(pb.mul(this.alphaRoughness, pb.sub(1, this.anisotropy)), 0.0001);\r\n this.$l.anisoDenom = pb.mul(\r\n Math.PI,\r\n this.at,\r\n this.ab,\r\n pb.pow(\r\n pb.add(\r\n pb.div(pb.mul(this.ToH, this.ToH), pb.mul(this.at, this.at)),\r\n pb.div(pb.mul(this.BoH, this.BoH), pb.mul(this.ab, this.ab)),\r\n pb.mul(this.NoH, this.NoH)\r\n ),\r\n 2\r\n )\r\n );\r\n this.D = pb.div(1, pb.max(this.anisoDenom, 0.0001));\r\n }).$elseif(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.glint), function () {\r\n this.$l.glintNoise = pb.fract(\r\n pb.mul(\r\n pb.sin(pb.add(pb.dot(this.H, pb.vec3(127.1, 311.7, 74.7)), pb.mul(this.NoH, 43.1))),\r\n 43758.5453\r\n )\r\n );\r\n this.$l.glintMask = pb.smoothStep(0.97, 1, this.glintNoise);\r\n this.D = pb.mul(this.Dggx, pb.add(1, pb.mul(this.glintMask, 8)));\r\n });\r\n this.$l.V = that.visGGX(this, this.NoV, this.NoL, this.alphaRoughness);\r\n this.$l.specular = pb.mul(\r\n this.lightColor,\r\n this.D,\r\n this.V,\r\n this.F,\r\n this.data.specularWeight,\r\n this.specularScale\r\n );\r\n if (that.sheen) {\r\n this.specular = pb.mul(this.specular, this.data.sheenAlbedoScaling);\r\n }\r\n this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.none), function () {\r\n this.specular = pb.vec3(0);\r\n });\r\n this.outColor = pb.add(this.outColor, this.specular);\r\n if (that.iridescence) {\r\n this.$l.iridescenceFresnelMax = pb.vec3(\r\n pb.max(\r\n pb.max(this.data.iridescenceFresnel.r, this.data.iridescenceFresnel.g),\r\n this.data.iridescenceFresnel.b\r\n )\r\n );\r\n this.F = pb.mix(this.schlickFresnel, this.iridescenceFresnelMax, this.data.iridescenceFactor.x);\r\n }\r\n this.$l.diffuseBRDF = pb.mul(\r\n pb.sub(pb.vec3(1), pb.mul(this.F, this.data.specularWeight)),\r\n pb.div(this.data.diffuse.rgb, Math.PI)\r\n );\r\n this.$l.diffuse = pb.mul(\r\n this.lightColor,\r\n pb.max(this.diffuseBRDF, pb.vec3(0)),\r\n this.diffuseScale\r\n );\r\n if (that.transmission && that.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n this.$l.transmissionRay = that.getVolumeTransmissionRay(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.data.thicknessFactor,\r\n this.data.f0.a\r\n );\r\n this.$l.pointToLight = pb.normalize(pb.sub(this.L, this.transmissionRay));\r\n this.$l.transmittedLight = pb.mul(\r\n this.lightColor,\r\n that.getPunctualRadianceTransmission(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pointToLight,\r\n this.alphaRoughness,\r\n this.data.f0.rgb,\r\n this.data.f90.rgb,\r\n this.data.diffuse.rgb,\r\n this.data.f0.a\r\n )\r\n );\r\n this.transmittedLight = that.applyVolumeAttenuation(\r\n this,\r\n this.transmittedLight,\r\n pb.length(this.transmissionRay),\r\n this.data.attenuationColor,\r\n this.data.attenuationDistance\r\n );\r\n this.diffuse = pb.mix(this.diffuse, this.transmittedLight, this.data.transmissionFactor);\r\n }\r\n if (that.sheen) {\r\n this.diffuse = pb.mul(this.diffuse, this.data.sheenAlbedoScaling);\r\n }\r\n this.outColor = pb.add(this.outColor, this.diffuse);\r\n if (that.sheen) {\r\n this.$l.sheenD = that.D_Charlie(this, this.NoH, this.data.sheenRoughness);\r\n this.$l.sheenV = that.V_Ashikhmin(this, this.NoL, this.NoV);\r\n this.outColor = pb.add(\r\n this.outColor,\r\n pb.mul(this.lightColor, this.data.sheenColor, this.sheenD, this.sheenV)\r\n );\r\n }\r\n if (that.clearcoat) {\r\n this.alphaRoughness = pb.mul(this.data.ccFactor.y, this.data.ccFactor.y);\r\n this.NoH = pb.clamp(pb.dot(this.data.ccNormal, this.H), 0, 1);\r\n this.NoL = pb.clamp(pb.dot(this.data.ccNormal, this.L), 0, 1);\r\n this.ccF0 = pb.vec3(pb.pow(pb.div(pb.sub(this.data.f0.a, 1), pb.add(this.data.f0.a, 1)), 2));\r\n this.F = that.fresnelSchlick(this, this.VoH, this.ccF0, pb.vec3(1));\r\n this.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.V = that.visGGX(this, this.data.ccNoV, this.NoL, this.alphaRoughness);\r\n this.outColor = pb.add(this.outColor, pb.mul(this.D, this.V, this.F, this.data.ccFactor.x));\r\n }\r\n });\r\n }\r\n );\r\n scope.$g[funcName](\r\n lightDir,\r\n lightColor,\r\n normal,\r\n viewVec,\r\n commonData,\r\n diffuseScale,\r\n specularScale,\r\n sourceRadiusFactor,\r\n outColor\r\n );\r\n }\r\n get reflectionMode() {\r\n return this._reflectionMode;\r\n }\r\n set reflectionMode(val: PBRReflectionMode) {\r\n if (val !== this._reflectionMode) {\r\n this._reflectionMode = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropy() {\r\n return this._anisotropy;\r\n }\r\n set anisotropy(val) {\r\n const clamped = Math.max(-0.95, Math.min(0.95, val));\r\n if (clamped !== this._anisotropy) {\r\n this._anisotropy = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirection() {\r\n return this._anisotropyDirection;\r\n }\r\n set anisotropyDirection(val) {\r\n if (val !== this._anisotropyDirection) {\r\n this._anisotropyDirection = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirectionScaleBias(): Immutable<Vector2> {\r\n return this._anisotropyDirectionScaleBias;\r\n }\r\n set anisotropyDirectionScaleBias(val: Immutable<Vector2>) {\r\n if (!val.equalsTo(this._anisotropyDirectionScaleBias)) {\r\n this._anisotropyDirectionScaleBias.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n calculateAnisotropyDirectionScaleBias(scope: PBInsideFunctionScope) {\r\n return scope.zAnisotropyDirectionScaleBias as PBShaderExp;\r\n }\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_PBRMetallicRoughnessLight';\r\n const that = this;\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('worldPos'),\r\n pb.vec3('normal'),\r\n pb.mat3('TBN'),\r\n pb.vec3('viewVec'),\r\n pb.vec4('albedo'),\r\n ...(outRoughness ? [pb.vec4('outRoughness').out()] : [])\r\n ],\r\n function () {\r\n this.$l.pbrData = that.getCommonData(this, this.albedo, this.normal, this.viewVec, this.TBN);\r\n this.$l.lightingColor = pb.vec3(0);\r\n this.$l.emissiveColor = that.calculateEmissiveColor(this);\r\n if (outRoughness) {\r\n that.indirectLighting(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.lightingColor,\r\n this.outRoughness\r\n );\r\n } else {\r\n that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor);\r\n }\r\n that.forEachLight(this, function (type, posRange, dirCutoff, colorIntensity, extra, shadow) {\r\n this.$if(pb.equal(type, LIGHT_TYPE_RECT), function () {\r\n that.directRectLight(\r\n this,\r\n this.worldPos,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n posRange,\r\n dirCutoff,\r\n extra,\r\n colorIntensity,\r\n this.lightingColor\r\n );\r\n }).$else(function () {\r\n this.$l.diffuse = pb.vec3();\r\n this.$l.specular = pb.vec3();\r\n this.$l.diffuseScale = pb.float(1);\r\n this.$l.specularScale = pb.float(1);\r\n this.$l.sourceRadiusFactor = pb.float(0);\r\n this.$if(pb.equal(type, LIGHT_TYPE_POINT), function () {\r\n this.diffuseScale = extra.x;\r\n this.specularScale = extra.y;\r\n this.sourceRadiusFactor = pb.div(\r\n extra.z,\r\n pb.max(pb.distance(posRange.xyz, this.worldPos), 0.0001)\r\n );\r\n });\r\n this.$l.lightAtten = that.calculateLightAttenuation(\r\n this,\r\n type,\r\n this.worldPos,\r\n posRange,\r\n dirCutoff\r\n );\r\n this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);\r\n this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten, this.NoL);\r\n if (shadow) {\r\n this.lightColor = pb.mul(\r\n this.lightColor,\r\n that.calculateShadow(this, this.worldPos, this.NoL)\r\n );\r\n }\r\n that.directLighting(\r\n this,\r\n this.lightDir,\r\n this.lightColor,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.diffuseScale,\r\n this.specularScale,\r\n this.sourceRadiusFactor,\r\n this.lightingColor\r\n );\r\n });\r\n });\r\n this.$return(pb.add(this.lightingColor, this.emissiveColor));\r\n }\r\n );\r\n return (\r\n outRoughness\r\n ? pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo, outRoughness)\r\n : pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo)\r\n ) as PBShaderExp;\r\n }\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n if (this.needFragmentColor() && this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {\r\n scope.$outputs.zMetallic = this.getInstancedUniform(scope, METALLIC_UNIFORM);\r\n scope.$outputs.zRoughness = this.getInstancedUniform(scope, ROUGHNESS_UNIFORM);\r\n scope.$outputs.zSpecularFactor = this.getInstancedUniform(scope, SPECULAR_FACTOR_UNFORM);\r\n }\r\n }\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n if (this.needFragmentColor()) {\r\n const pb = scope.$builder;\r\n if (!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n scope.zMetallic = pb.float().uniform(2);\r\n scope.zRoughness = pb.float().uniform(2);\r\n scope.zSpecularFactor = pb.vec4().uniform(2);\r\n }\r\n scope.zReflectionMode = pb.float().uniform(2);\r\n scope.zAnisotropy = pb.float().uniform(2);\r\n scope.zAnisotropyDirection = pb.float().uniform(2);\r\n scope.zAnisotropyDirectionScaleBias = pb.vec2().uniform(2);\r\n }\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColor(ctx)) {\r\n if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n bindGroup.setValue('zMetallic', this._metallic);\r\n bindGroup.setValue('zRoughness', this._roughness);\r\n bindGroup.setValue('zSpecularFactor', this._specularFactor);\r\n bindGroup.setValue('zReflectionMode', PBR_REFLECTION_MODE[this._reflectionMode]);\r\n bindGroup.setValue('zAnisotropy', this._anisotropy);\r\n bindGroup.setValue('zAnisotropyDirection', this._anisotropyDirection);\r\n bindGroup.setValue('zAnisotropyDirectionScaleBias', this._anisotropyDirectionScaleBias);\r\n }\r\n }\r\n }\r\n calculateMetallic(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zMetallic : scope.zMetallic) as PBShaderExp;\r\n }\r\n calculateRoughness(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zRoughness : scope.zRoughness) as PBShaderExp;\r\n }\r\n calculateSpecularFactor(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSpecularFactor : scope.zSpecularFactor) as PBShaderExp;\r\n }\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const metallic = this.calculateMetallic(scope, albedo, normal);\r\n const roughness = this.calculateRoughness(scope, albedo, normal);\r\n const specularFactor = this.calculateSpecularFactor(scope, albedo, normal);\r\n const reflectionMode = this.calculateReflectionMode(scope) as PBShaderExp;\r\n if (this.metallicRoughnessTexture) {\r\n scope.$l.metallicRoughnessSample = this.sampleMetallicRoughnessTexture(scope);\r\n data.metallic = pb.mul(metallic, scope.metallicRoughnessSample.z);\r\n data.roughness = pb.mul(roughness, scope.metallicRoughnessSample.y);\r\n } else {\r\n data.metallic = metallic;\r\n data.roughness = roughness;\r\n }\r\n data.roughness = pb.mul(data.roughness, ShaderHelper.getCameraRoughnessFactor(scope));\r\n if (this.specularColorTexture) {\r\n scope.$l.specularColor = pb.mul(specularFactor.rgb, this.sampleSpecularColorTexture(scope).rgb);\r\n } else {\r\n scope.$l.specularColor = specularFactor.rgb;\r\n }\r\n if (this.specularTexture) {\r\n data.specularWeight = pb.mul(specularFactor.a, this.sampleSpecularTexture(scope).a);\r\n } else {\r\n data.specularWeight = specularFactor.a;\r\n }\r\n data.specularWeight = pb.mul(\r\n data.specularWeight,\r\n pb.float(pb.notEqual(reflectionMode, PBR_REFLECTION_MODE.none))\r\n );\r\n data.f0 = pb.vec4(\r\n pb.mix(\r\n pb.min(pb.mul(this.getF0(scope).rgb, scope.specularColor), pb.vec3(1)),\r\n albedo.rgb,\r\n data.metallic\r\n ),\r\n this.getF0(scope).a\r\n );\r\n data.f90 = pb.vec3(1);\r\n data.diffuse = pb.vec4(pb.mix(albedo.rgb, pb.vec3(0), data.metallic), albedo.a);\r\n super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);\r\n }\r\n calculateReflectionMode(scope: PBInsideFunctionScope) {\r\n return scope.zReflectionMode as PBShaderExp;\r\n }\r\n calculateAnisotropy(scope: PBInsideFunctionScope) {\r\n return scope.zAnisotropy as PBShaderExp;\r\n }\r\n calculateAnisotropyDirection(scope: PBInsideFunctionScope) {\r\n return scope.zAnisotropyDirection as PBShaderExp;\r\n }\r\n } as unknown as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n}\r\n"],"names":["PBR_REFLECTION_MODE","none","ggx","anisotropic","glint","mixinPBRMetallicRoughness","BaseCls","pbrMetallicRoughnessMixed","S","applyMaterialMixins","mixinPBRCommon","mixinLight","mixinTextureProps","METALLIC_UNIFORM","defineInstanceUniform","ROUGHNESS_UNIFORM","SPECULAR_FACTOR_UNFORM","_metallic","_roughness","_specularFactor","_reflectionMode","_anisotropy","_anisotropyDirection","_anisotropyDirectionScaleBias","Vector4","one","Vector2","copyFrom","other","metallic","roughness","specularFactor","reflectionMode","anisotropy","anisotropyDirection","anisotropyDirectionScaleBias","val","uniformChanged","equalsTo","set","directLighting","scope","lightDir","lightColor","normal","viewVec","commonData","diffuseScale","specularScale","sourceRadiusFactor","outColor","pb","$builder","that","funcName","func","vec3","getCommonDatasStruct","float","inout","$l","zReflectionMode","zAnisotropy","zAnisotropyDirection","zAnisotropyDirectionScaleBias","H","normalize","add","L","NoH","clamp","dot","NoL","NoV","$if","greaterThan","VoH","schlickFresnel","fresnelSchlick","data","f0","rgb","f90","iridescence","F","mix","iridescenceFresnel","iridescenceFactor","x","specularRoughness","alphaRoughness","mul","Dggx","distributionGGX","D","equal","dirAngle","Math","PI","anisotropyDirectionTexture","dirSample","sampleAnisotropyDirectionTexture","r","y","anisoAngle","up","t0","cross","lessThan","length","b0","tangent","cos","sin","bitangent","ToH","BoH","at","max","ab","sub","anisoDenom","pow","div","$elseif","glintNoise","fract","glintMask","smoothStep","V","visGGX","specular","specularWeight","sheen","sheenAlbedoScaling","iridescenceFresnelMax","g","b","diffuseBRDF","diffuse","transmission","drawContext","renderPass","type","RENDER_PASS_TYPE_LIGHT","transmissionRay","getVolumeTransmissionRay","thicknessFactor","a","pointToLight","transmittedLight","getPunctualRadianceTransmission","applyVolumeAttenuation","attenuationColor","attenuationDistance","transmissionFactor","sheenD","D_Charlie","sheenRoughness","sheenV","V_Ashikhmin","sheenColor","clearcoat","ccFactor","ccNormal","ccF0","ccNoV","$g","clamped","min","calculateAnisotropyDirectionScaleBias","PBRLight","worldPos","albedo","TBN","outRoughness","mat3","vec4","out","pbrData","getCommonData","lightingColor","emissiveColor","calculateEmissiveColor","indirectLighting","forEachLight","posRange","dirCutoff","colorIntensity","extra","shadow","LIGHT_TYPE_RECT","directRectLight","$else","LIGHT_TYPE_POINT","z","distance","xyz","lightAtten","calculateLightAttenuation","calculateLightDirection","calculateShadow","$return","getGlobalScope","vertexShader","needFragmentColor","materialFlags","MaterialVaryingFlags","INSTANCING","$outputs","zMetallic","getInstancedUniform","zRoughness","zSpecularFactor","fragmentShader","uniform","vec2","applyUniformValues","bindGroup","ctx","pass","setValue","calculateMetallic","_albedo","_normal","instancing","$inputs","calculateRoughness","calculateSpecularFactor","calculateCommonData","calculateReflectionMode","metallicRoughnessTexture","metallicRoughnessSample","sampleMetallicRoughnessTexture","ShaderHelper","getCameraRoughnessFactor","specularColorTexture","specularColor","sampleSpecularColorTexture","specularTexture","sampleSpecularTexture","notEqual","getF0","calculateAnisotropy","calculateAnisotropyDirection"],"mappings":";;;;;;;;AAsBA,MAAMA,mBAAyD,GAAA;IAC7DC,IAAM,EAAA,CAAA;IACNC,GAAK,EAAA,CAAA;IACLC,WAAa,EAAA,CAAA;IACbC,KAAO,EAAA;AACT,CAAA;AA4CA;;;;;IAMO,SAASC,yBAAAA,CAAyDC,OAAU,EAAA;IACjF,IAAKA,OAAgBC,CAAAA,yBAAyB,EAAE;QAC9C,OAAOD,OAAAA;AACT;IACA,MAAME,C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MAAMoB,eAAe;AAC9B;AACAsL,QAAAA,mBAAAA,CAAoB1M,KAA4B,EAAE;AAChD,YAAA,OAAOA,MAAMqB,WAAW;AAC1B;AACAsL,QAAAA,4BAAAA,CAA6B3M,KAA4B,EAAE;AACzD,YAAA,OAAOA,MAAMsB,oBAAoB;AACnC;AACF,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"pbrmetallicroughness.js","sources":["../../../../src/material/mixins/lightmodel/pbrmetallicroughness.ts"],"sourcesContent":["import type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport type { MeshMaterial } from '../../meshmaterial';\r\nimport { applyMaterialMixins } from '../../meshmaterial';\r\nimport type { TextureMixinInstanceTypes } from '../texture';\r\nimport { mixinTextureProps } from '../texture';\r\nimport type { IMixinPBRCommon } from '../pbr/common';\r\nimport { mixinPBRCommon } from '../pbr/common';\r\nimport type { DrawContext } from '../../../render';\r\nimport type { Immutable } from '@zephyr3d/base';\r\nimport { Vector2, Vector4 } from '@zephyr3d/base';\r\nimport type { IMixinLight } from '../lit';\r\nimport { mixinLight } from '../lit';\r\nimport { ShaderHelper } from '../../shader/helper';\r\nimport {\r\n LIGHT_TYPE_POINT,\r\n LIGHT_TYPE_RECT,\r\n MaterialVaryingFlags,\r\n RENDER_PASS_TYPE_LIGHT\r\n} from '../../../values';\r\n\r\n/**\r\n * Reflection model used by the PBR metallic-roughness material.\r\n *\r\n * @public\r\n */\r\nexport type PBRReflectionMode = 'none' | 'ggx' | 'anisotropic' | 'glint';\r\n\r\nconst PBR_REFLECTION_MODE: Record<PBRReflectionMode, number> = {\r\n none: 0,\r\n ggx: 1,\r\n anisotropic: 2,\r\n glint: 3\r\n};\r\n\r\n/**\r\n * Interface for PBRMetallicRoughness lighting model mixin\r\n * @public\r\n */\r\nexport type IMixinPBRMetallicRoughness = {\r\n metallic: number;\r\n roughness: number;\r\n specularFactor: Vector4;\r\n reflectionMode: PBRReflectionMode;\r\n anisotropy: number;\r\n anisotropyDirection: number;\r\n anisotropyDirectionScaleBias: Vector2;\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ): PBShaderExp;\r\n calculateMetallic(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateRoughness(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateSpecularFactor(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp\r\n ): PBShaderExp;\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ): void;\r\n} & IMixinPBRCommon &\r\n IMixinLight &\r\n TextureMixinInstanceTypes<\r\n ['metallicRoughness', 'occlusion', 'specular', 'specularColor', 'anisotropyDirection']\r\n >;\r\n\r\n/**\r\n * PBRMetallicRoughness lighting model mixin\r\n * @param BaseCls - Class to mix in\r\n * @returns Mixed class\r\n * @public\r\n */\r\nexport function mixinPBRMetallicRoughness<T extends typeof MeshMaterial>(BaseCls: T) {\r\n if ((BaseCls as any).pbrMetallicRoughnessMixed) {\r\n return BaseCls as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n }\r\n const S = applyMaterialMixins(\r\n BaseCls,\r\n mixinPBRCommon,\r\n mixinLight,\r\n mixinTextureProps('metallicRoughness'),\r\n mixinTextureProps('specular'),\r\n mixinTextureProps('specularColor'),\r\n mixinTextureProps('anisotropyDirection')\r\n );\r\n const METALLIC_UNIFORM = S.defineInstanceUniform('metallic', 'float', 'Metallic');\r\n const ROUGHNESS_UNIFORM = S.defineInstanceUniform('roughness', 'float', 'Roughness');\r\n const SPECULAR_FACTOR_UNFORM = S.defineInstanceUniform('specularFactor', 'rgba', 'SpecularFactor');\r\n\r\n return class extends S {\r\n static readonly pbrMetallicRoughnessMixed = true;\r\n private _metallic: number;\r\n private _roughness: number;\r\n private readonly _specularFactor: Vector4;\r\n private _reflectionMode: PBRReflectionMode;\r\n private _anisotropy: number;\r\n private _anisotropyDirection: number;\r\n private readonly _anisotropyDirectionScaleBias: Vector2;\r\n constructor() {\r\n super();\r\n this._metallic = 1;\r\n this._roughness = 1;\r\n this._specularFactor = Vector4.one();\r\n this._reflectionMode = 'ggx';\r\n this._anisotropy = 0.75;\r\n this._anisotropyDirection = 0;\r\n this._anisotropyDirectionScaleBias = new Vector2(1, 0);\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.metallic = other.metallic;\r\n this.roughness = other.roughness;\r\n this.specularFactor = other.specularFactor;\r\n this.reflectionMode = other.reflectionMode;\r\n this.anisotropy = other.anisotropy;\r\n this.anisotropyDirection = other.anisotropyDirection;\r\n this.anisotropyDirectionScaleBias = other.anisotropyDirectionScaleBias;\r\n }\r\n get metallic() {\r\n return this._metallic;\r\n }\r\n set metallic(val) {\r\n if (val !== this._metallic) {\r\n this._metallic = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get roughness() {\r\n return this._roughness;\r\n }\r\n set roughness(val) {\r\n if (val !== this._roughness) {\r\n this._roughness = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get specularFactor(): Immutable<Vector4> {\r\n return this._specularFactor;\r\n }\r\n set specularFactor(val: Immutable<Vector4>) {\r\n if (!val.equalsTo(this._specularFactor)) {\r\n this._specularFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n directLighting(\r\n scope: PBInsideFunctionScope,\r\n lightDir: PBShaderExp,\r\n lightColor: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n commonData: PBShaderExp,\r\n diffuseScale: PBShaderExp,\r\n specularScale: PBShaderExp,\r\n sourceRadiusFactor: PBShaderExp,\r\n outColor: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const that = this as any;\r\n const funcName = 'Z_PBRMR_DirectLighting';\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('L'),\r\n pb.vec3('lightColor'),\r\n pb.vec3('normal'),\r\n pb.vec3('viewVec'),\r\n that.getCommonDatasStruct(scope)('data'),\r\n pb.float('diffuseScale'),\r\n pb.float('specularScale'),\r\n pb.float('sourceRadiusFactor'),\r\n pb.vec3('outColor').inout()\r\n ],\r\n function () {\r\n this.$l.reflectionMode = this.zReflectionMode;\r\n this.$l.anisotropy = this.zAnisotropy;\r\n this.$l.anisotropyDirection = this.zAnisotropyDirection;\r\n this.$l.anisotropyDirectionScaleBias = this.zAnisotropyDirectionScaleBias;\r\n this.$l.H = pb.normalize(pb.add(this.viewVec, this.L));\r\n this.$l.NoH = pb.clamp(pb.dot(this.normal, this.H), 0, 1);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.L), 0, 1);\r\n this.$l.NoV = pb.clamp(pb.dot(this.normal, this.viewVec), 0, 1);\r\n this.$if(pb.greaterThan(this.NoL, 0), function () {\r\n this.$l.VoH = pb.clamp(pb.dot(this.viewVec, this.H), 0, 1);\r\n this.$l.schlickFresnel = that.fresnelSchlick(this, this.VoH, this.data.f0.rgb, this.data.f90);\r\n if (that.iridescence) {\r\n this.$l.F = pb.mix(\r\n this.schlickFresnel,\r\n this.data.iridescenceFresnel,\r\n this.data.iridescenceFactor.x\r\n );\r\n } else {\r\n this.$l.F = this.schlickFresnel;\r\n }\r\n this.$l.specularRoughness = pb.clamp(pb.add(this.data.roughness, this.sourceRadiusFactor), 0, 1);\r\n this.$l.alphaRoughness = pb.mul(this.specularRoughness, this.specularRoughness);\r\n this.$l.Dggx = that.distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.$l.D = this.Dggx;\r\n this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.anisotropic), function () {\r\n this.$l.dirAngle = pb.mul(this.anisotropyDirection, Math.PI / 180);\r\n if (that.anisotropyDirectionTexture) {\r\n this.$l.dirSample = that.sampleAnisotropyDirectionTexture(this);\r\n this.$l.dirAngle = pb.mul(\r\n pb.add(\r\n pb.mul(this.dirSample.r, this.anisotropyDirectionScaleBias.x),\r\n this.anisotropyDirectionScaleBias.y\r\n ),\r\n Math.PI / 180\r\n );\r\n }\r\n this.$l.anisoAngle = this.dirAngle;\r\n this.$l.up = pb.vec3(0, 1, 0);\r\n this.$l.t0 = pb.normalize(pb.cross(this.up, this.normal));\r\n this.$if(pb.lessThan(pb.length(this.t0), 0.001), function () {\r\n this.t0 = pb.normalize(pb.cross(pb.vec3(1, 0, 0), this.normal));\r\n });\r\n this.$l.b0 = pb.normalize(pb.cross(this.normal, this.t0));\r\n this.$l.tangent = pb.normalize(\r\n pb.add(pb.mul(this.t0, pb.cos(this.anisoAngle)), pb.mul(this.b0, pb.sin(this.anisoAngle)))\r\n );\r\n this.$l.bitangent = pb.normalize(pb.cross(this.normal, this.tangent));\r\n this.$l.ToH = pb.dot(this.tangent, this.H);\r\n this.$l.BoH = pb.dot(this.bitangent, this.H);\r\n this.$l.at = pb.max(pb.mul(this.alphaRoughness, pb.add(1, this.anisotropy)), 0.0001);\r\n this.$l.ab = pb.max(pb.mul(this.alphaRoughness, pb.sub(1, this.anisotropy)), 0.0001);\r\n this.$l.anisoDenom = pb.mul(\r\n Math.PI,\r\n this.at,\r\n this.ab,\r\n pb.pow(\r\n pb.add(\r\n pb.div(pb.mul(this.ToH, this.ToH), pb.mul(this.at, this.at)),\r\n pb.div(pb.mul(this.BoH, this.BoH), pb.mul(this.ab, this.ab)),\r\n pb.mul(this.NoH, this.NoH)\r\n ),\r\n 2\r\n )\r\n );\r\n this.D = pb.div(1, pb.max(this.anisoDenom, 0.0001));\r\n }).$elseif(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.glint), function () {\r\n this.$l.glintNoise = pb.fract(\r\n pb.mul(\r\n pb.sin(pb.add(pb.dot(this.H, pb.vec3(127.1, 311.7, 74.7)), pb.mul(this.NoH, 43.1))),\r\n 43758.5453\r\n )\r\n );\r\n this.$l.glintMask = pb.smoothStep(0.97, 1, this.glintNoise);\r\n this.D = pb.mul(this.Dggx, pb.add(1, pb.mul(this.glintMask, 8)));\r\n });\r\n this.$l.V = that.visGGX(this, this.NoV, this.NoL, this.alphaRoughness);\r\n this.$l.specular = pb.mul(\r\n this.lightColor,\r\n this.D,\r\n this.V,\r\n this.F,\r\n this.data.specularWeight,\r\n this.specularScale\r\n );\r\n if (that.sheen) {\r\n this.specular = pb.mul(this.specular, this.data.sheenAlbedoScaling);\r\n }\r\n this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.none), function () {\r\n this.specular = pb.vec3(0);\r\n });\r\n this.outColor = pb.add(this.outColor, this.specular);\r\n if (that.iridescence) {\r\n this.$l.iridescenceFresnelMax = pb.vec3(\r\n pb.max(\r\n pb.max(this.data.iridescenceFresnel.r, this.data.iridescenceFresnel.g),\r\n this.data.iridescenceFresnel.b\r\n )\r\n );\r\n this.F = pb.mix(this.schlickFresnel, this.iridescenceFresnelMax, this.data.iridescenceFactor.x);\r\n }\r\n this.$l.diffuseBRDF = pb.mul(\r\n pb.sub(pb.vec3(1), pb.mul(this.F, this.data.specularWeight)),\r\n pb.div(this.data.diffuse.rgb, Math.PI)\r\n );\r\n this.$l.diffuse = pb.mul(\r\n this.lightColor,\r\n pb.max(this.diffuseBRDF, pb.vec3(0)),\r\n this.diffuseScale\r\n );\r\n if (that.transmission && that.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n this.$l.transmissionRay = that.getVolumeTransmissionRay(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.data.thicknessFactor,\r\n this.data.f0.a\r\n );\r\n this.$l.pointToLight = pb.normalize(pb.sub(this.L, this.transmissionRay));\r\n this.$l.transmittedLight = pb.mul(\r\n this.lightColor,\r\n that.getPunctualRadianceTransmission(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pointToLight,\r\n this.alphaRoughness,\r\n this.data.f0.rgb,\r\n this.data.f90.rgb,\r\n this.data.diffuse.rgb,\r\n this.data.f0.a\r\n )\r\n );\r\n this.transmittedLight = that.applyVolumeAttenuation(\r\n this,\r\n this.transmittedLight,\r\n pb.length(this.transmissionRay),\r\n this.data.attenuationColor,\r\n this.data.attenuationDistance\r\n );\r\n this.diffuse = pb.mix(this.diffuse, this.transmittedLight, this.data.transmissionFactor);\r\n }\r\n if (that.sheen) {\r\n this.diffuse = pb.mul(this.diffuse, this.data.sheenAlbedoScaling);\r\n }\r\n this.outColor = pb.add(this.outColor, this.diffuse);\r\n if (that.sheen) {\r\n this.$l.sheenD = that.D_Charlie(this, this.NoH, this.data.sheenRoughness);\r\n this.$l.sheenV = that.V_Ashikhmin(this, this.NoL, this.NoV);\r\n this.outColor = pb.add(\r\n this.outColor,\r\n pb.mul(this.lightColor, this.data.sheenColor, this.sheenD, this.sheenV)\r\n );\r\n }\r\n if (that.clearcoat) {\r\n this.alphaRoughness = pb.mul(this.data.ccFactor.y, this.data.ccFactor.y);\r\n this.NoH = pb.clamp(pb.dot(this.data.ccNormal, this.H), 0, 1);\r\n this.NoL = pb.clamp(pb.dot(this.data.ccNormal, this.L), 0, 1);\r\n this.ccF0 = pb.vec3(pb.pow(pb.div(pb.sub(this.data.f0.a, 1), pb.add(this.data.f0.a, 1)), 2));\r\n this.F = that.fresnelSchlick(this, this.VoH, this.ccF0, pb.vec3(1));\r\n this.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.V = that.visGGX(this, this.data.ccNoV, this.NoL, this.alphaRoughness);\r\n this.outColor = pb.add(this.outColor, pb.mul(this.D, this.V, this.F, this.data.ccFactor.x));\r\n }\r\n });\r\n }\r\n );\r\n scope.$g[funcName](\r\n lightDir,\r\n lightColor,\r\n normal,\r\n viewVec,\r\n commonData,\r\n diffuseScale,\r\n specularScale,\r\n sourceRadiusFactor,\r\n outColor\r\n );\r\n }\r\n get reflectionMode() {\r\n return this._reflectionMode;\r\n }\r\n set reflectionMode(val: PBRReflectionMode) {\r\n if (val !== this._reflectionMode) {\r\n this._reflectionMode = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropy() {\r\n return this._anisotropy;\r\n }\r\n set anisotropy(val) {\r\n const clamped = Math.max(-0.95, Math.min(0.95, val));\r\n if (clamped !== this._anisotropy) {\r\n this._anisotropy = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirection() {\r\n return this._anisotropyDirection;\r\n }\r\n set anisotropyDirection(val) {\r\n if (val !== this._anisotropyDirection) {\r\n this._anisotropyDirection = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirectionScaleBias(): Immutable<Vector2> {\r\n return this._anisotropyDirectionScaleBias;\r\n }\r\n set anisotropyDirectionScaleBias(val: Immutable<Vector2>) {\r\n if (!val.equalsTo(this._anisotropyDirectionScaleBias)) {\r\n this._anisotropyDirectionScaleBias.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n calculateAnisotropyDirectionScaleBias(scope: PBInsideFunctionScope) {\r\n return scope.zAnisotropyDirectionScaleBias as PBShaderExp;\r\n }\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_PBRMetallicRoughnessLight';\r\n const that = this;\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('worldPos'),\r\n pb.vec3('normal'),\r\n pb.mat3('TBN'),\r\n pb.vec3('viewVec'),\r\n pb.vec4('albedo'),\r\n ...(outRoughness ? [pb.vec4('outRoughness').out()] : [])\r\n ],\r\n function () {\r\n this.$l.pbrData = that.getCommonData(this, this.albedo, this.normal, this.viewVec, this.TBN);\r\n this.$l.lightingColor = pb.vec3(0);\r\n this.$l.emissiveColor = that.calculateEmissiveColor(this);\r\n if (outRoughness) {\r\n that.indirectLighting(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.lightingColor,\r\n this.outRoughness\r\n );\r\n } else {\r\n that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor);\r\n }\r\n that.forEachLight(this, function (type, posRange, dirCutoff, colorIntensity, extra, shadow) {\r\n this.$if(pb.equal(type, LIGHT_TYPE_RECT), function () {\r\n that.directRectLight(\r\n this,\r\n this.worldPos,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n posRange,\r\n dirCutoff,\r\n extra,\r\n colorIntensity,\r\n this.lightingColor\r\n );\r\n }).$else(function () {\r\n this.$l.diffuse = pb.vec3();\r\n this.$l.specular = pb.vec3();\r\n this.$l.diffuseScale = pb.float(1);\r\n this.$l.specularScale = pb.float(1);\r\n this.$l.sourceRadiusFactor = pb.float(0);\r\n this.$if(pb.equal(type, LIGHT_TYPE_POINT), function () {\r\n this.diffuseScale = extra.x;\r\n this.specularScale = extra.y;\r\n this.sourceRadiusFactor = pb.div(\r\n extra.z,\r\n pb.max(pb.distance(posRange.xyz, this.worldPos), 0.0001)\r\n );\r\n });\r\n this.$l.lightAtten = that.calculateLightAttenuation(\r\n this,\r\n type,\r\n this.worldPos,\r\n posRange,\r\n dirCutoff\r\n );\r\n this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);\r\n this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten, this.NoL);\r\n if (shadow) {\r\n this.lightColor = pb.mul(\r\n this.lightColor,\r\n that.calculateShadow(this, this.worldPos, this.NoL)\r\n );\r\n }\r\n that.directLighting(\r\n this,\r\n this.lightDir,\r\n this.lightColor,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.diffuseScale,\r\n this.specularScale,\r\n this.sourceRadiusFactor,\r\n this.lightingColor\r\n );\r\n });\r\n });\r\n this.$return(pb.add(this.lightingColor, this.emissiveColor));\r\n }\r\n );\r\n return (\r\n outRoughness\r\n ? pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo, outRoughness)\r\n : pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo)\r\n ) as PBShaderExp;\r\n }\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n if (this.needFragmentColor() && this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {\r\n scope.$outputs.zMetallic = this.getInstancedUniform(scope, METALLIC_UNIFORM);\r\n scope.$outputs.zRoughness = this.getInstancedUniform(scope, ROUGHNESS_UNIFORM);\r\n scope.$outputs.zSpecularFactor = this.getInstancedUniform(scope, SPECULAR_FACTOR_UNFORM);\r\n }\r\n }\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n if (this.needFragmentColor()) {\r\n const pb = scope.$builder;\r\n if (!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n scope.zMetallic = pb.float().uniform(2);\r\n scope.zRoughness = pb.float().uniform(2);\r\n scope.zSpecularFactor = pb.vec4().uniform(2);\r\n }\r\n scope.zReflectionMode = pb.float().uniform(2);\r\n scope.zAnisotropy = pb.float().uniform(2);\r\n scope.zAnisotropyDirection = pb.float().uniform(2);\r\n scope.zAnisotropyDirectionScaleBias = pb.vec2().uniform(2);\r\n }\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColor(ctx)) {\r\n if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n bindGroup.setValue('zMetallic', this._metallic);\r\n bindGroup.setValue('zRoughness', this._roughness);\r\n bindGroup.setValue('zSpecularFactor', this._specularFactor);\r\n bindGroup.setValue('zReflectionMode', PBR_REFLECTION_MODE[this._reflectionMode]);\r\n bindGroup.setValue('zAnisotropy', this._anisotropy);\r\n bindGroup.setValue('zAnisotropyDirection', this._anisotropyDirection);\r\n bindGroup.setValue('zAnisotropyDirectionScaleBias', this._anisotropyDirectionScaleBias);\r\n }\r\n }\r\n }\r\n calculateMetallic(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zMetallic : scope.zMetallic) as PBShaderExp;\r\n }\r\n calculateRoughness(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zRoughness : scope.zRoughness) as PBShaderExp;\r\n }\r\n calculateSpecularFactor(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSpecularFactor : scope.zSpecularFactor) as PBShaderExp;\r\n }\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const metallic = this.calculateMetallic(scope, albedo, normal);\r\n const roughness = this.calculateRoughness(scope, albedo, normal);\r\n const specularFactor = this.calculateSpecularFactor(scope, albedo, normal);\r\n const reflectionMode = this.calculateReflectionMode(scope) as PBShaderExp;\r\n if (this.metallicRoughnessTexture) {\r\n scope.$l.metallicRoughnessSample = this.sampleMetallicRoughnessTexture(scope);\r\n data.metallic = pb.mul(metallic, scope.metallicRoughnessSample.z);\r\n data.roughness = pb.mul(roughness, scope.metallicRoughnessSample.y);\r\n } else {\r\n data.metallic = metallic;\r\n data.roughness = roughness;\r\n }\r\n data.roughness = pb.mul(data.roughness, ShaderHelper.getCameraRoughnessFactor(scope));\r\n if (this.specularColorTexture) {\r\n scope.$l.specularColor = pb.mul(specularFactor.rgb, this.sampleSpecularColorTexture(scope).rgb);\r\n } else {\r\n scope.$l.specularColor = specularFactor.rgb;\r\n }\r\n if (this.specularTexture) {\r\n data.specularWeight = pb.mul(specularFactor.a, this.sampleSpecularTexture(scope).a);\r\n } else {\r\n data.specularWeight = specularFactor.a;\r\n }\r\n data.specularWeight = pb.mul(\r\n data.specularWeight,\r\n pb.float(pb.notEqual(reflectionMode, PBR_REFLECTION_MODE.none))\r\n );\r\n data.f0 = pb.vec4(\r\n pb.mix(\r\n pb.min(pb.mul(this.getF0(scope).rgb, scope.specularColor), pb.vec3(1)),\r\n albedo.rgb,\r\n data.metallic\r\n ),\r\n this.getF0(scope).a\r\n );\r\n data.f90 = pb.vec3(1);\r\n data.diffuse = pb.vec4(pb.mix(albedo.rgb, pb.vec3(0), data.metallic), albedo.a);\r\n super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);\r\n }\r\n calculateReflectionMode(scope: PBInsideFunctionScope) {\r\n return scope.zReflectionMode as PBShaderExp;\r\n }\r\n calculateAnisotropy(scope: PBInsideFunctionScope) {\r\n return scope.zAnisotropy as PBShaderExp;\r\n }\r\n calculateAnisotropyDirection(scope: PBInsideFunctionScope) {\r\n return scope.zAnisotropyDirection as PBShaderExp;\r\n }\r\n } as unknown as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n}\r\n"],"names":["PBR_REFLECTION_MODE","none","ggx","anisotropic","glint","mixinPBRMetallicRoughness","BaseCls","pbrMetallicRoughnessMixed","S","applyMaterialMixins","mixinPBRCommon","mixinLight","mixinTextureProps","METALLIC_UNIFORM","defineInstanceUniform","ROUGHNESS_UNIFORM","SPECULAR_FACTOR_UNFORM","_metallic","_roughness","_specularFactor","_reflectionMode","_anisotropy","_anisotropyDirection","_anisotropyDirectionScaleBias","Vector4","one","Vector2","copyFrom","other","metallic","roughness","specularFactor","reflectionMode","anisotropy","anisotropyDirection","anisotropyDirectionScaleBias","val","uniformChanged","equalsTo","set","directLighting","scope","lightDir","lightColor","normal","viewVec","commonData","diffuseScale","specularScale","sourceRadiusFactor","outColor","pb","$builder","that","funcName","func","vec3","getCommonDatasStruct","float","inout","$l","zReflectionMode","zAnisotropy","zAnisotropyDirection","zAnisotropyDirectionScaleBias","H","normalize","add","L","NoH","clamp","dot","NoL","NoV","$if","greaterThan","VoH","schlickFresnel","fresnelSchlick","data","f0","rgb","f90","iridescence","F","mix","iridescenceFresnel","iridescenceFactor","x","specularRoughness","alphaRoughness","mul","Dggx","distributionGGX","D","equal","dirAngle","Math","PI","anisotropyDirectionTexture","dirSample","sampleAnisotropyDirectionTexture","r","y","anisoAngle","up","t0","cross","lessThan","length","b0","tangent","cos","sin","bitangent","ToH","BoH","at","max","ab","sub","anisoDenom","pow","div","$elseif","glintNoise","fract","glintMask","smoothStep","V","visGGX","specular","specularWeight","sheen","sheenAlbedoScaling","iridescenceFresnelMax","g","b","diffuseBRDF","diffuse","transmission","drawContext","renderPass","type","RENDER_PASS_TYPE_LIGHT","transmissionRay","getVolumeTransmissionRay","thicknessFactor","a","pointToLight","transmittedLight","getPunctualRadianceTransmission","applyVolumeAttenuation","attenuationColor","attenuationDistance","transmissionFactor","sheenD","D_Charlie","sheenRoughness","sheenV","V_Ashikhmin","sheenColor","clearcoat","ccFactor","ccNormal","ccF0","ccNoV","$g","clamped","min","calculateAnisotropyDirectionScaleBias","PBRLight","worldPos","albedo","TBN","outRoughness","mat3","vec4","out","pbrData","getCommonData","lightingColor","emissiveColor","calculateEmissiveColor","indirectLighting","forEachLight","posRange","dirCutoff","colorIntensity","extra","shadow","LIGHT_TYPE_RECT","directRectLight","$else","LIGHT_TYPE_POINT","z","distance","xyz","lightAtten","calculateLightAttenuation","calculateLightDirection","calculateShadow","$return","getGlobalScope","vertexShader","needFragmentColor","materialFlags","MaterialVaryingFlags","INSTANCING","$outputs","zMetallic","getInstancedUniform","zRoughness","zSpecularFactor","fragmentShader","uniform","vec2","applyUniformValues","bindGroup","ctx","pass","setValue","calculateMetallic","_albedo","_normal","instancing","$inputs","calculateRoughness","calculateSpecularFactor","calculateCommonData","calculateReflectionMode","metallicRoughnessTexture","metallicRoughnessSample","sampleMetallicRoughnessTexture","ShaderHelper","getCameraRoughnessFactor","specularColorTexture","specularColor","sampleSpecularColorTexture","specularTexture","sampleSpecularTexture","notEqual","getF0","calculateAnisotropy","calculateAnisotropyDirection"],"mappings":";;;;;;;;AA2BA,MAAMA,mBAAyD,GAAA;IAC7DC,IAAM,EAAA,CAAA;IACNC,GAAK,EAAA,CAAA;IACLC,WAAa,EAAA,CAAA;IACbC,KAAO,EAAA;AACT,CAAA;AA4CA;;;;;IAMO,SAASC,yBAAAA,CAAyDC,OAAU,EAAA;IACjF,IAAKA,OAAgBC,CAAAA,yBAAyB,EAAE;QAC9C,OAAOD,OAAAA;AACT;IACA,MAAME,CAAAA,GAAIC,mBACRH,CAAAA,OAAAA,EACAI,cACAC,EAAAA,UAAAA,EACAC,iBAAkB,CAAA,mBAAA,CAAA,EAClBA,iBAAkB,CAAA,UAAA,CAAA,EAClBA,iBAAkB,CAAA,eAAA,CAAA,EAClBA,iBAAkB,CAAA,qBAAA,CAAA,CAAA;AAEpB,IAAA,MAAMC,gBAAmBL,GAAAA,CAAAA,CAAEM,qBAAqB,CAAC,YAAY,OAAS,EAAA,UAAA,CAAA;AACtE,IAAA,MAAMC,iBAAoBP,GAAAA,CAAAA,CAAEM,qBAAqB,CAAC,aAAa,OAAS,EAAA,WAAA,CAAA;AACxE,IAAA,MAAME,sBAAyBR,GAAAA,CAAAA,CAAEM,qBAAqB,CAAC,kBAAkB,MAAQ,EAAA,gBAAA,CAAA;AAEjF,IAAA,OAAO,cAAcN,CAAAA,CAAAA;AACnB,QAAA,OAAgBD,4BAA4B,IAAK;QACzCU,SAAkB;QAClBC,UAAmB;QACVC,e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