@zephyr3d/scene 0.9.25 → 0.9.27

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 (299) hide show
  1. package/dist/animation/animationset.js +92 -30
  2. package/dist/animation/animationset.js.map +1 -1
  3. package/dist/animation/hair/gpu_hair_simulation.js +1090 -0
  4. package/dist/animation/hair/gpu_hair_simulation.js.map +1 -0
  5. package/dist/animation/joint_dynamics/controller.js +7 -5
  6. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  7. package/dist/animation/joint_dynamics/convex_collider.js +320 -0
  8. package/dist/animation/joint_dynamics/convex_collider.js.map +1 -0
  9. package/dist/animation/joint_dynamics/joint_dynamics_system.js +81 -5
  10. package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
  11. package/dist/animation/morphtrack.js +3 -4
  12. package/dist/animation/morphtrack.js.map +1 -1
  13. package/dist/animation/skeleton.js +79 -25
  14. package/dist/animation/skeleton.js.map +1 -1
  15. package/dist/animation/spring/multi_chain_spring_system.js +577 -179
  16. package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
  17. package/dist/animation/spring/spring_collider.js +4 -3
  18. package/dist/animation/spring/spring_collider.js.map +1 -1
  19. package/dist/animation/spring/spring_node_pose_tracker.js +40 -0
  20. package/dist/animation/spring/spring_node_pose_tracker.js.map +1 -0
  21. package/dist/animation/spring/spring_particle.js +2 -0
  22. package/dist/animation/spring/spring_particle.js.map +1 -1
  23. package/dist/animation/spring/spring_system.js +11 -3
  24. package/dist/animation/spring/spring_system.js.map +1 -1
  25. package/dist/animation/spring_modifier.js +10 -0
  26. package/dist/animation/spring_modifier.js.map +1 -1
  27. package/dist/app/engine.js +53 -43
  28. package/dist/app/engine.js.map +1 -1
  29. package/dist/app/scriptingsystem.js +119 -6
  30. package/dist/app/scriptingsystem.js.map +1 -1
  31. package/dist/app/scriptregistry.js +3 -2
  32. package/dist/app/scriptregistry.js.map +1 -1
  33. package/dist/asset/assetmanager.js +284 -67
  34. package/dist/asset/assetmanager.js.map +1 -1
  35. package/dist/asset/loaders/zhair/zhair_format.js +288 -0
  36. package/dist/asset/loaders/zhair/zhair_format.js.map +1 -0
  37. package/dist/asset/loaders/zhair/zhair_loader.js +221 -0
  38. package/dist/asset/loaders/zhair/zhair_loader.js.map +1 -0
  39. package/dist/asset/model.js +184 -69
  40. package/dist/asset/model.js.map +1 -1
  41. package/dist/camera/camera.js +268 -44
  42. package/dist/camera/camera.js.map +1 -1
  43. package/dist/camera/perspectivecamera.js +3 -1
  44. package/dist/camera/perspectivecamera.js.map +1 -1
  45. package/dist/index.d.ts +9044 -5139
  46. package/dist/index.js +17 -6
  47. package/dist/index.js.map +1 -1
  48. package/dist/material/eye.js +932 -0
  49. package/dist/material/eye.js.map +1 -0
  50. package/dist/material/hair.js +917 -0
  51. package/dist/material/hair.js.map +1 -0
  52. package/dist/material/hairstrand.js +842 -0
  53. package/dist/material/hairstrand.js.map +1 -0
  54. package/dist/material/hairstrand_data.js +162 -0
  55. package/dist/material/hairstrand_data.js.map +1 -0
  56. package/dist/material/lambert.js +5 -2
  57. package/dist/material/lambert.js.map +1 -1
  58. package/dist/material/material.js +48 -10
  59. package/dist/material/material.js.map +1 -1
  60. package/dist/material/meshmaterial.js +120 -19
  61. package/dist/material/meshmaterial.js.map +1 -1
  62. package/dist/material/mixins/albedocolor.js +1 -1
  63. package/dist/material/mixins/albedocolor.js.map +1 -1
  64. package/dist/material/mixins/lightmodel/blinnphong.js +5 -3
  65. package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
  66. package/dist/material/mixins/lightmodel/lambert.js +5 -4
  67. package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
  68. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +3 -3
  69. package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
  70. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +5 -5
  71. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  72. package/dist/material/mixins/lightmodel/pbrspecularglossness.js +3 -3
  73. package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
  74. package/dist/material/mixins/lit.js +106 -19
  75. package/dist/material/mixins/lit.js.map +1 -1
  76. package/dist/material/mixins/pbr/common.js +4 -4
  77. package/dist/material/mixins/pbr/common.js.map +1 -1
  78. package/dist/material/mixins/texture.js +48 -11
  79. package/dist/material/mixins/texture.js.map +1 -1
  80. package/dist/material/mtoon.js +6 -5
  81. package/dist/material/mtoon.js.map +1 -1
  82. package/dist/material/pbrblueprint.js +146 -28
  83. package/dist/material/pbrblueprint.js.map +1 -1
  84. package/dist/material/pbrblueprint_instance.js +501 -0
  85. package/dist/material/pbrblueprint_instance.js.map +1 -0
  86. package/dist/material/pbrmr.js +15 -16
  87. package/dist/material/pbrmr.js.map +1 -1
  88. package/dist/material/shader/helper.js +734 -23
  89. package/dist/material/shader/helper.js.map +1 -1
  90. package/dist/material/shader/terrain_blend.js +55 -0
  91. package/dist/material/shader/terrain_blend.js.map +1 -0
  92. package/dist/material/skin.js +192 -32
  93. package/dist/material/skin.js.map +1 -1
  94. package/dist/material/spriteblueprint.js +16 -1
  95. package/dist/material/spriteblueprint.js.map +1 -1
  96. package/dist/material/subsurfaceprofile.js +86 -23
  97. package/dist/material/subsurfaceprofile.js.map +1 -1
  98. package/dist/material/water.js +2059 -72
  99. package/dist/material/water.js.map +1 -1
  100. package/dist/posteffect/bloom.js +167 -7
  101. package/dist/posteffect/bloom.js.map +1 -1
  102. package/dist/posteffect/coloradjust.js +2 -1
  103. package/dist/posteffect/coloradjust.js.map +1 -1
  104. package/dist/posteffect/compositor.js.map +1 -1
  105. package/dist/posteffect/fxaa.js +2 -1
  106. package/dist/posteffect/fxaa.js.map +1 -1
  107. package/dist/posteffect/grayscale.js +3 -1
  108. package/dist/posteffect/grayscale.js.map +1 -1
  109. package/dist/posteffect/motionblur.js +664 -56
  110. package/dist/posteffect/motionblur.js.map +1 -1
  111. package/dist/posteffect/posteffect.js +12 -1
  112. package/dist/posteffect/posteffect.js.map +1 -1
  113. package/dist/posteffect/sao.js +46 -44
  114. package/dist/posteffect/sao.js.map +1 -1
  115. package/dist/posteffect/skinsss.js +368 -69
  116. package/dist/posteffect/skinsss.js.map +1 -1
  117. package/dist/posteffect/ssgi.js +16 -9
  118. package/dist/posteffect/ssgi.js.map +1 -1
  119. package/dist/posteffect/ssr.js +3 -0
  120. package/dist/posteffect/ssr.js.map +1 -1
  121. package/dist/posteffect/sss.js +121 -36
  122. package/dist/posteffect/sss.js.map +1 -1
  123. package/dist/posteffect/taa.js.map +1 -1
  124. package/dist/posteffect/tonemap.js +44 -1
  125. package/dist/posteffect/tonemap.js.map +1 -1
  126. package/dist/render/abuffer_oit.js +8 -2
  127. package/dist/render/abuffer_oit.js.map +1 -1
  128. package/dist/render/clipmap.js +156 -5
  129. package/dist/render/clipmap.js.map +1 -1
  130. package/dist/render/cull_visitor.js +20 -0
  131. package/dist/render/cull_visitor.js.map +1 -1
  132. package/dist/render/depthpass.js +36 -2
  133. package/dist/render/depthpass.js.map +1 -1
  134. package/dist/render/drawable_mixin.js +26 -1
  135. package/dist/render/drawable_mixin.js.map +1 -1
  136. package/dist/render/dualdepthpeeling_oit.js +3 -2
  137. package/dist/render/dualdepthpeeling_oit.js.map +1 -1
  138. package/dist/render/envlight.js +1 -1
  139. package/dist/render/envlight.js.map +1 -1
  140. package/dist/render/fbm_wavegenerator.js +6 -3
  141. package/dist/render/fbm_wavegenerator.js.map +1 -1
  142. package/dist/render/fft_wavegenerator.js +57 -15
  143. package/dist/render/fft_wavegenerator.js.map +1 -1
  144. package/dist/render/gerstner_wavegenerator.js +130 -20
  145. package/dist/render/gerstner_wavegenerator.js.map +1 -1
  146. package/dist/render/globalbindgroup_allocator.js +3 -0
  147. package/dist/render/globalbindgroup_allocator.js.map +1 -1
  148. package/dist/render/hzb.js +80 -22
  149. package/dist/render/hzb.js.map +1 -1
  150. package/dist/render/lightpass.js +6 -3
  151. package/dist/render/lightpass.js.map +1 -1
  152. package/dist/render/oit.js +29 -0
  153. package/dist/render/oit.js.map +1 -0
  154. package/dist/render/render_queue.js +39 -0
  155. package/dist/render/render_queue.js.map +1 -1
  156. package/dist/render/renderer.js +4 -0
  157. package/dist/render/renderer.js.map +1 -1
  158. package/dist/render/rendergraph/blackboard.js +1 -0
  159. package/dist/render/rendergraph/blackboard.js.map +1 -1
  160. package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
  161. package/dist/render/rendergraph/executor.js +2 -0
  162. package/dist/render/rendergraph/executor.js.map +1 -1
  163. package/dist/render/rendergraph/forward_plus_builder.js +379 -10
  164. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
  165. package/dist/render/rendergraph/frame_resource_requirements.js +1 -0
  166. package/dist/render/rendergraph/frame_resource_requirements.js.map +1 -1
  167. package/dist/render/rendergraph/history_resources.js +8 -1
  168. package/dist/render/rendergraph/history_resources.js.map +1 -1
  169. package/dist/render/rendergraph/rendergraph.js.map +1 -1
  170. package/dist/render/rendergraph/texture_affinity_cache.js +1 -1
  171. package/dist/render/rendergraph/texture_affinity_cache.js.map +1 -1
  172. package/dist/render/rendergraph/types.js.map +1 -1
  173. package/dist/render/shadow_mask_pass.js +73 -8
  174. package/dist/render/shadow_mask_pass.js.map +1 -1
  175. package/dist/render/sky.js +166 -126
  176. package/dist/render/sky.js.map +1 -1
  177. package/dist/render/underwater.js +624 -0
  178. package/dist/render/underwater.js.map +1 -0
  179. package/dist/render/water_caustics.js +1380 -0
  180. package/dist/render/water_caustics.js.map +1 -0
  181. package/dist/render/weightedblended_oit.js +3 -2
  182. package/dist/render/weightedblended_oit.js.map +1 -1
  183. package/dist/scene/basesprite.js +8 -0
  184. package/dist/scene/basesprite.js.map +1 -1
  185. package/dist/scene/batchgroup.js +3 -0
  186. package/dist/scene/batchgroup.js.map +1 -1
  187. package/dist/scene/environment.js +4 -1
  188. package/dist/scene/environment.js.map +1 -1
  189. package/dist/scene/hair.js +963 -0
  190. package/dist/scene/hair.js.map +1 -0
  191. package/dist/scene/light.js +5 -1
  192. package/dist/scene/light.js.map +1 -1
  193. package/dist/scene/mesh.js +481 -47
  194. package/dist/scene/mesh.js.map +1 -1
  195. package/dist/scene/meshdrawable.js +6 -0
  196. package/dist/scene/meshdrawable.js.map +1 -1
  197. package/dist/scene/msdftext.js +3 -0
  198. package/dist/scene/msdftext.js.map +1 -1
  199. package/dist/scene/msdftextsprite.js +3 -0
  200. package/dist/scene/msdftextsprite.js.map +1 -1
  201. package/dist/scene/particlesys.js +6 -0
  202. package/dist/scene/particlesys.js.map +1 -1
  203. package/dist/scene/scene.js +3 -0
  204. package/dist/scene/scene.js.map +1 -1
  205. package/dist/scene/scene_node.js +6 -1
  206. package/dist/scene/scene_node.js.map +1 -1
  207. package/dist/scene/terrain-cm/grass.js +3 -0
  208. package/dist/scene/terrain-cm/grass.js.map +1 -1
  209. package/dist/scene/terrain-cm/grassmaterial.js +3 -0
  210. package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
  211. package/dist/scene/terrain-cm/terrain-cm.js +6 -0
  212. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  213. package/dist/scene/terrain-cm/texture_cache.js +309 -0
  214. package/dist/scene/terrain-cm/texture_cache.js.map +1 -0
  215. package/dist/scene/water.js +546 -4
  216. package/dist/scene/water.js.map +1 -1
  217. package/dist/shaders/atmosphere.js.map +1 -1
  218. package/dist/shaders/diffusion.js +54 -0
  219. package/dist/shaders/diffusion.js.map +1 -0
  220. package/dist/shaders/shadow.js +33 -21
  221. package/dist/shaders/shadow.js.map +1 -1
  222. package/dist/shaders/temporal.js +71 -33
  223. package/dist/shaders/temporal.js.map +1 -1
  224. package/dist/shaders/water.js +22 -19
  225. package/dist/shaders/water.js.map +1 -1
  226. package/dist/shaders/water_medium.js +56 -0
  227. package/dist/shaders/water_medium.js.map +1 -0
  228. package/dist/shadow/dom.js +546 -0
  229. package/dist/shadow/dom.js.map +1 -0
  230. package/dist/shadow/pcf_opt.js +3 -5
  231. package/dist/shadow/pcf_opt.js.map +1 -1
  232. package/dist/shadow/pcf_pd.js +1 -1
  233. package/dist/shadow/pcf_pd.js.map +1 -1
  234. package/dist/shadow/receiver_bias.js +41 -0
  235. package/dist/shadow/receiver_bias.js.map +1 -0
  236. package/dist/shadow/shader.js +20 -60
  237. package/dist/shadow/shader.js.map +1 -1
  238. package/dist/shadow/shadow_impl.js +89 -0
  239. package/dist/shadow/shadow_impl.js.map +1 -1
  240. package/dist/shadow/shadow_region.js +1 -1
  241. package/dist/shadow/shadow_region.js.map +1 -1
  242. package/dist/shadow/shadowmapper.js +150 -37
  243. package/dist/shadow/shadowmapper.js.map +1 -1
  244. package/dist/shapes/shape.js +11 -2
  245. package/dist/shapes/shape.js.map +1 -1
  246. package/dist/shapes/sphere.js +50 -9
  247. package/dist/shapes/sphere.js.map +1 -1
  248. package/dist/utility/blueprint/common/constants.js +112 -2
  249. package/dist/utility/blueprint/common/constants.js.map +1 -1
  250. package/dist/utility/blueprint/material/func.js +142 -49
  251. package/dist/utility/blueprint/material/func.js.map +1 -1
  252. package/dist/utility/blueprint/material/ir.js +490 -25
  253. package/dist/utility/blueprint/material/ir.js.map +1 -1
  254. package/dist/utility/blueprint/material/texture.js +898 -4
  255. package/dist/utility/blueprint/material/texture.js.map +1 -1
  256. package/dist/utility/serialization/manager.js +434 -101
  257. package/dist/utility/serialization/manager.js.map +1 -1
  258. package/dist/utility/serialization/scene/animation.js +401 -5
  259. package/dist/utility/serialization/scene/animation.js.map +1 -1
  260. package/dist/utility/serialization/scene/batch.js +4 -0
  261. package/dist/utility/serialization/scene/batch.js.map +1 -1
  262. package/dist/utility/serialization/scene/camera.js +186 -26
  263. package/dist/utility/serialization/scene/camera.js.map +1 -1
  264. package/dist/utility/serialization/scene/common.js +26 -5
  265. package/dist/utility/serialization/scene/common.js.map +1 -1
  266. package/dist/utility/serialization/scene/hair.js +1141 -0
  267. package/dist/utility/serialization/scene/hair.js.map +1 -0
  268. package/dist/utility/serialization/scene/light.js +84 -4
  269. package/dist/utility/serialization/scene/light.js.map +1 -1
  270. package/dist/utility/serialization/scene/material.js +1867 -166
  271. package/dist/utility/serialization/scene/material.js.map +1 -1
  272. package/dist/utility/serialization/scene/mesh.js +231 -14
  273. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  274. package/dist/utility/serialization/scene/node.js +141 -7
  275. package/dist/utility/serialization/scene/node.js.map +1 -1
  276. package/dist/utility/serialization/scene/particle.js +4 -0
  277. package/dist/utility/serialization/scene/particle.js.map +1 -1
  278. package/dist/utility/serialization/scene/primitive.js +18 -0
  279. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  280. package/dist/utility/serialization/scene/sprite.js +4 -0
  281. package/dist/utility/serialization/scene/sprite.js.map +1 -1
  282. package/dist/utility/serialization/scene/terrain.js +4 -0
  283. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  284. package/dist/utility/serialization/scene/text.js +4 -0
  285. package/dist/utility/serialization/scene/text.js.map +1 -1
  286. package/dist/utility/serialization/scene/water.js +1105 -21
  287. package/dist/utility/serialization/scene/water.js.map +1 -1
  288. package/dist/utility/serialization/types.js.map +1 -1
  289. package/dist/utility/shprojector.js +9 -8
  290. package/dist/utility/shprojector.js.map +1 -1
  291. package/dist/values.js +49 -2
  292. package/dist/values.js.map +1 -1
  293. package/package.json +3 -3
  294. package/dist/render/rendergraph/frame_graph_context.js +0 -41
  295. package/dist/render/rendergraph/frame_graph_context.js.map +0 -1
  296. package/dist/shaders/ssgi.js +0 -63
  297. package/dist/shaders/ssgi.js.map +0 -1
  298. package/dist/shaders/ssgi_reprojection.js +0 -118
  299. package/dist/shaders/ssgi_reprojection.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"mtoon.js","sources":["../../src/material/mtoon.ts"],"sourcesContent":["import type { Immutable } from '@zephyr3d/base';\r\nimport { DEPTH_COMPARE_CLOSER, Vector2, Vector3 } from '@zephyr3d/base';\r\nimport type {\r\n BindGroup,\r\n PBFunctionScope,\r\n PBInsideFunctionScope,\r\n PBShaderExp,\r\n RenderStateSet\r\n} from '@zephyr3d/device';\r\nimport type { DrawContext, Primitive } from '../render';\r\nimport { applyMaterialMixins, MeshMaterial } from './meshmaterial';\r\nimport { mixinAlbedoColor } from './mixins/albedocolor';\r\nimport { mixinLambert } from './mixins/lightmodel/lambert';\r\nimport { mixinTextureProps } from './mixins/texture';\r\nimport { QUEUE_OPAQUE, QUEUE_TRANSPARENT, RENDER_PASS_TYPE_LIGHT } from '../values';\r\nimport { ShaderHelper } from './shader/helper';\r\n\r\n/**\r\n * MToonMaterial outline width mode.\r\n *\r\n * @public\r\n */\r\nexport type MToonOutlineWidthMode = 'none' | 'worldCoordinates' | 'screenCoordinates';\r\n\r\ntype RuntimeMaterialPassMethods = {\r\n bind(device: DrawContext['device'], pass: number): boolean;\r\n draw(primitive: Primitive, ctx: DrawContext, numInstances?: number): void;\r\n};\r\n\r\nconst ToonMaterialBase = applyMaterialMixins(\r\n MeshMaterial,\r\n mixinAlbedoColor,\r\n mixinLambert,\r\n mixinTextureProps('shadeMultiply'),\r\n mixinTextureProps('shadingShift'),\r\n mixinTextureProps('matcap'),\r\n mixinTextureProps('rimMultiply'),\r\n mixinTextureProps('outlineWidthMultiply'),\r\n mixinTextureProps('uvAnimationMask'),\r\n mixinTextureProps('emissive')\r\n);\r\n\r\n/**\r\n * MToonMaterial is a material that implements the MToon shader, which is a stylized shader commonly used for rendering anime-style characters. It supports features such as rim lighting, matcap, and outline rendering.\r\n *\r\n * @public\r\n */\r\nexport class MToonMaterial extends ToonMaterialBase {\r\n private static readonly FEATURE_OUTLINE_WIDTH_MODE = this.defineFeature();\r\n private static readonly FEATURE_OUTLINE_TANGENT_NORMALS = this.defineFeature();\r\n private readonly _shadeColorFactor: Vector3;\r\n private readonly _matcapFactor: Vector3;\r\n private readonly _parametricRimColorFactor: Vector3;\r\n private readonly _outlineColorFactor: Vector3;\r\n private readonly _uvAnimationScroll: Vector2;\r\n private readonly _emissiveColor: Vector3;\r\n private _shadingShiftFactor: number;\r\n private _shadingShiftTextureScale: number;\r\n private _shadingToonyFactor: number;\r\n private _giEqualizationFactor: number;\r\n private _parametricRimFresnelPowerFactor: number;\r\n private _parametricRimLiftFactor: number;\r\n private _rimLightingMixFactor: number;\r\n private _outlineWidthFactor: number;\r\n private _outlineLightingMixFactor: number;\r\n private _uvAnimationRotationSpeedFactor: number;\r\n private _emissiveStrength: number;\r\n private _transparentWithZWrite: boolean;\r\n private _renderQueueOffsetNumber: number;\r\n constructor() {\r\n super();\r\n this._shadeColorFactor = new Vector3(0, 0, 0);\r\n this._matcapFactor = new Vector3(1, 1, 1);\r\n this._parametricRimColorFactor = new Vector3(0, 0, 0);\r\n this._outlineColorFactor = new Vector3(0, 0, 0);\r\n this._uvAnimationScroll = new Vector2(0, 0);\r\n this._emissiveColor = new Vector3(0, 0, 0);\r\n this._shadingShiftFactor = 0;\r\n this._shadingShiftTextureScale = 1;\r\n this._shadingToonyFactor = 0.9;\r\n this._giEqualizationFactor = 0.9;\r\n this._parametricRimFresnelPowerFactor = 5;\r\n this._parametricRimLiftFactor = 0;\r\n this._rimLightingMixFactor = 1;\r\n this._outlineWidthFactor = 0;\r\n this._outlineLightingMixFactor = 1;\r\n this._uvAnimationRotationSpeedFactor = 0;\r\n this._emissiveStrength = 1;\r\n this._transparentWithZWrite = false;\r\n this._renderQueueOffsetNumber = 0;\r\n this.outlineWidthMode = 'none';\r\n this.outlineUsesTangentNormals = false;\r\n }\r\n get shadeColorFactor(): Immutable<Vector3> {\r\n return this._shadeColorFactor;\r\n }\r\n set shadeColorFactor(val: Immutable<Vector3>) {\r\n this._shadeColorFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n get shadingShiftFactor(): number {\r\n return this._shadingShiftFactor;\r\n }\r\n set shadingShiftFactor(val: number) {\r\n if (val !== this._shadingShiftFactor) {\r\n this._shadingShiftFactor = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get shadingShiftTextureScale(): number {\r\n return this._shadingShiftTextureScale;\r\n }\r\n set shadingShiftTextureScale(val: number) {\r\n if (val !== this._shadingShiftTextureScale) {\r\n this._shadingShiftTextureScale = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get shadingToonyFactor(): number {\r\n return this._shadingToonyFactor;\r\n }\r\n set shadingToonyFactor(val: number) {\r\n const toony = Math.min(Math.max(val, 0), 0.99);\r\n if (toony !== this._shadingToonyFactor) {\r\n this._shadingToonyFactor = toony;\r\n this.uniformChanged();\r\n }\r\n }\r\n get giEqualizationFactor(): number {\r\n return this._giEqualizationFactor;\r\n }\r\n set giEqualizationFactor(val: number) {\r\n const factor = Math.min(Math.max(val, 0), 1);\r\n if (factor !== this._giEqualizationFactor) {\r\n this._giEqualizationFactor = factor;\r\n this.uniformChanged();\r\n }\r\n }\r\n get matcapFactor(): Immutable<Vector3> {\r\n return this._matcapFactor;\r\n }\r\n set matcapFactor(val: Immutable<Vector3>) {\r\n this._matcapFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n get parametricRimColorFactor(): Immutable<Vector3> {\r\n return this._parametricRimColorFactor;\r\n }\r\n set parametricRimColorFactor(val: Immutable<Vector3>) {\r\n this._parametricRimColorFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n get parametricRimFresnelPowerFactor(): number {\r\n return this._parametricRimFresnelPowerFactor;\r\n }\r\n set parametricRimFresnelPowerFactor(val: number) {\r\n if (val !== this._parametricRimFresnelPowerFactor) {\r\n this._parametricRimFresnelPowerFactor = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get parametricRimLiftFactor(): number {\r\n return this._parametricRimLiftFactor;\r\n }\r\n set parametricRimLiftFactor(val: number) {\r\n if (val !== this._parametricRimLiftFactor) {\r\n this._parametricRimLiftFactor = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get rimLightingMixFactor(): number {\r\n return this._rimLightingMixFactor;\r\n }\r\n set rimLightingMixFactor(val: number) {\r\n const factor = Math.min(Math.max(val, 0), 1);\r\n if (factor !== this._rimLightingMixFactor) {\r\n this._rimLightingMixFactor = factor;\r\n this.uniformChanged();\r\n }\r\n }\r\n get outlineWidthMode(): MToonOutlineWidthMode {\r\n return this.featureUsed<MToonOutlineWidthMode>(MToonMaterial.FEATURE_OUTLINE_WIDTH_MODE);\r\n }\r\n set outlineWidthMode(val: MToonOutlineWidthMode) {\r\n if (val !== 'none' && this.numPasses < 2) {\r\n this.numPasses = 2;\r\n }\r\n this.useFeature(MToonMaterial.FEATURE_OUTLINE_WIDTH_MODE, val);\r\n this.numPasses = val === 'none' ? 1 : 2;\r\n }\r\n get outlineWidthFactor(): number {\r\n return this._outlineWidthFactor;\r\n }\r\n set outlineWidthFactor(val: number) {\r\n const width = Math.max(val, 0);\r\n if (width !== this._outlineWidthFactor) {\r\n this._outlineWidthFactor = width;\r\n this.uniformChanged();\r\n }\r\n }\r\n get outlineColorFactor(): Immutable<Vector3> {\r\n return this._outlineColorFactor;\r\n }\r\n set outlineColorFactor(val: Immutable<Vector3>) {\r\n this._outlineColorFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n get outlineLightingMixFactor(): number {\r\n return this._outlineLightingMixFactor;\r\n }\r\n set outlineLightingMixFactor(val: number) {\r\n const factor = Math.min(Math.max(val, 0), 1);\r\n if (factor !== this._outlineLightingMixFactor) {\r\n this._outlineLightingMixFactor = factor;\r\n this.uniformChanged();\r\n }\r\n }\r\n get outlineUsesTangentNormals(): boolean {\r\n return !!this.featureUsed<boolean>(MToonMaterial.FEATURE_OUTLINE_TANGENT_NORMALS);\r\n }\r\n set outlineUsesTangentNormals(val: boolean) {\r\n this.useFeature(MToonMaterial.FEATURE_OUTLINE_TANGENT_NORMALS, !!val);\r\n }\r\n get transparentWithZWrite(): boolean {\r\n return this._transparentWithZWrite;\r\n }\r\n set transparentWithZWrite(val: boolean) {\r\n if (!!val !== this._transparentWithZWrite) {\r\n this._transparentWithZWrite = !!val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get renderQueueOffsetNumber(): number {\r\n return this._renderQueueOffsetNumber;\r\n }\r\n set renderQueueOffsetNumber(val: number) {\r\n const offset = Math.trunc(val);\r\n if (offset !== this._renderQueueOffsetNumber) {\r\n this._renderQueueOffsetNumber = offset;\r\n this.uniformChanged();\r\n }\r\n }\r\n get uvAnimationScrollXSpeedFactor(): number {\r\n return this._uvAnimationScroll.x;\r\n }\r\n set uvAnimationScrollXSpeedFactor(val: number) {\r\n if (val !== this._uvAnimationScroll.x) {\r\n this._uvAnimationScroll.x = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get uvAnimationScrollYSpeedFactor(): number {\r\n return this._uvAnimationScroll.y;\r\n }\r\n set uvAnimationScrollYSpeedFactor(val: number) {\r\n if (val !== this._uvAnimationScroll.y) {\r\n this._uvAnimationScroll.y = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get uvAnimationRotationSpeedFactor(): number {\r\n return this._uvAnimationRotationSpeedFactor;\r\n }\r\n set uvAnimationRotationSpeedFactor(val: number) {\r\n if (val !== this._uvAnimationRotationSpeedFactor) {\r\n this._uvAnimationRotationSpeedFactor = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get emissiveColor(): Immutable<Vector3> {\r\n return this._emissiveColor;\r\n }\r\n set emissiveColor(val: Immutable<Vector3>) {\r\n this._emissiveColor.set(val);\r\n this.uniformChanged();\r\n }\r\n get emissiveStrength(): number {\r\n return this._emissiveStrength;\r\n }\r\n set emissiveStrength(val: number) {\r\n if (val !== this._emissiveStrength) {\r\n this._emissiveStrength = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n clone(): MToonMaterial {\r\n const other = new MToonMaterial();\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.shadeColorFactor = other.shadeColorFactor;\r\n this.shadingShiftFactor = other.shadingShiftFactor;\r\n this.shadingShiftTextureScale = other.shadingShiftTextureScale;\r\n this.shadingToonyFactor = other.shadingToonyFactor;\r\n this.giEqualizationFactor = other.giEqualizationFactor;\r\n this.matcapFactor = other.matcapFactor;\r\n this.parametricRimColorFactor = other.parametricRimColorFactor;\r\n this.parametricRimFresnelPowerFactor = other.parametricRimFresnelPowerFactor;\r\n this.parametricRimLiftFactor = other.parametricRimLiftFactor;\r\n this.rimLightingMixFactor = other.rimLightingMixFactor;\r\n this.outlineWidthMode = other.outlineWidthMode;\r\n this.outlineWidthFactor = other.outlineWidthFactor;\r\n this.outlineColorFactor = other.outlineColorFactor;\r\n this.outlineLightingMixFactor = other.outlineLightingMixFactor;\r\n this.outlineUsesTangentNormals = other.outlineUsesTangentNormals;\r\n this.transparentWithZWrite = other.transparentWithZWrite;\r\n this.renderQueueOffsetNumber = other.renderQueueOffsetNumber;\r\n this.uvAnimationScrollXSpeedFactor = other.uvAnimationScrollXSpeedFactor;\r\n this.uvAnimationScrollYSpeedFactor = other.uvAnimationScrollYSpeedFactor;\r\n this.uvAnimationRotationSpeedFactor = other.uvAnimationRotationSpeedFactor;\r\n this.emissiveColor = other.emissiveColor;\r\n this.emissiveStrength = other.emissiveStrength;\r\n }\r\n getQueueType() {\r\n return this.isTransparentPass(0) ? QUEUE_TRANSPARENT : QUEUE_OPAQUE;\r\n }\r\n passToHash(pass: number): string {\r\n return super.passToHash(pass > 0 ? 1 : 0);\r\n }\r\n isTransparentPass(pass: number, ctx?: DrawContext): boolean {\r\n return pass === 0 && super.isTransparentPass(pass, ctx);\r\n }\r\n protected updateRenderStates(pass: number, stateSet: RenderStateSet, ctx: DrawContext): void {\r\n super.updateRenderStates(pass, stateSet, ctx);\r\n if (pass > 0) {\r\n stateSet.useRasterizerState().cullMode = 'front';\r\n stateSet.defaultBlendingState();\r\n stateSet.useDepthState().enableTest(true).enableWrite(true).setCompareFunc(DEPTH_COMPARE_CLOSER);\r\n } else if (this._transparentWithZWrite && this.isTransparentPass(pass, ctx)) {\r\n stateSet.useDepthState().enableTest(true).enableWrite(true);\r\n }\r\n }\r\n draw(primitive: Primitive, ctx: DrawContext, numInstances = 0): void {\r\n const material = this as unknown as RuntimeMaterialPassMethods;\r\n if (this.numPasses > 1 && ctx.renderPass!.type === RENDER_PASS_TYPE_LIGHT && !ctx.lightBlending) {\r\n // Draw the inflated hull first so the regular pass hides interior outline fragments.\r\n material.bind(ctx.device, 1);\r\n this.drawPrimitive(1, primitive, ctx, numInstances);\r\n material.bind(ctx.device, 0);\r\n this.drawPrimitive(0, primitive, ctx, numInstances);\r\n } else {\r\n (MeshMaterial.prototype as unknown as RuntimeMaterialPassMethods).draw.call(\r\n this,\r\n primitive,\r\n ctx,\r\n numInstances\r\n );\r\n }\r\n }\r\n drawPrimitive(pass: number, primitive: Primitive, ctx: DrawContext, numInstances: number): void {\r\n if (pass > 0 && (ctx.renderPass!.type !== RENDER_PASS_TYPE_LIGHT || ctx.lightBlending)) {\r\n return;\r\n }\r\n super.drawPrimitive(pass, primitive, ctx, numInstances);\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number): void {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColorInput(ctx)) {\r\n bindGroup.setValue('shadeColorFactor', this._shadeColorFactor);\r\n bindGroup.setValue('shadingShiftFactor', this._shadingShiftFactor);\r\n bindGroup.setValue('shadingShiftTextureScale', this._shadingShiftTextureScale);\r\n bindGroup.setValue('shadingToonyFactor', this._shadingToonyFactor);\r\n bindGroup.setValue('giEqualizationFactor', this._giEqualizationFactor);\r\n bindGroup.setValue('matcapFactor', this._matcapFactor);\r\n bindGroup.setValue('parametricRimColorFactor', this._parametricRimColorFactor);\r\n bindGroup.setValue('parametricRimFresnelPowerFactor', this._parametricRimFresnelPowerFactor);\r\n bindGroup.setValue('parametricRimLiftFactor', this._parametricRimLiftFactor);\r\n bindGroup.setValue('rimLightingMixFactor', this._rimLightingMixFactor);\r\n bindGroup.setValue('uvAnimationScroll', this._uvAnimationScroll);\r\n bindGroup.setValue('uvAnimationRotationSpeedFactor', this._uvAnimationRotationSpeedFactor);\r\n bindGroup.setValue('emissiveColor', this._emissiveColor);\r\n bindGroup.setValue('emissiveStrength', this._emissiveStrength);\r\n } else if (pass > 0 && this.outlineWidthMultiplyTexture && this.usesAnimatedUV()) {\r\n bindGroup.setValue('uvAnimationScroll', this._uvAnimationScroll);\r\n bindGroup.setValue('uvAnimationRotationSpeedFactor', this._uvAnimationRotationSpeedFactor);\r\n }\r\n if (pass > 0) {\r\n bindGroup.setValue('outlineWidthFactor', this._outlineWidthFactor);\r\n if (this.outlineWidthMultiplyTexture) {\r\n bindGroup.setTexture(\r\n 'outlineWidthTex',\r\n this.outlineWidthMultiplyTexture,\r\n this.outlineWidthMultiplyTextureSampler\r\n );\r\n if (this.uvAnimationMaskTexture && this.usesAnimatedUV()) {\r\n bindGroup.setTexture(\r\n 'uvAnimationMaskTex',\r\n this.uvAnimationMaskTexture,\r\n this.uvAnimationMaskTextureSampler\r\n );\r\n }\r\n if (this.outlineWidthMultiplyTexCoordMatrix) {\r\n bindGroup.setValue('outlineWidthTextureMatrix', this.outlineWidthMultiplyTexCoordMatrix);\r\n }\r\n }\r\n }\r\n if (pass > 0 && ctx.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n bindGroup.setValue('outlineColorFactor', this._outlineColorFactor);\r\n bindGroup.setValue('outlineLightingMixFactor', this._outlineLightingMixFactor);\r\n }\r\n }\r\n private usesAnimatedUV(): boolean {\r\n return (\r\n this._uvAnimationScroll.x !== 0 ||\r\n this._uvAnimationScroll.y !== 0 ||\r\n this._uvAnimationRotationSpeedFactor !== 0\r\n );\r\n }\r\n private applyUVAnimation(scope: PBInsideFunctionScope, uv: PBShaderExp): PBShaderExp {\r\n if (!this.usesAnimatedUV()) {\r\n return uv;\r\n }\r\n const pb = scope.$builder;\r\n const funcName = 'Z_mtoonUVAnimation';\r\n const that = this;\r\n if (!scope.uvAnimationScroll) {\r\n scope.uvAnimationScroll = pb.vec2().uniform(2);\r\n }\r\n if (!scope.uvAnimationRotationSpeedFactor) {\r\n scope.uvAnimationRotationSpeedFactor = pb.float().uniform(2);\r\n }\r\n if (that.uvAnimationMaskTexture && pb.shaderKind !== 'fragment' && !scope.uvAnimationMaskTex) {\r\n scope.uvAnimationMaskTex = pb.tex2D().uniform(2);\r\n }\r\n pb.func(funcName, [pb.vec2('uv')], function () {\r\n this.$l.mask = that.uvAnimationMaskTexture\r\n ? pb.shaderKind === 'fragment'\r\n ? pb.textureSample(that.getUvAnimationMaskTextureUniform(this), this.uv).b\r\n : pb.textureSampleLevel(this.uvAnimationMaskTex, this.uv, 0).b\r\n : pb.float(1);\r\n this.$l.time = ShaderHelper.getElapsedTime(this);\r\n this.$l.rotation = pb.mul(this.time, this.uvAnimationRotationSpeedFactor, this.mask);\r\n this.$l.c = pb.cos(this.rotation);\r\n this.$l.s = pb.sin(this.rotation);\r\n this.$l.centeredUv = pb.sub(this.uv, pb.vec2(0.5));\r\n this.$l.rotatedUv = pb.add(\r\n pb.vec2(\r\n pb.add(pb.mul(this.c, this.centeredUv.x), pb.mul(this.s, this.centeredUv.y)),\r\n pb.add(pb.mul(pb.neg(this.s), this.centeredUv.x), pb.mul(this.c, this.centeredUv.y))\r\n ),\r\n pb.vec2(0.5)\r\n );\r\n this.$return(pb.add(this.rotatedUv, pb.mul(this.uvAnimationScroll, this.time, this.mask)));\r\n });\r\n return pb.getGlobalScope()[funcName](uv);\r\n }\r\n private getMToonBaseUV(scope: PBInsideFunctionScope): PBShaderExp {\r\n return this.albedoTexture\r\n ? this.applyUVAnimation(scope, this.getAlbedoTexCoord(scope))\r\n : scope.$builder.vec2(0);\r\n }\r\n private getMToonNormalUV(scope: PBInsideFunctionScope): PBShaderExp {\r\n return this.normalTexture\r\n ? this.applyUVAnimation(scope, this.getNormalTexCoord(scope))\r\n : scope.$builder.vec2(0);\r\n }\r\n private sampleAlbedo(scope: PBInsideFunctionScope, uv: PBShaderExp): PBShaderExp {\r\n return this.calculateAlbedoColor(scope, uv);\r\n }\r\n private sampleShadeColor(scope: PBInsideFunctionScope): PBShaderExp {\r\n const pb = scope.$builder;\r\n return this.shadeMultiplyTexture\r\n ? pb.mul(\r\n scope.shadeColorFactor,\r\n this.sampleShadeMultiplyTexture(\r\n scope,\r\n this.applyUVAnimation(scope, this.getShadeMultiplyTexCoord(scope))\r\n ).rgb\r\n )\r\n : scope.shadeColorFactor;\r\n }\r\n private sampleNormal(scope: PBInsideFunctionScope, uv: PBShaderExp): PBShaderExp {\r\n const pb = scope.$builder;\r\n if (!this.normalTexture) {\r\n return pb.normalize(scope.$inputs.wNorm);\r\n }\r\n scope.$l.TBN = this.calculateTBN(scope, scope.$inputs.worldPos, scope.$inputs.wNorm);\r\n scope.$l.normalTex = pb.sub(pb.mul(this.sampleNormalTexture(scope, uv).rgb, 2), pb.vec3(1));\r\n scope.normalTex = pb.mul(scope.normalTex, pb.vec3(pb.vec3(this.getUniformNormalScale(scope)).xx, 1));\r\n return pb.normalize(pb.mul(scope.TBN, scope.normalTex));\r\n }\r\n private calculateMToonDirectLighting(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n baseColor: PBShaderExp,\r\n shadeColor: PBShaderExp,\r\n shadingShift: PBShaderExp\r\n ): PBShaderExp {\r\n const pb = scope.$builder;\r\n const that = this;\r\n const funcName = 'Z_mtoonDirectLighting';\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('worldPos'),\r\n pb.vec3('normal'),\r\n pb.vec3('baseColor'),\r\n pb.vec3('shadeColor'),\r\n pb.float('shadingShift')\r\n ],\r\n function () {\r\n this.$l.directColor = pb.vec3(0);\r\n that.forEachLight(this, function (type, posRange, dirCutoff, colorIntensity, extra, shadow) {\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 extra\r\n );\r\n this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);\r\n this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten);\r\n this.$l.NoL = pb.dot(this.normal, this.lightDir);\r\n this.$l.shiftedShading = pb.add(this.NoL, this.shadingShift);\r\n this.$l.shading = pb.clamp(\r\n pb.div(\r\n pb.sub(this.shiftedShading, pb.add(-1, this.shadingToonyFactor)),\r\n pb.max(pb.sub(2, pb.mul(this.shadingToonyFactor, 2)), 0.00001)\r\n ),\r\n 0,\r\n 1\r\n );\r\n this.$l.lightDiffuse = pb.mix(this.shadeColor, this.baseColor, this.shading);\r\n if (shadow) {\r\n this.$l.shadowValue = that.calculateShadow(this, this.worldPos, pb.clamp(this.NoL, 0, 1));\r\n this.lightDiffuse = pb.mix(this.shadeColor, this.lightDiffuse, this.shadowValue);\r\n }\r\n this.directColor = pb.add(this.directColor, pb.mul(this.lightDiffuse, this.lightColor));\r\n });\r\n this.$return(this.directColor);\r\n }\r\n );\r\n return pb.getGlobalScope()[funcName](worldPos, normal, baseColor, shadeColor, shadingShift);\r\n }\r\n private calculateMToonGI(\r\n scope: PBInsideFunctionScope,\r\n normal: PBShaderExp,\r\n baseColor: PBShaderExp\r\n ): PBShaderExp {\r\n const pb = scope.$builder;\r\n if (!this.needCalculateEnvLight()) {\r\n return pb.vec3(0);\r\n }\r\n scope.$l.rawGi = this.getEnvLightIrradiance(scope, normal);\r\n scope.$l.uniformGi = pb.mul(\r\n pb.add(\r\n this.getEnvLightIrradiance(scope, pb.vec3(0, 1, 0)),\r\n this.getEnvLightIrradiance(scope, pb.vec3(0, -1, 0))\r\n ),\r\n 0.5\r\n );\r\n scope.$l.gi = pb.mix(scope.rawGi, scope.uniformGi, scope.giEqualizationFactor);\r\n return pb.mul(scope.gi, baseColor);\r\n }\r\n private calculateMToonRim(\r\n scope: PBInsideFunctionScope,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n uv: PBShaderExp,\r\n lighting: PBShaderExp\r\n ): PBShaderExp {\r\n const pb = scope.$builder;\r\n scope.$l.rim = pb.vec3(0);\r\n if (this.matcapTexture) {\r\n scope.$l.worldViewX = pb.normalize(pb.vec3(viewVec.z, 0, pb.neg(viewVec.x)));\r\n scope.$l.worldViewY = pb.normalize(pb.cross(viewVec, scope.worldViewX));\r\n scope.$l.matcapUv = pb.add(\r\n pb.mul(pb.vec2(pb.dot(scope.worldViewX, normal), pb.dot(scope.worldViewY, normal)), 0.495),\r\n pb.vec2(0.5)\r\n );\r\n scope.rim = pb.add(\r\n scope.rim,\r\n pb.mul(scope.matcapFactor, this.sampleMatcapTexture(scope, scope.matcapUv).rgb)\r\n );\r\n }\r\n scope.$l.NoV = pb.clamp(pb.dot(normal, viewVec), 0, 1);\r\n scope.$l.parametricRim = pb.pow(\r\n pb.clamp(pb.add(pb.sub(1, scope.NoV), scope.parametricRimLiftFactor), 0, 1),\r\n pb.max(scope.parametricRimFresnelPowerFactor, 0.00001)\r\n );\r\n scope.rim = pb.add(scope.rim, pb.mul(scope.parametricRimColorFactor, scope.parametricRim));\r\n if (this.rimMultiplyTexture) {\r\n scope.rim = pb.mul(\r\n scope.rim,\r\n this.sampleRimMultiplyTexture(scope, this.applyUVAnimation(scope, this.getRimMultiplyTexCoord(scope)))\r\n .rgb\r\n );\r\n }\r\n return pb.mul(scope.rim, pb.mix(pb.vec3(1), lighting, scope.rimLightingMixFactor));\r\n }\r\n private calculateMToonEmission(scope: PBInsideFunctionScope): PBShaderExp {\r\n const pb = scope.$builder;\r\n const emission = this.emissiveTexture\r\n ? pb.mul(\r\n scope.emissiveColor,\r\n scope.emissiveStrength,\r\n this.sampleEmissiveTexture(scope, this.applyUVAnimation(scope, this.getEmissiveTexCoord(scope))).rgb\r\n )\r\n : pb.mul(scope.emissiveColor, scope.emissiveStrength);\r\n // Material-authored emitters are not covered by the CPU-side light pre-exposure, so a physical\r\n // scene exposes them here. The factor is 1 in legacy.\r\n return pb.mul(emission, ShaderHelper.getPreExposureUniform(scope)) as PBShaderExp;\r\n }\r\n vertexShader(scope: PBFunctionScope): void {\r\n super.vertexShader(scope);\r\n const pb = scope.$builder;\r\n scope.$l.oPos = ShaderHelper.resolveVertexPosition(scope);\r\n scope.$l.oNorm = ShaderHelper.resolveVertexNormal(scope);\r\n if (this.pass > 0 && this.outlineUsesTangentNormals) {\r\n scope.$l.oOutlineNorm = ShaderHelper.resolveVertexTangent(scope).xyz;\r\n }\r\n scope.$l.worldNormal = pb.normalize(\r\n pb.mul(ShaderHelper.getNormalMatrix(scope), pb.vec4(scope.oNorm, 0)).xyz\r\n );\r\n scope.$l.worldOutlineNormal =\r\n this.pass > 0 && this.outlineUsesTangentNormals\r\n ? pb.normalize(pb.mul(ShaderHelper.getNormalMatrix(scope), pb.vec4(scope.oOutlineNorm, 0)).xyz)\r\n : scope.worldNormal;\r\n scope.$l.worldPos = pb.mul(ShaderHelper.getWorldMatrix(scope), pb.vec4(scope.oPos, 1)).xyz;\r\n if (this.pass > 0) {\r\n scope.outlineWidthFactor = pb.float().uniform(2);\r\n scope.$l.width = scope.outlineWidthFactor;\r\n if (this.outlineWidthMultiplyTexture) {\r\n scope.outlineWidthTex = pb.tex2D().uniform(2);\r\n const uvIndex = this.outlineWidthMultiplyTexCoordIndex;\r\n const semantic = `texCoord${uvIndex}` as any;\r\n if (!scope.$getVertexAttrib(semantic)) {\r\n scope.$inputs[semantic] = pb.vec2().attrib(semantic);\r\n }\r\n if (this.outlineWidthMultiplyTexCoordMatrix) {\r\n scope.outlineWidthTextureMatrix = pb.mat4().uniform(2);\r\n scope.$l.outlineUv = pb.mul(\r\n scope.outlineWidthTextureMatrix,\r\n pb.vec4(this.applyUVAnimation(scope, scope.$inputs[semantic]), 0, 1)\r\n ).xy;\r\n } else {\r\n scope.$l.outlineUv = this.applyUVAnimation(scope, scope.$inputs[semantic]);\r\n }\r\n scope.width = pb.mul(scope.width, pb.textureSampleLevel(scope.outlineWidthTex, scope.outlineUv, 0).g);\r\n }\r\n scope.width = pb.max(scope.width, 0);\r\n scope.$l.hasOutlineWidth = pb.float(pb.greaterThan(scope.width, 0));\r\n if (this.outlineWidthMode === 'worldCoordinates') {\r\n scope.$l.baseClipPos = pb.mul(\r\n ShaderHelper.getViewProjectionMatrix(scope),\r\n pb.vec4(scope.worldPos, 1)\r\n );\r\n scope.worldPos = pb.add(scope.worldPos, pb.mul(scope.worldOutlineNormal, scope.width));\r\n scope.$l.clipPos = pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.worldPos, 1));\r\n scope.$l.baseNdc = pb.div(scope.baseClipPos.xy, pb.max(scope.baseClipPos.w, 0.00001));\r\n scope.$l.inflatedNdc = pb.div(scope.clipPos.xy, pb.max(scope.clipPos.w, 0.00001));\r\n scope.$l.outlineNdcDelta = pb.sub(scope.inflatedNdc, scope.baseNdc);\r\n scope.$l.outlinePixelWidth = pb.length(\r\n pb.mul(scope.outlineNdcDelta, ShaderHelper.getRenderSize(scope), 0.5)\r\n );\r\n scope.$l.outlinePixelScale = pb.mix(\r\n 1,\r\n pb.div(pb.max(scope.outlinePixelWidth, 1), pb.max(scope.outlinePixelWidth, 0.00001)),\r\n scope.hasOutlineWidth\r\n );\r\n scope.$l.adjustedNdc = pb.add(scope.baseNdc, pb.mul(scope.outlineNdcDelta, scope.outlinePixelScale));\r\n scope.clipPos = pb.vec4(pb.mul(scope.adjustedNdc, scope.clipPos.w), scope.clipPos.zw);\r\n scope.$outputs.worldPos = scope.worldPos;\r\n scope.$outputs.wNorm = scope.worldOutlineNormal;\r\n ShaderHelper.setClipSpacePosition(scope, scope.clipPos);\r\n return;\r\n } else if (this.outlineWidthMode === 'screenCoordinates') {\r\n scope.$l.clipNormalPos = pb.mul(\r\n ShaderHelper.getViewProjectionMatrix(scope),\r\n pb.vec4(pb.add(scope.worldPos, scope.worldOutlineNormal), 1)\r\n );\r\n scope.$l.clipPos = pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.worldPos, 1));\r\n scope.$l.screenNormal = pb.sub(\r\n pb.div(scope.clipNormalPos.xy, pb.max(scope.clipNormalPos.w, 0.00001)),\r\n pb.div(scope.clipPos.xy, pb.max(scope.clipPos.w, 0.00001))\r\n );\r\n scope.screenNormal = pb.normalize(\r\n pb.mul(\r\n scope.screenNormal,\r\n pb.vec2(1, pb.div(ShaderHelper.getRenderSize(scope).x, ShaderHelper.getRenderSize(scope).y))\r\n )\r\n );\r\n scope.$l.screenUnitPixels = pb.length(\r\n pb.mul(scope.screenNormal, ShaderHelper.getRenderSize(scope), 0.5)\r\n );\r\n scope.width = pb.mul(\r\n pb.max(scope.width, pb.div(1, pb.max(scope.screenUnitPixels, 0.00001))),\r\n scope.hasOutlineWidth\r\n );\r\n\r\n //scope.clipPos.xy = pb.add(scope.clipPos.xy, pb.mul(scope.screenNormal, scope.width, scope.clipPos.w));\r\n scope.clipPos = pb.vec4(\r\n pb.add(scope.clipPos.xy, pb.mul(scope.screenNormal, scope.width, scope.clipPos.w)),\r\n scope.clipPos.zw\r\n );\r\n scope.$outputs.worldPos = scope.worldPos;\r\n scope.$outputs.wNorm = scope.worldOutlineNormal;\r\n ShaderHelper.setClipSpacePosition(scope, scope.clipPos);\r\n return;\r\n }\r\n }\r\n scope.$outputs.worldPos = scope.worldPos;\r\n scope.$outputs.wNorm = this.pass > 0 ? scope.worldOutlineNormal : scope.worldNormal;\r\n ShaderHelper.setClipSpacePosition(\r\n scope,\r\n pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1))\r\n );\r\n }\r\n fragmentShader(scope: PBFunctionScope): void {\r\n super.fragmentShader(scope);\r\n const pb = scope.$builder;\r\n if (this.needFragmentColorInput()) {\r\n scope.shadeColorFactor = pb.vec3().uniform(2);\r\n scope.shadingShiftFactor = pb.float().uniform(2);\r\n scope.shadingShiftTextureScale = pb.float().uniform(2);\r\n scope.shadingToonyFactor = pb.float().uniform(2);\r\n scope.giEqualizationFactor = pb.float().uniform(2);\r\n scope.matcapFactor = pb.vec3().uniform(2);\r\n scope.parametricRimColorFactor = pb.vec3().uniform(2);\r\n scope.parametricRimFresnelPowerFactor = pb.float().uniform(2);\r\n scope.parametricRimLiftFactor = pb.float().uniform(2);\r\n scope.rimLightingMixFactor = pb.float().uniform(2);\r\n scope.uvAnimationScroll = pb.vec2().uniform(2);\r\n scope.uvAnimationRotationSpeedFactor = pb.float().uniform(2);\r\n scope.emissiveColor = pb.vec3().uniform(2);\r\n scope.emissiveStrength = pb.float().uniform(2);\r\n if (this.pass > 0) {\r\n scope.outlineColorFactor = pb.vec3().uniform(2);\r\n scope.outlineLightingMixFactor = pb.float().uniform(2);\r\n scope.$l.albedo = this.sampleAlbedo(scope, this.getMToonBaseUV(scope));\r\n scope.$l.outlineLighting = pb.mix(pb.vec3(1), scope.albedo.rgb, scope.outlineLightingMixFactor);\r\n this.outputFragmentColor(\r\n scope,\r\n scope.$inputs.worldPos,\r\n pb.vec4(pb.mul(scope.outlineColorFactor, scope.outlineLighting), scope.albedo.a)\r\n );\r\n } else {\r\n scope.$l.uv = this.getMToonBaseUV(scope);\r\n scope.$l.albedo = this.sampleAlbedo(scope, scope.uv);\r\n if (this.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n scope.$l.normal = this.sampleNormal(scope, this.getMToonNormalUV(scope));\r\n scope.$l.shadingShift = scope.shadingShiftFactor;\r\n if (this.shadingShiftTexture) {\r\n scope.shadingShift = pb.add(\r\n scope.shadingShift,\r\n pb.mul(\r\n this.sampleShadingShiftTexture(\r\n scope,\r\n this.applyUVAnimation(scope, this.getShadingShiftTexCoord(scope))\r\n ).r,\r\n scope.shadingShiftTextureScale\r\n )\r\n );\r\n }\r\n scope.$l.shadeColor = this.sampleShadeColor(scope);\r\n scope.$l.viewVec = this.calculateViewVector(scope, scope.$inputs.worldPos);\r\n scope.$l.directLighting = this.calculateMToonDirectLighting(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.normal,\r\n scope.albedo.rgb,\r\n scope.shadeColor,\r\n scope.shadingShift\r\n );\r\n scope.$l.giLighting = this.calculateMToonGI(scope, scope.normal, scope.albedo.rgb);\r\n scope.$l.lighting = pb.max(scope.directLighting, scope.giLighting);\r\n scope.$l.rim = this.calculateMToonRim(scope, scope.normal, scope.viewVec, scope.uv, scope.lighting);\r\n scope.$l.emission = this.calculateMToonEmission(scope);\r\n scope.$l.outColor = pb.vec4(\r\n pb.add(scope.directLighting, scope.giLighting, scope.rim, scope.emission),\r\n scope.albedo.a\r\n );\r\n this.outputFragmentColor(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.outColor,\r\n pb.vec4(1, 1, 0, 1),\r\n pb.vec4(pb.add(pb.mul(scope.normal, 0.5), pb.vec3(0.5)), 1)\r\n );\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.albedo);\r\n }\r\n }\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, null);\r\n }\r\n }\r\n}\r\n"],"names":["ToonMaterialBase","applyMaterialMixins","MeshMaterial","mixinAlbedoColor","mixinLambert","mixinTextureProps","MToonMaterial","FEATURE_OUTLINE_WIDTH_MODE","defineFeature","FEATURE_OUTLINE_TANGENT_NORMALS","_shadeColorFactor","_matcapFactor","_parametricRimColorFactor","_outlineColorFactor","_uvAnimationScroll","_emissiveColor","_shadingShiftFactor","_shadingShiftTextureScale","_shadingToonyFactor","_giEqualizationFactor","_parametricRimFresnelPowerFactor","_parametricRimLiftFactor","_rimLightingMixFactor","_outlineWidthFactor","_outlineLightingMixFactor","_uvAnimationRotationSpeedFactor","_emissiveStrength","_transparentWithZWrite","_renderQueueOffsetNumber","Vector3","Vector2","outlineWidthMode","outlineUsesTangentNormals","shadeColorFactor","val","set","uniformChanged","shadingShiftFactor","shadingShiftTextureScale","shadingToonyFactor","toony","Math","min","max","giEqualizationFactor","factor","matcapFactor","parametricRimColorFactor","parametricRimFresnelPowerFactor","parametricRimLiftFactor","rimLightingMixFactor","featureUsed","numPasses","useFeature","outlineWidthFactor","width","outlineColorFactor","outlineLightingMixFactor","transparentWithZWrite","renderQueueOffsetNumber","offset","trunc","uvAnimationScrollXSpeedFactor","x","uvAnimationScrollYSpeedFactor","y","uvAnimationRotationSpeedFactor","emissiveColor","emissiveStrength","clone","other","copyFrom","getQueueType","isTransparentPass","QUEUE_TRANSPARENT","QUEUE_OPAQUE","passToHash","pass","ctx","updateRenderStates","stateSet","useRasterizerState","cullMode","defaultBlendingState","useDepthState","enableTest","enableWrite","setCompareFunc","DEPTH_COMPARE_CLOSER","draw","primitive","numInstances","material","renderPass","type","RENDER_PASS_TYPE_LIGHT","lightBlending","bind","device","drawPrimitive","prototype","call","applyUniformValues","bindGroup","needFragmentColorInput","setValue","outlineWidthMultiplyTexture","usesAnimatedUV","setTexture","outlineWidthMultiplyTextureSampler","uvAnimationMaskTexture","uvAnimationMaskTextureSampler","outlineWidthMultiplyTexCoordMatrix","applyUVAnimation","scope","uv","pb","$builder","funcName","that","uvAnimationScroll","vec2","uniform","float","shaderKind","uvAnimationMaskTex","tex2D","func","$l","mask","textureSample","getUvAnimationMaskTextureUniform","b","textureSampleLevel","time","ShaderHelper","getElapsedTime","rotation","mul","c","cos","s","sin","centeredUv","sub","rotatedUv","add","neg","$return","getGlobalScope","getMToonBaseUV","albedoTexture","getAlbedoTexCoord","getMToonNormalUV","normalTexture","getNormalTexCoord","sampleAlbedo","calculateAlbedoColor","sampleShadeColor","shadeMultiplyTexture","sampleShadeMultiplyTexture","getShadeMultiplyTexCoord","rgb","sampleNormal","normalize","$inputs","wNorm","TBN","calculateTBN","worldPos","normalTex","sampleNormalTexture","vec3","getUniformNormalScale","xx","calculateMToonDirectLighting","normal","baseColor","shadeColor","shadingShift","directColor","forEachLight","posRange","dirCutoff","colorIntensity","extra","shadow","lightAtten","calculateLightAttenuation","lightDir","calculateLightDirection","lightColor","a","NoL","dot","shiftedShading","shading","clamp","div","lightDiffuse","mix","shadowValue","calculateShadow","calculateMToonGI","needCalculateEnvLight","rawGi","getEnvLightIrradiance","uniformGi","gi","calculateMToonRim","viewVec","lighting","rim","matcapTexture","worldViewX","z","worldViewY","cross","matcapUv","sampleMatcapTexture","NoV","parametricRim","pow","rimMultiplyTexture","sampleRimMultiplyTexture","getRimMultiplyTexCoord","calculateMToonEmission","emission","emissiveTexture","sampleEmissiveTexture","getEmissiveTexCoord","getPreExposureUniform","vertexShader","oPos","resolveVertexPosition","oNorm","resolveVertexNormal","oOutlineNorm","resolveVertexTangent","xyz","worldNormal","getNormalMatrix","vec4","worldOutlineNormal","getWorldMatrix","outlineWidthTex","uvIndex","outlineWidthMultiplyTexCoordIndex","semantic","$getVertexAttrib","attrib","outlineWidthTextureMatrix","mat4","outlineUv","xy","g","hasOutlineWidth","greaterThan","baseClipPos","getViewProjectionMatrix","clipPos","baseNdc","w","inflatedNdc","outlineNdcDelta","outlinePixelWidth","length","getRenderSize","outlinePixelScale","adjustedNdc","zw","$outputs","setClipSpacePosition","clipNormalPos","screenNormal","screenUnitPixels","fragmentShader","albedo","outlineLighting","outputFragmentColor","drawContext","shadingShiftTexture","sampleShadingShiftTexture","getShadingShiftTexCoord","r","calculateViewVector","directLighting","giLighting","outColor"],"mappings":";;;;;;;;AA6BA,MAAMA,mBAAmBC,mBACvBC,CAAAA,YAAAA,EACAC,gBACAC,EAAAA,YAAAA,EACAC,kBAAkB,eAClBA,CAAAA,EAAAA,iBAAAA,CAAkB,cAClBA,CAAAA,EAAAA,iBAAAA,CAAkB,WAClBA,iBAAkB,CAAA,aAAA,CAAA,EAClBA,kBAAkB,sBAClBA,CAAAA,EAAAA,iBAAAA,CAAkB,oBAClBA,iBAAkB,CAAA,UAAA,CAAA,CAAA;AAGpB;;;;IAKO,MAAMC,aAAsBN,SAAAA,gBAAAA,CAAAA;AACjC,IAAA,OAAwBO,0BAA6B,GAAA,IAAI,CAACC,aAAa,EAAG;AAC1E,IAAA,OAAwBC,+BAAkC,GAAA,IAAI,CAACD,aAAa,EAAG;IAC9DE,iBAA2B;IAC3BC,aAAuB;IACvBC,yBAAmC;IACnCC,mBAA6B;IAC7BC,kBAA4B;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O,CAACI,QAAQ,EACtBvD,MAAM8K,QAAQ,EACd5K,EAAG8H,CAAAA,IAAI,CAAC,CAAG,EAAA,CAAA,EAAG,CAAG,EAAA,CAAA,CAAA,EACjB9H,GAAG8H,IAAI,CAAC9H,EAAG8B,CAAAA,GAAG,CAAC9B,EAAGsB,CAAAA,GAAG,CAACxB,KAAAA,CAAM8D,MAAM,EAAE,GAAA,CAAA,EAAM5D,EAAGwD,CAAAA,IAAI,CAAC,GAAO,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA;iBAEtD,MAAA;oBACL,IAAI,CAAC2G,mBAAmB,CAACrK,KAAOA,EAAAA,KAAAA,CAAMmD,OAAO,CAACI,QAAQ,EAAEvD,KAAAA,CAAMmK,MAAM,CAAA;AACtE;AACF;SACK,MAAA;YACL,IAAI,CAACE,mBAAmB,CAACrK,KAAAA,EAAOA,MAAMmD,OAAO,CAACI,QAAQ,EAAE,IAAA,CAAA;AAC1D;AACF;AACF;;;;"}
