@zephyr3d/scene 0.9.3 → 0.9.5

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 (188) hide show
  1. package/dist/animation/animationmask.js +224 -0
  2. package/dist/animation/animationmask.js.map +1 -0
  3. package/dist/animation/animationset.js +268 -67
  4. package/dist/animation/animationset.js.map +1 -1
  5. package/dist/animation/animationtrack.js.map +1 -1
  6. package/dist/animation/eulerrotationtrack.js +3 -0
  7. package/dist/animation/eulerrotationtrack.js.map +1 -1
  8. package/dist/animation/fixed_geometry_cache_track.js +7 -0
  9. package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
  10. package/dist/animation/ik_modifier.js.map +1 -1
  11. package/dist/animation/joint_dynamics/collision.js +6 -4
  12. package/dist/animation/joint_dynamics/collision.js.map +1 -1
  13. package/dist/animation/joint_dynamics/controller.js +390 -43
  14. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  15. package/dist/animation/joint_dynamics/joint_dynamics_system.js +62 -3
  16. package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
  17. package/dist/animation/joint_dynamics/solver.js +4 -3
  18. package/dist/animation/joint_dynamics/solver.js.map +1 -1
  19. package/dist/animation/joint_dynamics/types.js.map +1 -1
  20. package/dist/animation/joint_dynamics_modifier.js +2 -0
  21. package/dist/animation/joint_dynamics_modifier.js.map +1 -1
  22. package/dist/animation/morphtarget.js +3 -72
  23. package/dist/animation/morphtarget.js.map +1 -1
  24. package/dist/animation/morphtrack.js +3 -0
  25. package/dist/animation/morphtrack.js.map +1 -1
  26. package/dist/animation/pca_geometry_cache_track.js +3 -0
  27. package/dist/animation/pca_geometry_cache_track.js.map +1 -1
  28. package/dist/animation/proptrack.js +3 -0
  29. package/dist/animation/proptrack.js.map +1 -1
  30. package/dist/animation/rotationtrack.js +3 -0
  31. package/dist/animation/rotationtrack.js.map +1 -1
  32. package/dist/animation/scaletrack.js +3 -0
  33. package/dist/animation/scaletrack.js.map +1 -1
  34. package/dist/animation/skeleton.js +254 -79
  35. package/dist/animation/skeleton.js.map +1 -1
  36. package/dist/animation/skeleton_modifier.js.map +1 -1
  37. package/dist/animation/spring/spring_particle.js +4 -4
  38. package/dist/animation/spring/spring_particle.js.map +1 -1
  39. package/dist/animation/spring_modifier.js.map +1 -1
  40. package/dist/animation/translationtrack.js +3 -0
  41. package/dist/animation/translationtrack.js.map +1 -1
  42. package/dist/app/engine.js +129 -17
  43. package/dist/app/engine.js.map +1 -1
  44. package/dist/app/scriptregistry.js +251 -80
  45. package/dist/app/scriptregistry.js.map +1 -1
  46. package/dist/asset/assetmanager.js +133 -102
  47. package/dist/asset/assetmanager.js.map +1 -1
  48. package/dist/asset/loaders/gltf/gltf_loader.js +18 -14
  49. package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
  50. package/dist/asset/loaders/loader.js +1 -6
  51. package/dist/asset/loaders/loader.js.map +1 -1
  52. package/dist/asset/loaders/zabc/zabc_loader.js.map +1 -1
  53. package/dist/asset/model.js +1052 -183
  54. package/dist/asset/model.js.map +1 -1
  55. package/dist/avatar/wardrobe.js +474 -0
  56. package/dist/avatar/wardrobe.js.map +1 -0
  57. package/dist/index.d.ts +1810 -233
  58. package/dist/index.js +13 -3
  59. package/dist/index.js.map +1 -1
  60. package/dist/material/material.js +1 -1
  61. package/dist/material/material.js.map +1 -1
  62. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +6 -3
  63. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  64. package/dist/material/mixins/pbr/common.js +72 -15
  65. package/dist/material/mixins/pbr/common.js.map +1 -1
  66. package/dist/material/msdf_text.js +180 -0
  67. package/dist/material/msdf_text.js.map +1 -0
  68. package/dist/material/msdf_text_sprite.js +64 -0
  69. package/dist/material/msdf_text_sprite.js.map +1 -0
  70. package/dist/material/pbrblueprint.js +21 -6
  71. package/dist/material/pbrblueprint.js.map +1 -1
  72. package/dist/material/shader/helper.js +277 -277
  73. package/dist/material/shader/helper.js.map +1 -1
  74. package/dist/material/sprite_sdf.js +106 -0
  75. package/dist/material/sprite_sdf.js.map +1 -0
  76. package/dist/posteffect/ssr.js +1 -0
  77. package/dist/posteffect/ssr.js.map +1 -1
  78. package/dist/render/abuffer_oit.js +1 -0
  79. package/dist/render/abuffer_oit.js.map +1 -1
  80. package/dist/render/cluster_light.js.map +1 -1
  81. package/dist/render/cull_visitor.js +28 -0
  82. package/dist/render/cull_visitor.js.map +1 -1
  83. package/dist/render/drawable.js.map +1 -1
  84. package/dist/render/drawable_mixin.js +1 -0
  85. package/dist/render/drawable_mixin.js.map +1 -1
  86. package/dist/render/envlight.js +54 -1
  87. package/dist/render/envlight.js.map +1 -1
  88. package/dist/render/fbm_wavegenerator.js +1 -0
  89. package/dist/render/fbm_wavegenerator.js.map +1 -1
  90. package/dist/render/gerstner_wavegenerator.js +1 -0
  91. package/dist/render/gerstner_wavegenerator.js.map +1 -1
  92. package/dist/render/globalbindgroup_allocator.js +1 -0
  93. package/dist/render/globalbindgroup_allocator.js.map +1 -1
  94. package/dist/render/render_queue.js +1 -0
  95. package/dist/render/render_queue.js.map +1 -1
  96. package/dist/render/sky.js +9 -0
  97. package/dist/render/sky.js.map +1 -1
  98. package/dist/scene/basesprite.js +1 -5
  99. package/dist/scene/basesprite.js.map +1 -1
  100. package/dist/scene/batchgroup.js +18 -8
  101. package/dist/scene/batchgroup.js.map +1 -1
  102. package/dist/scene/environment.js +16 -2
  103. package/dist/scene/environment.js.map +1 -1
  104. package/dist/scene/mesh.js +164 -102
  105. package/dist/scene/mesh.js.map +1 -1
  106. package/dist/scene/meshdrawable.js +96 -0
  107. package/dist/scene/meshdrawable.js.map +1 -0
  108. package/dist/scene/msdftext.js +341 -0
  109. package/dist/scene/msdftext.js.map +1 -0
  110. package/dist/scene/msdftextsprite.js +349 -0
  111. package/dist/scene/msdftextsprite.js.map +1 -0
  112. package/dist/scene/particlesys.js +1 -0
  113. package/dist/scene/particlesys.js.map +1 -1
  114. package/dist/scene/scene.js +2 -0
  115. package/dist/scene/scene.js.map +1 -1
  116. package/dist/scene/scene_node.js +437 -230
  117. package/dist/scene/scene_node.js.map +1 -1
  118. package/dist/scene/sdftextsprite.js +322 -0
  119. package/dist/scene/sdftextsprite.js.map +1 -0
  120. package/dist/scene/terrain-cm/grass.js +1 -0
  121. package/dist/scene/terrain-cm/grass.js.map +1 -1
  122. package/dist/scene/terrain-cm/grassmaterial.js +1 -0
  123. package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
  124. package/dist/scene/terrain-cm/terrain-cm.js +1 -0
  125. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  126. package/dist/scene/textsprite.js +120 -0
  127. package/dist/scene/textsprite.js.map +1 -0
  128. package/dist/scene/water.js +1 -0
  129. package/dist/scene/water.js.map +1 -1
  130. package/dist/shadow/shader.js +1 -0
  131. package/dist/shadow/shader.js.map +1 -1
  132. package/dist/text/font/font_asset.js +884 -0
  133. package/dist/text/font/font_asset.js.map +1 -0
  134. package/dist/text/font/sfnt_reader.js +43 -0
  135. package/dist/text/font/sfnt_reader.js.map +1 -0
  136. package/dist/text/msdf/generator.js +417 -0
  137. package/dist/text/msdf/generator.js.map +1 -0
  138. package/dist/text/msdf/shape.js +146 -0
  139. package/dist/text/msdf/shape.js.map +1 -0
  140. package/dist/text/runtime/msdf_glyph_atlas.js +146 -0
  141. package/dist/text/runtime/msdf_glyph_atlas.js.map +1 -0
  142. package/dist/text/runtime/msdf_text_atlas_manager.js +50 -0
  143. package/dist/text/runtime/msdf_text_atlas_manager.js.map +1 -0
  144. package/dist/text/runtime/text_layout.js +96 -0
  145. package/dist/text/runtime/text_layout.js.map +1 -0
  146. package/dist/utility/blueprint/material/inputs.js +188 -1
  147. package/dist/utility/blueprint/material/inputs.js.map +1 -1
  148. package/dist/utility/blueprint/material/ir.js +16 -1
  149. package/dist/utility/blueprint/material/ir.js.map +1 -1
  150. package/dist/utility/blueprint/material/pbr.js +32 -0
  151. package/dist/utility/blueprint/material/pbr.js.map +1 -1
  152. package/dist/utility/bounding_volume.js.map +1 -1
  153. package/dist/utility/pmrem.js +34 -8
  154. package/dist/utility/pmrem.js.map +1 -1
  155. package/dist/utility/serialization/manager.js +340 -283
  156. package/dist/utility/serialization/manager.js.map +1 -1
  157. package/dist/utility/serialization/scene/animation.js +702 -7
  158. package/dist/utility/serialization/scene/animation.js.map +1 -1
  159. package/dist/utility/serialization/scene/batch.js +2 -0
  160. package/dist/utility/serialization/scene/batch.js.map +1 -1
  161. package/dist/utility/serialization/scene/camera.js +2 -0
  162. package/dist/utility/serialization/scene/camera.js.map +1 -1
  163. package/dist/utility/serialization/scene/light.js +2 -0
  164. package/dist/utility/serialization/scene/light.js.map +1 -1
  165. package/dist/utility/serialization/scene/material.js +1 -0
  166. package/dist/utility/serialization/scene/material.js.map +1 -1
  167. package/dist/utility/serialization/scene/mesh.js +66 -4
  168. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  169. package/dist/utility/serialization/scene/node.js +189 -8
  170. package/dist/utility/serialization/scene/node.js.map +1 -1
  171. package/dist/utility/serialization/scene/particle.js +2 -0
  172. package/dist/utility/serialization/scene/particle.js.map +1 -1
  173. package/dist/utility/serialization/scene/primitive.js +1 -0
  174. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  175. package/dist/utility/serialization/scene/sprite.js +2 -0
  176. package/dist/utility/serialization/scene/sprite.js.map +1 -1
  177. package/dist/utility/serialization/scene/terrain.js +2 -0
  178. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  179. package/dist/utility/serialization/scene/text.js +516 -0
  180. package/dist/utility/serialization/scene/text.js.map +1 -0
  181. package/dist/utility/serialization/scene/water.js +2 -0
  182. package/dist/utility/serialization/scene/water.js.map +1 -1
  183. package/dist/utility/serialization/types.js.map +1 -1
  184. package/dist/utility/textures/sheenlut.js +138 -0
  185. package/dist/utility/textures/sheenlut.js.map +1 -0
  186. package/dist/values.js +48 -48
  187. package/dist/values.js.map +1 -1
  188. package/package.json +3 -3
@@ -0,0 +1,180 @@
1
+ import { DRef, Vector3 } from '@zephyr3d/base';
2
+ import { MeshMaterial } from './meshmaterial.js';
3
+ import { ShaderHelper } from './shader/helper.js';
4
+ import { fetchSampler } from '../utility/misc.js';
5
+
6
+ /**
7
+ * Atlas-based MSDF text material.
8
+ *
9
+ * @public
10
+ */ class MSDFTextMaterial extends MeshMaterial {
11
+ static FEATURE_TEXT_ATLAS = this.defineFeature();
12
+ _atlas;
13
+ _textColor;
14
+ _outlineColor;
15
+ _distanceRange;
16
+ _atlasSize;
17
+ _smallGlyphThreshold;
18
+ _outlineWidth;
19
+ constructor(){
20
+ super();
21
+ this._atlas = new DRef();
22
+ this._textColor = new Vector3(1, 1, 1);
23
+ this._outlineColor = new Vector3(0, 0, 0);
24
+ this._distanceRange = 6;
25
+ this._atlasSize = new Float32Array([
26
+ 1,
27
+ 1
28
+ ]);
29
+ this._smallGlyphThreshold = 18;
30
+ this._outlineWidth = 0;
31
+ this.cullMode = 'none';
32
+ this.blendMode = 'blend';
33
+ }
34
+ get atlasTexture() {
35
+ return this._atlas.get();
36
+ }
37
+ set atlasTexture(tex) {
38
+ tex = tex ?? null;
39
+ if (tex !== this._atlas.get()) {
40
+ this._atlas.set(tex);
41
+ this.useFeature(MSDFTextMaterial.FEATURE_TEXT_ATLAS, !!tex);
42
+ this.uniformChanged();
43
+ }
44
+ }
45
+ get textColor() {
46
+ return this._textColor;
47
+ }
48
+ set textColor(value) {
49
+ if (!this._textColor.equalsTo(value)) {
50
+ this._textColor.set(value);
51
+ this.uniformChanged();
52
+ }
53
+ }
54
+ get outlineColor() {
55
+ return this._outlineColor;
56
+ }
57
+ set outlineColor(value) {
58
+ if (!this._outlineColor.equalsTo(value)) {
59
+ this._outlineColor.set(value);
60
+ this.uniformChanged();
61
+ }
62
+ }
63
+ get distanceRange() {
64
+ return this._distanceRange;
65
+ }
66
+ set distanceRange(value) {
67
+ if (this._distanceRange !== value) {
68
+ this._distanceRange = value;
69
+ this.uniformChanged();
70
+ }
71
+ }
72
+ get smallGlyphThreshold() {
73
+ return this._smallGlyphThreshold;
74
+ }
75
+ set smallGlyphThreshold(value) {
76
+ if (this._smallGlyphThreshold !== value) {
77
+ this._smallGlyphThreshold = value;
78
+ this.uniformChanged();
79
+ }
80
+ }
81
+ get outlineWidth() {
82
+ return this._outlineWidth;
83
+ }
84
+ set outlineWidth(value) {
85
+ value = Math.max(0, value);
86
+ if (this._outlineWidth !== value) {
87
+ this._outlineWidth = value;
88
+ this.uniformChanged();
89
+ }
90
+ }
91
+ clone() {
92
+ const other = new MSDFTextMaterial();
93
+ other.copyFrom(this);
94
+ return other;
95
+ }
96
+ copyFrom(other) {
97
+ super.copyFrom(other);
98
+ this.atlasTexture = other.atlasTexture;
99
+ this.textColor = other.textColor;
100
+ this.outlineColor = other.outlineColor;
101
+ this.distanceRange = other.distanceRange;
102
+ this.smallGlyphThreshold = other.smallGlyphThreshold;
103
+ this.outlineWidth = other.outlineWidth;
104
+ this._atlasSize[0] = other._atlasSize[0];
105
+ this._atlasSize[1] = other._atlasSize[1];
106
+ }
107
+ vertexShader(scope) {
108
+ super.vertexShader(scope);
109
+ const pb = scope.$builder;
110
+ scope.$l.oPos = ShaderHelper.resolveVertexPosition(scope);
111
+ scope.$inputs.zMSDFUV = pb.vec2().attrib('texCoord0');
112
+ scope.$outputs.zMSDFUV = scope.$inputs.zMSDFUV;
113
+ scope.$outputs.zMSDFLocalPos = scope.oPos.xy;
114
+ scope.$outputs.worldPos = pb.mul(ShaderHelper.getWorldMatrix(scope), pb.vec4(scope.oPos, 1)).xyz;
115
+ ShaderHelper.setClipSpacePosition(scope, pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1)));
116
+ }
117
+ fragmentShader(scope) {
118
+ super.fragmentShader(scope);
119
+ if (this.needFragmentColor()) {
120
+ const pb = scope.$builder;
121
+ scope.zMSDFAtlas = pb.tex2D().uniform(2);
122
+ scope.zMSDFTextColor = pb.vec3().uniform(2);
123
+ scope.zMSDFOutlineColor = pb.vec3().uniform(2);
124
+ scope.zMSDFDistanceRange = pb.float().uniform(2);
125
+ scope.zMSDFAtlasSize = pb.vec2().uniform(2);
126
+ scope.zMSDFSmallGlyphThreshold = pb.float().uniform(2);
127
+ scope.zMSDFOutlineWidth = pb.float().uniform(2);
128
+ scope.$l.sample = pb.textureSample(scope.zMSDFAtlas, scope.$inputs.zMSDFUV);
129
+ scope.$l.msdf = scope.sample.rgb;
130
+ scope.$l.sdf = scope.sample.a;
131
+ scope.$l.sd = median3(pb, scope.msdf.r, scope.msdf.g, scope.msdf.b);
132
+ scope.$l.unitRange = pb.div(pb.vec2(scope.zMSDFDistanceRange), pb.max(scope.zMSDFAtlasSize, pb.vec2(1)));
133
+ scope.$l.screenTexSize = pb.div(pb.vec2(1), pb.max(pb.fwidth(scope.$inputs.zMSDFUV), pb.vec2(1e-4)));
134
+ scope.$l.screenPxRange = pb.max(pb.mul(0.5, pb.dot(scope.unitRange, scope.screenTexSize)), 1);
135
+ scope.$l.msdfPxDistance = pb.mul(scope.screenPxRange, pb.sub(scope.sd, 0.5));
136
+ scope.$l.sdfPxDistance = pb.mul(scope.screenPxRange, pb.sub(scope.sdf, 0.5));
137
+ scope.$l.alphaMsdf = pb.clamp(pb.add(scope.msdfPxDistance, 0.5), 0, 1);
138
+ scope.$l.alphaSdf = pb.clamp(pb.add(scope.sdfPxDistance, 0.5), 0, 1);
139
+ scope.$l.glyphPixelSpan = pb.min(scope.screenTexSize.x, scope.screenTexSize.y);
140
+ scope.$l.useSdf = pb.lessThan(scope.glyphPixelSpan, scope.zMSDFSmallGlyphThreshold);
141
+ scope.$l.alpha = pb.mix(scope.alphaMsdf, scope.alphaSdf, pb.float(scope.useSdf));
142
+ scope.$l.localUnitsPerPixel = pb.max(pb.min(pb.fwidth(scope.$inputs.zMSDFLocalPos.x), pb.fwidth(scope.$inputs.zMSDFLocalPos.y)), 1e-4);
143
+ scope.$l.outlinePxWidth = pb.div(scope.zMSDFOutlineWidth, scope.localUnitsPerPixel);
144
+ scope.$l.outlineAlpha = pb.clamp(pb.add(scope.sdfPxDistance, pb.add(0.5, scope.outlinePxWidth)), 0, 1);
145
+ scope.$l.outlineMaskRaw = pb.max(pb.sub(scope.outlineAlpha, scope.alpha), 0);
146
+ scope.$l.hasOutline = pb.greaterThan(scope.zMSDFOutlineWidth, 1e-4);
147
+ scope.$l.outlineMask = pb.mul(scope.outlineMaskRaw, pb.float(scope.hasOutline));
148
+ scope.$l.finalAlpha = pb.clamp(pb.add(scope.alpha, scope.outlineMask), 0, 1);
149
+ scope.$l.weightedColor = pb.add(pb.mul(scope.zMSDFTextColor, scope.alpha), pb.mul(scope.zMSDFOutlineColor, scope.outlineMask));
150
+ scope.$l.finalColor = pb.div(scope.weightedColor, pb.max(scope.finalAlpha, 1e-4));
151
+ this.outputFragmentColor(scope, scope.$inputs.worldPos, pb.vec4(scope.finalColor, scope.finalAlpha));
152
+ } else {
153
+ this.outputFragmentColor(scope, scope.$inputs.worldPos, null);
154
+ }
155
+ }
156
+ applyUniformValues(bindGroup, ctx, pass) {
157
+ super.applyUniformValues(bindGroup, ctx, pass);
158
+ if (this.needFragmentColor(ctx) && this.atlasTexture) {
159
+ bindGroup.setValue('zMSDFTextColor', this._textColor);
160
+ bindGroup.setValue('zMSDFOutlineColor', this._outlineColor);
161
+ bindGroup.setValue('zMSDFDistanceRange', this._distanceRange);
162
+ this._atlasSize[0] = this.atlasTexture.width;
163
+ this._atlasSize[1] = this.atlasTexture.height;
164
+ bindGroup.setValue('zMSDFAtlasSize', this._atlasSize);
165
+ bindGroup.setValue('zMSDFSmallGlyphThreshold', this._smallGlyphThreshold);
166
+ bindGroup.setValue('zMSDFOutlineWidth', this._outlineWidth);
167
+ bindGroup.setTexture('zMSDFAtlas', this.atlasTexture, fetchSampler('clamp_linear'));
168
+ }
169
+ }
170
+ onDispose() {
171
+ super.onDispose();
172
+ this._atlas.dispose();
173
+ }
174
+ }
175
+ function median3(pb, a, b, c) {
176
+ return pb.sub(pb.sub(pb.add(a, b, c), pb.min(pb.min(a, b), c)), pb.max(pb.max(a, b), c));
177
+ }
178
+
179
+ export { MSDFTextMaterial };
180
+ //# sourceMappingURL=msdf_text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"msdf_text.js","sources":["../../src/material/msdf_text.ts"],"sourcesContent":["import type {\r\n BindGroup,\r\n PBFunctionScope,\r\n PBInsideFunctionScope,\r\n PBShaderExp,\r\n Texture2D\r\n} from '@zephyr3d/device';\r\nimport { DRef, type Clonable, type Immutable, Vector3 } from '@zephyr3d/base';\r\nimport type { DrawContext } from '../render';\r\nimport { MeshMaterial } from './meshmaterial';\r\nimport { ShaderHelper } from './shader/helper';\r\nimport { fetchSampler } from '../utility/misc';\r\n\r\n/**\r\n * Atlas-based MSDF text material.\r\n *\r\n * @public\r\n */\r\nexport class MSDFTextMaterial extends MeshMaterial implements Clonable<MSDFTextMaterial> {\r\n static FEATURE_TEXT_ATLAS = this.defineFeature();\r\n private _atlas: DRef<Texture2D>;\r\n private _textColor: Vector3;\r\n private _outlineColor: Vector3;\r\n private _distanceRange: number;\r\n private _atlasSize: Float32Array<ArrayBuffer>;\r\n private _smallGlyphThreshold: number;\r\n private _outlineWidth: number;\r\n constructor() {\r\n super();\r\n this._atlas = new DRef();\r\n this._textColor = new Vector3(1, 1, 1);\r\n this._outlineColor = new Vector3(0, 0, 0);\r\n this._distanceRange = 6;\r\n this._atlasSize = new Float32Array([1, 1]);\r\n this._smallGlyphThreshold = 18;\r\n this._outlineWidth = 0;\r\n this.cullMode = 'none';\r\n this.blendMode = 'blend';\r\n }\r\n get atlasTexture() {\r\n return this._atlas.get();\r\n }\r\n set atlasTexture(tex) {\r\n tex = tex ?? null;\r\n if (tex !== this._atlas.get()) {\r\n this._atlas.set(tex);\r\n this.useFeature(MSDFTextMaterial.FEATURE_TEXT_ATLAS, !!tex);\r\n this.uniformChanged();\r\n }\r\n }\r\n get textColor(): Immutable<Vector3> {\r\n return this._textColor;\r\n }\r\n set textColor(value: Immutable<Vector3>) {\r\n if (!this._textColor.equalsTo(value)) {\r\n this._textColor.set(value);\r\n this.uniformChanged();\r\n }\r\n }\r\n get outlineColor(): Immutable<Vector3> {\r\n return this._outlineColor;\r\n }\r\n set outlineColor(value: Immutable<Vector3>) {\r\n if (!this._outlineColor.equalsTo(value)) {\r\n this._outlineColor.set(value);\r\n this.uniformChanged();\r\n }\r\n }\r\n get distanceRange() {\r\n return this._distanceRange;\r\n }\r\n set distanceRange(value: number) {\r\n if (this._distanceRange !== value) {\r\n this._distanceRange = value;\r\n this.uniformChanged();\r\n }\r\n }\r\n get smallGlyphThreshold() {\r\n return this._smallGlyphThreshold;\r\n }\r\n set smallGlyphThreshold(value: number) {\r\n if (this._smallGlyphThreshold !== value) {\r\n this._smallGlyphThreshold = value;\r\n this.uniformChanged();\r\n }\r\n }\r\n get outlineWidth() {\r\n return this._outlineWidth;\r\n }\r\n set outlineWidth(value: number) {\r\n value = Math.max(0, value);\r\n if (this._outlineWidth !== value) {\r\n this._outlineWidth = value;\r\n this.uniformChanged();\r\n }\r\n }\r\n clone() {\r\n const other = new MSDFTextMaterial();\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.atlasTexture = other.atlasTexture;\r\n this.textColor = other.textColor;\r\n this.outlineColor = other.outlineColor;\r\n this.distanceRange = other.distanceRange;\r\n this.smallGlyphThreshold = other.smallGlyphThreshold;\r\n this.outlineWidth = other.outlineWidth;\r\n this._atlasSize[0] = other._atlasSize[0];\r\n this._atlasSize[1] = other._atlasSize[1];\r\n }\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n const pb = scope.$builder;\r\n scope.$l.oPos = ShaderHelper.resolveVertexPosition(scope);\r\n scope.$inputs.zMSDFUV = pb.vec2().attrib('texCoord0');\r\n scope.$outputs.zMSDFUV = scope.$inputs.zMSDFUV;\r\n scope.$outputs.zMSDFLocalPos = scope.oPos.xy;\r\n scope.$outputs.worldPos = pb.mul(ShaderHelper.getWorldMatrix(scope), pb.vec4(scope.oPos, 1)).xyz;\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) {\r\n super.fragmentShader(scope);\r\n if (this.needFragmentColor()) {\r\n const pb = scope.$builder;\r\n scope.zMSDFAtlas = pb.tex2D().uniform(2);\r\n scope.zMSDFTextColor = pb.vec3().uniform(2);\r\n scope.zMSDFOutlineColor = pb.vec3().uniform(2);\r\n scope.zMSDFDistanceRange = pb.float().uniform(2);\r\n scope.zMSDFAtlasSize = pb.vec2().uniform(2);\r\n scope.zMSDFSmallGlyphThreshold = pb.float().uniform(2);\r\n scope.zMSDFOutlineWidth = pb.float().uniform(2);\r\n scope.$l.sample = pb.textureSample(scope.zMSDFAtlas, scope.$inputs.zMSDFUV);\r\n scope.$l.msdf = scope.sample.rgb;\r\n scope.$l.sdf = scope.sample.a;\r\n scope.$l.sd = median3(pb, scope.msdf.r, scope.msdf.g, scope.msdf.b);\r\n scope.$l.unitRange = pb.div(\r\n pb.vec2(scope.zMSDFDistanceRange),\r\n pb.max(scope.zMSDFAtlasSize, pb.vec2(1))\r\n );\r\n scope.$l.screenTexSize = pb.div(pb.vec2(1), pb.max(pb.fwidth(scope.$inputs.zMSDFUV), pb.vec2(1e-4)));\r\n scope.$l.screenPxRange = pb.max(pb.mul(0.5, pb.dot(scope.unitRange, scope.screenTexSize)), 1);\r\n scope.$l.msdfPxDistance = pb.mul(scope.screenPxRange, pb.sub(scope.sd, 0.5));\r\n scope.$l.sdfPxDistance = pb.mul(scope.screenPxRange, pb.sub(scope.sdf, 0.5));\r\n scope.$l.alphaMsdf = pb.clamp(pb.add(scope.msdfPxDistance, 0.5), 0, 1);\r\n scope.$l.alphaSdf = pb.clamp(pb.add(scope.sdfPxDistance, 0.5), 0, 1);\r\n scope.$l.glyphPixelSpan = pb.min(scope.screenTexSize.x, scope.screenTexSize.y);\r\n scope.$l.useSdf = pb.lessThan(scope.glyphPixelSpan, scope.zMSDFSmallGlyphThreshold);\r\n scope.$l.alpha = pb.mix(scope.alphaMsdf, scope.alphaSdf, pb.float(scope.useSdf));\r\n scope.$l.localUnitsPerPixel = pb.max(\r\n pb.min(pb.fwidth(scope.$inputs.zMSDFLocalPos.x), pb.fwidth(scope.$inputs.zMSDFLocalPos.y)),\r\n 1e-4\r\n );\r\n scope.$l.outlinePxWidth = pb.div(scope.zMSDFOutlineWidth, scope.localUnitsPerPixel);\r\n scope.$l.outlineAlpha = pb.clamp(pb.add(scope.sdfPxDistance, pb.add(0.5, scope.outlinePxWidth)), 0, 1);\r\n scope.$l.outlineMaskRaw = pb.max(pb.sub(scope.outlineAlpha, scope.alpha), 0);\r\n scope.$l.hasOutline = pb.greaterThan(scope.zMSDFOutlineWidth, 1e-4);\r\n scope.$l.outlineMask = pb.mul(scope.outlineMaskRaw, pb.float(scope.hasOutline));\r\n scope.$l.finalAlpha = pb.clamp(pb.add(scope.alpha, scope.outlineMask), 0, 1);\r\n scope.$l.weightedColor = pb.add(\r\n pb.mul(scope.zMSDFTextColor, scope.alpha),\r\n pb.mul(scope.zMSDFOutlineColor, scope.outlineMask)\r\n );\r\n scope.$l.finalColor = pb.div(scope.weightedColor, pb.max(scope.finalAlpha, 1e-4));\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, pb.vec4(scope.finalColor, scope.finalAlpha));\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, null);\r\n }\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColor(ctx) && this.atlasTexture) {\r\n bindGroup.setValue('zMSDFTextColor', this._textColor);\r\n bindGroup.setValue('zMSDFOutlineColor', this._outlineColor);\r\n bindGroup.setValue('zMSDFDistanceRange', this._distanceRange);\r\n this._atlasSize[0] = this.atlasTexture.width;\r\n this._atlasSize[1] = this.atlasTexture.height;\r\n bindGroup.setValue('zMSDFAtlasSize', this._atlasSize);\r\n bindGroup.setValue('zMSDFSmallGlyphThreshold', this._smallGlyphThreshold);\r\n bindGroup.setValue('zMSDFOutlineWidth', this._outlineWidth);\r\n bindGroup.setTexture('zMSDFAtlas', this.atlasTexture, fetchSampler('clamp_linear'));\r\n }\r\n }\r\n protected onDispose() {\r\n super.onDispose();\r\n this._atlas.dispose();\r\n }\r\n}\r\n\r\nfunction median3(pb: PBInsideFunctionScope['$builder'], a: PBShaderExp, b: PBShaderExp, c: PBShaderExp) {\r\n return pb.sub(pb.sub(pb.add(a, b, c), pb.min(pb.min(a, b), c)), pb.max(pb.max(a, b), c));\r\n}\r\n"],"names":["MSDFTextMaterial","MeshMaterial","FEATURE_TEXT_ATLAS","defineFeature","_atlas","_textColor","_outlineColor","_distanceRange","_atlasSize","_smallGlyphThreshold","_outlineWidth","DRef","Vector3","Float32Array","cullMode","blendMode","atlasTexture","get","tex","set","useFeature","uniformChanged","textColor","value","equalsTo","outlineColor","distanceRange","smallGlyphThreshold","outlineWidth","Math","max","clone","other","copyFrom","vertexShader","scope","pb","$builder","$l","oPos","ShaderHelper","resolveVertexPosition","$inputs","zMSDFUV","vec2","attrib","$outputs","zMSDFLocalPos","xy","worldPos","mul","getWorldMatrix","vec4","xyz","setClipSpacePosition","getViewProjectionMatrix","fragmentShader","needFragmentColor","zMSDFAtlas","tex2D","uniform","zMSDFTextColor","vec3","zMSDFOutlineColor","zMSDFDistanceRange","float","zMSDFAtlasSize","zMSDFSmallGlyphThreshold","zMSDFOutlineWidth","sample","textureSample","msdf","rgb","sdf","a","sd","median3","r","g","b","unitRange","div","screenTexSize","fwidth","screenPxRange","dot","msdfPxDistance","sub","sdfPxDistance","alphaMsdf","clamp","add","alphaSdf","glyphPixelSpan","min","x","y","useSdf","lessThan","alpha","mix","localUnitsPerPixel","outlinePxWidth","outlineAlpha","outlineMaskRaw","hasOutline","greaterThan","outlineMask","finalAlpha","weightedColor","finalColor","outputFragmentColor","applyUniformValues","bindGroup","ctx","pass","setValue","width","height","setTexture","fetchSampler","onDispose","dispose","c"],"mappings":";;;;;AAaA;;;;IAKO,MAAMA,gBAAyBC,SAAAA,YAAAA,CAAAA;AACpC,IAAA,OAAOC,kBAAqB,GAAA,IAAI,CAACC,aAAa,EAAG;IACzCC,MAAwB;IACxBC,UAAoB;IACpBC,aAAuB;IACvBC,cAAuB;IACvBC,UAAsC;IACtCC,oBAA6B;IAC7BC,aAAsB;IAC9B,WAAc,EAAA;QACZ,KAAK,EAAA;QACL,IAAI,CAACN,MAAM,GAAG,IAAIO,IAAAA,EAAAA;AAClB,QAAA,IAAI,CAACN,UAAU,GAAG,IAAIO,OAAAA,CAAQ,GAAG,CAAG,EAAA,CAAA,CAAA;AACpC,QAAA,IAAI,CAACN,aAAa,GAAG,IAAIM,OAAAA,CAAQ,GAAG,CAAG,EAAA,CAAA,CAAA;QACvC,IAAI,CAACL,cAAc,GAAG,CAAA;AACtB,QAAA,IAAI,CAACC,UAAU,GAAG,IAAIK,YAAa,CAAA;AAAC,YAAA,CAAA;AAAG,YAAA;AAAE,SAAA,CAAA;QACzC,IAAI,CAACJ,oBAAoB,GAAG,EAAA;QAC5B,IAAI,CAACC,aAAa,GAAG,CAAA;QACrB,IAAI,CAACI,QAAQ,GAAG,MAAA;QAChB,IAAI,CAACC,SAAS,GAAG,OAAA;AACnB;AACA,IAAA,IAAIC,YAAe,GAAA;AACjB,QAAA,OAAO,IAAI,CAACZ,MAAM,CAACa,GAAG,EAAA;AACxB;IACA,IAAID,YAAAA,CAAaE,GAAG,EAAE;AACpBA,QAAAA,GAAAA,GAAMA,GAAO,IAAA,IAAA;AACb,QAAA,IAAIA,QAAQ,IAAI,CAACd,MAAM,CAACa,GAAG,EAAI,EAAA;AAC7B,YAAA,IAAI,CAACb,MAAM,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;QACN,IAAI,CAACrH,MAAM,CAACsH,OAAO,EAAA;AACrB;AACF;AAEA,SAAS9C,QAAQxC,EAAqC,EAAEsC,CAAc,EAAEK,CAAc,EAAE4C,CAAc,EAAA;AACpG,IAAA,OAAOvF,EAAGmD,CAAAA,GAAG,CAACnD,EAAAA,CAAGmD,GAAG,CAACnD,EAAGuD,CAAAA,GAAG,CAACjB,CAAAA,EAAGK,CAAG4C,EAAAA,CAAAA,CAAAA,EAAIvF,EAAG0D,CAAAA,GAAG,CAAC1D,EAAAA,CAAG0D,GAAG,CAACpB,CAAGK,EAAAA,CAAAA,CAAAA,EAAI4C,CAAKvF,CAAAA,CAAAA,EAAAA,EAAAA,CAAGN,GAAG,CAACM,EAAGN,CAAAA,GAAG,CAAC4C,CAAAA,EAAGK,CAAI4C,CAAAA,EAAAA,CAAAA,CAAAA,CAAAA;AACvF;;;;"}
@@ -0,0 +1,64 @@
1
+ import { ShaderHelper } from './shader/helper.js';
2
+ import { MeshMaterial } from './meshmaterial.js';
3
+ import { MSDFTextMaterial } from './msdf_text.js';
4
+
5
+ /**
6
+ * Billboard MSDF text material.
7
+ *
8
+ * @public
9
+ */ class MSDFTextSpriteMaterial extends MSDFTextMaterial {
10
+ _rotation;
11
+ constructor(){
12
+ super();
13
+ this._rotation = 0;
14
+ }
15
+ get rotation() {
16
+ return this._rotation;
17
+ }
18
+ set rotation(value) {
19
+ if (this._rotation !== value) {
20
+ this._rotation = value;
21
+ this.uniformChanged();
22
+ }
23
+ }
24
+ clone() {
25
+ const other = new MSDFTextSpriteMaterial();
26
+ other.copyFrom(this);
27
+ return other;
28
+ }
29
+ copyFrom(other) {
30
+ super.copyFrom(other);
31
+ this.rotation = other.rotation;
32
+ }
33
+ vertexShader(scope) {
34
+ MeshMaterial.prototype.vertexShader.call(this, scope);
35
+ const pb = scope.$builder;
36
+ scope.$l.oPos = ShaderHelper.resolveVertexPosition(scope);
37
+ scope.$inputs.zMSDFUV = pb.vec2().attrib('texCoord0');
38
+ scope.$outputs.zMSDFUV = scope.$inputs.zMSDFUV;
39
+ scope.$outputs.zMSDFLocalPos = scope.oPos.xy;
40
+ scope.zMSDFSpriteRotation = pb.float().uniform(2);
41
+ scope.$l.worldPos = ShaderHelper.getWorldMatrix(scope)[3].xyz;
42
+ scope.$l.scaleX = pb.sqrt(pb.dot(ShaderHelper.getWorldMatrix(scope)[0].xyz, ShaderHelper.getWorldMatrix(scope)[0].xyz));
43
+ scope.$l.scaleY = pb.sqrt(pb.dot(ShaderHelper.getWorldMatrix(scope)[1].xyz, ShaderHelper.getWorldMatrix(scope)[1].xyz));
44
+ scope.$l.localPos = scope.oPos.xy;
45
+ const viewMatrix = ShaderHelper.getViewMatrix(scope);
46
+ scope.$l.forward = pb.vec3(viewMatrix[0].z, viewMatrix[1].z, viewMatrix[2].z);
47
+ scope.$l.axis = scope.$choice(pb.lessThan(pb.abs(scope.forward.y), 0.999), pb.vec3(0, 1, 0), pb.vec3(1, 0, 0));
48
+ scope.$l.right = pb.normalize(pb.cross(scope.axis, scope.forward));
49
+ scope.$l.up = pb.normalize(pb.cross(scope.forward, scope.right));
50
+ scope.$l.c = pb.cos(scope.zMSDFSpriteRotation);
51
+ scope.$l.s = pb.sin(scope.zMSDFSpriteRotation);
52
+ scope.$l.rightRot = pb.add(pb.mul(scope.up, scope.s), pb.mul(scope.right, scope.c));
53
+ scope.$l.upRot = pb.sub(pb.mul(scope.up, scope.c), pb.mul(scope.right, scope.s));
54
+ scope.$outputs.worldPos = pb.add(scope.worldPos, pb.mul(scope.rightRot, pb.mul(scope.localPos.x, scope.scaleX)), pb.mul(scope.upRot, pb.mul(scope.localPos.y, scope.scaleY)));
55
+ ShaderHelper.setClipSpacePosition(scope, pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1)));
56
+ }
57
+ applyUniformValues(bindGroup, ctx, pass) {
58
+ super.applyUniformValues(bindGroup, ctx, pass);
59
+ bindGroup.setValue('zMSDFSpriteRotation', this._rotation);
60
+ }
61
+ }
62
+
63
+ export { MSDFTextSpriteMaterial };
64
+ //# sourceMappingURL=msdf_text_sprite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"msdf_text_sprite.js","sources":["../../src/material/msdf_text_sprite.ts"],"sourcesContent":["import type { BindGroup, PBFunctionScope } from '@zephyr3d/device';\r\nimport type { Clonable } from '@zephyr3d/base';\r\nimport { ShaderHelper } from './shader/helper';\r\nimport { MeshMaterial } from './meshmaterial';\r\nimport { MSDFTextMaterial } from './msdf_text';\r\nimport type { DrawContext } from '../render';\r\n\r\n/**\r\n * Billboard MSDF text material.\r\n *\r\n * @public\r\n */\r\nexport class MSDFTextSpriteMaterial extends MSDFTextMaterial implements Clonable<MSDFTextSpriteMaterial> {\r\n private _rotation: number;\r\n constructor() {\r\n super();\r\n this._rotation = 0;\r\n }\r\n get rotation() {\r\n return this._rotation;\r\n }\r\n set rotation(value: number) {\r\n if (this._rotation !== value) {\r\n this._rotation = value;\r\n this.uniformChanged();\r\n }\r\n }\r\n clone() {\r\n const other = new MSDFTextSpriteMaterial();\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.rotation = other.rotation;\r\n }\r\n vertexShader(scope: PBFunctionScope) {\r\n MeshMaterial.prototype.vertexShader.call(this, scope);\r\n const pb = scope.$builder;\r\n scope.$l.oPos = ShaderHelper.resolveVertexPosition(scope);\r\n scope.$inputs.zMSDFUV = pb.vec2().attrib('texCoord0');\r\n scope.$outputs.zMSDFUV = scope.$inputs.zMSDFUV;\r\n scope.$outputs.zMSDFLocalPos = scope.oPos.xy;\r\n scope.zMSDFSpriteRotation = pb.float().uniform(2);\r\n scope.$l.worldPos = ShaderHelper.getWorldMatrix(scope)[3].xyz;\r\n scope.$l.scaleX = pb.sqrt(\r\n pb.dot(ShaderHelper.getWorldMatrix(scope)[0].xyz, ShaderHelper.getWorldMatrix(scope)[0].xyz)\r\n );\r\n scope.$l.scaleY = pb.sqrt(\r\n pb.dot(ShaderHelper.getWorldMatrix(scope)[1].xyz, ShaderHelper.getWorldMatrix(scope)[1].xyz)\r\n );\r\n scope.$l.localPos = scope.oPos.xy;\r\n const viewMatrix = ShaderHelper.getViewMatrix(scope);\r\n scope.$l.forward = pb.vec3(viewMatrix[0].z, viewMatrix[1].z, viewMatrix[2].z);\r\n scope.$l.axis = scope.$choice(\r\n pb.lessThan(pb.abs(scope.forward.y), 0.999),\r\n pb.vec3(0, 1, 0),\r\n pb.vec3(1, 0, 0)\r\n );\r\n scope.$l.right = pb.normalize(pb.cross(scope.axis, scope.forward));\r\n scope.$l.up = pb.normalize(pb.cross(scope.forward, scope.right));\r\n scope.$l.c = pb.cos(scope.zMSDFSpriteRotation);\r\n scope.$l.s = pb.sin(scope.zMSDFSpriteRotation);\r\n scope.$l.rightRot = pb.add(pb.mul(scope.up, scope.s), pb.mul(scope.right, scope.c));\r\n scope.$l.upRot = pb.sub(pb.mul(scope.up, scope.c), pb.mul(scope.right, scope.s));\r\n scope.$outputs.worldPos = pb.add(\r\n scope.worldPos,\r\n pb.mul(scope.rightRot, pb.mul(scope.localPos.x, scope.scaleX)),\r\n pb.mul(scope.upRot, pb.mul(scope.localPos.y, scope.scaleY))\r\n );\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 applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n bindGroup.setValue('zMSDFSpriteRotation', this._rotation);\r\n }\r\n}\r\n"],"names":["MSDFTextSpriteMaterial","MSDFTextMaterial","_rotation","rotation","value","uniformChanged","clone","other","copyFrom","vertexShader","scope","MeshMaterial","prototype","call","pb","$builder","$l","oPos","ShaderHelper","resolveVertexPosition","$inputs","zMSDFUV","vec2","attrib","$outputs","zMSDFLocalPos","xy","zMSDFSpriteRotation","float","uniform","worldPos","getWorldMatrix","xyz","scaleX","sqrt","dot","scaleY","localPos","viewMatrix","getViewMatrix","forward","vec3","z","axis","$choice","lessThan","abs","y","right","normalize","cross","up","c","cos","s","sin","rightRot","add","mul","upRot","sub","x","setClipSpacePosition","getViewProjectionMatrix","vec4","applyUniformValues","bindGroup","ctx","pass","setValue"],"mappings":";;;;AAOA;;;;IAKO,MAAMA,sBAA+BC,SAAAA,gBAAAA,CAAAA;IAClCC,SAAkB;IAC1B,WAAc,EAAA;QACZ,KAAK,EAAA;QACL,IAAI,CAACA,SAAS,GAAG,CAAA;AACnB;AACA,IAAA,IAAIC,QAAW,GAAA;QACb,OAAO,IAAI,CAACD,SAAS;AACvB;IACA,IAAIC,QAAAA,CAASC,KAAa,EAAE;AAC1B,QAAA,IAAI,IAAI,CAACF,SAAS,KAAKE,KAAO,EAAA;YAC5B,IAAI,CAACF,SAAS,GAAGE,KAAAA;AACjB,YAAA,IAAI,CAACC,cAAc,EAAA;AACrB;AACF;IACAC,KAAQ,GAAA;AACN,QAAA,MAAMC,QAAQ,IAAIP,sBAAAA,EAAAA;QAClBO,KAAMC,CAAAA,QAAQ,CAAC,IAAI,CAAA;QACnB,OAAOD,KAAAA;AACT;AACAC,IAAAA,QAAAA,CAASD,KAAW,EAAE;AACpB,QAAA,KAAK,CAACC,QAASD,CAAAA,KAAAA,CAAAA;AACf,QAAA,IAAI,CAACJ,QAAQ,GAAGI,KAAAA,CAAMJ,QAAQ;AAChC;AACAM,IAAAA,YAAAA,CAAaC,KAAsB,EAAE;AACnCC,QAAAA,YAAAA,CAAaC,SAAS,CAACH,YAAY,CAACI,IAAI,CAAC,IAAI,EAAEH,KAAAA,CAAAA;QAC/C,MAAMI,EAAAA,GAAKJ,MAAMK,QAAQ;AACzBL,QAAAA,KAAAA,CAAMM,EAAE,CAACC,IAAI,GAAGC,YAAAA,CAAaC,qBAAqB,CAACT,KAAAA,CAAAA;QACnDA,KAAMU,CAAAA,OAAO,CAACC,OAAO,G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;;;"}
@@ -337,6 +337,17 @@ const PBR_REFLECTION_MODE = {
337
337
  scope.$l.oTangent = this.getOutput(outputs, 'Tangent') ?? ShaderHelper.resolveVertexTangent(scope);
338
338
  scope.$outputs.zVertexTangent = pb.mul(ShaderHelper.getNormalMatrix(scope), pb.vec4(scope.oTangent.xyz, 0)).xyz;
339
339
  scope.$outputs.zVertexBinormal = pb.mul(pb.cross(scope.$outputs.zVertexNormal, scope.$outputs.zVertexTangent), scope.oTangent.w);
340
+ for (const outputName of [
341
+ 'Output1',
342
+ 'Output2',
343
+ 'Output3',
344
+ 'Output4'
345
+ ]){
346
+ const output = this.getOutput(outputs, outputName);
347
+ if (output) {
348
+ scope.$outputs[outputName] = output;
349
+ }
350
+ }
340
351
  }