1
+ {"version":3,"file":"mtoon.js","sources":["../../src/material/mtoon.ts"],"sourcesContent":["import type { Immutable } from '@zephyr3d/base';\r\nimport { DEPTH_COMPARE_CLOSER, Vector2, Vector3 } from '@zephyr3d/base';\r\nimport type {\r\n BindGroup,\r\n PBFunctionScope,\r\n PBInsideFunctionScope,\r\n PBShaderExp,\r\n RenderStateSet\r\n} from '@zephyr3d/device';\r\nimport type { DrawContext, Primitive } from '../render';\r\nimport { applyMaterialMixins, MeshMaterial } from './meshmaterial';\r\nimport { mixinAlbedoColor } from './mixins/albedocolor';\r\nimport { mixinLambert } from './mixins/lightmodel/lambert';\r\nimport { mixinTextureProps } from './mixins/texture';\r\nimport { QUEUE_OPAQUE, QUEUE_TRANSPARENT, RENDER_PASS_TYPE_LIGHT } from '../values';\r\nimport { ShaderHelper } from './shader/helper';\r\n\r\n/**\r\n * MToonMaterial outline width mode.\r\n *\r\n * @public\r\n */\r\nexport type MToonOutlineWidthMode = 'none' | 'worldCoordinates' | 'screenCoordinates';\r\n\r\ntype RuntimeMaterialPassMethods = {\r\n bind(device: DrawContext['device'], pass: number): boolean;\r\n draw(primitive: Primitive, ctx: DrawContext, numInstances?: number): void;\r\n};\r\n\r\nconst ToonMaterialBase = applyMaterialMixins(\r\n MeshMaterial,\r\n mixinAlbedoColor,\r\n mixinLambert,\r\n mixinTextureProps('shadeMultiply'),\r\n mixinTextureProps('shadingShift'),\r\n mixinTextureProps('matcap'),\r\n mixinTextureProps('rimMultiply'),\r\n mixinTextureProps('outlineWidthMultiply'),\r\n mixinTextureProps('uvAnimationMask'),\r\n mixinTextureProps('emissive')\r\n);\r\n\r\n/**\r\n * MToonMaterial is a material that implements the MToon shader, which is a stylized shader commonly used for rendering anime-style characters. It supports features such as rim lighting, matcap, and outline rendering.\r\n *\r\n * @public\r\n */\r\nexport class MToonMaterial extends ToonMaterialBase {\r\n private static readonly FEATURE_OUTLINE_WIDTH_MODE = this.defineFeature();\r\n private static readonly FEATURE_OUTLINE_TANGENT_NORMALS = this.defineFeature();\r\n private readonly _shadeColorFactor: Vector3;\r\n private readonly _matcapFactor: Vector3;\r\n private readonly _parametricRimColorFactor: Vector3;\r\n private readonly _outlineColorFactor: Vector3;\r\n private readonly _uvAnimationScroll: Vector2;\r\n private readonly _emissiveColor: Vector3;\r\n private _shadingShiftFactor: number;\r\n private _shadingShiftTextureScale: number;\r\n private _shadingToonyFactor: number;\r\n private _giEqualizationFactor: number;\r\n private _parametricRimFresnelPowerFactor: number;\r\n private _parametricRimLiftFactor: number;\r\n private _rimLightingMixFactor: number;\r\n private _outlineWidthFactor: number;\r\n private _outlineLightingMixFactor: number;\r\n private _uvAnimationRotationSpeedFactor: number;\r\n private _emissiveStrength: number;\r\n private _transparentWithZWrite: boolean;\r\n private _renderQueueOffsetNumber: number;\r\n constructor() {\r\n super();\r\n this._shadeColorFactor = new Vector3(0, 0, 0);\r\n this._matcapFactor = new Vector3(1, 1, 1);\r\n this._parametricRimColorFactor = new Vector3(0, 0, 0);\r\n this._outlineColorFactor = new Vector3(0, 0, 0);\r\n this._uvAnimationScroll = new Vector2(0, 0);\r\n this._emissiveColor = new Vector3(0, 0, 0);\r\n this._shadingShiftFactor = 0;\r\n this._shadingShiftTextureScale = 1;\r\n this._shadingToonyFactor = 0.9;\r\n this._giEqualizationFactor = 0.9;\r\n this._parametricRimFresnelPowerFactor = 5;\r\n this._parametricRimLiftFactor = 0;\r\n this._rimLightingMixFactor = 1;\r\n this._outlineWidthFactor = 0;\r\n this._outlineLightingMixFactor = 1;\r\n this._uvAnimationRotationSpeedFactor = 0;\r\n this._emissiveStrength = 1;\r\n this._transparentWithZWrite = false;\r\n this._renderQueueOffsetNumber = 0;\r\n this.outlineWidthMode = 'none';\r\n this.outlineUsesTangentNormals = false;\r\n }\r\n get shadeColorFactor(): Immutable<Vector3> {\r\n return this._shadeColorFactor;\r\n }\r\n set shadeColorFactor(val: Immutable<Vector3>) {\r\n this._shadeColorFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n get shadingShiftFactor(): number {\r\n return this._shadingShiftFactor;\r\n }\r\n set shadingShiftFactor(val: number) {\r\n if (val !== this._shadingShiftFactor) {\r\n this._shadingShiftFactor = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get shadingShiftTextureScale(): number {\r\n return this._shadingShiftTextureScale;\r\n }\r\n set shadingShiftTextureScale(val: number) {\r\n if (val !== this._shadingShiftTextureScale) {\r\n this._shadingShiftTextureScale = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get shadingToonyFactor(): number {\r\n return this._shadingToonyFactor;\r\n }\r\n set shadingToonyFactor(val: number) {\r\n const toony = Math.min(Math.max(val, 0), 0.99);\r\n if (toony !== this._shadingToonyFactor) {\r\n this._shadingToonyFactor = toony;\r\n this.uniformChanged();\r\n }\r\n }\r\n get giEqualizationFactor(): number {\r\n return this._giEqualizationFactor;\r\n }\r\n set giEqualizationFactor(val: number) {\r\n const factor = Math.min(Math.max(val, 0), 1);\r\n if (factor !== this._giEqualizationFactor) {\r\n this._giEqualizationFactor = factor;\r\n this.uniformChanged();\r\n }\r\n }\r\n get matcapFactor(): Immutable<Vector3> {\r\n return this._matcapFactor;\r\n }\r\n set matcapFactor(val: Immutable<Vector3>) {\r\n this._matcapFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n get parametricRimColorFactor(): Immutable<Vector3> {\r\n return this._parametricRimColorFactor;\r\n }\r\n set parametricRimColorFactor(val: Immutable<Vector3>) {\r\n this._parametricRimColorFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n get parametricRimFresnelPowerFactor(): number {\r\n return this._parametricRimFresnelPowerFactor;\r\n }\r\n set parametricRimFresnelPowerFactor(val: number) {\r\n if (val !== this._parametricRimFresnelPowerFactor) {\r\n this._parametricRimFresnelPowerFactor = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get parametricRimLiftFactor(): number {\r\n return this._parametricRimLiftFactor;\r\n }\r\n set parametricRimLiftFactor(val: number) {\r\n if (val !== this._parametricRimLiftFactor) {\r\n this._parametricRimLiftFactor = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get rimLightingMixFactor(): number {\r\n return this._rimLightingMixFactor;\r\n }\r\n set rimLightingMixFactor(val: number) {\r\n const factor = Math.min(Math.max(val, 0), 1);\r\n if (factor !== this._rimLightingMixFactor) {\r\n this._rimLightingMixFactor = factor;\r\n this.uniformChanged();\r\n }\r\n }\r\n get outlineWidthMode(): MToonOutlineWidthMode {\r\n return this.featureUsed<MToonOutlineWidthMode>(MToonMaterial.FEATURE_OUTLINE_WIDTH_MODE);\r\n }\r\n set outlineWidthMode(val: MToonOutlineWidthMode) {\r\n if (val !== 'none' && this.numPasses < 2) {\r\n this.numPasses = 2;\r\n }\r\n this.useFeature(MToonMaterial.FEATURE_OUTLINE_WIDTH_MODE, val);\r\n this.numPasses = val === 'none' ? 1 : 2;\r\n }\r\n get outlineWidthFactor(): number {\r\n return this._outlineWidthFactor;\r\n }\r\n set outlineWidthFactor(val: number) {\r\n const width = Math.max(val, 0);\r\n if (width !== this._outlineWidthFactor) {\r\n this._outlineWidthFactor = width;\r\n this.uniformChanged();\r\n }\r\n }\r\n get outlineColorFactor(): Immutable<Vector3> {\r\n return this._outlineColorFactor;\r\n }\r\n set outlineColorFactor(val: Immutable<Vector3>) {\r\n this._outlineColorFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n get outlineLightingMixFactor(): number {\r\n return this._outlineLightingMixFactor;\r\n }\r\n set outlineLightingMixFactor(val: number) {\r\n const factor = Math.min(Math.max(val, 0), 1);\r\n if (factor !== this._outlineLightingMixFactor) {\r\n this._outlineLightingMixFactor = factor;\r\n this.uniformChanged();\r\n }\r\n }\r\n get outlineUsesTangentNormals(): boolean {\r\n return !!this.featureUsed<boolean>(MToonMaterial.FEATURE_OUTLINE_TANGENT_NORMALS);\r\n }\r\n set outlineUsesTangentNormals(val: boolean) {\r\n this.useFeature(MToonMaterial.FEATURE_OUTLINE_TANGENT_NORMALS, !!val);\r\n }\r\n get transparentWithZWrite(): boolean {\r\n return this._transparentWithZWrite;\r\n }\r\n set transparentWithZWrite(val: boolean) {\r\n if (!!val !== this._transparentWithZWrite) {\r\n this._transparentWithZWrite = !!val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get renderQueueOffsetNumber(): number {\r\n return this._renderQueueOffsetNumber;\r\n }\r\n set renderQueueOffsetNumber(val: number) {\r\n const offset = Math.trunc(val);\r\n if (offset !== this._renderQueueOffsetNumber) {\r\n this._renderQueueOffsetNumber = offset;\r\n this.uniformChanged();\r\n }\r\n }\r\n get uvAnimationScrollXSpeedFactor(): number {\r\n return this._uvAnimationScroll.x;\r\n }\r\n set uvAnimationScrollXSpeedFactor(val: number) {\r\n if (val !== this._uvAnimationScroll.x) {\r\n this._uvAnimationScroll.x = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get uvAnimationScrollYSpeedFactor(): number {\r\n return this._uvAnimationScroll.y;\r\n }\r\n set uvAnimationScrollYSpeedFactor(val: number) {\r\n if (val !== this._uvAnimationScroll.y) {\r\n this._uvAnimationScroll.y = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get uvAnimationRotationSpeedFactor(): number {\r\n return this._uvAnimationRotationSpeedFactor;\r\n }\r\n set uvAnimationRotationSpeedFactor(val: number) {\r\n if (val !== this._uvAnimationRotationSpeedFactor) {\r\n this._uvAnimationRotationSpeedFactor = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get emissiveColor(): Immutable<Vector3> {\r\n return this._emissiveColor;\r\n }\r\n set emissiveColor(val: Immutable<Vector3>) {\r\n this._emissiveColor.set(val);\r\n this.uniformChanged();\r\n }\r\n get emissiveStrength(): number {\r\n return this._emissiveStrength;\r\n }\r\n set emissiveStrength(val: number) {\r\n if (val !== this._emissiveStrength) {\r\n this._emissiveStrength = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n clone(): MToonMaterial {\r\n const other = new MToonMaterial();\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.shadeColorFactor = other.shadeColorFactor;\r\n this.shadingShiftFactor = other.shadingShiftFactor;\r\n this.shadingShiftTextureScale = other.shadingShiftTextureScale;\r\n this.shadingToonyFactor = other.shadingToonyFactor;\r\n this.giEqualizationFactor = other.giEqualizationFactor;\r\n this.matcapFactor = other.matcapFactor;\r\n this.parametricRimColorFactor = other.parametricRimColorFactor;\r\n this.parametricRimFresnelPowerFactor = other.parametricRimFresnelPowerFactor;\r\n this.parametricRimLiftFactor = other.parametricRimLiftFactor;\r\n this.rimLightingMixFactor = other.rimLightingMixFactor;\r\n this.outlineWidthMode = other.outlineWidthMode;\r\n this.outlineWidthFactor = other.outlineWidthFactor;\r\n this.outlineColorFactor = other.outlineColorFactor;\r\n this.outlineLightingMixFactor = other.outlineLightingMixFactor;\r\n this.outlineUsesTangentNormals = other.outlineUsesTangentNormals;\r\n this.transparentWithZWrite = other.transparentWithZWrite;\r\n this.renderQueueOffsetNumber = other.renderQueueOffsetNumber;\r\n this.uvAnimationScrollXSpeedFactor = other.uvAnimationScrollXSpeedFactor;\r\n this.uvAnimationScrollYSpeedFactor = other.uvAnimationScrollYSpeedFactor;\r\n this.uvAnimationRotationSpeedFactor = other.uvAnimationRotationSpeedFactor;\r\n this.emissiveColor = other.emissiveColor;\r\n this.emissiveStrength = other.emissiveStrength;\r\n }\r\n getQueueType() {\r\n return this.isTransparentPass(0) ? QUEUE_TRANSPARENT : QUEUE_OPAQUE;\r\n }\r\n passToHash(pass: number): string {\r\n return super.passToHash(pass > 0 ? 1 : 0);\r\n }\r\n isTransparentPass(pass: number, ctx?: DrawContext): boolean {\r\n return pass === 0 && super.isTransparentPass(pass, ctx);\r\n }\r\n protected updateRenderStates(pass: number, stateSet: RenderStateSet, ctx: DrawContext): void {\r\n super.updateRenderStates(pass, stateSet, ctx);\r\n if (pass > 0) {\r\n stateSet.useRasterizerState().cullMode = 'front';\r\n stateSet.defaultBlendingState();\r\n stateSet.useDepthState().enableTest(true).enableWrite(true).setCompareFunc(DEPTH_COMPARE_CLOSER);\r\n } else if (this._transparentWithZWrite && this.isTransparentPass(pass, ctx)) {\r\n stateSet.useDepthState().enableTest(true).enableWrite(true);\r\n }\r\n }\r\n draw(primitive: Primitive, ctx: DrawContext, numInstances = 0): void {\r\n const material = this as unknown as RuntimeMaterialPassMethods;\r\n if (this.numPasses > 1 && ctx.renderPass!.type === RENDER_PASS_TYPE_LIGHT && !ctx.lightBlending) {\r\n // Draw the inflated hull first so the regular pass hides interior outline fragments.\r\n material.bind(ctx.device, 1);\r\n this.drawPrimitive(1, primitive, ctx, numInstances);\r\n material.bind(ctx.device, 0);\r\n this.drawPrimitive(0, primitive, ctx, numInstances);\r\n } else {\r\n (MeshMaterial.prototype as unknown as RuntimeMaterialPassMethods).draw.call(\r\n this,\r\n primitive,\r\n ctx,\r\n numInstances\r\n );\r\n }\r\n }\r\n drawPrimitive(pass: number, primitive: Primitive, ctx: DrawContext, numInstances: number): void {\r\n if (pass > 0 && (ctx.renderPass!.type !== RENDER_PASS_TYPE_LIGHT || ctx.lightBlending)) {\r\n return;\r\n }\r\n super.drawPrimitive(pass, primitive, ctx, numInstances);\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number): void {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColorInput(ctx)) {\r\n bindGroup.setValue('shadeColorFactor', this._shadeColorFactor);\r\n bindGroup.setValue('shadingShiftFactor', this._shadingShiftFactor);\r\n bindGroup.setValue('shadingShiftTextureScale', this._shadingShiftTextureScale);\r\n bindGroup.setValue('shadingToonyFactor', this._shadingToonyFactor);\r\n bindGroup.setValue('giEqualizationFactor', this._giEqualizationFactor);\r\n bindGroup.setValue('matcapFactor', this._matcapFactor);\r\n bindGroup.setValue('parametricRimColorFactor', this._parametricRimColorFactor);\r\n bindGroup.setValue('parametricRimFresnelPowerFactor', this._parametricRimFresnelPowerFactor);\r\n bindGroup.setValue('parametricRimLiftFactor', this._parametricRimLiftFactor);\r\n bindGroup.setValue('rimLightingMixFactor', this._rimLightingMixFactor);\r\n bindGroup.setValue('uvAnimationScroll', this._uvAnimationScroll);\r\n bindGroup.setValue('uvAnimationRotationSpeedFactor', this._uvAnimationRotationSpeedFactor);\r\n bindGroup.setValue('emissiveColor', this._emissiveColor);\r\n bindGroup.setValue('emissiveStrength', this._emissiveStrength);\r\n } else if (pass > 0 && this.outlineWidthMultiplyTexture && this.usesAnimatedUV()) {\r\n bindGroup.setValue('uvAnimationScroll', this._uvAnimationScroll);\r\n bindGroup.setValue('uvAnimationRotationSpeedFactor', this._uvAnimationRotationSpeedFactor);\r\n }\r\n if (pass > 0) {\r\n bindGroup.setValue('outlineWidthFactor', this._outlineWidthFactor);\r\n if (this.outlineWidthMultiplyTexture) {\r\n bindGroup.setTexture(\r\n 'outlineWidthTex',\r\n this.outlineWidthMultiplyTexture,\r\n this.outlineWidthMultiplyTextureSampler\r\n );\r\n if (this.uvAnimationMaskTexture && this.usesAnimatedUV()) {\r\n bindGroup.setTexture(\r\n 'uvAnimationMaskTex',\r\n this.uvAnimationMaskTexture,\r\n this.uvAnimationMaskTextureSampler\r\n );\r\n }\r\n if (this.outlineWidthMultiplyTexCoordMatrix) {\r\n bindGroup.setValue('outlineWidthTextureMatrix', this.outlineWidthMultiplyTexCoordMatrix);\r\n }\r\n }\r\n }\r\n if (pass > 0 && ctx.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n bindGroup.setValue('outlineColorFactor', this._outlineColorFactor);\r\n bindGroup.setValue('outlineLightingMixFactor', this._outlineLightingMixFactor);\r\n }\r\n }\r\n private usesAnimatedUV(): boolean {\r\n return (\r\n this._uvAnimationScroll.x !== 0 ||\r\n this._uvAnimationScroll.y !== 0 ||\r\n this._uvAnimationRotationSpeedFactor !== 0\r\n );\r\n }\r\n private applyUVAnimation(scope: PBInsideFunctionScope, uv: PBShaderExp): PBShaderExp {\r\n if (!this.usesAnimatedUV()) {\r\n return uv;\r\n }\r\n const pb = scope.$builder;\r\n const funcName = 'Z_mtoonUVAnimation';\r\n const that = this;\r\n if (!scope.uvAnimationScroll) {\r\n scope.uvAnimationScroll = pb.vec2().uniform(2);\r\n }\r\n if (!scope.uvAnimationRotationSpeedFactor) {\r\n scope.uvAnimationRotationSpeedFactor = pb.float().uniform(2);\r\n }\r\n if (that.uvAnimationMaskTexture && pb.shaderKind !== 'fragment' && !scope.uvAnimationMaskTex) {\r\n scope.uvAnimationMaskTex = pb.tex2D().uniform(2);\r\n }\r\n pb.func(funcName, [pb.vec2('uv')], function () {\r\n this.$l.mask = that.uvAnimationMaskTexture\r\n ? pb.shaderKind === 'fragment'\r\n ? pb.textureSample(that.getUvAnimationMaskTextureUniform(this), this.uv).b\r\n : pb.textureSampleLevel(this.uvAnimationMaskTex, this.uv, 0).b\r\n : pb.float(1);\r\n this.$l.time = ShaderHelper.getElapsedTime(this);\r\n this.$l.rotation = pb.mul(this.time, this.uvAnimationRotationSpeedFactor, this.mask);\r\n this.$l.c = pb.cos(this.rotation);\r\n this.$l.s = pb.sin(this.rotation);\r\n this.$l.centeredUv = pb.sub(this.uv, pb.vec2(0.5));\r\n this.$l.rotatedUv = pb.add(\r\n pb.vec2(\r\n pb.add(pb.mul(this.c, this.centeredUv.x), pb.mul(this.s, this.centeredUv.y)),\r\n pb.add(pb.mul(pb.neg(this.s), this.centeredUv.x), pb.mul(this.c, this.centeredUv.y))\r\n ),\r\n pb.vec2(0.5)\r\n );\r\n this.$return(pb.add(this.rotatedUv, pb.mul(this.uvAnimationScroll, this.time, this.mask)));\r\n });\r\n return pb.getGlobalScope()[funcName](uv);\r\n }\r\n private getMToonBaseUV(scope: PBInsideFunctionScope): PBShaderExp {\r\n return this.albedoTexture\r\n ? this.applyUVAnimation(scope, this.getAlbedoTexCoord(scope))\r\n : scope.$builder.vec2(0);\r\n }\r\n private getMToonNormalUV(scope: PBInsideFunctionScope): PBShaderExp {\r\n return this.normalTexture\r\n ? this.applyUVAnimation(scope, this.getNormalTexCoord(scope))\r\n : scope.$builder.vec2(0);\r\n }\r\n private sampleAlbedo(scope: PBInsideFunctionScope, uv: PBShaderExp): PBShaderExp {\r\n return this.calculateAlbedoColor(scope, uv);\r\n }\r\n private sampleShadeColor(scope: PBInsideFunctionScope): PBShaderExp {\r\n const pb = scope.$builder;\r\n return this.shadeMultiplyTexture\r\n ? pb.mul(\r\n scope.shadeColorFactor,\r\n this.sampleShadeMultiplyTexture(\r\n scope,\r\n this.applyUVAnimation(scope, this.getShadeMultiplyTexCoord(scope))\r\n ).rgb\r\n )\r\n : scope.shadeColorFactor;\r\n }\r\n private sampleNormal(scope: PBInsideFunctionScope, uv: PBShaderExp): PBShaderExp {\r\n const pb = scope.$builder;\r\n if (!this.normalTexture) {\r\n return pb.normalize(scope.$inputs.wNorm);\r\n }\r\n scope.$l.TBN = this.calculateTBN(scope, scope.$inputs.worldPos, scope.$inputs.wNorm);\r\n scope.$l.normalTex = pb.sub(pb.mul(this.sampleNormalTexture(scope, uv).rgb, 2), pb.vec3(1));\r\n scope.normalTex = pb.mul(scope.normalTex, pb.vec3(pb.vec3(this.getUniformNormalScale(scope)).xx, 1));\r\n return pb.normalize(pb.mul(scope.TBN, scope.normalTex));\r\n }\r\n private calculateMToonDirectLighting(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n baseColor: PBShaderExp,\r\n shadeColor: PBShaderExp,\r\n shadingShift: PBShaderExp,\r\n geometricNormal: PBShaderExp\r\n ): PBShaderExp {\r\n const pb = scope.$builder;\r\n const that = this;\r\n const funcName = 'Z_mtoonDirectLighting';\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('worldPos'),\r\n pb.vec3('normal'),\r\n pb.vec3('baseColor'),\r\n pb.vec3('shadeColor'),\r\n pb.float('shadingShift'),\r\n pb.vec3('geometricNormal')\r\n ],\r\n function () {\r\n this.$l.directColor = pb.vec3(0);\r\n that.forEachLight(this, function (type, posRange, dirCutoff, colorIntensity, extra, shadow) {\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 extra\r\n );\r\n this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);\r\n this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten);\r\n this.$l.NoL = pb.dot(this.normal, this.lightDir);\r\n this.$l.shiftedShading = pb.add(this.NoL, this.shadingShift);\r\n this.$l.shading = pb.clamp(\r\n pb.div(\r\n pb.sub(this.shiftedShading, pb.add(-1, this.shadingToonyFactor)),\r\n pb.max(pb.sub(2, pb.mul(this.shadingToonyFactor, 2)), 0.00001)\r\n ),\r\n 0,\r\n 1\r\n );\r\n this.$l.lightDiffuse = pb.mix(this.shadeColor, this.baseColor, this.shading);\r\n if (shadow) {\r\n this.$l.shadowValue = that.calculateShadow(\r\n this,\r\n this.worldPos,\r\n this.geometricNormal,\r\n pb.clamp(this.NoL, 0, 1)\r\n );\r\n this.lightDiffuse = pb.mix(this.shadeColor, this.lightDiffuse, this.shadowValue);\r\n }\r\n this.directColor = pb.add(this.directColor, pb.mul(this.lightDiffuse, this.lightColor));\r\n });\r\n this.$return(this.directColor);\r\n }\r\n );\r\n return pb\r\n .getGlobalScope()\r\n [funcName](worldPos, normal, baseColor, shadeColor, shadingShift, geometricNormal);\r\n }\r\n private calculateMToonGI(\r\n scope: PBInsideFunctionScope,\r\n normal: PBShaderExp,\r\n baseColor: PBShaderExp\r\n ): PBShaderExp {\r\n const pb = scope.$builder;\r\n if (!this.needCalculateEnvLight()) {\r\n return pb.vec3(0);\r\n }\r\n scope.$l.rawGi = this.getEnvLightIrradiance(scope, normal);\r\n scope.$l.uniformGi = pb.mul(\r\n pb.add(\r\n this.getEnvLightIrradiance(scope, pb.vec3(0, 1, 0)),\r\n this.getEnvLightIrradiance(scope, pb.vec3(0, -1, 0))\r\n ),\r\n 0.5\r\n );\r\n scope.$l.gi = pb.mix(scope.rawGi, scope.uniformGi, scope.giEqualizationFactor);\r\n return pb.mul(scope.gi, baseColor);\r\n }\r\n private calculateMToonRim(\r\n scope: PBInsideFunctionScope,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n uv: PBShaderExp,\r\n lighting: PBShaderExp\r\n ): PBShaderExp {\r\n const pb = scope.$builder;\r\n scope.$l.rim = pb.vec3(0);\r\n if (this.matcapTexture) {\r\n scope.$l.worldViewX = pb.normalize(pb.vec3(viewVec.z, 0, pb.neg(viewVec.x)));\r\n scope.$l.worldViewY = pb.normalize(pb.cross(viewVec, scope.worldViewX));\r\n scope.$l.matcapUv = pb.add(\r\n pb.mul(pb.vec2(pb.dot(scope.worldViewX, normal), pb.dot(scope.worldViewY, normal)), 0.495),\r\n pb.vec2(0.5)\r\n );\r\n scope.rim = pb.add(\r\n scope.rim,\r\n pb.mul(scope.matcapFactor, this.sampleMatcapTexture(scope, scope.matcapUv).rgb)\r\n );\r\n }\r\n scope.$l.NoV = pb.clamp(pb.dot(normal, viewVec), 0, 1);\r\n scope.$l.parametricRim = pb.pow(\r\n pb.clamp(pb.add(pb.sub(1, scope.NoV), scope.parametricRimLiftFactor), 0, 1),\r\n pb.max(scope.parametricRimFresnelPowerFactor, 0.00001)\r\n );\r\n scope.rim = pb.add(scope.rim, pb.mul(scope.parametricRimColorFactor, scope.parametricRim));\r\n if (this.rimMultiplyTexture) {\r\n scope.rim = pb.mul(\r\n scope.rim,\r\n this.sampleRimMultiplyTexture(scope, this.applyUVAnimation(scope, this.getRimMultiplyTexCoord(scope)))\r\n .rgb\r\n );\r\n }\r\n return pb.mul(scope.rim, pb.mix(pb.vec3(1), lighting, scope.rimLightingMixFactor));\r\n }\r\n private calculateMToonEmission(scope: PBInsideFunctionScope): PBShaderExp {\r\n const pb = scope.$builder;\r\n const emission = this.emissiveTexture\r\n ? pb.mul(\r\n scope.emissiveColor,\r\n scope.emissiveStrength,\r\n this.sampleEmissiveTexture(scope, this.applyUVAnimation(scope, this.getEmissiveTexCoord(scope))).rgb\r\n )\r\n : pb.mul(scope.emissiveColor, scope.emissiveStrength);\r\n // Material-authored emitters are not covered by the CPU-side light pre-exposure, so a physical\r\n // scene exposes them here. The factor is 1 in legacy.\r\n return pb.mul(emission, ShaderHelper.getPreExposureUniform(scope)) as PBShaderExp;\r\n }\r\n vertexShader(scope: PBFunctionScope): void {\r\n super.vertexShader(scope);\r\n const pb = scope.$builder;\r\n scope.$l.oPos = ShaderHelper.resolveVertexPosition(scope);\r\n scope.$l.oNorm = ShaderHelper.resolveVertexNormal(scope);\r\n if (this.pass > 0 && this.outlineUsesTangentNormals) {\r\n scope.$l.oOutlineNorm = ShaderHelper.resolveVertexTangent(scope).xyz;\r\n }\r\n scope.$l.worldNormal = pb.normalize(\r\n pb.mul(ShaderHelper.getNormalMatrix(scope), pb.vec4(scope.oNorm, 0)).xyz\r\n );\r\n scope.$l.worldOutlineNormal =\r\n this.pass > 0 && this.outlineUsesTangentNormals\r\n ? pb.normalize(pb.mul(ShaderHelper.getNormalMatrix(scope), pb.vec4(scope.oOutlineNorm, 0)).xyz)\r\n : scope.worldNormal;\r\n scope.$l.worldPos = pb.mul(ShaderHelper.getWorldMatrix(scope), pb.vec4(scope.oPos, 1)).xyz;\r\n if (this.pass > 0) {\r\n scope.outlineWidthFactor = pb.float().uniform(2);\r\n scope.$l.width = scope.outlineWidthFactor;\r\n if (this.outlineWidthMultiplyTexture) {\r\n scope.outlineWidthTex = pb.tex2D().uniform(2);\r\n const uvIndex = this.outlineWidthMultiplyTexCoordIndex;\r\n const semantic = `texCoord${uvIndex}` as any;\r\n if (!scope.$getVertexAttrib(semantic)) {\r\n scope.$inputs[semantic] = pb.vec2().attrib(semantic);\r\n }\r\n if (this.outlineWidthMultiplyTexCoordMatrix) {\r\n scope.outlineWidthTextureMatrix = pb.mat4().uniform(2);\r\n scope.$l.outlineUv = pb.mul(\r\n scope.outlineWidthTextureMatrix,\r\n pb.vec4(this.applyUVAnimation(scope, scope.$inputs[semantic]), 0, 1)\r\n ).xy;\r\n } else {\r\n scope.$l.outlineUv = this.applyUVAnimation(scope, scope.$inputs[semantic]);\r\n }\r\n scope.width = pb.mul(scope.width, pb.textureSampleLevel(scope.outlineWidthTex, scope.outlineUv, 0).g);\r\n }\r\n scope.width = pb.max(scope.width, 0);\r\n scope.$l.hasOutlineWidth = pb.float(pb.greaterThan(scope.width, 0));\r\n if (this.outlineWidthMode === 'worldCoordinates') {\r\n scope.$l.baseClipPos = pb.mul(\r\n ShaderHelper.getViewProjectionMatrix(scope),\r\n pb.vec4(scope.worldPos, 1)\r\n );\r\n scope.worldPos = pb.add(scope.worldPos, pb.mul(scope.worldOutlineNormal, scope.width));\r\n scope.$l.clipPos = pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.worldPos, 1));\r\n scope.$l.baseNdc = pb.div(scope.baseClipPos.xy, pb.max(scope.baseClipPos.w, 0.00001));\r\n scope.$l.inflatedNdc = pb.div(scope.clipPos.xy, pb.max(scope.clipPos.w, 0.00001));\r\n scope.$l.outlineNdcDelta = pb.sub(scope.inflatedNdc, scope.baseNdc);\r\n scope.$l.outlinePixelWidth = pb.length(\r\n pb.mul(scope.outlineNdcDelta, ShaderHelper.getRenderSize(scope), 0.5)\r\n );\r\n scope.$l.outlinePixelScale = pb.mix(\r\n 1,\r\n pb.div(pb.max(scope.outlinePixelWidth, 1), pb.max(scope.outlinePixelWidth, 0.00001)),\r\n scope.hasOutlineWidth\r\n );\r\n scope.$l.adjustedNdc = pb.add(scope.baseNdc, pb.mul(scope.outlineNdcDelta, scope.outlinePixelScale));\r\n scope.clipPos = pb.vec4(pb.mul(scope.adjustedNdc, scope.clipPos.w), scope.clipPos.zw);\r\n scope.$outputs.worldPos = scope.worldPos;\r\n scope.$outputs.wNorm = scope.worldOutlineNormal;\r\n ShaderHelper.setClipSpacePosition(scope, scope.clipPos);\r\n return;\r\n } else if (this.outlineWidthMode === 'screenCoordinates') {\r\n scope.$l.clipNormalPos = pb.mul(\r\n ShaderHelper.getViewProjectionMatrix(scope),\r\n pb.vec4(pb.add(scope.worldPos, scope.worldOutlineNormal), 1)\r\n );\r\n scope.$l.clipPos = pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.worldPos, 1));\r\n scope.$l.screenNormal = pb.sub(\r\n pb.div(scope.clipNormalPos.xy, pb.max(scope.clipNormalPos.w, 0.00001)),\r\n pb.div(scope.clipPos.xy, pb.max(scope.clipPos.w, 0.00001))\r\n );\r\n scope.screenNormal = pb.normalize(\r\n pb.mul(\r\n scope.screenNormal,\r\n pb.vec2(1, pb.div(ShaderHelper.getRenderSize(scope).x, ShaderHelper.getRenderSize(scope).y))\r\n )\r\n );\r\n scope.$l.screenUnitPixels = pb.length(\r\n pb.mul(scope.screenNormal, ShaderHelper.getRenderSize(scope), 0.5)\r\n );\r\n scope.width = pb.mul(\r\n pb.max(scope.width, pb.div(1, pb.max(scope.screenUnitPixels, 0.00001))),\r\n scope.hasOutlineWidth\r\n );\r\n\r\n //scope.clipPos.xy = pb.add(scope.clipPos.xy, pb.mul(scope.screenNormal, scope.width, scope.clipPos.w));\r\n scope.clipPos = pb.vec4(\r\n pb.add(scope.clipPos.xy, pb.mul(scope.screenNormal, scope.width, scope.clipPos.w)),\r\n scope.clipPos.zw\r\n );\r\n scope.$outputs.worldPos = scope.worldPos;\r\n scope.$outputs.wNorm = scope.worldOutlineNormal;\r\n ShaderHelper.setClipSpacePosition(scope, scope.clipPos);\r\n return;\r\n }\r\n }\r\n scope.$outputs.worldPos = scope.worldPos;\r\n scope.$outputs.wNorm = this.pass > 0 ? scope.worldOutlineNormal : scope.worldNormal;\r\n ShaderHelper.setClipSpacePosition(\r\n scope,\r\n pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1))\r\n );\r\n }\r\n fragmentShader(scope: PBFunctionScope): void {\r\n super.fragmentShader(scope);\r\n const pb = scope.$builder;\r\n if (this.needFragmentColorInput()) {\r\n scope.shadeColorFactor = pb.vec3().uniform(2);\r\n scope.shadingShiftFactor = pb.float().uniform(2);\r\n scope.shadingShiftTextureScale = pb.float().uniform(2);\r\n scope.shadingToonyFactor = pb.float().uniform(2);\r\n scope.giEqualizationFactor = pb.float().uniform(2);\r\n scope.matcapFactor = pb.vec3().uniform(2);\r\n scope.parametricRimColorFactor = pb.vec3().uniform(2);\r\n scope.parametricRimFresnelPowerFactor = pb.float().uniform(2);\r\n scope.parametricRimLiftFactor = pb.float().uniform(2);\r\n scope.rimLightingMixFactor = pb.float().uniform(2);\r\n scope.uvAnimationScroll = pb.vec2().uniform(2);\r\n scope.uvAnimationRotationSpeedFactor = pb.float().uniform(2);\r\n scope.emissiveColor = pb.vec3().uniform(2);\r\n scope.emissiveStrength = pb.float().uniform(2);\r\n if (this.pass > 0) {\r\n scope.outlineColorFactor = pb.vec3().uniform(2);\r\n scope.outlineLightingMixFactor = pb.float().uniform(2);\r\n scope.$l.albedo = this.sampleAlbedo(scope, this.getMToonBaseUV(scope));\r\n scope.$l.outlineLighting = pb.mix(pb.vec3(1), scope.albedo.rgb, scope.outlineLightingMixFactor);\r\n this.outputFragmentColor(\r\n scope,\r\n scope.$inputs.worldPos,\r\n pb.vec4(pb.mul(scope.outlineColorFactor, scope.outlineLighting), scope.albedo.a)\r\n );\r\n } else {\r\n scope.$l.uv = this.getMToonBaseUV(scope);\r\n scope.$l.albedo = this.sampleAlbedo(scope, scope.uv);\r\n if (this.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n scope.$l.normal = this.sampleNormal(scope, this.getMToonNormalUV(scope));\r\n scope.$l.shadingShift = scope.shadingShiftFactor;\r\n if (this.shadingShiftTexture) {\r\n scope.shadingShift = pb.add(\r\n scope.shadingShift,\r\n pb.mul(\r\n this.sampleShadingShiftTexture(\r\n scope,\r\n this.applyUVAnimation(scope, this.getShadingShiftTexCoord(scope))\r\n ).r,\r\n scope.shadingShiftTextureScale\r\n )\r\n );\r\n }\r\n scope.$l.shadeColor = this.sampleShadeColor(scope);\r\n scope.$l.viewVec = this.calculateViewVector(scope, scope.$inputs.worldPos);\r\n scope.$l.directLighting = this.calculateMToonDirectLighting(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.normal,\r\n scope.albedo.rgb,\r\n scope.shadeColor,\r\n scope.shadingShift,\r\n pb.normalize(scope.$inputs.wNorm)\r\n );\r\n scope.$l.giLighting = this.calculateMToonGI(scope, scope.normal, scope.albedo.rgb);\r\n scope.$l.lighting = pb.max(scope.directLighting, scope.giLighting);\r\n scope.$l.rim = this.calculateMToonRim(scope, scope.normal, scope.viewVec, scope.uv, scope.lighting);\r\n scope.$l.emission = this.calculateMToonEmission(scope);\r\n scope.$l.outColor = pb.vec4(\r\n pb.add(scope.directLighting, scope.giLighting, scope.rim, scope.emission),\r\n scope.albedo.a\r\n );\r\n this.outputFragmentColor(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.outColor,\r\n pb.vec4(1, 1, 0, 1),\r\n pb.vec4(pb.add(pb.mul(scope.normal, 0.5), pb.vec3(0.5)), 1)\r\n );\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.albedo);\r\n }\r\n }\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, null);\r\n }\r\n }\r\n}\r\n"],"names":["ToonMaterialBase","applyMaterialMixins","MeshMaterial","mixinAlbedoColor","mixinLambert","mixinTextureProps","MToonMaterial","FEATURE_OUTLINE_WIDTH_MODE","defineFeature","FEATURE_OUTLINE_TANGENT_NORMALS","_shadeColorFactor","_matcapFactor","_parametricRimColorFactor","_outlineColorFactor","_uvAnimationScroll","_emissiveColor","_shadingShiftFactor","_shadingShiftTextureScale","_shadingToonyFactor","_giEqualizationFactor","_parametricRimFresnelPowerFactor","_parametricRimLiftFactor","_rimLightingMixFactor","_outlineWidthFactor","_outlineLightingMixFactor","_uvAnimationRotationSpeedFactor","_emissiveStrength","_transparentWithZWrite","_renderQueueOffsetNumber","Vector3","Vector2","outlineWidthMode","outlineUsesTangentNormals","shadeColorFactor","val","set","uniformChanged","shadingShiftFactor","shadingShiftTextureScale","shadingToonyFactor","toony","Math","min","max","giEqualizationFactor","factor","matcapFactor","parametricRimColorFactor","parametricRimFresnelPowerFactor","parametricRimLiftFactor","rimLightingMixFactor","featureUsed","numPasses","useFeature","outlineWidthFactor","width","outlineColorFactor","outlineLightingMixFactor","transparentWithZWrite","renderQueueOffsetNumber","offset","trunc","uvAnimationScrollXSpeedFactor","x","uvAnimationScrollYSpeedFactor","y","uvAnimationRotationSpeedFactor","emissiveColor","emissiveStrength","clone","other","copyFrom","getQueueType","isTransparentPass","QUEUE_TRANSPARENT","QUEUE_OPAQUE","passToHash","pass","ctx","updateRenderStates","stateSet","useRasterizerState","cullMode","defaultBlendingState","useDepthState","enableTest","enableWrite","setCompareFunc","DEPTH_COMPARE_CLOSER","draw","primitive","numInstances","material","renderPass","type","RENDER_PASS_TYPE_LIGHT","lightBlending","bind","device","drawPrimitive","prototype","call","applyUniformValues","bindGroup","needFragmentColorInput","setValue","outlineWidthMultiplyTexture","usesAnimatedUV","setTexture","outlineWidthMultiplyTextureSampler","uvAnimationMaskTexture","uvAnimationMaskTextureSampler","outlineWidthMultiplyTexCoordMatrix","applyUVAnimation","scope","uv","pb","$builder","funcName","that","uvAnimationScroll","vec2","uniform","float","shaderKind","uvAnimationMaskTex","tex2D","func","$l","mask","textureSample","getUvAnimationMaskTextureUniform","b","textureSampleLevel","time","ShaderHelper","getElapsedTime","rotation","mul","c","cos","s","sin","centeredUv","sub","rotatedUv","add","neg","$return","getGlobalScope","getMToonBaseUV","albedoTexture","getAlbedoTexCoord","getMToonNormalUV","normalTexture","getNormalTexCoord","sampleAlbedo","calculateAlbedoColor","sampleShadeColor","shadeMultiplyTexture","sampleShadeMultiplyTexture","getShadeMultiplyTexCoord","rgb","sampleNormal","normalize","$inputs","wNorm","TBN","calculateTBN","worldPos","normalTex","sampleNormalTexture","vec3","getUniformNormalScale","xx","calculateMToonDirectLighting","normal","baseColor","shadeColor","shadingShift","geometricNormal","directColor","forEachLight","posRange","dirCutoff","colorIntensity","extra","shadow","lightAtten","calculateLightAttenuation","lightDir","calculateLightDirection","lightColor","a","NoL","dot","shiftedShading","shading","clamp","div","lightDiffuse","mix","shadowValue","calculateShadow","calculateMToonGI","needCalculateEnvLight","rawGi","getEnvLightIrradiance","uniformGi","gi","calculateMToonRim","viewVec","lighting","rim","matcapTexture","worldViewX","z","worldViewY","cross","matcapUv","sampleMatcapTexture","NoV","parametricRim","pow","rimMultiplyTexture","sampleRimMultiplyTexture","getRimMultiplyTexCoord","calculateMToonEmission","emission","emissiveTexture","sampleEmissiveTexture","getEmissiveTexCoord","getPreExposureUniform","vertexShader","oPos","resolveVertexPosition","oNorm","resolveVertexNormal","oOutlineNorm","resolveVertexTangent","xyz","worldNormal","getNormalMatrix","vec4","worldOutlineNormal","getWorldMatrix","outlineWidthTex","uvIndex","outlineWidthMultiplyTexCoordIndex","semantic","$getVertexAttrib","attrib","outlineWidthTextureMatrix","mat4","outlineUv","xy","g","hasOutlineWidth","greaterThan","baseClipPos","getViewProjectionMatrix","clipPos","baseNdc","w","inflatedNdc","outlineNdcDelta","outlinePixelWidth","length","getRenderSize","outlinePixelScale","adjustedNdc","zw","$outputs","setClipSpacePosition","clipNormalPos","screenNormal","screenUnitPixels","fragmentShader","albedo","outlineLighting","outputFragmentColor","drawContext","shadingShiftTexture","sampleShadingShiftTexture","getShadingShiftTexCoord","r","calculateViewVector","directLighting","giLighting","outColor"],"mappings":";;;;;;;;AA6BA,MAAMA,mBAAmBC,mBACvBC,CAAAA,YAAAA,EACAC,gBACAC,EAAAA,YAAAA,EACAC,kBAAkB,eAClBA,CAAAA,EAAAA,iBAAAA,CAAkB,cAClBA,CAAAA,EAAAA,iBAAAA,CAAkB,WAClBA,iBAAkB,CAAA,aAAA,CAAA,EAClBA,kBAAkB,sBAClBA,CAAAA,EAAAA,iBAAAA,CAAkB,oBAClBA,iBAAkB,CAAA,UAAA,CAAA,CAAA;AAGpB;;;;IAKO,MAAMC,aAAsBN,SAAAA,gBAAAA,CAAAA;AACjC,IAAA,OAAwBO,0BAA6B,GAAA,IAAI,CAACC,aAAa,EAAG;AAC1E,IAAA,OAAwBC,+BAAkC,GAAA,IAAI,CAACD,aAAa,EAAG;IAC9DE,iBAA2B;IAC3BC,aAAuB;IACvBC,yBAAmC;IACnCC,mBAA6B;IAC7BC,kBAA4B;IAC5BC,cAAwB;IACjCC,mBAA4B;IAC5BC,yBAAkC;IAClCC,mBAA4B;IAC5BC,qBAA8B;IAC9BC,gCAAyC;IACzCC,wBAAiC;IACjCC,qBAA8B;IAC9BC,mBAA4B;IAC5BC,yBAAkC;IAClCC,+BAAwC;IACxCC,iBAA0B;IAC1BC,sBAAgC;IAChCC,wBAAiC;IACzC,WAAc,EAAA;QACZ,KAAK,EAAA;AACL,QAAA,IAAI,CAAClB,iBAAiB,GAAG,IAAImB,OAAAA,CAAQ,GAAG,CAAG,EAAA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G8B,CAAAA,GAAG,CAAC9B,EAAGsB,CAAAA,GAAG,CAACxB,KAAAA,CAAM8D,MAAM,EAAE,GAAA,CAAA,EAAM5D,EAAGwD,CAAAA,IAAI,CAAC,GAAO,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA;iBAEtD,MAAA;oBACL,IAAI,CAAC4G,mBAAmB,CAACtK,KAAOA,EAAAA,KAAAA,CAAMmD,OAAO,CAACI,QAAQ,EAAEvD,KAAAA,CAAMoK,MAAM,CAAA;AACtE;AACF;SACK,MAAA;YACL,IAAI,CAACE,mBAAmB,CAACtK,KAAAA,EAAOA,MAAMmD,OAAO,CAACI,QAAQ,EAAE,IAAA,CAAA;AAC1D;AACF;AACF;;;;"}
@@ -1,9 +1,16 @@
1
1
  import { DRef, Vector4 } from '@zephyr3d/base';