341
352
  /**
342
353
  * Builds the fragment shader for this PBR blueprint material.
@@ -407,12 +418,6 @@ const PBR_REFLECTION_MODE = {
407
418
  bindGroup.setValue('zAnisotropy', this._anisotropy);
408
419
  bindGroup.setValue('zAnisotropyDirection', this._anisotropyDirection);
409
420
  bindGroup.setValue('zAnisotropyDirectionScaleBias', this._anisotropyDirectionScaleBias);
410
- for (const u of this._uniformValues){
411
- bindGroup.setValue(u.name, u.finalValue);
412
- }
413
- for (const u of this._uniformTextures){
414
- bindGroup.setTexture(u.name, u.finalTexture.get(), u.finalSampler);
415
- }
416
421
  if (this.subsurfaceScattering && ctx.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
417
422
  bindGroup.setValue('zSubsurfaceColor', this._subsurfaceColor);
418
423
  bindGroup.setValue('zSubsurfaceScale', this._subsurfaceScale);
@@ -420,6 +425,16 @@ const PBR_REFLECTION_MODE = {
420
425
  bindGroup.setValue('zSubsurfaceIntensity', this._subsurfaceIntensity);
421
426
  }
422
427
  }
428
+ for (const u of this._uniformValues){
429
+ if (u.inVertexShader || this.needFragmentColor(ctx)) {
430
+ bindGroup.setValue(u.name, u.finalValue);
431
+ }
432
+ }
433
+ for (const u of this._uniformTextures){
434
+ if (u.inVertexShader || this.needFragmentColor(ctx)) {
435
+ bindGroup.setTexture(u.name, u.finalTexture.get(), u.finalSampler);
436
+ }
437
+ }
423
438
  }
424
439
  /**
425
440
  * Creates a unique hash string used for program caching.
@@ -1 +1 @@
1
- {"version":3,"file":"pbrblueprint.js","sources":["../../src/material/pbrblueprint.ts"],"sourcesContent":["import { MeshMaterial, applyMaterialMixins } from './meshmaterial';\r\nimport type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport { ShaderHelper } from './shader/helper';\r\nimport { MaterialVaryingFlags, RENDER_PASS_TYPE_LIGHT } from '../values';\r\nimport { DRef, Vector2, Vector3, Vector4, type Clonable, type Immutable } from '@zephyr3d/base';\r\nimport { mixinPBRBluePrint } from './mixins/lightmodel/pbrblueprintmixin';\r\nimport type { BluePrintUniformTexture, BluePrintUniformValue } from '../utility/blueprint/material/ir';\r\nimport { MaterialBlueprintIR } from '../utility/blueprint/material/ir';\r\nimport type { DrawContext } from '../render/drawable';\r\nimport { PBRBlockNode, VertexBlockNode } from '../utility/blueprint/material/pbr';\r\nimport type { PBRReflectionMode } from './mixins/lightmodel/pbrmetallicroughness';\r\n\r\nconst PBR_REFLECTION_MODE: Record<PBRReflectionMode, number> = {\r\n none: 0,\r\n ggx: 1,\r\n anisotropic: 2,\r\n glint: 3\r\n};\r\n\r\n/**\r\n * Physically-based rendering material driven by blueprint graphs.\r\n *\r\n * @remarks\r\n * This material extends {@link MeshMaterial} with PBR behavior via\r\n * {@link mixinPBRBluePrint}, and uses {@link MaterialBlueprintIR}\r\n * graphs for both vertex and fragment stages.\r\n *\r\n * - The **vertex blueprint IR** (`vertexIR`) controls vertex\r\n * transformations and per-vertex data.\r\n * - The **fragment blueprint IR** (`fragmentIR`) produces inputs\r\n * for the PBR shading model (albedo, roughness, metalness, etc.).\r\n *\r\n * Uniform values and textures for the blueprints are provided via\r\n * {@link PBRBluePrintMaterial.uniformValues} and\r\n * {@link PBRBluePrintMaterial.uniformTextures}.\r\n *\r\n * @public\r\n */\r\nexport class PBRBluePrintMaterial\r\n extends applyMaterialMixins(MeshMaterial, mixinPBRBluePrint)\r\n implements Clonable<PBRBluePrintMaterial>\r\n{\r\n /** @internal */\r\n private static readonly FEATURE_VERTEX_COLOR = this.defineFeature();\r\n /** @internal */\r\n private static readonly FEATURE_VERTEX_UV = this.defineFeature();\r\n /** @internal */\r\n private static readonly FEATURE_SUBSURFACE_SCATTERING = this.defineFeature();\r\n /** @internal */\r\n private _irFrag: MaterialBlueprintIR;\r\n /** @internal */\r\n private _irVertex: MaterialBlueprintIR;\r\n /** @internal */\r\n private _uniformValues: BluePrintUniformValue[];\r\n /** @internal */\r\n private _uniformTextures: BluePrintUniformTexture[];\r\n /** @internal */\r\n private _reflectionMode: PBRReflectionMode;\r\n /** @internal */\r\n private readonly _subsurfaceColor: Vector3;\r\n /** @internal */\r\n private _subsurfaceScale: number;\r\n /** @internal */\r\n private _subsurfacePower: number;\r\n /** @internal */\r\n private _subsurfaceIntensity: number;\r\n /** @internal */\r\n private _anisotropy: number;\r\n /** @internal */\r\n private _anisotropyDirection: number;\r\n /** @internal */\r\n private readonly _anisotropyDirectionScaleBias: Vector2;\r\n /**\r\n * Creates a new {@link PBRBluePrintMaterial} instance.\r\n *\r\n * @param irFrag - Optional fragment blueprint IR. If omitted, a default\r\n * IR containing a single {@link PBRBlockNode} is created.\r\n * @param irVertex - Optional vertex blueprint IR. If omitted, a default\r\n * IR containing a single {@link VertexBlockNode} is created.\r\n * @param uniformValues - Optional initial list of uniform value descriptors.\r\n * @param uniformTextures - Optional initial list of texture uniform descriptors.\r\n */\r\n constructor(\r\n irFrag?: MaterialBlueprintIR,\r\n irVertex?: MaterialBlueprintIR,\r\n uniformValues?: BluePrintUniformValue[],\r\n uniformTextures?: BluePrintUniformTexture[]\r\n ) {\r\n super();\r\n this._irFrag =\r\n irFrag ??\r\n new MaterialBlueprintIR(\r\n {\r\n nodeMap: { '1': new PBRBlockNode() },\r\n roots: [1],\r\n order: [1],\r\n graph: { incoming: {}, outgoing: {} }\r\n },\r\n '',\r\n {\r\n nodes: [{ id: 1, title: '', locked: true, node: { ClassName: 'PBRBlockNode', Object: '' } }],\r\n links: []\r\n }\r\n );\r\n this._irVertex =\r\n irVertex ??\r\n new MaterialBlueprintIR(\r\n {\r\n nodeMap: { '1': new VertexBlockNode() },\r\n roots: [1],\r\n order: [1],\r\n graph: { incoming: {}, outgoing: {} }\r\n },\r\n '',\r\n {\r\n nodes: [{ id: 1, title: '', locked: true, node: { ClassName: 'VertexBlockNode', Object: '' } }],\r\n links: []\r\n }\r\n );\r\n this._uniformValues = uniformValues ?? [];\r\n this._uniformTextures = uniformTextures ?? [];\r\n this._reflectionMode = 'ggx';\r\n this._subsurfaceColor = new Vector3(1, 0.3, 0.2);\r\n this._subsurfaceScale = 0.5;\r\n this._subsurfacePower = 1.5;\r\n this._subsurfaceIntensity = 0.5;\r\n this._anisotropy = 0.75;\r\n this._anisotropyDirection = 0;\r\n this._anisotropyDirectionScaleBias = new Vector2(1, 0);\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_SUBSURFACE_SCATTERING, false);\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_VERTEX_COLOR, this._irVertex.behaviors.useVertexColor);\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_VERTEX_UV, this._irVertex.behaviors.useVertexUV);\r\n }\r\n get reflectionMode() {\r\n return this._reflectionMode;\r\n }\r\n set reflectionMode(val: PBRReflectionMode) {\r\n if (val !== this._reflectionMode) {\r\n this._reflectionMode = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get subsurfaceScattering() {\r\n return this.featureUsed<boolean>(PBRBluePrintMaterial.FEATURE_SUBSURFACE_SCATTERING);\r\n }\r\n set subsurfaceScattering(val: boolean) {\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_SUBSURFACE_SCATTERING, !!val);\r\n }\r\n get subsurfaceColor(): Immutable<Vector3> {\r\n return this._subsurfaceColor;\r\n }\r\n set subsurfaceColor(val: Immutable<Vector3>) {\r\n if (!val.equalsTo(this._subsurfaceColor)) {\r\n this._subsurfaceColor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n get subsurfaceScale() {\r\n return this._subsurfaceScale;\r\n }\r\n set subsurfaceScale(val: number) {\r\n if (val !== this._subsurfaceScale) {\r\n this._subsurfaceScale = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get subsurfacePower() {\r\n return this._subsurfacePower;\r\n }\r\n set subsurfacePower(val: number) {\r\n if (val !== this._subsurfacePower) {\r\n this._subsurfacePower = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get subsurfaceIntensity() {\r\n return this._subsurfaceIntensity;\r\n }\r\n set subsurfaceIntensity(val: number) {\r\n if (val !== this._subsurfaceIntensity) {\r\n this._subsurfaceIntensity = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropy() {\r\n return this._anisotropy;\r\n }\r\n set anisotropy(val: number) {\r\n const clamped = Math.max(-0.95, Math.min(0.95, val));\r\n if (clamped !== this._anisotropy) {\r\n this._anisotropy = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirection() {\r\n return this._anisotropyDirection;\r\n }\r\n set anisotropyDirection(val: number) {\r\n if (val !== this._anisotropyDirection) {\r\n this._anisotropyDirection = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirectionScaleBias(): Immutable<Vector2> {\r\n return this._anisotropyDirectionScaleBias;\r\n }\r\n set anisotropyDirectionScaleBias(val: Immutable<Vector2>) {\r\n if (!val.equalsTo(this._anisotropyDirectionScaleBias)) {\r\n this._anisotropyDirectionScaleBias.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Gets the fragment blueprint IR.\r\n */\r\n get fragmentIR() {\r\n return this._irFrag;\r\n }\r\n set fragmentIR(ir: MaterialBlueprintIR) {\r\n if (ir && ir !== this._irFrag) {\r\n this._irFrag = ir;\r\n this.clearCache();\r\n this.optionChanged(true);\r\n }\r\n }\r\n /**\r\n * Gets the vertex blueprint IR.\r\n */\r\n get vertexIR() {\r\n return this._irVertex;\r\n }\r\n set vertexIR(ir: MaterialBlueprintIR) {\r\n if (ir && ir !== this._irVertex) {\r\n this._irVertex = ir;\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_VERTEX_COLOR, this._irVertex.behaviors.useVertexColor);\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_VERTEX_UV, this._irVertex.behaviors.useVertexUV);\r\n this.clearCache();\r\n this.optionChanged(true);\r\n }\r\n }\r\n /**\r\n * Gets the list of uniform value descriptors used by the blueprints.\r\n */\r\n get uniformValues() {\r\n return this._uniformValues;\r\n }\r\n set uniformValues(val: BluePrintUniformValue[]) {\r\n this._uniformValues = (val ?? []).map((v) => ({ ...v }));\r\n this.uniformChanged();\r\n }\r\n /**\r\n * Gets the list of texture uniform descriptors used by the blueprints.\r\n */\r\n get uniformTextures() {\r\n return this._uniformTextures;\r\n }\r\n set uniformTextures(val: BluePrintUniformTexture[]) {\r\n if (val !== this._uniformTextures) {\r\n const newUniforms = val.map((v) => ({\r\n finalTexture: new DRef(v.finalTexture!.get()),\r\n finalSampler: v.finalSampler,\r\n name: v.name,\r\n params: v.params?.clone() ?? Vector4.zero(),\r\n texture: v.texture,\r\n type: v.type,\r\n sRGB: v.sRGB,\r\n wrapS: v.wrapS,\r\n wrapT: v.wrapT,\r\n inFragmentShader: v.inFragmentShader,\r\n inVertexShader: v.inVertexShader,\r\n minFilter: v.minFilter,\r\n magFilter: v.magFilter,\r\n mipFilter: v.mipFilter\r\n }));\r\n for (const u of this._uniformTextures) {\r\n u.finalTexture!.dispose();\r\n }\r\n this._uniformTextures = newUniforms;\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Creates a deep copy of this material.\r\n *\r\n * @remarks\r\n * The clone shares the same vertex/fragment IR references and copies\r\n * the current blueprint uniform descriptors, then calls `copyFrom`\r\n * to copy base-class and mixin state.\r\n *\r\n * @returns A new {@link PBRBluePrintMaterial} instance.\r\n */\r\n clone() {\r\n const other = new PBRBluePrintMaterial(\r\n this._irFrag,\r\n this._irVertex,\r\n this._uniformValues,\r\n this._uniformTextures\r\n );\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.reflectionMode = other.reflectionMode;\r\n this.subsurfaceScattering = other.subsurfaceScattering;\r\n this.subsurfaceColor = other.subsurfaceColor;\r\n this.subsurfaceScale = other.subsurfaceScale;\r\n this.subsurfacePower = other.subsurfacePower;\r\n this.subsurfaceIntensity = other.subsurfaceIntensity;\r\n this.anisotropy = other.anisotropy;\r\n this.anisotropyDirection = other.anisotropyDirection;\r\n this.anisotropyDirectionScaleBias = other.anisotropyDirectionScaleBias;\r\n }\r\n /**\r\n * Builds the vertex shader for this PBR blueprint material.\r\n *\r\n * @param scope - The current vertex shader function scope.\r\n */\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n const pb = scope.$builder;\r\n scope.$inputs.zVertexPos = pb.vec3().attrib('position');\r\n scope.$inputs.zVertexNormal = pb.vec3().attrib('normal');\r\n scope.$inputs.zVertexTangent = pb.vec4().attrib('tangent');\r\n if (this.featureUsed(PBRBluePrintMaterial.FEATURE_VERTEX_COLOR)) {\r\n scope.$inputs.zVertexColor = pb.vec4().attrib('diffuse');\r\n }\r\n if (this.featureUsed(PBRBluePrintMaterial.FEATURE_VERTEX_UV)) {\r\n scope.$inputs.zVertexUV = pb.vec2().attrib('texCoord0');\r\n }\r\n\r\n for (const u of [...this._uniformValues, ...this._uniformTextures]) {\r\n if (u.inVertexShader) {\r\n // @ts-ignore\r\n pb.getGlobalScope()[u.name] = pb[u.type]().uniform(2);\r\n }\r\n }\r\n const outputs = this._irVertex.create(pb)!;\r\n scope.$l.oPos = this.getOutput(outputs, 'Position') ?? ShaderHelper.resolveVertexPosition(scope);\r\n const worldMatrix = ShaderHelper.getWorldMatrix(scope);\r\n scope.$outputs.worldPos = pb.mul(worldMatrix, pb.vec4(scope.oPos, 1)).xyz;\r\n scope.$l.csPos = pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1));\r\n ShaderHelper.setClipSpacePosition(scope, scope.csPos);\r\n scope.$outputs.zVertexColor =\r\n this.getOutput(outputs, 'Color') ??\r\n (this.featureUsed(PBRBluePrintMaterial.FEATURE_VERTEX_COLOR) ? scope.$inputs.zVertexColor : pb.vec4(1));\r\n scope.$outputs.zVertexUV =\r\n this.getOutput(outputs, 'UV') ??\r\n (this.featureUsed(PBRBluePrintMaterial.FEATURE_VERTEX_UV) ? scope.$inputs.zVertexUV : pb.vec2(0));\r\n scope.$l.oNorm = this.getOutput(outputs, 'Normal') ?? ShaderHelper.resolveVertexNormal(scope);\r\n scope.$outputs.zVertexNormal = pb.mul(ShaderHelper.getNormalMatrix(scope), pb.vec4(scope.oNorm, 0)).xyz;\r\n scope.$l.oTangent = this.getOutput(outputs, 'Tangent') ?? ShaderHelper.resolveVertexTangent(scope);\r\n scope.$outputs.zVertexTangent = pb.mul(\r\n ShaderHelper.getNormalMatrix(scope),\r\n pb.vec4(scope.oTangent.xyz, 0)\r\n ).xyz;\r\n scope.$outputs.zVertexBinormal = pb.mul(\r\n pb.cross(scope.$outputs.zVertexNormal, scope.$outputs.zVertexTangent),\r\n scope.oTangent.w\r\n );\r\n }\r\n /**\r\n * Builds the fragment shader for this PBR blueprint material.\r\n *\r\n * @param scope - The current fragment shader function scope.\r\n */\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n const pb = scope.$builder;\r\n if (\r\n this.subsurfaceScattering &&\r\n this.needFragmentColor() &&\r\n this.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT\r\n ) {\r\n scope.zSubsurfaceColor = pb.vec3().uniform(2);\r\n scope.zSubsurfaceScale = pb.float().uniform(2);\r\n scope.zSubsurfacePower = pb.float().uniform(2);\r\n scope.zSubsurfaceIntensity = pb.float().uniform(2);\r\n }\r\n if (this.needFragmentColor()) {\r\n scope.zAnisotropy = pb.float().uniform(2);\r\n scope.zAnisotropyDirection = pb.float().uniform(2);\r\n scope.zAnisotropyDirectionScaleBias = pb.vec2().uniform(2);\r\n for (const u of [...this._uniformValues, ...this._uniformTextures]) {\r\n if (u.inFragmentShader) {\r\n // @ts-ignore\r\n pb.getGlobalScope()[u.name] = pb[u.type]().uniform(2);\r\n }\r\n }\r\n scope.$l.viewVec = this.calculateViewVector(scope, scope.$inputs.worldPos);\r\n scope.$l.commonData = this.getCommonDatasStruct(scope)();\r\n this.getCommonData(\r\n scope,\r\n scope.commonData,\r\n scope.viewVec,\r\n scope.$inputs.worldPos,\r\n scope.$inputs.zVertexNormal,\r\n scope.$inputs.zVertexTangent,\r\n scope.$inputs.zVertexBinormal,\r\n scope.$inputs.zVertexColor,\r\n scope.$inputs.zVertexUV,\r\n this._irFrag\r\n );\r\n if (this.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n if (this.drawContext.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS) {\r\n scope.$l.outRoughness = pb.vec4();\r\n scope.$l.litColor = this.PBRLight(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.viewVec,\r\n scope.commonData,\r\n scope.outRoughness\r\n );\r\n if (this.subsurfaceScattering) {\r\n scope.litColor = this.applySubsurfaceScattering(\r\n scope,\r\n scope.litColor,\r\n scope.commonData.albedo.rgb,\r\n scope.commonData.normal,\r\n scope.viewVec\r\n );\r\n }\r\n this.outputFragmentColor(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.litColor,\r\n scope.outRoughness,\r\n pb.vec4(pb.add(pb.mul(scope.commonData.normal, 0.5), pb.vec3(0.5)), 1)\r\n );\r\n } else {\r\n scope.$l.litColor = this.PBRLight(scope, scope.$inputs.worldPos, scope.viewVec, scope.commonData);\r\n if (this.subsurfaceScattering) {\r\n scope.litColor = this.applySubsurfaceScattering(\r\n scope,\r\n scope.litColor,\r\n scope.commonData.albedo.rgb,\r\n scope.commonData.normal,\r\n scope.viewVec\r\n );\r\n }\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.litColor);\r\n }\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.commonData.albedo);\r\n }\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, null);\r\n }\r\n }\r\n /**\r\n * Applies runtime uniform values and textures to the given bind group.\r\n *\r\n * @remarks\r\n * - Calls the base implementation first to bind standard mesh/PBR uniforms.\r\n * - If fragment color is needed for the current context, all blueprint\r\n * scalar/vector uniform values and textures are then bound by name.\r\n *\r\n * @param bindGroup - The bind group to which material resources are bound.\r\n * @param ctx - The current draw context.\r\n * @param pass - Index of the active render pass.\r\n */\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColor(ctx)) {\r\n bindGroup.setValue('zReflectionMode', PBR_REFLECTION_MODE[this._reflectionMode]);\r\n bindGroup.setValue('zAnisotropy', this._anisotropy);\r\n bindGroup.setValue('zAnisotropyDirection', this._anisotropyDirection);\r\n bindGroup.setValue('zAnisotropyDirectionScaleBias', this._anisotropyDirectionScaleBias);\r\n for (const u of this._uniformValues) {\r\n bindGroup.setValue(u.name, u.finalValue!);\r\n }\r\n for (const u of this._uniformTextures) {\r\n bindGroup.setTexture(u.name, u.finalTexture!.get()!, u.finalSampler);\r\n }\r\n if (this.subsurfaceScattering && ctx.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n bindGroup.setValue('zSubsurfaceColor', this._subsurfaceColor);\r\n bindGroup.setValue('zSubsurfaceScale', this._subsurfaceScale);\r\n bindGroup.setValue('zSubsurfacePower', this._subsurfacePower);\r\n bindGroup.setValue('zSubsurfaceIntensity', this._subsurfaceIntensity);\r\n }\r\n }\r\n }\r\n /**\r\n * Creates a unique hash string used for program caching.\r\n *\r\n * @remarks\r\n * The hash includes:\r\n * - The base material hash (`super._createHash()`).\r\n * - The fragment IR hash.\r\n * - The vertex IR hash.\r\n *\r\n * Different blueprint graphs will therefore produce different programs.\r\n *\r\n * @returns A hash string that uniquely identifies this material configuration.\r\n */\r\n protected _createHash() {\r\n return `${super._createHash()}:${this._irFrag.hash}:${this._irVertex.hash}`;\r\n }\r\n /**\r\n * Creates the GPU program for this blueprint PBR material.\r\n *\r\n * @remarks\r\n * This calls the base implementation and returns its result.\r\n * Commented-out `console.log` lines are provided for debugging the\r\n * generated vertex and fragment shader sources.\r\n *\r\n * @param ctx - The current draw context.\r\n * @param pass - Index of the active render pass.\r\n * @returns The created GPU program.\r\n */\r\n protected createProgram(ctx: DrawContext, pass: number) {\r\n const program = super.createProgram(ctx, pass);\r\n //console.log(program.getShaderSource('vertex'));\r\n //console.log(program.getShaderSource('fragment'));\r\n return program;\r\n }\r\n /**\r\n * Disposes resources associated with this material.\r\n *\r\n * @remarks\r\n * - Calls the base `onDispose` to clean up inherited resources.\r\n * - Disposes all `finalTexture` references from the blueprint\r\n * texture uniform descriptors.\r\n *\r\n * This method is intended to be called by the engine's resource\r\n * management system rather than directly by user code.\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n for (const u of this._uniformTextures) {\r\n u.finalTexture!.dispose();\r\n }\r\n }\r\n /**\r\n * Retrieves a named output expression from a blueprint output list.\r\n *\r\n * @param outputs - The list of outputs generated by a blueprint graph.\r\n * @param name - The desired output name (e.g. `\"Position\"`, `\"Color\"`, `\"UV\"`).\r\n * @returns The expression associated with the given name, or `undefined` if not found.\r\n */\r\n private getOutput(\r\n outputs: {\r\n name: string;\r\n exp: number | boolean | PBShaderExp;\r\n }[],\r\n name: string\r\n ) {\r\n return outputs.find((output) => output.name === name)?.exp;\r\n }\r\n private applySubsurfaceScattering(\r\n scope: PBInsideFunctionScope,\r\n litColor: PBShaderExp,\r\n albedoRGB: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n scope.$l.NoV = pb.clamp(pb.dot(normal, viewVec), 0, 1);\r\n scope.$l.wrapNdotV = pb.clamp(\r\n pb.div(pb.add(pb.sub(1, scope.NoV), scope.zSubsurfaceScale), pb.add(1, scope.zSubsurfaceScale)),\r\n 0,\r\n 1\r\n );\r\n scope.$l.sssFactor = pb.mul(pb.pow(scope.wrapNdotV, scope.zSubsurfacePower), scope.zSubsurfaceIntensity);\r\n return pb.vec4(\r\n pb.add(litColor.rgb, pb.mul(albedoRGB, scope.zSubsurfaceColor, scope.sssFactor)),\r\n litColor.a\r\n );\r\n }\r\n}\r\n"],"names":["PBR_REFLECTION_MODE","none","ggx","anisotropic","glint","PBRBluePrintMaterial","applyMaterialMixins","MeshMaterial","mixinPBRBluePrint","FEATURE_VERTEX_COLOR","defineFeature","FEATURE_VERTEX_UV","FEATURE_SUBSURFACE_SCATTERING","irFrag","irVertex","uniformValues","uniformTextures","_irFrag","MaterialBlueprintIR","nodeMap","PBRBlockNode","roots","order","graph","incoming","outgoing","nodes","id","title","locked","node","ClassName","Object","links","_irVertex","VertexBlockNode","_uniformValues","_uniformTextures","_reflectionMode","_subsurfaceColor","Vector3","_subsurfaceScale","_subsurfacePower","_subsurfaceIntensity","_anisotropy","_anisotropyDirection","_anisotropyDirectionScaleBias","Vector2","useFeature","behaviors","useVertexColor","useVertexUV","reflectionMode","val","uniformChanged","subsurfaceScattering","featureUsed","subsurfaceColor","equalsTo","set","subsurfaceScale","subsurfacePower","subsurfaceIntensity","anisotropy","clamped","Math","max","min","anisotropyDirection","anisotropyDirectionScaleBias","fragmentIR","ir","clearCache","optionChanged","vertexIR","map","v","newUniforms","finalTexture","DRef","get","finalSampler","name","params","clone","Vector4","zero","texture","type","sRGB","wrapS","wrapT","inFragmentShader","inVertexShader","minFilter","magFilter","mipFilter","u","dispose","other","copyFrom","vertexShader","scope","pb","$builder","$inputs","zVertexPos","vec3","attrib","zVertexNormal","zVertexTangent","vec4","zVertexColor","zVertexUV","vec2","getGlobalScope","uniform","outputs","create","$l","oPos","getOutput","ShaderHelper","resolveVertexPosition","worldMatrix","getWorldMatrix","$outputs","worldPos","mul","xyz","csPos","getViewProjectionMatrix","setClipSpacePosition","oNorm","resolveVertexNormal","getNormalMatrix","oTangent","resolveVertexTangent","zVertexBinormal","cross","w","fragmentShader","needFragmentColor","drawContext","renderPass","RENDER_PASS_TYPE_LIGHT","zSubsurfaceColor","zSubsurfaceScale","float","zSubsurfacePower","zSubsurfaceIntensity","zAnisotropy","zAnisotropyDirection","zAnisotropyDirectionScaleBias","viewVec","calculateViewVector","commonData","getCommonDatasStruct","getCommonData","materialFlags","MaterialVaryingFlags","SSR_STORE_ROUGHNESS","outRoughness","litColor","PBRLight","applySubsurfaceScattering","albedo","rgb","normal","outputFragmentColor","add","applyUniformValues","bindGroup","ctx","pass","setValue","finalValue","setTexture","_createHash","hash","createProgram","program","onDispose","find","output","exp","albedoRGB","NoV","clamp","dot","wrapNdotV","div","sub","sssFactor","pow","a"],"mappings":";;;;;;;;AAYA,MAAMA,mBAAyD,GAAA;IAC7DC,IAAM,EAAA,CAAA;IACNC,GAAK,EAAA,CAAA;IACLC,WAAa,EAAA,CAAA;IACbC,KAAO,EAAA;AACT,CAAA;AAEA;;;;;;;;;;;;;;;;;;AAkBC,IACM,MAAMC,oBACHC,SAAAA,mBAAAA,CAAoBC,YAAcC,EAAAA,iBAAAA,CAAAA,CAAAA;AAG1C,qBACA,OAAwBC,oBAAAA,GAAuB,IAAI,CAACC,aAAa,EAAG;AACpE,qBACA,OAAwBC,iBAAAA,GAAoB,IAAI,CAACD,aAAa,EAAG;AACjE,qBACA,OAAwBE,6BAAAA,GAAgC,IAAI,CAACF,aAAa,EAAG;qBAE7E,OAAqC;qBAErC,SAAuC;qBAEvC,cAAgD;qBAEhD,gBAAoD;qBAEpD,eAA2C;qBAE3C,gBAA2C;qBAE3C,gBAAiC;qBAEjC,gBAAiC;qBAEjC,oBAAqC;qBAErC,WAA4B;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MAAMgD,oBAAoB,CAAA;QACvG,OAAO/C,EAAAA,CAAGQ,IAAI,CACZR,EAAAA,CAAGmE,GAAG,CAACP,QAAAA,CAASI,GAAG,EAAEhE,EAAAA,CAAGyB,GAAG,CAAC0D,SAAAA,EAAWpF,MAAM4C,gBAAgB,EAAE5C,MAAM2F,SAAS,CAAA,CAAA,EAC9E9B,SAASgC,CAAC,CAAA;AAEd;AACF;;;;"}
1
+ {"version":3,"file":"pbrblueprint.js","sources":["../../src/material/pbrblueprint.ts"],"sourcesContent":["import { MeshMaterial, applyMaterialMixins } from './meshmaterial';\r\nimport type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport { ShaderHelper } from './shader/helper';\r\nimport { MaterialVaryingFlags, RENDER_PASS_TYPE_LIGHT } from '../values';\r\nimport { DRef, Vector2, Vector3, Vector4, type Clonable, type Immutable } from '@zephyr3d/base';\r\nimport { mixinPBRBluePrint } from './mixins/lightmodel/pbrblueprintmixin';\r\nimport type { BluePrintUniformTexture, BluePrintUniformValue } from '../utility/blueprint/material/ir';\r\nimport { MaterialBlueprintIR } from '../utility/blueprint/material/ir';\r\nimport type { DrawContext } from '../render/drawable';\r\nimport { PBRBlockNode, VertexBlockNode } from '../utility/blueprint/material/pbr';\r\nimport type { PBRReflectionMode } from './mixins/lightmodel/pbrmetallicroughness';\r\n\r\nconst PBR_REFLECTION_MODE: Record<PBRReflectionMode, number> = {\r\n none: 0,\r\n ggx: 1,\r\n anisotropic: 2,\r\n glint: 3\r\n};\r\n\r\n/**\r\n * Physically-based rendering material driven by blueprint graphs.\r\n *\r\n * @remarks\r\n * This material extends {@link MeshMaterial} with PBR behavior via\r\n * {@link mixinPBRBluePrint}, and uses {@link MaterialBlueprintIR}\r\n * graphs for both vertex and fragment stages.\r\n *\r\n * - The **vertex blueprint IR** (`vertexIR`) controls vertex\r\n * transformations and per-vertex data.\r\n * - The **fragment blueprint IR** (`fragmentIR`) produces inputs\r\n * for the PBR shading model (albedo, roughness, metalness, etc.).\r\n *\r\n * Uniform values and textures for the blueprints are provided via\r\n * {@link PBRBluePrintMaterial.uniformValues} and\r\n * {@link PBRBluePrintMaterial.uniformTextures}.\r\n *\r\n * @public\r\n */\r\nexport class PBRBluePrintMaterial\r\n extends applyMaterialMixins(MeshMaterial, mixinPBRBluePrint)\r\n implements Clonable<PBRBluePrintMaterial>\r\n{\r\n /** @internal */\r\n private static readonly FEATURE_VERTEX_COLOR = this.defineFeature();\r\n /** @internal */\r\n private static readonly FEATURE_VERTEX_UV = this.defineFeature();\r\n /** @internal */\r\n private static readonly FEATURE_SUBSURFACE_SCATTERING = this.defineFeature();\r\n /** @internal */\r\n private _irFrag: MaterialBlueprintIR;\r\n /** @internal */\r\n private _irVertex: MaterialBlueprintIR;\r\n /** @internal */\r\n private _uniformValues: BluePrintUniformValue[];\r\n /** @internal */\r\n private _uniformTextures: BluePrintUniformTexture[];\r\n /** @internal */\r\n private _reflectionMode: PBRReflectionMode;\r\n /** @internal */\r\n private readonly _subsurfaceColor: Vector3;\r\n /** @internal */\r\n private _subsurfaceScale: number;\r\n /** @internal */\r\n private _subsurfacePower: number;\r\n /** @internal */\r\n private _subsurfaceIntensity: number;\r\n /** @internal */\r\n private _anisotropy: number;\r\n /** @internal */\r\n private _anisotropyDirection: number;\r\n /** @internal */\r\n private readonly _anisotropyDirectionScaleBias: Vector2;\r\n /**\r\n * Creates a new {@link PBRBluePrintMaterial} instance.\r\n *\r\n * @param irFrag - Optional fragment blueprint IR. If omitted, a default\r\n * IR containing a single {@link PBRBlockNode} is created.\r\n * @param irVertex - Optional vertex blueprint IR. If omitted, a default\r\n * IR containing a single {@link VertexBlockNode} is created.\r\n * @param uniformValues - Optional initial list of uniform value descriptors.\r\n * @param uniformTextures - Optional initial list of texture uniform descriptors.\r\n */\r\n constructor(\r\n irFrag?: MaterialBlueprintIR,\r\n irVertex?: MaterialBlueprintIR,\r\n uniformValues?: BluePrintUniformValue[],\r\n uniformTextures?: BluePrintUniformTexture[]\r\n ) {\r\n super();\r\n this._irFrag =\r\n irFrag ??\r\n new MaterialBlueprintIR(\r\n {\r\n nodeMap: { '1': new PBRBlockNode() },\r\n roots: [1],\r\n order: [1],\r\n graph: { incoming: {}, outgoing: {} }\r\n },\r\n '',\r\n {\r\n nodes: [{ id: 1, title: '', locked: true, node: { ClassName: 'PBRBlockNode', Object: '' } }],\r\n links: []\r\n }\r\n );\r\n this._irVertex =\r\n irVertex ??\r\n new MaterialBlueprintIR(\r\n {\r\n nodeMap: { '1': new VertexBlockNode() },\r\n roots: [1],\r\n order: [1],\r\n graph: { incoming: {}, outgoing: {} }\r\n },\r\n '',\r\n {\r\n nodes: [{ id: 1, title: '', locked: true, node: { ClassName: 'VertexBlockNode', Object: '' } }],\r\n links: []\r\n }\r\n );\r\n this._uniformValues = uniformValues ?? [];\r\n this._uniformTextures = uniformTextures ?? [];\r\n this._reflectionMode = 'ggx';\r\n this._subsurfaceColor = new Vector3(1, 0.3, 0.2);\r\n this._subsurfaceScale = 0.5;\r\n this._subsurfacePower = 1.5;\r\n this._subsurfaceIntensity = 0.5;\r\n this._anisotropy = 0.75;\r\n this._anisotropyDirection = 0;\r\n this._anisotropyDirectionScaleBias = new Vector2(1, 0);\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_SUBSURFACE_SCATTERING, false);\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_VERTEX_COLOR, this._irVertex.behaviors.useVertexColor);\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_VERTEX_UV, this._irVertex.behaviors.useVertexUV);\r\n }\r\n get reflectionMode() {\r\n return this._reflectionMode;\r\n }\r\n set reflectionMode(val: PBRReflectionMode) {\r\n if (val !== this._reflectionMode) {\r\n this._reflectionMode = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get subsurfaceScattering() {\r\n return this.featureUsed<boolean>(PBRBluePrintMaterial.FEATURE_SUBSURFACE_SCATTERING);\r\n }\r\n set subsurfaceScattering(val: boolean) {\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_SUBSURFACE_SCATTERING, !!val);\r\n }\r\n get subsurfaceColor(): Immutable<Vector3> {\r\n return this._subsurfaceColor;\r\n }\r\n set subsurfaceColor(val: Immutable<Vector3>) {\r\n if (!val.equalsTo(this._subsurfaceColor)) {\r\n this._subsurfaceColor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n get subsurfaceScale() {\r\n return this._subsurfaceScale;\r\n }\r\n set subsurfaceScale(val: number) {\r\n if (val !== this._subsurfaceScale) {\r\n this._subsurfaceScale = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get subsurfacePower() {\r\n return this._subsurfacePower;\r\n }\r\n set subsurfacePower(val: number) {\r\n if (val !== this._subsurfacePower) {\r\n this._subsurfacePower = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get subsurfaceIntensity() {\r\n return this._subsurfaceIntensity;\r\n }\r\n set subsurfaceIntensity(val: number) {\r\n if (val !== this._subsurfaceIntensity) {\r\n this._subsurfaceIntensity = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropy() {\r\n return this._anisotropy;\r\n }\r\n set anisotropy(val: number) {\r\n const clamped = Math.max(-0.95, Math.min(0.95, val));\r\n if (clamped !== this._anisotropy) {\r\n this._anisotropy = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirection() {\r\n return this._anisotropyDirection;\r\n }\r\n set anisotropyDirection(val: number) {\r\n if (val !== this._anisotropyDirection) {\r\n this._anisotropyDirection = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirectionScaleBias(): Immutable<Vector2> {\r\n return this._anisotropyDirectionScaleBias;\r\n }\r\n set anisotropyDirectionScaleBias(val: Immutable<Vector2>) {\r\n if (!val.equalsTo(this._anisotropyDirectionScaleBias)) {\r\n this._anisotropyDirectionScaleBias.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Gets the fragment blueprint IR.\r\n */\r\n get fragmentIR() {\r\n return this._irFrag;\r\n }\r\n set fragmentIR(ir: MaterialBlueprintIR) {\r\n if (ir && ir !== this._irFrag) {\r\n this._irFrag = ir;\r\n this.clearCache();\r\n this.optionChanged(true);\r\n }\r\n }\r\n /**\r\n * Gets the vertex blueprint IR.\r\n */\r\n get vertexIR() {\r\n return this._irVertex;\r\n }\r\n set vertexIR(ir: MaterialBlueprintIR) {\r\n if (ir && ir !== this._irVertex) {\r\n this._irVertex = ir;\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_VERTEX_COLOR, this._irVertex.behaviors.useVertexColor);\r\n this.useFeature(PBRBluePrintMaterial.FEATURE_VERTEX_UV, this._irVertex.behaviors.useVertexUV);\r\n this.clearCache();\r\n this.optionChanged(true);\r\n }\r\n }\r\n /**\r\n * Gets the list of uniform value descriptors used by the blueprints.\r\n */\r\n get uniformValues() {\r\n return this._uniformValues;\r\n }\r\n set uniformValues(val: BluePrintUniformValue[]) {\r\n this._uniformValues = (val ?? []).map((v) => ({ ...v }));\r\n this.uniformChanged();\r\n }\r\n /**\r\n * Gets the list of texture uniform descriptors used by the blueprints.\r\n */\r\n get uniformTextures() {\r\n return this._uniformTextures;\r\n }\r\n set uniformTextures(val: BluePrintUniformTexture[]) {\r\n if (val !== this._uniformTextures) {\r\n const newUniforms = val.map((v) => ({\r\n finalTexture: new DRef(v.finalTexture!.get()),\r\n finalSampler: v.finalSampler,\r\n name: v.name,\r\n params: v.params?.clone() ?? Vector4.zero(),\r\n texture: v.texture,\r\n type: v.type,\r\n sRGB: v.sRGB,\r\n wrapS: v.wrapS,\r\n wrapT: v.wrapT,\r\n inFragmentShader: v.inFragmentShader,\r\n inVertexShader: v.inVertexShader,\r\n minFilter: v.minFilter,\r\n magFilter: v.magFilter,\r\n mipFilter: v.mipFilter\r\n }));\r\n for (const u of this._uniformTextures) {\r\n u.finalTexture!.dispose();\r\n }\r\n this._uniformTextures = newUniforms;\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Creates a deep copy of this material.\r\n *\r\n * @remarks\r\n * The clone shares the same vertex/fragment IR references and copies\r\n * the current blueprint uniform descriptors, then calls `copyFrom`\r\n * to copy base-class and mixin state.\r\n *\r\n * @returns A new {@link PBRBluePrintMaterial} instance.\r\n */\r\n clone() {\r\n const other = new PBRBluePrintMaterial(\r\n this._irFrag,\r\n this._irVertex,\r\n this._uniformValues,\r\n this._uniformTextures\r\n );\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.reflectionMode = other.reflectionMode;\r\n this.subsurfaceScattering = other.subsurfaceScattering;\r\n this.subsurfaceColor = other.subsurfaceColor;\r\n this.subsurfaceScale = other.subsurfaceScale;\r\n this.subsurfacePower = other.subsurfacePower;\r\n this.subsurfaceIntensity = other.subsurfaceIntensity;\r\n this.anisotropy = other.anisotropy;\r\n this.anisotropyDirection = other.anisotropyDirection;\r\n this.anisotropyDirectionScaleBias = other.anisotropyDirectionScaleBias;\r\n }\r\n /**\r\n * Builds the vertex shader for this PBR blueprint material.\r\n *\r\n * @param scope - The current vertex shader function scope.\r\n */\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n const pb = scope.$builder;\r\n scope.$inputs.zVertexPos = pb.vec3().attrib('position');\r\n scope.$inputs.zVertexNormal = pb.vec3().attrib('normal');\r\n scope.$inputs.zVertexTangent = pb.vec4().attrib('tangent');\r\n if (this.featureUsed(PBRBluePrintMaterial.FEATURE_VERTEX_COLOR)) {\r\n scope.$inputs.zVertexColor = pb.vec4().attrib('diffuse');\r\n }\r\n if (this.featureUsed(PBRBluePrintMaterial.FEATURE_VERTEX_UV)) {\r\n scope.$inputs.zVertexUV = pb.vec2().attrib('texCoord0');\r\n }\r\n\r\n for (const u of [...this._uniformValues, ...this._uniformTextures]) {\r\n if (u.inVertexShader) {\r\n // @ts-ignore\r\n pb.getGlobalScope()[u.name] = pb[u.type]().uniform(2);\r\n }\r\n }\r\n const outputs = this._irVertex.create(pb)!;\r\n scope.$l.oPos = this.getOutput(outputs, 'Position') ?? ShaderHelper.resolveVertexPosition(scope);\r\n const worldMatrix = ShaderHelper.getWorldMatrix(scope);\r\n scope.$outputs.worldPos = pb.mul(worldMatrix, pb.vec4(scope.oPos, 1)).xyz;\r\n scope.$l.csPos = pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.worldPos, 1));\r\n ShaderHelper.setClipSpacePosition(scope, scope.csPos);\r\n scope.$outputs.zVertexColor =\r\n this.getOutput(outputs, 'Color') ??\r\n (this.featureUsed(PBRBluePrintMaterial.FEATURE_VERTEX_COLOR) ? scope.$inputs.zVertexColor : pb.vec4(1));\r\n scope.$outputs.zVertexUV =\r\n this.getOutput(outputs, 'UV') ??\r\n (this.featureUsed(PBRBluePrintMaterial.FEATURE_VERTEX_UV) ? scope.$inputs.zVertexUV : pb.vec2(0));\r\n scope.$l.oNorm = this.getOutput(outputs, 'Normal') ?? ShaderHelper.resolveVertexNormal(scope);\r\n scope.$outputs.zVertexNormal = pb.mul(ShaderHelper.getNormalMatrix(scope), pb.vec4(scope.oNorm, 0)).xyz;\r\n scope.$l.oTangent = this.getOutput(outputs, 'Tangent') ?? ShaderHelper.resolveVertexTangent(scope);\r\n scope.$outputs.zVertexTangent = pb.mul(\r\n ShaderHelper.getNormalMatrix(scope),\r\n pb.vec4(scope.oTangent.xyz, 0)\r\n ).xyz;\r\n scope.$outputs.zVertexBinormal = pb.mul(\r\n pb.cross(scope.$outputs.zVertexNormal, scope.$outputs.zVertexTangent),\r\n scope.oTangent.w\r\n );\r\n for (const outputName of ['Output1', 'Output2', 'Output3', 'Output4']) {\r\n const output = this.getOutput(outputs, outputName);\r\n if (output) {\r\n scope.$outputs[outputName] = output;\r\n }\r\n }\r\n }\r\n /**\r\n * Builds the fragment shader for this PBR blueprint material.\r\n *\r\n * @param scope - The current fragment shader function scope.\r\n */\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n const pb = scope.$builder;\r\n if (\r\n this.subsurfaceScattering &&\r\n this.needFragmentColor() &&\r\n this.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT\r\n ) {\r\n scope.zSubsurfaceColor = pb.vec3().uniform(2);\r\n scope.zSubsurfaceScale = pb.float().uniform(2);\r\n scope.zSubsurfacePower = pb.float().uniform(2);\r\n scope.zSubsurfaceIntensity = pb.float().uniform(2);\r\n }\r\n if (this.needFragmentColor()) {\r\n scope.zAnisotropy = pb.float().uniform(2);\r\n scope.zAnisotropyDirection = pb.float().uniform(2);\r\n scope.zAnisotropyDirectionScaleBias = pb.vec2().uniform(2);\r\n for (const u of [...this._uniformValues, ...this._uniformTextures]) {\r\n if (u.inFragmentShader) {\r\n // @ts-ignore\r\n pb.getGlobalScope()[u.name] = pb[u.type]().uniform(2);\r\n }\r\n }\r\n scope.$l.viewVec = this.calculateViewVector(scope, scope.$inputs.worldPos);\r\n scope.$l.commonData = this.getCommonDatasStruct(scope)();\r\n this.getCommonData(\r\n scope,\r\n scope.commonData,\r\n scope.viewVec,\r\n scope.$inputs.worldPos,\r\n scope.$inputs.zVertexNormal,\r\n scope.$inputs.zVertexTangent,\r\n scope.$inputs.zVertexBinormal,\r\n scope.$inputs.zVertexColor,\r\n scope.$inputs.zVertexUV,\r\n this._irFrag\r\n );\r\n if (this.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n if (this.drawContext.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS) {\r\n scope.$l.outRoughness = pb.vec4();\r\n scope.$l.litColor = this.PBRLight(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.viewVec,\r\n scope.commonData,\r\n scope.outRoughness\r\n );\r\n if (this.subsurfaceScattering) {\r\n scope.litColor = this.applySubsurfaceScattering(\r\n scope,\r\n scope.litColor,\r\n scope.commonData.albedo.rgb,\r\n scope.commonData.normal,\r\n scope.viewVec\r\n );\r\n }\r\n this.outputFragmentColor(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.litColor,\r\n scope.outRoughness,\r\n pb.vec4(pb.add(pb.mul(scope.commonData.normal, 0.5), pb.vec3(0.5)), 1)\r\n );\r\n } else {\r\n scope.$l.litColor = this.PBRLight(scope, scope.$inputs.worldPos, scope.viewVec, scope.commonData);\r\n if (this.subsurfaceScattering) {\r\n scope.litColor = this.applySubsurfaceScattering(\r\n scope,\r\n scope.litColor,\r\n scope.commonData.albedo.rgb,\r\n scope.commonData.normal,\r\n scope.viewVec\r\n );\r\n }\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.litColor);\r\n }\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.commonData.albedo);\r\n }\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, null);\r\n }\r\n }\r\n /**\r\n * Applies runtime uniform values and textures to the given bind group.\r\n *\r\n * @remarks\r\n * - Calls the base implementation first to bind standard mesh/PBR uniforms.\r\n * - If fragment color is needed for the current context, all blueprint\r\n * scalar/vector uniform values and textures are then bound by name.\r\n *\r\n * @param bindGroup - The bind group to which material resources are bound.\r\n * @param ctx - The current draw context.\r\n * @param pass - Index of the active render pass.\r\n */\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColor(ctx)) {\r\n bindGroup.setValue('zReflectionMode', PBR_REFLECTION_MODE[this._reflectionMode]);\r\n bindGroup.setValue('zAnisotropy', this._anisotropy);\r\n bindGroup.setValue('zAnisotropyDirection', this._anisotropyDirection);\r\n bindGroup.setValue('zAnisotropyDirectionScaleBias', this._anisotropyDirectionScaleBias);\r\n if (this.subsurfaceScattering && ctx.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n bindGroup.setValue('zSubsurfaceColor', this._subsurfaceColor);\r\n bindGroup.setValue('zSubsurfaceScale', this._subsurfaceScale);\r\n bindGroup.setValue('zSubsurfacePower', this._subsurfacePower);\r\n bindGroup.setValue('zSubsurfaceIntensity', this._subsurfaceIntensity);\r\n }\r\n }\r\n for (const u of this._uniformValues) {\r\n if (u.inVertexShader || this.needFragmentColor(ctx)) {\r\n bindGroup.setValue(u.name, u.finalValue!);\r\n }\r\n }\r\n for (const u of this._uniformTextures) {\r\n if (u.inVertexShader || this.needFragmentColor(ctx)) {\r\n bindGroup.setTexture(u.name, u.finalTexture!.get()!, u.finalSampler);\r\n }\r\n }\r\n }\r\n /**\r\n * Creates a unique hash string used for program caching.\r\n *\r\n * @remarks\r\n * The hash includes:\r\n * - The base material hash (`super._createHash()`).\r\n * - The fragment IR hash.\r\n * - The vertex IR hash.\r\n *\r\n * Different blueprint graphs will therefore produce different programs.\r\n *\r\n * @returns A hash string that uniquely identifies this material configuration.\r\n */\r\n protected _createHash() {\r\n return `${super._createHash()}:${this._irFrag.hash}:${this._irVertex.hash}`;\r\n }\r\n /**\r\n * Creates the GPU program for this blueprint PBR material.\r\n *\r\n * @remarks\r\n * This calls the base implementation and returns its result.\r\n * Commented-out `console.log` lines are provided for debugging the\r\n * generated vertex and fragment shader sources.\r\n *\r\n * @param ctx - The current draw context.\r\n * @param pass - Index of the active render pass.\r\n * @returns The created GPU program.\r\n */\r\n protected createProgram(ctx: DrawContext, pass: number) {\r\n const program = super.createProgram(ctx, pass);\r\n //console.log(program.getShaderSource('vertex'));\r\n //console.log(program.getShaderSource('fragment'));\r\n return program;\r\n }\r\n /**\r\n * Disposes resources associated with this material.\r\n *\r\n * @remarks\r\n * - Calls the base `onDispose` to clean up inherited resources.\r\n * - Disposes all `finalTexture` references from the blueprint\r\n * texture uniform descriptors.\r\n *\r\n * This method is intended to be called by the engine's resource\r\n * management system rather than directly by user code.\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n for (const u of this._uniformTextures) {\r\n u.finalTexture!.dispose();\r\n }\r\n }\r\n /**\r\n * Retrieves a named output expression from a blueprint output list.\r\n *\r\n * @param outputs - The list of outputs generated by a blueprint graph.\r\n * @param name - The desired output name (e.g. `\"Position\"`, `\"Color\"`, `\"UV\"`).\r\n * @returns The expression associated with the given name, or `undefined` if not found.\r\n */\r\n private getOutput(\r\n outputs: {\r\n name: string;\r\n exp: number | boolean | PBShaderExp;\r\n }[],\r\n name: string\r\n ) {\r\n return outputs.find((output) => output.name === name)?.exp;\r\n }\r\n private applySubsurfaceScattering(\r\n scope: PBInsideFunctionScope,\r\n litColor: PBShaderExp,\r\n albedoRGB: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n scope.$l.NoV = pb.clamp(pb.dot(normal, viewVec), 0, 1);\r\n scope.$l.wrapNdotV = pb.clamp(\r\n pb.div(pb.add(pb.sub(1, scope.NoV), scope.zSubsurfaceScale), pb.add(1, scope.zSubsurfaceScale)),\r\n 0,\r\n 1\r\n );\r\n scope.$l.sssFactor = pb.mul(pb.pow(scope.wrapNdotV, scope.zSubsurfacePower), scope.zSubsurfaceIntensity);\r\n return pb.vec4(\r\n pb.add(litColor.rgb, pb.mul(albedoRGB, scope.zSubsurfaceColor, scope.sssFactor)),\r\n litColor.a\r\n );\r\n }\r\n}\r\n"],"names":["PBR_REFLECTION_MODE","none","ggx","anisotropic","glint","PBRBluePrintMaterial","applyMaterialMixins","MeshMaterial","mixinPBRBluePrint","FEATURE_VERTEX_COLOR","defineFeature","FEATURE_VERTEX_UV","FEATURE_SUBSURFACE_SCATTERING","irFrag","irVertex","uniformValues","uniformTextures","_irFrag","MaterialBlueprintIR","nodeMap","PBRBlockNode","roots","order","graph","incoming","outgoing","nodes","id","title","locked","node","ClassName","Object","links","_irVertex","VertexBlockNode","_uniformValues","_uniformTextures","_reflectionMode","_subsurfaceColor","Vector3","_subsurfaceScale","_subsurfacePower","_subsurfaceIntensity","_anisotropy","_anisotropyDirection","_anisotropyDirectionScaleBias","Vector2","useFeature","behaviors","useVertexColor","useVertexUV","reflectionMode","val","uniformChanged","subsurfaceScattering","featureUsed","subsurfaceColor","equalsTo","set","subsurfaceScale","subsurfacePower","subsurfaceIntensity","anisotropy","clamped","Math","max","min","anisotropyDirection","anisotropyDirectionScaleBias","fragmentIR","ir","clearCache","optionChanged","vertexIR","map","v","newUniforms","finalTexture","DRef","get","finalSampler","name","params","clone","Vector4","zero","texture","type","sRGB","wrapS","wrapT","inFragmentShader","inVertexShader","minFilter","magFilter","mipFilter","u","dispose","other","copyFrom","vertexShader","scope","pb","$builder","$inputs","zVertexPos","vec3","attrib","zVertexNormal","zVertexTangent","vec4","zVertexColor","zVertexUV","vec2","getGlobalScope","uniform","outputs","create","$l","oPos","getOutput","ShaderHelper","resolveVertexPosition","worldMatrix","getWorldMatrix","$outputs","worldPos","mul","xyz","csPos","getViewProjectionMatrix","setClipSpacePosition","oNorm","resolveVertexNormal","getNormalMatrix","oTangent","resolveVertexTangent","zVertexBinormal","cross","w","outputName","output","fragmentShader","needFragmentColor","drawContext","renderPass","RENDER_PASS_TYPE_LIGHT","zSubsurfaceColor","zSubsurfaceScale","float","zSubsurfacePower","zSubsurfaceIntensity","zAnisotropy","zAnisotropyDirection","zAnisotropyDirectionScaleBias","viewVec","calculateViewVector","commonData","getCommonDatasStruct","getCommonData","materialFlags","MaterialVaryingFlags","SSR_STORE_ROUGHNESS","outRoughness","litColor","PBRLight","applySubsurfaceScattering","albedo","rgb","normal","outputFragmentColor","add","applyUniformValues","bindGroup","ctx","pass","setValue","finalValue","setTexture","_createHash","hash","createProgram","program","onDispose","find","exp","albedoRGB","NoV","clamp","dot","wrapNdotV","div","sub","sssFactor","pow","a"],"mappings":";;;;;;;;AAYA,MAAMA,mBAAyD,GAAA;IAC7DC,IAAM,EAAA,CAAA;IACNC,GAAK,EAAA,CAAA;IACLC,WAAa,EAAA,CAAA;IACbC,KAAO,EAAA;AACT,CAAA;AAEA;;;;;;;;;;;;;;;;;;AAkBC,IACM,MAAMC,oBACHC,SAAAA,mBAAAA,CAAoBC,YAAcC,EAAAA,iBAAAA,CAAAA,CAAAA;AAG1C,qB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