2
2
  import { ShaderHelper } from './shader/helper.js';
3
3
  import { MaterialBlueprintIR } from '../utility/blueprint/material/ir.js';
4
+ import { getDefaultTexture2D } from '../utility/blueprint/material/texture.js';
4
5
  import { PBRBlockNode, VertexBlockNode } from '../utility/blueprint/material/pbr.js';
5
6
  import { PBRMetallicRoughnessMaterial } from './pbrmr.js';
6
7
 
8
+ const PBR_REFLECTION_MODE = {
9
+ none: 0,
10
+ ggx: 1,
11
+ anisotropic: 2,
12
+ glint: 3
13
+ };
7
14
  const DEFAULT_OUTPUT_NAMES = [
8
15
  'BaseColor',
9
16
  'Metallic',
@@ -139,6 +146,7 @@ const DEFAULT_OUTPUT_NAMES = [
139
146
  set uniformTextures(val) {
140
147
  if (val !== this._uniformTextures) {
141
148
  const newUniforms = (val ?? []).map((v)=>({
149
+ exposed: v.exposed ?? true,
142
150
  finalTexture: new DRef(v.finalTexture?.get() ?? null),
143
151
  finalSampler: v.finalSampler,
144
152
  inFragmentShader: v.inFragmentShader,
@@ -164,6 +172,13 @@ const DEFAULT_OUTPUT_NAMES = [
164
172
  hasConnectedOutput(name) {
165
173
  return this._connectedOutputs.has(name);
166
174
  }
175
+ /**
176
+ * Binds fragment-stage uniforms consumed while evaluating blueprint PBR outputs.
177
+ *
178
+ * @param bindGroup - Material bind group used by the output evaluation shader.
179
+ */ applyBlueprintOutputUniformValues(bindGroup) {
180
+ this.applyBlueprintUniformValues(bindGroup, true);
181
+ }
167
182
  clone() {
168
183
  const other = new PBRBluePrintMaterial(this._irFrag, this._irVertex, this._uniformValues, this._uniformTextures);
169
184
  other.copyFrom(this);
@@ -193,13 +208,24 @@ const DEFAULT_OUTPUT_NAMES = [
193
208
  if (this._vertexUsesUV) {
194
209
  scope.$outputs.zVertexUV = scope.zVertexUV;
195
210
  }
196
- for (const u of [
197
- ...this._uniformValues,
198
- ...this._uniformTextures
199
- ]){
211
+ for (const u of this._uniformValues){
212
+ if (u.inVertexShader) {
213
+ // @ts-ignore dynamic shader type constructor
214
+ const exp = pb[u.type]().uniform(2);
215
+ pb.getGlobalScope()[u.name] = exp;
216
+ }
217
+ }
218
+ for (const u of this._uniformTextures){
200
219
  if (u.inVertexShader) {
201
220
  // @ts-ignore dynamic shader type constructor
202
- pb.getGlobalScope()[u.name] = pb[u.type]().uniform(2);
221
+ const exp = pb[u.type]().uniform(2).withSampler({
222
+ addressU: u.wrapS,
223
+ addressV: u.wrapT,
224
+ minFilter: u.minFilter,
225
+ magFilter: u.magFilter,
226
+ mipFilter: u.mipFilter
227
+ });
228
+ pb.getGlobalScope()[u.name] = exp;
203
229
  }
204
230
  }
205
231
  const outputs = this._irVertex.create(pb);
@@ -255,15 +281,7 @@ const DEFAULT_OUTPUT_NAMES = [
255
281
  fragmentShader(scope) {
256
282
  const pb = scope.$builder;
257
283
  if (this.needFragmentColorInput()) {
258
- for (const u of [
259
- ...this._uniformValues,
260
- ...this._uniformTextures
261
- ]){
262
- if (u.inFragmentShader) {
263
- // @ts-ignore dynamic shader type constructor
264
- pb.getGlobalScope()[u.name] = pb[u.type]().uniform(2);
265
- }
266
- }
284
+ this.declareBlueprintOutputUniforms(scope, true);
267
285
  scope.zVertexColor = scope.$inputs.zOutDiffuse ?? pb.vec4(1);
268
286
  scope.zVertexUV = scope.$inputs.zVertexUV ?? pb.vec2(0);
269
287
  scope.zVertexNormal = scope.$inputs.wNorm ?? pb.vec3(0, 0, 1);
@@ -276,22 +294,14 @@ const DEFAULT_OUTPUT_NAMES = [
276
294
  applyUniformValues(bindGroup, ctx, pass) {
277
295
  super.applyUniformValues(bindGroup, ctx, pass);
278
296
  if (this.needFragmentColorInput(ctx)) {
279
- for (const u of this._uniformValues){
280
- bindGroup.setValue(u.name, u.finalValue);
281
- }
282
- for (const u of this._uniformTextures){
283
- const texture = u.finalTexture?.get();
284
- if (texture) {
285
- bindGroup.setTexture(u.name, texture, u.finalSampler);
286
- }
287
- }
297
+ this.applyBlueprintUniformValues(bindGroup, false);
288
298
  }
289
299
  }
290
300
  createProgram(ctx, pass) {
291
301
  return super.createProgram(ctx, pass);
292
302
  }
293
303
  _createHash() {
294
- return `${super._createHash()}:${this._irFrag.hash}:${this._irVertex.hash}:${this._connectedOutputHash()}`;
304
+ return `${super._createHash()}:${this._irFrag.hash}:${this._irVertex.hash}:${this._connectedOutputHash()}:${this._suppressedBackendTextureHash()}`;
295
305
  }
296
306
  onDispose() {
297
307
  super.onDispose();
@@ -337,6 +347,37 @@ const DEFAULT_OUTPUT_NAMES = [
337
347
  }
338
348
  return base;
339
349
  }
350
+ calculateCommonData(scope, albedo, normal, viewVec, TBN, data) {
351
+ const pb = scope.$builder;
352
+ const metallic = this.calculateMetallic(scope, albedo, normal);
353
+ const roughness = this.calculateRoughness(scope, albedo, normal);
354
+ const specularFactor = this.calculateSpecularFactor(scope, albedo, normal);
355
+ const reflectionMode = scope.zReflectionMode;
356
+ if (this.hasMetallicRoughnessTexture()) {
357
+ scope.$l.metallicRoughnessSample = this.sampleMetallicRoughnessTexture(scope);
358
+ data.metallic = this._connectedOutputs.has('Metallic') ? metallic : pb.mul(metallic, scope.metallicRoughnessSample.z);
359
+ data.roughness = this._connectedOutputs.has('Roughness') ? roughness : pb.mul(roughness, scope.metallicRoughnessSample.y);
360
+ } else {
361
+ data.metallic = metallic;
362
+ data.roughness = roughness;
363
+ }
364
+ data.roughness = pb.mul(data.roughness, ShaderHelper.getCameraRoughnessFactor(scope));
365
+ if (this.hasSpecularColorTexture()) {
366
+ scope.$l.specularColor = pb.mul(specularFactor.rgb, this.sampleSpecularColorTexture(scope).rgb);
367
+ } else {
368
+ scope.$l.specularColor = specularFactor.rgb;
369
+ }
370
+ if (this.hasSpecularTexture()) {
371
+ data.specularWeight = pb.mul(specularFactor.a, this.sampleSpecularTexture(scope).a);
372
+ } else {
373
+ data.specularWeight = specularFactor.a;
374
+ }
375
+ data.specularWeight = pb.mul(data.specularWeight, pb.float(pb.notEqual(reflectionMode, PBR_REFLECTION_MODE.none)));
376
+ data.f0 = pb.vec4(pb.mix(pb.min(pb.mul(this.getF0(scope).rgb, scope.specularColor), pb.vec3(1)), albedo.rgb, data.metallic), this.getF0(scope).a);
377
+ data.f90 = pb.vec3(1);
378
+ data.diffuse = pb.vec4(pb.mix(albedo.rgb, pb.vec3(0), data.metallic), albedo.a);
379
+ super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);
380
+ }
340
381
  calculateEmissiveColor(scope) {
341
382
  const emissive = this.getBlueprintOutput(scope, 'Emissive');
342
383
  if (emissive !== undefined) {
@@ -470,19 +511,46 @@ const DEFAULT_OUTPUT_NAMES = [
470
511
  scope.$inputs.zVertexUV = pb.vec2().attrib('texCoord0');
471
512
  return scope.$inputs.zVertexUV;
472
513
  }
473
- if (this.albedoTexture) {
514
+ if (this.hasAlbedoTexture()) {
474
515
  return this.getAlbedoTexCoord(scope) ?? pb.vec2(0);
475
516
  }
476
517
  return pb.vec2(0);
477
518
  }
519
+ isMaterialTextureEnabled(name) {
520
+ switch(name){
521
+ case 'albedo':
522
+ return !this._connectedOutputs.has('BaseColor');
523
+ case 'specularColor':
524
+ return !this._connectedOutputs.has('Specular');
525
+ case 'specular':
526
+ return !this._connectedOutputs.has('SpecularWeight');
527
+ case 'emissive':
528
+ return !this._connectedOutputs.has('Emissive');
529
+ case 'normal':
530
+ return !(this._connectedOutputs.has('Normal') || this._connectedOutputs.has('Tangent'));
531
+ case 'occlusion':
532
+ return !this._connectedOutputs.has('AO');
533
+ case 'metallicRoughness':
534
+ return !(this._connectedOutputs.has('Metallic') && this._connectedOutputs.has('Roughness'));
535
+ default:
536
+ return super.isMaterialTextureEnabled(name);
537
+ }
538
+ }
478
539
  getBlueprintOutput(scope, name) {
479
540
  if (!this._connectedOutputs.has(name)) {
480
541
  return undefined;
481
542
  }
482
- return this.getBlueprintOutputMap(scope)[name];
543
+ return this.evaluateBlueprintOutputs(scope)[name];
483
544
  }
484
- getBlueprintOutputMap(scope) {
545
+ /**
546
+ * Evaluates the fragment blueprint and returns all PBR surface outputs.
547
+ *
548
+ * @param scope - Shader function scope used to generate output expressions.
549
+ * @param inputs - Optional explicit surface inputs. Missing values use the active draw scope.
550
+ * @returns A complete output map with defaults for graph outputs that are not connected.
551
+ */ evaluateBlueprintOutputs(scope, inputs = {}) {
485
552
  const pb = scope.$builder;
553
+ this.declareBlueprintOutputUniforms(scope);
486
554
  const funcName = 'Z_GetPBRBlueprintOutputs';
487
555
  const that = this;
488
556
  const outputsStruct = pb.defineStruct(DEFAULT_OUTPUT_NAMES.map((name)=>{
@@ -560,13 +628,52 @@ const DEFAULT_OUTPUT_NAMES = [
560
628
  this.$return(outputsStruct(baseColor, metallic, roughness, specular, emissive, normal, tangent, opacity, specularWeight, ao));
561
629
  });
562
630
  }
563
- const result = pb.getGlobalScope()[funcName](this.getBlueprintWorldPos(scope), this.getBlueprintFragmentVertexColor(scope), this.getBlueprintFragmentVertexUV(scope), this.getBlueprintFragmentVertexNormal(scope), this.getBlueprintFragmentVertexTangent(scope), this.getBlueprintFragmentVertexBinormal(scope));
631
+ const result = pb.getGlobalScope()[funcName](inputs.worldPosition ?? this.getBlueprintWorldPos(scope), inputs.vertexColor ?? this.getBlueprintFragmentVertexColor(scope), inputs.vertexUV ?? this.getBlueprintFragmentVertexUV(scope), inputs.vertexNormal ?? this.getBlueprintFragmentVertexNormal(scope), inputs.vertexTangent ?? this.getBlueprintFragmentVertexTangent(scope), inputs.vertexBinormal ?? this.getBlueprintFragmentVertexBinormal(scope));
564
632
  const map = {};
565
633
  for (const name of DEFAULT_OUTPUT_NAMES){
566
634
  map[name] = result[name];
567
635
  }
568
636
  return map;
569
637
  }
638
+ declareBlueprintOutputUniforms(scope, replaceExisting = false) {
639
+ const pb = scope.$builder;
640
+ const globalScope = pb.getGlobalScope();
641
+ for (const uniform of this._uniformValues){
642
+ if (!uniform.inFragmentShader || !replaceExisting && globalScope[uniform.name]) {
643
+ continue;
644
+ }
645
+ // @ts-ignore dynamic shader type constructor
646
+ const exp = pb[uniform.type]().uniform(2);
647
+ globalScope[uniform.name] = exp;
648
+ }
649
+ for (const uniform of this._uniformTextures){
650
+ if (!uniform.inFragmentShader || !replaceExisting && globalScope[uniform.name]) {
651
+ continue;
652
+ }
653
+ // @ts-ignore dynamic shader type constructor
654
+ const exp = pb[uniform.type]().uniform(2).withSampler({
655
+ addressU: uniform.wrapS,
656
+ addressV: uniform.wrapT,
657
+ minFilter: uniform.minFilter,
658
+ magFilter: uniform.magFilter,
659
+ mipFilter: uniform.mipFilter
660
+ });
661
+ globalScope[uniform.name] = exp;
662
+ }
663
+ }
664
+ applyBlueprintUniformValues(bindGroup, fragmentOnly) {
665
+ for (const uniform of this._uniformValues){
666
+ if (!fragmentOnly || uniform.inFragmentShader) {
667
+ bindGroup.setValue(uniform.name, uniform.finalValue);
668
+ }
669
+ }
670
+ for (const uniform of this._uniformTextures){
671
+ if (!fragmentOnly || uniform.inFragmentShader) {
672
+ const texture = uniform.finalTexture?.get() ?? getDefaultTexture2D();
673
+ bindGroup.setTexture(uniform.name, texture, uniform.finalSampler);
674
+ }
675
+ }
676
+ }
570
677
  getBlueprintWorldPos(scope) {
571
678
  const pb = scope.$builder;
572
679
  return scope.$inputs.worldPos ?? scope.zWorldPos ?? pb.vec3(0);
@@ -579,6 +686,17 @@ const DEFAULT_OUTPUT_NAMES = [
579
686
  const pb = scope.$builder;
580
687
  return scope.$inputs.zVertexUV ?? scope.zVertexUV ?? pb.vec2(0);
581
688
  }
689
+ _suppressedBackendTextureHash() {
690
+ return [
691
+ Number(!this.isMaterialTextureEnabled('albedo')),
692
+ Number(!this.isMaterialTextureEnabled('metallicRoughness')),
693
+ Number(!this.isMaterialTextureEnabled('specularColor')),
694
+ Number(!this.isMaterialTextureEnabled('specular')),
695
+ Number(!this.isMaterialTextureEnabled('emissive')),
696
+ Number(!this.isMaterialTextureEnabled('normal')),
697
+ Number(!this.isMaterialTextureEnabled('occlusion'))
698
+ ].join('');
699
+ }
582
700
  getBlueprintFragmentVertexNormal(scope) {
583
701
  const pb = scope.$builder;
584
702
  return scope.$inputs.wNorm ?? scope.zVertexNormal ?? pb.vec3(0, 0, 1);