@zephyr3d/scene 0.9.0 → 0.9.1

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.
@@ -2,69 +2,69 @@ import { textToBase64 } from '@zephyr3d/base';
2
2
  import { init, parse } from '../node_modules/es-module-lexer/dist/lexer.js';
3
3
  import { getApp } from './api.js';
4
4
 
5
- /**
6
- * Converts JavaScript source to a data URL tied to a logical module id.
7
- *
8
- * @param js - The JavaScript source code to embed.
9
- * @param id - Logical module identifier (used only for sourceURL tagging).
10
- * @returns A `data:text/javascript;base64,...` URL with an encoded `#id` suffix.
11
- * @internal
5
+ /**
6
+ * Converts JavaScript source to a data URL tied to a logical module id.
7
+ *
8
+ * @param js - The JavaScript source code to embed.
9
+ * @param id - Logical module identifier (used only for sourceURL tagging).
10
+ * @returns A `data:text/javascript;base64,...` URL with an encoded `#id` suffix.
11
+ * @internal
12
12
  */ function toDataUrl(js, id) {
13
13
  const b64 = textToBase64(js);
14
14
  return `data:text/javascript;base64,${b64}#${encodeURIComponent(String(id))}`;
15
15
  }
16
- /**
17
- * Checks whether a specifier is an absolute HTTP(S) URL.
18
- * @internal
16
+ /**
17
+ * Checks whether a specifier is an absolute HTTP(S) URL.
18
+ * @internal
19
19
  */ function isAbsoluteUrl(spec) {
20
20
  return /^https?:\/\//i.test(spec);
21
21
  }
22
- /**
23
- * Checks whether a specifier is a special URL (data: or blob:).
24
- * @internal
22
+ /**
23
+ * Checks whether a specifier is a special URL (data: or blob:).
24
+ * @internal
25
25
  */ function isSpecialUrl(spec) {
26
26
  return /^(data|blob):/i.test(spec);
27
27
  }
28
- /**
29
- * Checks whether a specifier is a bare module (not starting with ./, ../, /, or #/).
30
- * @internal
28
+ /**
29
+ * Checks whether a specifier is a bare module (not starting with ./, ../, /, or #/).
30
+ * @internal
31
31
  */ function isBareModule(spec) {
32
32
  return !spec.startsWith('./') && !spec.startsWith('../') && !spec.startsWith('/') && !spec.startsWith('#/');
33
33
  }
34
- /**
35
- * Resolves, builds, and serves runtime modules using a VFS.
36
- *
37
- * Responsibilities:
38
- * - Resolve logical module IDs to physical paths or URLs.
39
- * - In editor mode, rewrite import specifiers and serve modules as data URLs after transpile.
40
- * - Transpile TypeScript to JavaScript on the fly (requires `window.ts` TypeScript runtime).
41
- * - Gather static and dynamic import dependencies for tooling.
42
- *
43
- * Modes:
44
- * - Editor mode (`editorMode === true`): modules are rewritten to data URLs after transpile/build.
45
- * - Runtime mode (`editorMode === false`): returns .js URLs directly (with .ts -\> .js mapping).
46
- *
47
- * Caching:
48
- * - Built modules are memoized in `_built` map keyed by logical ID.
49
- *
50
- * @public
34
+ /**
35
+ * Resolves, builds, and serves runtime modules using a VFS.
36
+ *
37
+ * Responsibilities:
38
+ * - Resolve logical module IDs to physical paths or URLs.
39
+ * - In editor mode, rewrite import specifiers and serve modules as data URLs after transpile.
40
+ * - Transpile TypeScript to JavaScript on the fly (requires `window.ts` TypeScript runtime).
41
+ * - Gather static and dynamic import dependencies for tooling.
42
+ *
43
+ * Modes:
44
+ * - Editor mode (`editorMode === true`): modules are rewritten to data URLs after transpile/build.
45
+ * - Runtime mode (`editorMode === false`): returns .js URLs directly (with .ts -\> .js mapping).
46
+ *
47
+ * Caching:
48
+ * - Built modules are memoized in `_built` map keyed by logical ID.
49
+ *
50
+ * @public
51
51
  */ class ScriptRegistry {
52
52
  _vfs;
53
53
  _scriptsRoot;
54
54
  _built;
55
- /**
56
- * @param vfs - The virtual file system for existence checks, reads, and path ops.
57
- * @param scriptsRoot - Root directory for script resolution (used with `#/` specifiers).
58
- * @param editorMode - Whether to build modules to data URLs and rewrite imports.
55
+ /**
56
+ * @param vfs - The virtual file system for existence checks, reads, and path ops.
57
+ * @param scriptsRoot - Root directory for script resolution (used with `#/` specifiers).
58
+ * @param editorMode - Whether to build modules to data URLs and rewrite imports.
59
59
  */ constructor(vfs, scriptsRoot){
60
60
  this._vfs = vfs;
61
61
  this._scriptsRoot = scriptsRoot;
62
62
  this._built = new Map();
63
63
  }
64
- /**
65
- * The active virtual file system.
66
- *
67
- * Assigning a new VFS clears the build cache.
64
+ /**
65
+ * The active virtual file system.
66
+ *
67
+ * Assigning a new VFS clears the build cache.
68
68
  */ get VFS() {
69
69
  return this._vfs;
70
70
  }
@@ -74,23 +74,23 @@ import { getApp } from './api.js';
74
74
  this._built.clear();
75
75
  }
76
76
  }
77
- /**
78
- * The root path used by `#/` specifiers.
77
+ /**
78
+ * The root path used by `#/` specifiers.
79
79
  */ get scriptsRoot() {
80
80
  return this._scriptsRoot;
81
81
  }
82
82
  set scriptsRoot(path) {
83
83
  this._scriptsRoot = path;
84
84
  }
85
- /**
86
- * Fetches raw source for a logical module id by probing known extensions.
87
- *
88
- * Search order:
89
- * - If `id` already ends with `.ts` or `.js` and is a file -\> return it.
90
- * - Else try `.id.ts`, then `.id.js`.
91
- *
92
- * @param id - Logical module identifier (absolute or logical path-like).
93
- * @returns Source code, resolved path, and type (`'js' | 'ts'`), or `undefined` if not found.
85
+ /**
86
+ * Fetches raw source for a logical module id by probing known extensions.
87
+ *
88
+ * Search order:
89
+ * - If `id` already ends with `.ts` or `.js` and is a file -\> return it.
90
+ * - Else try `.id.ts`, then `.id.js`.
91
+ *
92
+ * @param id - Logical module identifier (absolute or logical path-like).
93
+ * @returns Source code, resolved path, and type (`'js' | 'ts'`), or `undefined` if not found.
94
94
  */ async fetchSource(id) {
95
95
  let type = null;
96
96
  let pathWithExt = '';
@@ -139,18 +139,18 @@ import { getApp } from './api.js';
139
139
  };
140
140
  }
141
141
  }
142
- /**
143
- * Resolves a module entry to a URL suitable for dynamic import.
144
- *
145
- * Behavior:
146
- * - In editor mode, builds the module to a data URL.
147
- * - Otherwise, returns `.js` URL directly:
148
- * - If `id` ends with `.js`: return as-is.
149
- * - If `id` ends with `.ts`: map to `.js` (assumes pre-built file exists).
150
- * - Else: append `.js`.
151
- *
152
- * @param entryId - Entry module identifier (logical or path-like).
153
- * @returns A URL string that can be used in `import(...)`.
142
+ /**
143
+ * Resolves a module entry to a URL suitable for dynamic import.
144
+ *
145
+ * Behavior:
146
+ * - In editor mode, builds the module to a data URL.
147
+ * - Otherwise, returns `.js` URL directly:
148
+ * - If `id` ends with `.js`: return as-is.
149
+ * - If `id` ends with `.ts`: map to `.js` (assumes pre-built file exists).
150
+ * - Else: append `.js`.
151
+ *
152
+ * @param entryId - Entry module identifier (logical or path-like).
153
+ * @returns A URL string that can be used in `import(...)`.
154
154
  */ async resolveRuntimeUrl(entryId) {
155
155
  const id = await this.resolveLogicalId(entryId);
156
156
  if (id.startsWith('/assets/@builtins/')) {
@@ -158,15 +158,15 @@ import { getApp } from './api.js';
158
158
  }
159
159
  return getApp().editorMode !== 'none' ? await this.build(String(id)) : id.endsWith('.js') ? id : id.endsWith('.ts') ? `${id.slice(0, -3)}.js` : `${id}.js`;
160
160
  }
161
- /**
162
- * Recursively gathers direct static and dynamic import dependencies for a module.
163
- *
164
- * Only relative specifiers (`./` or `../`) are followed. Absolute, special, and bare
165
- * module specifiers are ignored here.
166
- *
167
- * @param entryId - The starting (possibly relative) specifier from `fromId`.
168
- * @param fromId - The logical id of the module containing `entryId`.
169
- * @param dependencies - Output map of `resolvedSourcePath -\> file contents`.
161
+ /**
162
+ * Recursively gathers direct static and dynamic import dependencies for a module.
163
+ *
164
+ * Only relative specifiers (`./` or `../`) are followed. Absolute, special, and bare
165
+ * module specifiers are ignored here.
166
+ *
167
+ * @param entryId - The starting (possibly relative) specifier from `fromId`.
168
+ * @param fromId - The logical id of the module containing `entryId`.
169
+ * @param dependencies - Output map of `resolvedSourcePath -\> file contents`.
170
170
  */ async getDependencies(entryId, fromId, dependencies) {
171
171
  const reStatic = /\b(?:import|export)\s+[^"']*?from\s+(['"])([^'"]+)\1/g;
172
172
  const reDynamic = /\bimport\s*\(\s*(['"])([^'"]+)\1\s*\)/g;
@@ -194,18 +194,18 @@ import { getApp } from './api.js';
194
194
  await gather(code, reStatic);
195
195
  await gather(code, reDynamic);
196
196
  }
197
- /**
198
- * Builds a logical module id into a data URL (editor mode pipeline).
199
- *
200
- * Steps:
201
- * - Resolve source path (.ts/.js) via {@link ScriptRegistry.resolveSourcePath}.
202
- * - Read source code.
203
- * - Rewrite import specifiers via {@link ScriptRegistry.rewriteImports}.
204
- * - Transpile TypeScript if needed via {@link ScriptRegistry.transpile}.
205
- * - Convert to `data:` URL and memoize in `_built`.
206
- *
207
- * @param id - Logical module id to build.
208
- * @returns Data URL string for dynamic import, or empty string if not found.
197
+ /**
198
+ * Builds a logical module id into a data URL (editor mode pipeline).
199
+ *
200
+ * Steps:
201
+ * - Resolve source path (.ts/.js) via {@link ScriptRegistry.resolveSourcePath}.
202
+ * - Read source code.
203
+ * - Rewrite import specifiers via {@link ScriptRegistry.rewriteImports}.
204
+ * - Transpile TypeScript if needed via {@link ScriptRegistry.transpile}.
205
+ * - Convert to `data:` URL and memoize in `_built`.
206
+ *
207
+ * @param id - Logical module id to build.
208
+ * @returns Data URL string for dynamic import, or empty string if not found.
209
209
  */ async build(id) {
210
210
  const key = String(id);
211
211
  const cached = this._built.get(key);
@@ -225,19 +225,19 @@ import { getApp } from './api.js';
225
225
  this._built.set(key, url);
226
226
  return url;
227
227
  }
228
- /**
229
- * Transpiles code to JavaScript and appends sourceURL/sourceMap hints.
230
- *
231
- * Behavior:
232
- * - For `'js'`, returns code with `//# sourceURL=logicalId`.
233
- * - For `'ts'`, requires `window.ts` (TypeScript compiler) to be present and
234
- * transpiles to ES2015/ESNext module with inline source maps.
235
- *
236
- * @param code - Source code to transpile.
237
- * @param _id - Logical module id (used for fileName/sourceURL).
238
- * @param type - Source type (`'js' | 'ts'`).
239
- * @returns Transpiled JavaScript source.
240
- * @throws If TypeScript runtime is not found for TS input.
228
+ /**
229
+ * Transpiles code to JavaScript and appends sourceURL/sourceMap hints.
230
+ *
231
+ * Behavior:
232
+ * - For `'js'`, returns code with `//# sourceURL=logicalId`.
233
+ * - For `'ts'`, requires `window.ts` (TypeScript compiler) to be present and
234
+ * transpiles to ES2015/ESNext module with inline source maps.
235
+ *
236
+ * @param code - Source code to transpile.
237
+ * @param _id - Logical module id (used for fileName/sourceURL).
238
+ * @param type - Source type (`'js' | 'ts'`).
239
+ * @returns Transpiled JavaScript source.
240
+ * @throws If TypeScript runtime is not found for TS input.
241
241
  */ async transpile(code, _id, type) {
242
242
  const logicalId = String(_id);
243
243
  if (type === 'js') {
@@ -266,26 +266,26 @@ import { getApp } from './api.js';
266
266
  out += `\n//# sourceURL=${logicalId}`;
267
267
  return out;
268
268
  }
269
- /**
270
- * Rewrites ESM import specifiers in `code` into runtime-loadable URLs.
271
- *
272
- * Parsing:
273
- * - Uses `es-module-lexer` to find import spans; sorts them ascending by start.
274
- *
275
- * Replacement rules:
276
- * - Skip invalid spans or ones without quoted specifiers.
277
- * - If spec is absolute URL, special URL (data:, blob:), or bare module:
278
- * - If it starts with `@zephyr3d/`, keep as-is (external).
279
- * - Otherwise resolve to a logical id and attempt to `build` it (if available).
280
- * - Else (relative spec), resolve from `fromId` and `build` recursively.
281
- *
282
- * Output:
283
- * - Directly writes the replacement specifier without re-adding quotes,
284
- * so replacements must themselves be quoted or be valid URLs/data URLs.
285
- *
286
- * @param code - Module source code to transform.
287
- * @param fromId - The logical id of the current module (resolution base for relatives).
288
- * @returns Transformed source with rewritten import specifiers.
269
+ /**
270
+ * Rewrites ESM import specifiers in `code` into runtime-loadable URLs.
271
+ *
272
+ * Parsing:
273
+ * - Uses `es-module-lexer` to find import spans; sorts them ascending by start.
274
+ *
275
+ * Replacement rules:
276
+ * - Skip invalid spans or ones without quoted specifiers.
277
+ * - If spec is absolute URL, special URL (data:, blob:), or bare module:
278
+ * - If it starts with `@zephyr3d/`, keep as-is (external).
279
+ * - Otherwise resolve to a logical id and attempt to `build` it (if available).
280
+ * - Else (relative spec), resolve from `fromId` and `build` recursively.
281
+ *
282
+ * Output:
283
+ * - Directly writes the replacement specifier without re-adding quotes,
284
+ * so replacements must themselves be quoted or be valid URLs/data URLs.
285
+ *
286
+ * @param code - Module source code to transform.
287
+ * @param fromId - The logical id of the current module (resolution base for relatives).
288
+ * @returns Transformed source with rewritten import specifiers.
289
289
  */ async rewriteImports(code, fromId) {
290
290
  await init;
291
291
  const [imports] = parse(code);
@@ -331,21 +331,21 @@ import { getApp } from './api.js';
331
331
  out += code.slice(last);
332
332
  return out;
333
333
  }
334
- /**
335
- * Resolves a specifier to a logical id suitable for further processing.
336
- *
337
- * Resolution rules:
338
- * - `#/path`: resolved against `scriptsRoot` via VFS join/normalize.
339
- * - `./` or `../`: resolved relative to `fromId` directory (requires `fromId`).
340
- * - `/absolute`: treated as absolute from root (normalized).
341
- * - Bare module in editor mode: if `/deps.lock.json` exists and contains an entry,
342
- * map to the dependency's `entry` path; otherwise return as-is.
343
- * - Else (non-editor bare module): return `spec` unchanged (external).
344
- *
345
- * @param spec - Import specifier string.
346
- * @param fromId - Optional base logical id used for relative resolution.
347
- * @returns A normalized logical id or an external specifier string.
348
- * @throws If a relative import is provided without `fromId`.
334
+ /**
335
+ * Resolves a specifier to a logical id suitable for further processing.
336
+ *
337
+ * Resolution rules:
338
+ * - `#/path`: resolved against `scriptsRoot` via VFS join/normalize.
339
+ * - `./` or `../`: resolved relative to `fromId` directory (requires `fromId`).
340
+ * - `/absolute`: treated as absolute from root (normalized).
341
+ * - Bare module in editor mode: if `/deps.lock.json` exists and contains an entry,
342
+ * map to the dependency's `entry` path; otherwise return as-is.
343
+ * - Else (non-editor bare module): return `spec` unchanged (external).
344
+ *
345
+ * @param spec - Import specifier string.
346
+ * @param fromId - Optional base logical id used for relative resolution.
347
+ * @returns A normalized logical id or an external specifier string.
348
+ * @throws If a relative import is provided without `fromId`.
349
349
  */ async resolveLogicalId(spec, fromId) {
350
350
  if (spec.startsWith('#/')) {
351
351
  return this._vfs.normalizePath(this._vfs.join(this._scriptsRoot, spec.slice(2)));
@@ -373,16 +373,16 @@ import { getApp } from './api.js';
373
373
  }
374
374
  return spec;
375
375
  }
376
- /**
377
- * Resolves a logical id to a concrete source path and type by probing extensions.
378
- *
379
- * Rules:
380
- * - If `logicalId` ends with `.ts` or `.js`/`.mjs` and is a file, return it.
381
- * - Else probe `logicalId.ts`, `logicalId.js`, `logicalId.mjs` in that order.
382
- * - Maps `.mjs` to type `'js'`.
383
- *
384
- * @param logicalId - The normalized logical module id (path-like).
385
- * @returns `{ type, path }` or `null` if not found.
376
+ /**
377
+ * Resolves a logical id to a concrete source path and type by probing extensions.
378
+ *
379
+ * Rules:
380
+ * - If `logicalId` ends with `.ts` or `.js`/`.mjs` and is a file, return it.
381
+ * - Else probe `logicalId.ts`, `logicalId.js`, `logicalId.mjs` in that order.
382
+ * - Maps `.mjs` to type `'js'`.
383
+ *
384
+ * @param logicalId - The normalized logical module id (path-like).
385
+ * @returns `{ type, path }` or `null` if not found.
386
386
  */ async resolveSourcePath(logicalId) {
387
387
  let type = null;
388
388
  let pathWithExt = '';
@@ -1 +1 @@
1
- {"version":3,"file":"scriptregistry.js","sources":["../../src/app/scriptregistry.ts"],"sourcesContent":["import type * as TS from 'typescript';\nimport type { Nullable, VFS } from '@zephyr3d/base';\nimport { textToBase64 } from '@zephyr3d/base';\nimport { init, parse } from 'es-module-lexer';\nimport { getApp } from './api';\n\n/**\n * Converts JavaScript source to a data URL tied to a logical module id.\n *\n * @param js - The JavaScript source code to embed.\n * @param id - Logical module identifier (used only for sourceURL tagging).\n * @returns A `data:text/javascript;base64,...` URL with an encoded `#id` suffix.\n * @internal\n */\nfunction toDataUrl(js: string, id: string) {\n const b64 = textToBase64(js);\n return `data:text/javascript;base64,${b64}#${encodeURIComponent(String(id))}`;\n}\n\n/**\n * Checks whether a specifier is an absolute HTTP(S) URL.\n * @internal\n */\nfunction isAbsoluteUrl(spec: string) {\n return /^https?:\\/\\//i.test(spec);\n}\n\n/**\n * Checks whether a specifier is a special URL (data: or blob:).\n * @internal\n */\nfunction isSpecialUrl(spec: string) {\n return /^(data|blob):/i.test(spec);\n}\n\n/**\n * Checks whether a specifier is a bare module (not starting with ./, ../, /, or #/).\n * @internal\n */\nfunction isBareModule(spec: string) {\n return !spec.startsWith('./') && !spec.startsWith('../') && !spec.startsWith('/') && !spec.startsWith('#/');\n}\n\n/**\n * Resolves, builds, and serves runtime modules using a VFS.\n *\n * Responsibilities:\n * - Resolve logical module IDs to physical paths or URLs.\n * - In editor mode, rewrite import specifiers and serve modules as data URLs after transpile.\n * - Transpile TypeScript to JavaScript on the fly (requires `window.ts` TypeScript runtime).\n * - Gather static and dynamic import dependencies for tooling.\n *\n * Modes:\n * - Editor mode (`editorMode === true`): modules are rewritten to data URLs after transpile/build.\n * - Runtime mode (`editorMode === false`): returns .js URLs directly (with .ts -\\> .js mapping).\n *\n * Caching:\n * - Built modules are memoized in `_built` map keyed by logical ID.\n *\n * @public\n */\nexport class ScriptRegistry {\n private _vfs: VFS;\n private _scriptsRoot: string;\n private _built: Map<string, string>; // logicalId -> dataURL\n\n /**\n * @param vfs - The virtual file system for existence checks, reads, and path ops.\n * @param scriptsRoot - Root directory for script resolution (used with `#/` specifiers).\n * @param editorMode - Whether to build modules to data URLs and rewrite imports.\n */\n constructor(vfs: VFS, scriptsRoot: string) {\n this._vfs = vfs;\n this._scriptsRoot = scriptsRoot;\n this._built = new Map();\n }\n\n /**\n * The active virtual file system.\n *\n * Assigning a new VFS clears the build cache.\n */\n get VFS() {\n return this._vfs;\n }\n set VFS(vfs: VFS) {\n if (vfs !== this._vfs) {\n this._vfs = vfs;\n this._built.clear();\n }\n }\n\n /**\n * The root path used by `#/` specifiers.\n */\n get scriptsRoot() {\n return this._scriptsRoot;\n }\n set scriptsRoot(path: string) {\n this._scriptsRoot = path;\n }\n\n /**\n * Fetches raw source for a logical module id by probing known extensions.\n *\n * Search order:\n * - If `id` already ends with `.ts` or `.js` and is a file -\\> return it.\n * - Else try `.id.ts`, then `.id.js`.\n *\n * @param id - Logical module identifier (absolute or logical path-like).\n * @returns Source code, resolved path, and type (`'js' | 'ts'`), or `undefined` if not found.\n */\n protected async fetchSource(id: string) {\n let type: Nullable<'js' | 'ts'> = null;\n let pathWithExt = '';\n if (id.endsWith('.ts')) {\n pathWithExt = id;\n type = 'ts';\n } else if (id.endsWith('.js')) {\n pathWithExt = id;\n type = 'js';\n }\n if (type) {\n const exists = await this._vfs.exists(pathWithExt);\n if (!exists) {\n type = null;\n }\n const stat = await this._vfs.stat(pathWithExt);\n if (stat.isDirectory) {\n type = null;\n }\n }\n const types = ['ts', 'js'] as const;\n if (!type) {\n for (const t of types) {\n pathWithExt = `${id}.${t}`;\n const exists = await this._vfs.exists(pathWithExt);\n if (exists) {\n const stats = await this._vfs.stat(pathWithExt);\n if (stats.isFile) {\n type = t;\n break;\n }\n }\n }\n }\n if (type) {\n const code = (await this._vfs.readFile(pathWithExt, { encoding: 'utf8' })) as string;\n return { code, type, path: pathWithExt };\n }\n }\n\n /**\n * Resolves a module entry to a URL suitable for dynamic import.\n *\n * Behavior:\n * - In editor mode, builds the module to a data URL.\n * - Otherwise, returns `.js` URL directly:\n * - If `id` ends with `.js`: return as-is.\n * - If `id` ends with `.ts`: map to `.js` (assumes pre-built file exists).\n * - Else: append `.js`.\n *\n * @param entryId - Entry module identifier (logical or path-like).\n * @returns A URL string that can be used in `import(...)`.\n */\n async resolveRuntimeUrl(entryId: string) {\n const id = await this.resolveLogicalId(entryId);\n if (id.startsWith('/assets/@builtins/')) {\n return await this.build(String(id));\n }\n return getApp().editorMode !== 'none'\n ? await this.build(String(id))\n : id.endsWith('.js')\n ? id\n : id.endsWith('.ts')\n ? `${id.slice(0, -3)}.js`\n : `${id}.js`;\n }\n\n /**\n * Recursively gathers direct static and dynamic import dependencies for a module.\n *\n * Only relative specifiers (`./` or `../`) are followed. Absolute, special, and bare\n * module specifiers are ignored here.\n *\n * @param entryId - The starting (possibly relative) specifier from `fromId`.\n * @param fromId - The logical id of the module containing `entryId`.\n * @param dependencies - Output map of `resolvedSourcePath -\\> file contents`.\n */\n async getDependencies(entryId: string, fromId: string, dependencies: Record<string, string>) {\n const reStatic = /\\b(?:import|export)\\s+[^\"']*?from\\s+(['\"])([^'\"]+)\\1/g;\n const reDynamic = /\\bimport\\s*\\(\\s*(['\"])([^'\"]+)\\1\\s*\\)/g;\n\n const normalizedId = await this.resolveLogicalId(entryId, fromId);\n const srcPath = await this.resolveSourcePath(normalizedId);\n if (!srcPath || dependencies[srcPath.path] !== undefined) {\n return;\n }\n const code = (await this._vfs.readFile(srcPath.path, { encoding: 'utf8' })) as string;\n dependencies[srcPath.path] = code;\n\n const gather = async (input: string, re: RegExp) => {\n for (;;) {\n const m = re.exec(input);\n if (!m) {\n break;\n }\n\n const spec = m[2];\n\n if (spec.startsWith('./') || spec.startsWith('../')) {\n await this.getDependencies(spec, normalizedId, dependencies);\n }\n }\n };\n\n await gather(code, reStatic);\n await gather(code, reDynamic);\n }\n\n /**\n * Builds a logical module id into a data URL (editor mode pipeline).\n *\n * Steps:\n * - Resolve source path (.ts/.js) via {@link ScriptRegistry.resolveSourcePath}.\n * - Read source code.\n * - Rewrite import specifiers via {@link ScriptRegistry.rewriteImports}.\n * - Transpile TypeScript if needed via {@link ScriptRegistry.transpile}.\n * - Convert to `data:` URL and memoize in `_built`.\n *\n * @param id - Logical module id to build.\n * @returns Data URL string for dynamic import, or empty string if not found.\n */\n private async build(id: string) {\n const key = String(id);\n const cached = this._built.get(key);\n if (cached) {\n return cached;\n }\n\n const srcPath = await this.resolveSourcePath(key);\n if (!srcPath) {\n return '';\n }\n const code = (await this._vfs.readFile(srcPath.path, { encoding: 'utf8' })) as string;\n\n const rewritten = await this.rewriteImports(code, key);\n const js = await this.transpile(rewritten, key, srcPath.type);\n const url = toDataUrl(js, key);\n this._built.set(key, url);\n return url;\n }\n\n /**\n * Transpiles code to JavaScript and appends sourceURL/sourceMap hints.\n *\n * Behavior:\n * - For `'js'`, returns code with `//# sourceURL=logicalId`.\n * - For `'ts'`, requires `window.ts` (TypeScript compiler) to be present and\n * transpiles to ES2015/ESNext module with inline source maps.\n *\n * @param code - Source code to transpile.\n * @param _id - Logical module id (used for fileName/sourceURL).\n * @param type - Source type (`'js' | 'ts'`).\n * @returns Transpiled JavaScript source.\n * @throws If TypeScript runtime is not found for TS input.\n */\n private async transpile(code: string, _id: string, type: 'js' | 'ts') {\n const logicalId = String(_id);\n\n if (type === 'js') {\n return `${code}\\n//# sourceURL=${logicalId}`;\n }\n\n const ts = (window as any).ts as typeof TS;\n if (!ts) {\n throw new Error('TypeScript runtime (window.ts) not found. Load typescript.js first.');\n }\n\n const res = ts.transpileModule(code, {\n compilerOptions: {\n target: ts.ScriptTarget.ES2015,\n module: ts.ModuleKind.ESNext,\n sourceMap: true,\n inlineSources: true,\n experimentalDecorators: true,\n useDefineForClassFields: false\n },\n fileName: logicalId\n });\n\n let out = res.outputText || '';\n if (res.sourceMapText) {\n const mapBase64 = btoa(unescape(encodeURIComponent(res.sourceMapText)));\n out += `\\n//# sourceMappingURL=data:application/json;base64,${mapBase64}`;\n }\n out += `\\n//# sourceURL=${logicalId}`;\n return out;\n }\n\n /**\n * Rewrites ESM import specifiers in `code` into runtime-loadable URLs.\n *\n * Parsing:\n * - Uses `es-module-lexer` to find import spans; sorts them ascending by start.\n *\n * Replacement rules:\n * - Skip invalid spans or ones without quoted specifiers.\n * - If spec is absolute URL, special URL (data:, blob:), or bare module:\n * - If it starts with `@zephyr3d/`, keep as-is (external).\n * - Otherwise resolve to a logical id and attempt to `build` it (if available).\n * - Else (relative spec), resolve from `fromId` and `build` recursively.\n *\n * Output:\n * - Directly writes the replacement specifier without re-adding quotes,\n * so replacements must themselves be quoted or be valid URLs/data URLs.\n *\n * @param code - Module source code to transform.\n * @param fromId - The logical id of the current module (resolution base for relatives).\n * @returns Transformed source with rewritten import specifiers.\n */\n private async rewriteImports(code: string, fromId: string) {\n await init;\n const [imports] = parse(code);\n const list = [...imports].sort((a, b) => (a.s || 0) - (b.s || 0));\n let out = '';\n let last = 0;\n\n for (const im of list) {\n // Skip import.meta entries reported by es-module-lexer.\n // Their \"specifier\" span points to the whole \"import.meta\" expression,\n // which must remain untouched.\n if (im.d === -2) {\n continue;\n }\n // must have quotes\n const hasQuote = im.ss != null && im.se != null;\n if (!hasQuote || im.se <= im.ss) {\n continue;\n }\n // must have contents\n if (im.e <= im.s) {\n continue;\n }\n // append [last, s)\n out += code.slice(last, im.s);\n\n const spec = code.slice(im.s, im.e); // original spec\n let replacement = spec;\n if (isAbsoluteUrl(spec) || isSpecialUrl(spec) || isBareModule(spec)) {\n if (spec.startsWith('@zephyr3d/')) {\n replacement = spec;\n } else {\n const depId = await this.resolveLogicalId(spec);\n replacement = await this.build(depId); // try build as dependence\n }\n } else {\n const depId = await this.resolveLogicalId(spec, String(fromId));\n replacement = await this.build(depId); // recursively build as dataURL\n }\n out += replacement; // 不加引号\n last = im.e;\n }\n out += code.slice(last);\n return out;\n }\n\n /**\n * Resolves a specifier to a logical id suitable for further processing.\n *\n * Resolution rules:\n * - `#/path`: resolved against `scriptsRoot` via VFS join/normalize.\n * - `./` or `../`: resolved relative to `fromId` directory (requires `fromId`).\n * - `/absolute`: treated as absolute from root (normalized).\n * - Bare module in editor mode: if `/deps.lock.json` exists and contains an entry,\n * map to the dependency's `entry` path; otherwise return as-is.\n * - Else (non-editor bare module): return `spec` unchanged (external).\n *\n * @param spec - Import specifier string.\n * @param fromId - Optional base logical id used for relative resolution.\n * @returns A normalized logical id or an external specifier string.\n * @throws If a relative import is provided without `fromId`.\n */\n async resolveLogicalId(spec: string, fromId?: string) {\n if (spec.startsWith('#/')) {\n return this._vfs.normalizePath(this._vfs.join(this._scriptsRoot, spec.slice(2)));\n } else if (spec.startsWith('./') || spec.startsWith('../')) {\n if (!fromId) {\n throw new Error(`Relative import \"${spec}\" requires fromId`);\n }\n return this._vfs.normalizePath(\n this._vfs.join(this._vfs.dirname(this._vfs.normalizePath(fromId)), spec)\n );\n } else if (spec.startsWith('/')) {\n return spec.replace(/^\\/+/, '/');\n } else if (getApp().editorMode !== 'none') {\n const libRoot = '/';\n // naked module, checking if it is a installed module in editor mode\n let depsLockPath = this._vfs.normalizePath(this._vfs.join(libRoot, 'libs/deps.lock.json'));\n let depsExists = await this._vfs.exists(depsLockPath);\n if (depsExists) {\n const content = (await this._vfs.readFile(depsLockPath, { encoding: 'utf8' })) as string;\n const depsInfo = JSON.parse(content) as { dependencies: Record<string, { entry: string }> };\n if (depsInfo?.dependencies[spec]) {\n return this._vfs.normalizePath(this._vfs.join(libRoot, depsInfo.dependencies[spec].entry));\n }\n }\n }\n return spec;\n }\n\n /**\n * Resolves a logical id to a concrete source path and type by probing extensions.\n *\n * Rules:\n * - If `logicalId` ends with `.ts` or `.js`/`.mjs` and is a file, return it.\n * - Else probe `logicalId.ts`, `logicalId.js`, `logicalId.mjs` in that order.\n * - Maps `.mjs` to type `'js'`.\n *\n * @param logicalId - The normalized logical module id (path-like).\n * @returns `{ type, path }` or `null` if not found.\n */\n async resolveSourcePath(logicalId: string) {\n let type: Nullable<'js' | 'ts'> = null;\n let pathWithExt = '';\n if (logicalId.endsWith('.ts')) {\n pathWithExt = logicalId;\n type = 'ts';\n } else if (logicalId.endsWith('.js') || logicalId.endsWith('.mjs')) {\n pathWithExt = logicalId;\n type = 'js';\n }\n if (type) {\n const exists = await this._vfs.exists(pathWithExt);\n if (!exists) {\n type = null;\n }\n const stat = await this._vfs.stat(pathWithExt);\n if (stat.isDirectory) {\n type = null;\n }\n }\n const types = ['ts', 'js', 'mjs'] as const;\n if (!type) {\n for (const t of types) {\n pathWithExt = `${logicalId}.${t}`;\n const exists = await this._vfs.exists(pathWithExt);\n if (exists) {\n const stats = await this._vfs.stat(pathWithExt);\n if (stats.isFile) {\n type = t === 'ts' ? 'ts' : 'js';\n break;\n }\n }\n }\n }\n return type ? { type, path: pathWithExt } : null;\n }\n}\n"],"names":["toDataUrl","js","id","b64","textToBase64","encodeURIComponent","String","isAbsoluteUrl","spec","test","isSpecialUrl","isBareModule","startsWith","ScriptRegistry","_vfs","_scriptsRoot","_built","vfs","scriptsRoot","Map","VFS","clear","path","fetchSource","type","pathWithExt","endsWith","exists","stat","isDirectory","types","t","stats","isFile","code","readFile","encoding","resolveRuntimeUrl","entryId","resolveLogicalId","build","getApp","editorMode","slice","getDependencies","fromId","dependencies","reStatic","reDynamic","normalizedId","srcPath","resolveSourcePath","undefined","gather","input","re","m","exec","key","cached","get","rewritten","rewriteImports","transpile","url","set","_id","logicalId","ts","window","Error","res","transpileModule","compilerOptions","target","ScriptTarget","ES2015","module","ModuleKind","ESNext","sourceMap","inlineSources","experimentalDecorators","useDefineForClassFields","fileName","out","outputText","sourceMapText","mapBase64","btoa","unescape","init","imports","parse","list","sort","a","b","s","last","im","d","hasQuote","ss","se","e","replacement","depId","normalizePath","join","dirname","replace","libRoot","depsLockPath","depsExists","content","depsInfo","JSON","entry"],"mappings":";;;;AAMA;;;;;;;AAOC,IACD,SAASA,SAAAA,CAAUC,EAAU,EAAEC,EAAU,EAAA;AACvC,IAAA,MAAMC,MAAMC,YAAaH,CAAAA,EAAAA,CAAAA;IACzB,OAAO,CAAC,4BAA4B,EAAEE,GAAAA,CAAI,CAAC,EAAEE,kBAAAA,CAAmBC,OAAOJ,EAAM,CAAA,CAAA,CAAA,CAAA;AAC/E;AAEA;;;IAIA,SAASK,cAAcC,IAAY,EAAA;IACjC,OAAO,eAAA,CAAgBC,IAAI,CAACD,IAAAA,CAAAA;AAC9B;AAEA;;;IAIA,SAASE,aAAaF,IAAY,EAAA;IAChC,OAAO,gBAAA,CAAiBC,IAAI,CAACD,IAAAA,CAAAA;AAC/B;AAEA;;;IAIA,SAASG,aAAaH,IAAY,EAAA;AAChC,IAAA,OAAO,CAACA,IAAKI,CAAAA,UAAU,CAAC,IAAS,CAAA,IAAA,CAACJ,KAAKI,UAAU,CAAC,KAAU,CAAA,IAAA,CAACJ,KAAKI,UAAU,CAAC,QAAQ,CAACJ,IAAAA,CAAKI,UAAU,CAAC,IAAA,CAAA;AACxG;AAEA;;;;;;;;;;;;;;;;;AAiBC,IACM,MAAMC,cAAAA,CAAAA;IACHC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,GAAA,IAAA;AAC3B,wBAAA;AACF;AACF;AACF;AACF;AACA,QAAA,OAAOP,IAAO,GAAA;AAAEA,YAAAA,IAAAA;YAAMF,IAAMG,EAAAA;SAAgB,GAAA,IAAA;AAC9C;AACF;;;;"}
1
+ {"version":3,"file":"scriptregistry.js","sources":["../../src/app/scriptregistry.ts"],"sourcesContent":["import type * as TS from 'typescript';\r\nimport type { Nullable, VFS } from '@zephyr3d/base';\r\nimport { textToBase64 } from '@zephyr3d/base';\r\nimport { init, parse } from 'es-module-lexer';\r\nimport { getApp } from './api';\r\n\r\n/**\r\n * Converts JavaScript source to a data URL tied to a logical module id.\r\n *\r\n * @param js - The JavaScript source code to embed.\r\n * @param id - Logical module identifier (used only for sourceURL tagging).\r\n * @returns A `data:text/javascript;base64,...` URL with an encoded `#id` suffix.\r\n * @internal\r\n */\r\nfunction toDataUrl(js: string, id: string) {\r\n const b64 = textToBase64(js);\r\n return `data:text/javascript;base64,${b64}#${encodeURIComponent(String(id))}`;\r\n}\r\n\r\n/**\r\n * Checks whether a specifier is an absolute HTTP(S) URL.\r\n * @internal\r\n */\r\nfunction isAbsoluteUrl(spec: string) {\r\n return /^https?:\\/\\//i.test(spec);\r\n}\r\n\r\n/**\r\n * Checks whether a specifier is a special URL (data: or blob:).\r\n * @internal\r\n */\r\nfunction isSpecialUrl(spec: string) {\r\n return /^(data|blob):/i.test(spec);\r\n}\r\n\r\n/**\r\n * Checks whether a specifier is a bare module (not starting with ./, ../, /, or #/).\r\n * @internal\r\n */\r\nfunction isBareModule(spec: string) {\r\n return !spec.startsWith('./') && !spec.startsWith('../') && !spec.startsWith('/') && !spec.startsWith('#/');\r\n}\r\n\r\n/**\r\n * Resolves, builds, and serves runtime modules using a VFS.\r\n *\r\n * Responsibilities:\r\n * - Resolve logical module IDs to physical paths or URLs.\r\n * - In editor mode, rewrite import specifiers and serve modules as data URLs after transpile.\r\n * - Transpile TypeScript to JavaScript on the fly (requires `window.ts` TypeScript runtime).\r\n * - Gather static and dynamic import dependencies for tooling.\r\n *\r\n * Modes:\r\n * - Editor mode (`editorMode === true`): modules are rewritten to data URLs after transpile/build.\r\n * - Runtime mode (`editorMode === false`): returns .js URLs directly (with .ts -\\> .js mapping).\r\n *\r\n * Caching:\r\n * - Built modules are memoized in `_built` map keyed by logical ID.\r\n *\r\n * @public\r\n */\r\nexport class ScriptRegistry {\r\n private _vfs: VFS;\r\n private _scriptsRoot: string;\r\n private _built: Map<string, string>; // logicalId -> dataURL\r\n\r\n /**\r\n * @param vfs - The virtual file system for existence checks, reads, and path ops.\r\n * @param scriptsRoot - Root directory for script resolution (used with `#/` specifiers).\r\n * @param editorMode - Whether to build modules to data URLs and rewrite imports.\r\n */\r\n constructor(vfs: VFS, scriptsRoot: string) {\r\n this._vfs = vfs;\r\n this._scriptsRoot = scriptsRoot;\r\n this._built = new Map();\r\n }\r\n\r\n /**\r\n * The active virtual file system.\r\n *\r\n * Assigning a new VFS clears the build cache.\r\n */\r\n get VFS() {\r\n return this._vfs;\r\n }\r\n set VFS(vfs: VFS) {\r\n if (vfs !== this._vfs) {\r\n this._vfs = vfs;\r\n this._built.clear();\r\n }\r\n }\r\n\r\n /**\r\n * The root path used by `#/` specifiers.\r\n */\r\n get scriptsRoot() {\r\n return this._scriptsRoot;\r\n }\r\n set scriptsRoot(path: string) {\r\n this._scriptsRoot = path;\r\n }\r\n\r\n /**\r\n * Fetches raw source for a logical module id by probing known extensions.\r\n *\r\n * Search order:\r\n * - If `id` already ends with `.ts` or `.js` and is a file -\\> return it.\r\n * - Else try `.id.ts`, then `.id.js`.\r\n *\r\n * @param id - Logical module identifier (absolute or logical path-like).\r\n * @returns Source code, resolved path, and type (`'js' | 'ts'`), or `undefined` if not found.\r\n */\r\n protected async fetchSource(id: string) {\r\n let type: Nullable<'js' | 'ts'> = null;\r\n let pathWithExt = '';\r\n if (id.endsWith('.ts')) {\r\n pathWithExt = id;\r\n type = 'ts';\r\n } else if (id.endsWith('.js')) {\r\n pathWithExt = id;\r\n type = 'js';\r\n }\r\n if (type) {\r\n const exists = await this._vfs.exists(pathWithExt);\r\n if (!exists) {\r\n type = null;\r\n }\r\n const stat = await this._vfs.stat(pathWithExt);\r\n if (stat.isDirectory) {\r\n type = null;\r\n }\r\n }\r\n const types = ['ts', 'js'] as const;\r\n if (!type) {\r\n for (const t of types) {\r\n pathWithExt = `${id}.${t}`;\r\n const exists = await this._vfs.exists(pathWithExt);\r\n if (exists) {\r\n const stats = await this._vfs.stat(pathWithExt);\r\n if (stats.isFile) {\r\n type = t;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n if (type) {\r\n const code = (await this._vfs.readFile(pathWithExt, { encoding: 'utf8' })) as string;\r\n return { code, type, path: pathWithExt };\r\n }\r\n }\r\n\r\n /**\r\n * Resolves a module entry to a URL suitable for dynamic import.\r\n *\r\n * Behavior:\r\n * - In editor mode, builds the module to a data URL.\r\n * - Otherwise, returns `.js` URL directly:\r\n * - If `id` ends with `.js`: return as-is.\r\n * - If `id` ends with `.ts`: map to `.js` (assumes pre-built file exists).\r\n * - Else: append `.js`.\r\n *\r\n * @param entryId - Entry module identifier (logical or path-like).\r\n * @returns A URL string that can be used in `import(...)`.\r\n */\r\n async resolveRuntimeUrl(entryId: string) {\r\n const id = await this.resolveLogicalId(entryId);\r\n if (id.startsWith('/assets/@builtins/')) {\r\n return await this.build(String(id));\r\n }\r\n return getApp().editorMode !== 'none'\r\n ? await this.build(String(id))\r\n : id.endsWith('.js')\r\n ? id\r\n : id.endsWith('.ts')\r\n ? `${id.slice(0, -3)}.js`\r\n : `${id}.js`;\r\n }\r\n\r\n /**\r\n * Recursively gathers direct static and dynamic import dependencies for a module.\r\n *\r\n * Only relative specifiers (`./` or `../`) are followed. Absolute, special, and bare\r\n * module specifiers are ignored here.\r\n *\r\n * @param entryId - The starting (possibly relative) specifier from `fromId`.\r\n * @param fromId - The logical id of the module containing `entryId`.\r\n * @param dependencies - Output map of `resolvedSourcePath -\\> file contents`.\r\n */\r\n async getDependencies(entryId: string, fromId: string, dependencies: Record<string, string>) {\r\n const reStatic = /\\b(?:import|export)\\s+[^\"']*?from\\s+(['\"])([^'\"]+)\\1/g;\r\n const reDynamic = /\\bimport\\s*\\(\\s*(['\"])([^'\"]+)\\1\\s*\\)/g;\r\n\r\n const normalizedId = await this.resolveLogicalId(entryId, fromId);\r\n const srcPath = await this.resolveSourcePath(normalizedId);\r\n if (!srcPath || dependencies[srcPath.path] !== undefined) {\r\n return;\r\n }\r\n const code = (await this._vfs.readFile(srcPath.path, { encoding: 'utf8' })) as string;\r\n dependencies[srcPath.path] = code;\r\n\r\n const gather = async (input: string, re: RegExp) => {\r\n for (;;) {\r\n const m = re.exec(input);\r\n if (!m) {\r\n break;\r\n }\r\n\r\n const spec = m[2];\r\n\r\n if (spec.startsWith('./') || spec.startsWith('../')) {\r\n await this.getDependencies(spec, normalizedId, dependencies);\r\n }\r\n }\r\n };\r\n\r\n await gather(code, reStatic);\r\n await gather(code, reDynamic);\r\n }\r\n\r\n /**\r\n * Builds a logical module id into a data URL (editor mode pipeline).\r\n *\r\n * Steps:\r\n * - Resolve source path (.ts/.js) via {@link ScriptRegistry.resolveSourcePath}.\r\n * - Read source code.\r\n * - Rewrite import specifiers via {@link ScriptRegistry.rewriteImports}.\r\n * - Transpile TypeScript if needed via {@link ScriptRegistry.transpile}.\r\n * - Convert to `data:` URL and memoize in `_built`.\r\n *\r\n * @param id - Logical module id to build.\r\n * @returns Data URL string for dynamic import, or empty string if not found.\r\n */\r\n private async build(id: string) {\r\n const key = String(id);\r\n const cached = this._built.get(key);\r\n if (cached) {\r\n return cached;\r\n }\r\n\r\n const srcPath = await this.resolveSourcePath(key);\r\n if (!srcPath) {\r\n return '';\r\n }\r\n const code = (await this._vfs.readFile(srcPath.path, { encoding: 'utf8' })) as string;\r\n\r\n const rewritten = await this.rewriteImports(code, key);\r\n const js = await this.transpile(rewritten, key, srcPath.type);\r\n const url = toDataUrl(js, key);\r\n this._built.set(key, url);\r\n return url;\r\n }\r\n\r\n /**\r\n * Transpiles code to JavaScript and appends sourceURL/sourceMap hints.\r\n *\r\n * Behavior:\r\n * - For `'js'`, returns code with `//# sourceURL=logicalId`.\r\n * - For `'ts'`, requires `window.ts` (TypeScript compiler) to be present and\r\n * transpiles to ES2015/ESNext module with inline source maps.\r\n *\r\n * @param code - Source code to transpile.\r\n * @param _id - Logical module id (used for fileName/sourceURL).\r\n * @param type - Source type (`'js' | 'ts'`).\r\n * @returns Transpiled JavaScript source.\r\n * @throws If TypeScript runtime is not found for TS input.\r\n */\r\n private async transpile(code: string, _id: string, type: 'js' | 'ts') {\r\n const logicalId = String(_id);\r\n\r\n if (type === 'js') {\r\n return `${code}\\n//# sourceURL=${logicalId}`;\r\n }\r\n\r\n const ts = (window as any).ts as typeof TS;\r\n if (!ts) {\r\n throw new Error('TypeScript runtime (window.ts) not found. Load typescript.js first.');\r\n }\r\n\r\n const res = ts.transpileModule(code, {\r\n compilerOptions: {\r\n target: ts.ScriptTarget.ES2015,\r\n module: ts.ModuleKind.ESNext,\r\n sourceMap: true,\r\n inlineSources: true,\r\n experimentalDecorators: true,\r\n useDefineForClassFields: false\r\n },\r\n fileName: logicalId\r\n });\r\n\r\n let out = res.outputText || '';\r\n if (res.sourceMapText) {\r\n const mapBase64 = btoa(unescape(encodeURIComponent(res.sourceMapText)));\r\n out += `\\n//# sourceMappingURL=data:application/json;base64,${mapBase64}`;\r\n }\r\n out += `\\n//# sourceURL=${logicalId}`;\r\n return out;\r\n }\r\n\r\n /**\r\n * Rewrites ESM import specifiers in `code` into runtime-loadable URLs.\r\n *\r\n * Parsing:\r\n * - Uses `es-module-lexer` to find import spans; sorts them ascending by start.\r\n *\r\n * Replacement rules:\r\n * - Skip invalid spans or ones without quoted specifiers.\r\n * - If spec is absolute URL, special URL (data:, blob:), or bare module:\r\n * - If it starts with `@zephyr3d/`, keep as-is (external).\r\n * - Otherwise resolve to a logical id and attempt to `build` it (if available).\r\n * - Else (relative spec), resolve from `fromId` and `build` recursively.\r\n *\r\n * Output:\r\n * - Directly writes the replacement specifier without re-adding quotes,\r\n * so replacements must themselves be quoted or be valid URLs/data URLs.\r\n *\r\n * @param code - Module source code to transform.\r\n * @param fromId - The logical id of the current module (resolution base for relatives).\r\n * @returns Transformed source with rewritten import specifiers.\r\n */\r\n private async rewriteImports(code: string, fromId: string) {\r\n await init;\r\n const [imports] = parse(code);\r\n const list = [...imports].sort((a, b) => (a.s || 0) - (b.s || 0));\r\n let out = '';\r\n let last = 0;\r\n\r\n for (const im of list) {\r\n // Skip import.meta entries reported by es-module-lexer.\r\n // Their \"specifier\" span points to the whole \"import.meta\" expression,\r\n // which must remain untouched.\r\n if (im.d === -2) {\r\n continue;\r\n }\r\n // must have quotes\r\n const hasQuote = im.ss != null && im.se != null;\r\n if (!hasQuote || im.se <= im.ss) {\r\n continue;\r\n }\r\n // must have contents\r\n if (im.e <= im.s) {\r\n continue;\r\n }\r\n // append [last, s)\r\n out += code.slice(last, im.s);\r\n\r\n const spec = code.slice(im.s, im.e); // original spec\r\n let replacement = spec;\r\n if (isAbsoluteUrl(spec) || isSpecialUrl(spec) || isBareModule(spec)) {\r\n if (spec.startsWith('@zephyr3d/')) {\r\n replacement = spec;\r\n } else {\r\n const depId = await this.resolveLogicalId(spec);\r\n replacement = await this.build(depId); // try build as dependence\r\n }\r\n } else {\r\n const depId = await this.resolveLogicalId(spec, String(fromId));\r\n replacement = await this.build(depId); // recursively build as dataURL\r\n }\r\n out += replacement; // 不加引号\r\n last = im.e;\r\n }\r\n out += code.slice(last);\r\n return out;\r\n }\r\n\r\n /**\r\n * Resolves a specifier to a logical id suitable for further processing.\r\n *\r\n * Resolution rules:\r\n * - `#/path`: resolved against `scriptsRoot` via VFS join/normalize.\r\n * - `./` or `../`: resolved relative to `fromId` directory (requires `fromId`).\r\n * - `/absolute`: treated as absolute from root (normalized).\r\n * - Bare module in editor mode: if `/deps.lock.json` exists and contains an entry,\r\n * map to the dependency's `entry` path; otherwise return as-is.\r\n * - Else (non-editor bare module): return `spec` unchanged (external).\r\n *\r\n * @param spec - Import specifier string.\r\n * @param fromId - Optional base logical id used for relative resolution.\r\n * @returns A normalized logical id or an external specifier string.\r\n * @throws If a relative import is provided without `fromId`.\r\n */\r\n async resolveLogicalId(spec: string, fromId?: string) {\r\n if (spec.startsWith('#/')) {\r\n return this._vfs.normalizePath(this._vfs.join(this._scriptsRoot, spec.slice(2)));\r\n } else if (spec.startsWith('./') || spec.startsWith('../')) {\r\n if (!fromId) {\r\n throw new Error(`Relative import \"${spec}\" requires fromId`);\r\n }\r\n return this._vfs.normalizePath(\r\n this._vfs.join(this._vfs.dirname(this._vfs.normalizePath(fromId)), spec)\r\n );\r\n } else if (spec.startsWith('/')) {\r\n return spec.replace(/^\\/+/, '/');\r\n } else if (getApp().editorMode !== 'none') {\r\n const libRoot = '/';\r\n // naked module, checking if it is a installed module in editor mode\r\n let depsLockPath = this._vfs.normalizePath(this._vfs.join(libRoot, 'libs/deps.lock.json'));\r\n let depsExists = await this._vfs.exists(depsLockPath);\r\n if (depsExists) {\r\n const content = (await this._vfs.readFile(depsLockPath, { encoding: 'utf8' })) as string;\r\n const depsInfo = JSON.parse(content) as { dependencies: Record<string, { entry: string }> };\r\n if (depsInfo?.dependencies[spec]) {\r\n return this._vfs.normalizePath(this._vfs.join(libRoot, depsInfo.dependencies[spec].entry));\r\n }\r\n }\r\n }\r\n return spec;\r\n }\r\n\r\n /**\r\n * Resolves a logical id to a concrete source path and type by probing extensions.\r\n *\r\n * Rules:\r\n * - If `logicalId` ends with `.ts` or `.js`/`.mjs` and is a file, return it.\r\n * - Else probe `logicalId.ts`, `logicalId.js`, `logicalId.mjs` in that order.\r\n * - Maps `.mjs` to type `'js'`.\r\n *\r\n * @param logicalId - The normalized logical module id (path-like).\r\n * @returns `{ type, path }` or `null` if not found.\r\n */\r\n async resolveSourcePath(logicalId: string) {\r\n let type: Nullable<'js' | 'ts'> = null;\r\n let pathWithExt = '';\r\n if (logicalId.endsWith('.ts')) {\r\n pathWithExt = logicalId;\r\n type = 'ts';\r\n } else if (logicalId.endsWith('.js') || logicalId.endsWith('.mjs')) {\r\n pathWithExt = logicalId;\r\n type = 'js';\r\n }\r\n if (type) {\r\n const exists = await this._vfs.exists(pathWithExt);\r\n if (!exists) {\r\n type = null;\r\n }\r\n const stat = await this._vfs.stat(pathWithExt);\r\n if (stat.isDirectory) {\r\n type = null;\r\n }\r\n }\r\n const types = ['ts', 'js', 'mjs'] as const;\r\n if (!type) {\r\n for (const t of types) {\r\n pathWithExt = `${logicalId}.${t}`;\r\n const exists = await this._vfs.exists(pathWithExt);\r\n if (exists) {\r\n const stats = await this._vfs.stat(pathWithExt);\r\n if (stats.isFile) {\r\n type = t === 'ts' ? 'ts' : 'js';\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n return type ? { type, path: pathWithExt } : null;\r\n }\r\n}\r\n"],"names":["toDataUrl","js","id","b64","textToBase64","encodeURIComponent","String","isAbsoluteUrl","spec","test","isSpecialUrl","isBareModule","startsWith","ScriptRegistry","_vfs","_scriptsRoot","_built","vfs","scriptsRoot","Map","VFS","clear","path","fetchSource","type","pathWithExt","endsWith","exists","stat","isDirectory","types","t","stats","isFile","code","readFile","encoding","resolveRuntimeUrl","entryId","resolveLogicalId","build","getApp","editorMode","slice","getDependencies","fromId","dependencies","reStatic","reDynamic","normalizedId","srcPath","resolveSourcePath","undefined","gather","input","re","m","exec","key","cached","get","rewritten","rewriteImports","transpile","url","set","_id","logicalId","ts","window","Error","res","transpileModule","compilerOptions","target","ScriptTarget","ES2015","module","ModuleKind","ESNext","sourceMap","inlineSources","experimentalDecorators","useDefineForClassFields","fileName","out","outputText","sourceMapText","mapBase64","btoa","unescape","init","imports","parse","list","sort","a","b","s","last","im","d","hasQuote","ss","se","e","replacement","depId","normalizePath","join","dirname","replace","libRoot","depsLockPath","depsExists","content","depsInfo","JSON","entry"],"mappings":";;;;AAMA;;;;;;;AAOC,IACD,SAASA,SAAAA,CAAUC,EAAU,EAA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YAAA,MAAMI,OAAO,MAAM,IAAI,CAACd,IAAI,CAACc,IAAI,CAACH,WAAAA,CAAAA;YAClC,IAAIG,IAAAA,CAAKC,WAAW,EAAE;gBACpBL,IAAO,GAAA,IAAA;AACT;AACF;AACA,QAAA,MAAMM,KAAQ,GAAA;AAAC,YAAA,IAAA;AAAM,YAAA,IAAA;AAAM,YAAA;AAAM,SAAA;AACjC,QAAA,IAAI,CAACN,IAAM,EAAA;YACT,KAAK,MAAMO,KAAKD,KAAO,CAAA;AACrBL,gBAAAA,WAAAA,GAAc,CAAG0C,EAAAA,SAAAA,CAAU,CAAC,EAAEpC,CAAG,CAAA,CAAA;AACjC,gBAAA,MAAMJ,SAAS,MAAM,IAAI,CAACb,IAAI,CAACa,MAAM,CAACF,WAAAA,CAAAA;AACtC,gBAAA,IAAIE,MAAQ,EAAA;AACV,oBAAA,MAAMK,QAAQ,MAAM,IAAI,CAAClB,IAAI,CAACc,IAAI,CAACH,WAAAA,CAAAA;oBACnC,IAAIO,KAAAA,CAAMC,MAAM,EAAE;wBAChBT,IAAOO,GAAAA,CAAAA,KAAM,OAAO,IAAO,GAAA,IAAA;AAC3B,wBAAA;AACF;AACF;AACF;AACF;AACA,QAAA,OAAOP,IAAO,GAAA;AAAEA,YAAAA,IAAAA;YAAMF,IAAMG,EAAAA;SAAgB,GAAA,IAAA;AAC9C;AACF;;;;"}
@@ -4,7 +4,7 @@ import { mixinPBRCommon } from '../pbr/common.js';
4
4
  import { Vector4, Vector2 } from '@zephyr3d/base';
5
5
  import { mixinLight } from '../lit.js';
6
6
  import { ShaderHelper } from '../../shader/helper.js';
7
- import { MaterialVaryingFlags, RENDER_PASS_TYPE_LIGHT, LIGHT_TYPE_RECT, LIGHT_TYPE_POINT } from '../../../values.js';
7
+ import { RENDER_PASS_TYPE_LIGHT, LIGHT_TYPE_RECT, LIGHT_TYPE_POINT, MaterialVaryingFlags } from '../../../values.js';
8
8
 
9
9
  const PBR_REFLECTION_MODE = {
10
10
  none: 0,
@@ -25,10 +25,6 @@ const PBR_REFLECTION_MODE = {
25
25
  const METALLIC_UNIFORM = S.defineInstanceUniform('metallic', 'float', 'Metallic');
26
26
  const ROUGHNESS_UNIFORM = S.defineInstanceUniform('roughness', 'float', 'Roughness');
27
27
  const SPECULAR_FACTOR_UNFORM = S.defineInstanceUniform('specularFactor', 'rgba', 'SpecularFactor');
28
- const REFLECTION_MODE_UNIFORM = S.defineInstanceUniform('reflectionMode', 'float', 'ReflectionMode');
29
- const ANISOTROPY_UNIFORM = S.defineInstanceUniform('anisotropy', 'float', 'Anisotropy');
30
- const ANISOTROPY_DIRECTION_UNIFORM = S.defineInstanceUniform('anisotropyDirection', 'float', 'AnisotropyDirection');
31
- const ANISOTROPY_DIRECTION_SCALE_BIAS_UNIFORM = S.defineInstanceUniform('anisotropyDirectionScaleBias', 'vec2', 'AnisotropyDirectionScaleBias');
32
28
  return class extends S {
33
29
  static pbrMetallicRoughnessMixed = true;
34
30
  _metallic;
@@ -88,7 +84,6 @@ const PBR_REFLECTION_MODE = {
88
84
  directLighting(scope, lightDir, lightColor, normal, viewVec, commonData, diffuseScale, specularScale, sourceRadiusFactor, outColor) {
89
85
  const pb = scope.$builder;
90
86
  const that = this;
91
- const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
92
87
  const funcName = 'Z_PBRMR_DirectLighting';
93
88
  pb.func(funcName, [
94
89
  pb.vec3('L'),
@@ -101,10 +96,10 @@ const PBR_REFLECTION_MODE = {
101
96
  pb.float('sourceRadiusFactor'),
102
97
  pb.vec3('outColor').inout()
103
98
  ], function() {
104
- this.$l.reflectionMode = instancing ? this.$inputs.zReflectionMode : this.zReflectionMode;
105
- this.$l.anisotropy = instancing ? this.$inputs.zAnisotropy : this.zAnisotropy;
106
- this.$l.anisotropyDirection = instancing ? this.$inputs.zAnisotropyDirection : this.zAnisotropyDirection;
107
- this.$l.anisotropyDirectionScaleBias = instancing ? this.$inputs.zAnisotropyDirectionScaleBias : this.zAnisotropyDirectionScaleBias;
99
+ this.$l.reflectionMode = this.zReflectionMode;
100
+ this.$l.anisotropy = this.zAnisotropy;
101
+ this.$l.anisotropyDirection = this.zAnisotropyDirection;
102
+ this.$l.anisotropyDirectionScaleBias = this.zAnisotropyDirectionScaleBias;
108
103
  this.$l.H = pb.normalize(pb.add(this.viewVec, this.L));
109
104
  this.$l.NoH = pb.clamp(pb.dot(this.normal, this.H), 0, 1);
110
105
  this.$l.NoL = pb.clamp(pb.dot(this.normal, this.L), 0, 1);
@@ -230,8 +225,7 @@ const PBR_REFLECTION_MODE = {
230
225
  }
231
226
  }
232
227
  calculateAnisotropyDirectionScaleBias(scope) {
233
- const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
234
- return instancing ? scope.$inputs.zAnisotropyDirectionScaleBias : scope.zAnisotropyDirectionScaleBias;
228
+ return scope.zAnisotropyDirectionScaleBias;
235
229
  }
236
230
  PBRLight(scope, worldPos, normal, viewVec, albedo, TBN, outRoughness) {
237
231
  const pb = scope.$builder;
@@ -289,10 +283,6 @@ const PBR_REFLECTION_MODE = {
289
283
  scope.$outputs.zMetallic = this.getInstancedUniform(scope, METALLIC_UNIFORM);
290
284
  scope.$outputs.zRoughness = this.getInstancedUniform(scope, ROUGHNESS_UNIFORM);
291
285
  scope.$outputs.zSpecularFactor = this.getInstancedUniform(scope, SPECULAR_FACTOR_UNFORM);
292
- scope.$outputs.zReflectionMode = this.getInstancedUniform(scope, REFLECTION_MODE_UNIFORM);
293
- scope.$outputs.zAnisotropy = this.getInstancedUniform(scope, ANISOTROPY_UNIFORM);
294
- scope.$outputs.zAnisotropyDirection = this.getInstancedUniform(scope, ANISOTROPY_DIRECTION_UNIFORM);
295
- scope.$outputs.zAnisotropyDirectionScaleBias = this.getInstancedUniform(scope, ANISOTROPY_DIRECTION_SCALE_BIAS_UNIFORM);
296
286
  }
297
287
  }
298
288
  fragmentShader(scope) {
@@ -303,11 +293,11 @@ const PBR_REFLECTION_MODE = {
303
293
  scope.zMetallic = pb.float().uniform(2);
304
294
  scope.zRoughness = pb.float().uniform(2);
305
295
  scope.zSpecularFactor = pb.vec4().uniform(2);
306
- scope.zReflectionMode = pb.float().uniform(2);
307
- scope.zAnisotropy = pb.float().uniform(2);
308
- scope.zAnisotropyDirection = pb.float().uniform(2);
309
- scope.zAnisotropyDirectionScaleBias = pb.vec2().uniform(2);
310
296
  }
297
+ scope.zReflectionMode = pb.float().uniform(2);
298
+ scope.zAnisotropy = pb.float().uniform(2);
299
+ scope.zAnisotropyDirection = pb.float().uniform(2);
300
+ scope.zAnisotropyDirectionScaleBias = pb.vec2().uniform(2);
311
301
  }
312
302
  }
313
303
  applyUniformValues(bindGroup, ctx, pass) {
@@ -368,16 +358,13 @@ const PBR_REFLECTION_MODE = {
368
358
  super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);
369
359
  }
370
360
  calculateReflectionMode(scope) {
371
- const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
372
- return instancing ? scope.$inputs.zReflectionMode : scope.zReflectionMode;
361
+ return scope.zReflectionMode;
373
362
  }
374
363
  calculateAnisotropy(scope) {
375
- const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
376
- return instancing ? scope.$inputs.zAnisotropy : scope.zAnisotropy;
364
+ return scope.zAnisotropy;
377
365
  }
378
366
  calculateAnisotropyDirection(scope) {
379
- const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);
380
- return instancing ? scope.$inputs.zAnisotropyDirection : scope.zAnisotropyDirection;
367
+ return scope.zAnisotropyDirection;
381
368
  }
382
369
  };
383
370
  }
@@ -1 +1 @@
1
- {"version":3,"file":"pbrmetallicroughness.js","sources":["../../../../src/material/mixins/lightmodel/pbrmetallicroughness.ts"],"sourcesContent":["import type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport type { MeshMaterial } from '../../meshmaterial';\r\nimport { applyMaterialMixins } from '../../meshmaterial';\r\nimport type { TextureMixinInstanceTypes } from '../texture';\r\nimport { mixinTextureProps } from '../texture';\r\nimport type { IMixinPBRCommon } from '../pbr/common';\r\nimport { mixinPBRCommon } from '../pbr/common';\r\nimport type { DrawContext } from '../../../render';\r\nimport type { Immutable } from '@zephyr3d/base';\r\nimport { Vector2, Vector4 } from '@zephyr3d/base';\r\nimport type { IMixinLight } from '../lit';\r\nimport { mixinLight } from '../lit';\r\nimport { ShaderHelper } from '../../shader/helper';\r\nimport {\r\n LIGHT_TYPE_POINT,\r\n LIGHT_TYPE_RECT,\r\n MaterialVaryingFlags,\r\n RENDER_PASS_TYPE_LIGHT\r\n} from '../../../values';\r\n\r\nexport type PBRReflectionMode = 'none' | 'ggx' | 'anisotropic' | 'glint';\r\n\r\nconst PBR_REFLECTION_MODE: Record<PBRReflectionMode, number> = {\r\n none: 0,\r\n ggx: 1,\r\n anisotropic: 2,\r\n glint: 3\r\n};\r\n\r\n/**\r\n * Interface for PBRMetallicRoughness lighting model mixin\r\n * @public\r\n */\r\nexport type IMixinPBRMetallicRoughness = {\r\n metallic: number;\r\n roughness: number;\r\n specularFactor: Vector4;\r\n reflectionMode: PBRReflectionMode;\r\n anisotropy: number;\r\n anisotropyDirection: number;\r\n anisotropyDirectionScaleBias: Vector2;\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ): PBShaderExp;\r\n calculateMetallic(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateRoughness(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateSpecularFactor(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp\r\n ): PBShaderExp;\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ): void;\r\n} & IMixinPBRCommon &\r\n IMixinLight &\r\n TextureMixinInstanceTypes<\r\n ['metallicRoughness', 'occlusion', 'specular', 'specularColor', 'anisotropyDirection']\r\n >;\r\n\r\n/**\r\n * PBRMetallicRoughness lighting model mixin\r\n * @param BaseCls - Class to mix in\r\n * @returns Mixed class\r\n * @public\r\n */\r\nexport function mixinPBRMetallicRoughness<T extends typeof MeshMaterial>(BaseCls: T) {\r\n if ((BaseCls as any).pbrMetallicRoughnessMixed) {\r\n return BaseCls as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n }\r\n const S = applyMaterialMixins(\r\n BaseCls,\r\n mixinPBRCommon,\r\n mixinLight,\r\n mixinTextureProps('metallicRoughness'),\r\n mixinTextureProps('specular'),\r\n mixinTextureProps('specularColor'),\r\n mixinTextureProps('anisotropyDirection')\r\n );\r\n const METALLIC_UNIFORM = S.defineInstanceUniform('metallic', 'float', 'Metallic');\r\n const ROUGHNESS_UNIFORM = S.defineInstanceUniform('roughness', 'float', 'Roughness');\r\n const SPECULAR_FACTOR_UNFORM = S.defineInstanceUniform('specularFactor', 'rgba', 'SpecularFactor');\r\n const REFLECTION_MODE_UNIFORM = S.defineInstanceUniform('reflectionMode', 'float', 'ReflectionMode');\r\n const ANISOTROPY_UNIFORM = S.defineInstanceUniform('anisotropy', 'float', 'Anisotropy');\r\n const ANISOTROPY_DIRECTION_UNIFORM = S.defineInstanceUniform(\r\n 'anisotropyDirection',\r\n 'float',\r\n 'AnisotropyDirection'\r\n );\r\n const ANISOTROPY_DIRECTION_SCALE_BIAS_UNIFORM = S.defineInstanceUniform(\r\n 'anisotropyDirectionScaleBias',\r\n 'vec2',\r\n 'AnisotropyDirectionScaleBias'\r\n );\r\n\r\n return class extends S {\r\n static readonly pbrMetallicRoughnessMixed = true;\r\n private _metallic: number;\r\n private _roughness: number;\r\n private readonly _specularFactor: Vector4;\r\n private _reflectionMode: PBRReflectionMode;\r\n private _anisotropy: number;\r\n private _anisotropyDirection: number;\r\n private readonly _anisotropyDirectionScaleBias: Vector2;\r\n constructor() {\r\n super();\r\n this._metallic = 1;\r\n this._roughness = 1;\r\n this._specularFactor = Vector4.one();\r\n this._reflectionMode = 'ggx';\r\n this._anisotropy = 0.75;\r\n this._anisotropyDirection = 0;\r\n this._anisotropyDirectionScaleBias = new Vector2(1, 0);\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.metallic = other.metallic;\r\n this.roughness = other.roughness;\r\n this.specularFactor = other.specularFactor;\r\n this.reflectionMode = other.reflectionMode;\r\n this.anisotropy = other.anisotropy;\r\n this.anisotropyDirection = other.anisotropyDirection;\r\n this.anisotropyDirectionScaleBias = other.anisotropyDirectionScaleBias;\r\n }\r\n get metallic() {\r\n return this._metallic;\r\n }\r\n set metallic(val) {\r\n if (val !== this._metallic) {\r\n this._metallic = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get roughness() {\r\n return this._roughness;\r\n }\r\n set roughness(val) {\r\n if (val !== this._roughness) {\r\n this._roughness = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get specularFactor(): Immutable<Vector4> {\r\n return this._specularFactor;\r\n }\r\n set specularFactor(val: Immutable<Vector4>) {\r\n if (!val.equalsTo(this._specularFactor)) {\r\n this._specularFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n directLighting(\r\n scope: PBInsideFunctionScope,\r\n lightDir: PBShaderExp,\r\n lightColor: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n commonData: PBShaderExp,\r\n diffuseScale: PBShaderExp,\r\n specularScale: PBShaderExp,\r\n sourceRadiusFactor: PBShaderExp,\r\n outColor: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const that = this as any;\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n const funcName = 'Z_PBRMR_DirectLighting';\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('L'),\r\n pb.vec3('lightColor'),\r\n pb.vec3('normal'),\r\n pb.vec3('viewVec'),\r\n that.getCommonDatasStruct(scope)('data'),\r\n pb.float('diffuseScale'),\r\n pb.float('specularScale'),\r\n pb.float('sourceRadiusFactor'),\r\n pb.vec3('outColor').inout()\r\n ],\r\n function () {\r\n this.$l.reflectionMode = instancing ? this.$inputs.zReflectionMode : this.zReflectionMode;\r\n this.$l.anisotropy = instancing ? this.$inputs.zAnisotropy : this.zAnisotropy;\r\n this.$l.anisotropyDirection = instancing\r\n ? this.$inputs.zAnisotropyDirection\r\n : this.zAnisotropyDirection;\r\n this.$l.anisotropyDirectionScaleBias = instancing\r\n ? this.$inputs.zAnisotropyDirectionScaleBias\r\n : this.zAnisotropyDirectionScaleBias;\r\n this.$l.H = pb.normalize(pb.add(this.viewVec, this.L));\r\n this.$l.NoH = pb.clamp(pb.dot(this.normal, this.H), 0, 1);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.L), 0, 1);\r\n this.$l.NoV = pb.clamp(pb.dot(this.normal, this.viewVec), 0, 1);\r\n this.$if(pb.greaterThan(this.NoL, 0), function () {\r\n this.$l.VoH = pb.clamp(pb.dot(this.viewVec, this.H), 0, 1);\r\n this.$l.schlickFresnel = that.fresnelSchlick(this, this.VoH, this.data.f0.rgb, this.data.f90);\r\n if (that.iridescence) {\r\n this.$l.F = pb.mix(\r\n this.schlickFresnel,\r\n this.data.iridescenceFresnel,\r\n this.data.iridescenceFactor.x\r\n );\r\n } else {\r\n this.$l.F = this.schlickFresnel;\r\n }\r\n this.$l.specularRoughness = pb.clamp(pb.add(this.data.roughness, this.sourceRadiusFactor), 0, 1);\r\n this.$l.alphaRoughness = pb.mul(this.specularRoughness, this.specularRoughness);\r\n this.$l.Dggx = that.distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.$l.D = this.Dggx;\r\n this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.anisotropic), function () {\r\n this.$l.dirAngle = pb.mul(this.anisotropyDirection, Math.PI / 180);\r\n if (that.anisotropyDirectionTexture) {\r\n this.$l.dirSample = that.sampleAnisotropyDirectionTexture(this);\r\n this.$l.dirAngle = pb.mul(\r\n pb.add(\r\n pb.mul(this.dirSample.r, this.anisotropyDirectionScaleBias.x),\r\n this.anisotropyDirectionScaleBias.y\r\n ),\r\n Math.PI / 180\r\n );\r\n }\r\n this.$l.anisoAngle = this.dirAngle;\r\n this.$l.up = pb.vec3(0, 1, 0);\r\n this.$l.t0 = pb.normalize(pb.cross(this.up, this.normal));\r\n this.$if(pb.lessThan(pb.length(this.t0), 0.001), function () {\r\n this.t0 = pb.normalize(pb.cross(pb.vec3(1, 0, 0), this.normal));\r\n });\r\n this.$l.b0 = pb.normalize(pb.cross(this.normal, this.t0));\r\n this.$l.tangent = pb.normalize(\r\n pb.add(pb.mul(this.t0, pb.cos(this.anisoAngle)), pb.mul(this.b0, pb.sin(this.anisoAngle)))\r\n );\r\n this.$l.bitangent = pb.normalize(pb.cross(this.normal, this.tangent));\r\n this.$l.ToH = pb.dot(this.tangent, this.H);\r\n this.$l.BoH = pb.dot(this.bitangent, this.H);\r\n this.$l.at = pb.max(pb.mul(this.alphaRoughness, pb.add(1, this.anisotropy)), 0.0001);\r\n this.$l.ab = pb.max(pb.mul(this.alphaRoughness, pb.sub(1, this.anisotropy)), 0.0001);\r\n this.$l.anisoDenom = pb.mul(\r\n Math.PI,\r\n this.at,\r\n this.ab,\r\n pb.pow(\r\n pb.add(\r\n pb.div(pb.mul(this.ToH, this.ToH), pb.mul(this.at, this.at)),\r\n pb.div(pb.mul(this.BoH, this.BoH), pb.mul(this.ab, this.ab)),\r\n pb.mul(this.NoH, this.NoH)\r\n ),\r\n 2\r\n )\r\n );\r\n this.D = pb.div(1, pb.max(this.anisoDenom, 0.0001));\r\n }).$elseif(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.glint), function () {\r\n this.$l.glintNoise = pb.fract(\r\n pb.mul(\r\n pb.sin(pb.add(pb.dot(this.H, pb.vec3(127.1, 311.7, 74.7)), pb.mul(this.NoH, 43.1))),\r\n 43758.5453\r\n )\r\n );\r\n this.$l.glintMask = pb.smoothStep(0.97, 1, this.glintNoise);\r\n this.D = pb.mul(this.Dggx, pb.add(1, pb.mul(this.glintMask, 8)));\r\n });\r\n this.$l.V = that.visGGX(this, this.NoV, this.NoL, this.alphaRoughness);\r\n this.$l.specular = pb.mul(\r\n this.lightColor,\r\n this.D,\r\n this.V,\r\n this.F,\r\n this.data.specularWeight,\r\n this.specularScale\r\n );\r\n if (that.sheen) {\r\n this.specular = pb.mul(this.specular, this.data.sheenAlbedoScaling);\r\n }\r\n this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.none), function () {\r\n this.specular = pb.vec3(0);\r\n });\r\n this.outColor = pb.add(this.outColor, this.specular);\r\n if (that.iridescence) {\r\n this.$l.iridescenceFresnelMax = pb.vec3(\r\n pb.max(\r\n pb.max(this.data.iridescenceFresnel.r, this.data.iridescenceFresnel.g),\r\n this.data.iridescenceFresnel.b\r\n )\r\n );\r\n this.F = pb.mix(this.schlickFresnel, this.iridescenceFresnelMax, this.data.iridescenceFactor.x);\r\n }\r\n this.$l.diffuseBRDF = pb.mul(\r\n pb.sub(pb.vec3(1), pb.mul(this.F, this.data.specularWeight)),\r\n pb.div(this.data.diffuse.rgb, Math.PI)\r\n );\r\n this.$l.diffuse = pb.mul(\r\n this.lightColor,\r\n pb.max(this.diffuseBRDF, pb.vec3(0)),\r\n this.diffuseScale\r\n );\r\n if (that.transmission && that.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n this.$l.transmissionRay = that.getVolumeTransmissionRay(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.data.thicknessFactor,\r\n this.data.f0.a\r\n );\r\n this.$l.pointToLight = pb.normalize(pb.sub(this.L, this.transmissionRay));\r\n this.$l.transmittedLight = pb.mul(\r\n this.lightColor,\r\n that.getPunctualRadianceTransmission(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pointToLight,\r\n this.alphaRoughness,\r\n this.data.f0.rgb,\r\n this.data.f90.rgb,\r\n this.data.diffuse.rgb,\r\n this.data.f0.a\r\n )\r\n );\r\n this.transmittedLight = that.applyVolumeAttenuation(\r\n this,\r\n this.transmittedLight,\r\n pb.length(this.transmissionRay),\r\n this.data.attenuationColor,\r\n this.data.attenuationDistance\r\n );\r\n this.diffuse = pb.mix(this.diffuse, this.transmittedLight, this.data.transmissionFactor);\r\n }\r\n if (that.sheen) {\r\n this.diffuse = pb.mul(this.diffuse, this.data.sheenAlbedoScaling);\r\n }\r\n this.outColor = pb.add(this.outColor, this.diffuse);\r\n if (that.sheen) {\r\n this.$l.sheenD = that.D_Charlie(this, this.NoH, this.data.sheenRoughness);\r\n this.$l.sheenV = that.V_Ashikhmin(this, this.NoL, this.NoV);\r\n this.outColor = pb.add(\r\n this.outColor,\r\n pb.mul(this.lightColor, this.data.sheenColor, this.sheenD, this.sheenV)\r\n );\r\n }\r\n if (that.clearcoat) {\r\n this.alphaRoughness = pb.mul(this.data.ccFactor.y, this.data.ccFactor.y);\r\n this.NoH = pb.clamp(pb.dot(this.data.ccNormal, this.H), 0, 1);\r\n this.NoL = pb.clamp(pb.dot(this.data.ccNormal, this.L), 0, 1);\r\n this.ccF0 = pb.vec3(pb.pow(pb.div(pb.sub(this.data.f0.a, 1), pb.add(this.data.f0.a, 1)), 2));\r\n this.F = that.fresnelSchlick(this, this.VoH, this.ccF0, pb.vec3(1));\r\n this.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.V = that.visGGX(this, this.data.ccNoV, this.NoL, this.alphaRoughness);\r\n this.outColor = pb.add(this.outColor, pb.mul(this.D, this.V, this.F, this.data.ccFactor.x));\r\n }\r\n });\r\n }\r\n );\r\n scope.$g[funcName](\r\n lightDir,\r\n lightColor,\r\n normal,\r\n viewVec,\r\n commonData,\r\n diffuseScale,\r\n specularScale,\r\n sourceRadiusFactor,\r\n outColor\r\n );\r\n }\r\n get reflectionMode() {\r\n return this._reflectionMode;\r\n }\r\n set reflectionMode(val: PBRReflectionMode) {\r\n if (val !== this._reflectionMode) {\r\n this._reflectionMode = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropy() {\r\n return this._anisotropy;\r\n }\r\n set anisotropy(val) {\r\n const clamped = Math.max(-0.95, Math.min(0.95, val));\r\n if (clamped !== this._anisotropy) {\r\n this._anisotropy = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirection() {\r\n return this._anisotropyDirection;\r\n }\r\n set anisotropyDirection(val) {\r\n if (val !== this._anisotropyDirection) {\r\n this._anisotropyDirection = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirectionScaleBias(): Immutable<Vector2> {\r\n return this._anisotropyDirectionScaleBias;\r\n }\r\n set anisotropyDirectionScaleBias(val: Immutable<Vector2>) {\r\n if (!val.equalsTo(this._anisotropyDirectionScaleBias)) {\r\n this._anisotropyDirectionScaleBias.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n calculateAnisotropyDirectionScaleBias(scope: PBInsideFunctionScope) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (\r\n instancing ? scope.$inputs.zAnisotropyDirectionScaleBias : scope.zAnisotropyDirectionScaleBias\r\n ) as PBShaderExp;\r\n }\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_PBRMetallicRoughnessLight';\r\n const that = this;\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('worldPos'),\r\n pb.vec3('normal'),\r\n pb.mat3('TBN'),\r\n pb.vec3('viewVec'),\r\n pb.vec4('albedo'),\r\n ...(outRoughness ? [pb.vec4('outRoughness').out()] : [])\r\n ],\r\n function () {\r\n this.$l.pbrData = that.getCommonData(this, this.albedo, this.normal, this.viewVec, this.TBN);\r\n this.$l.lightingColor = pb.vec3(0);\r\n this.$l.emissiveColor = that.calculateEmissiveColor(this);\r\n if (outRoughness) {\r\n that.indirectLighting(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.lightingColor,\r\n this.outRoughness\r\n );\r\n } else {\r\n that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor);\r\n }\r\n that.forEachLight(this, function (type, posRange, dirCutoff, colorIntensity, extra, shadow) {\r\n this.$if(pb.equal(type, LIGHT_TYPE_RECT), function () {\r\n that.directRectLight(\r\n this,\r\n this.worldPos,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n posRange,\r\n dirCutoff,\r\n extra,\r\n colorIntensity,\r\n this.lightingColor\r\n );\r\n }).$else(function () {\r\n this.$l.diffuse = pb.vec3();\r\n this.$l.specular = pb.vec3();\r\n this.$l.diffuseScale = pb.float(1);\r\n this.$l.specularScale = pb.float(1);\r\n this.$l.sourceRadiusFactor = pb.float(0);\r\n this.$if(pb.equal(type, LIGHT_TYPE_POINT), function () {\r\n this.diffuseScale = extra.x;\r\n this.specularScale = extra.y;\r\n this.sourceRadiusFactor = pb.div(\r\n extra.z,\r\n pb.max(pb.distance(posRange.xyz, this.worldPos), 0.0001)\r\n );\r\n });\r\n this.$l.lightAtten = that.calculateLightAttenuation(\r\n this,\r\n type,\r\n this.worldPos,\r\n posRange,\r\n dirCutoff\r\n );\r\n this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);\r\n this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten, this.NoL);\r\n if (shadow) {\r\n this.lightColor = pb.mul(\r\n this.lightColor,\r\n that.calculateShadow(this, this.worldPos, this.NoL)\r\n );\r\n }\r\n that.directLighting(\r\n this,\r\n this.lightDir,\r\n this.lightColor,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.diffuseScale,\r\n this.specularScale,\r\n this.sourceRadiusFactor,\r\n this.lightingColor\r\n );\r\n });\r\n });\r\n this.$return(pb.add(this.lightingColor, this.emissiveColor));\r\n }\r\n );\r\n return (\r\n outRoughness\r\n ? pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo, outRoughness)\r\n : pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo)\r\n ) as PBShaderExp;\r\n }\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n if (this.needFragmentColor() && this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {\r\n scope.$outputs.zMetallic = this.getInstancedUniform(scope, METALLIC_UNIFORM);\r\n scope.$outputs.zRoughness = this.getInstancedUniform(scope, ROUGHNESS_UNIFORM);\r\n scope.$outputs.zSpecularFactor = this.getInstancedUniform(scope, SPECULAR_FACTOR_UNFORM);\r\n scope.$outputs.zReflectionMode = this.getInstancedUniform(scope, REFLECTION_MODE_UNIFORM);\r\n scope.$outputs.zAnisotropy = this.getInstancedUniform(scope, ANISOTROPY_UNIFORM);\r\n scope.$outputs.zAnisotropyDirection = this.getInstancedUniform(scope, ANISOTROPY_DIRECTION_UNIFORM);\r\n scope.$outputs.zAnisotropyDirectionScaleBias = this.getInstancedUniform(\r\n scope,\r\n ANISOTROPY_DIRECTION_SCALE_BIAS_UNIFORM\r\n );\r\n }\r\n }\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n if (this.needFragmentColor()) {\r\n const pb = scope.$builder;\r\n if (!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n scope.zMetallic = pb.float().uniform(2);\r\n scope.zRoughness = pb.float().uniform(2);\r\n scope.zSpecularFactor = pb.vec4().uniform(2);\r\n scope.zReflectionMode = pb.float().uniform(2);\r\n scope.zAnisotropy = pb.float().uniform(2);\r\n scope.zAnisotropyDirection = pb.float().uniform(2);\r\n scope.zAnisotropyDirectionScaleBias = pb.vec2().uniform(2);\r\n }\r\n }\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColor(ctx)) {\r\n if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n bindGroup.setValue('zMetallic', this._metallic);\r\n bindGroup.setValue('zRoughness', this._roughness);\r\n bindGroup.setValue('zSpecularFactor', this._specularFactor);\r\n bindGroup.setValue('zReflectionMode', PBR_REFLECTION_MODE[this._reflectionMode]);\r\n bindGroup.setValue('zAnisotropy', this._anisotropy);\r\n bindGroup.setValue('zAnisotropyDirection', this._anisotropyDirection);\r\n bindGroup.setValue('zAnisotropyDirectionScaleBias', this._anisotropyDirectionScaleBias);\r\n }\r\n }\r\n }\r\n calculateMetallic(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zMetallic : scope.zMetallic) as PBShaderExp;\r\n }\r\n calculateRoughness(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zRoughness : scope.zRoughness) as PBShaderExp;\r\n }\r\n calculateSpecularFactor(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSpecularFactor : scope.zSpecularFactor) as PBShaderExp;\r\n }\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const metallic = this.calculateMetallic(scope, albedo, normal);\r\n const roughness = this.calculateRoughness(scope, albedo, normal);\r\n const specularFactor = this.calculateSpecularFactor(scope, albedo, normal);\r\n const reflectionMode = this.calculateReflectionMode(scope) as PBShaderExp;\r\n if (this.metallicRoughnessTexture) {\r\n scope.$l.metallicRoughnessSample = this.sampleMetallicRoughnessTexture(scope);\r\n data.metallic = pb.mul(metallic, scope.metallicRoughnessSample.z);\r\n data.roughness = pb.mul(roughness, scope.metallicRoughnessSample.y);\r\n } else {\r\n data.metallic = metallic;\r\n data.roughness = roughness;\r\n }\r\n data.roughness = pb.mul(data.roughness, ShaderHelper.getCameraRoughnessFactor(scope));\r\n if (this.specularColorTexture) {\r\n scope.$l.specularColor = pb.mul(specularFactor.rgb, this.sampleSpecularColorTexture(scope).rgb);\r\n } else {\r\n scope.$l.specularColor = specularFactor.rgb;\r\n }\r\n if (this.specularTexture) {\r\n data.specularWeight = pb.mul(specularFactor.a, this.sampleSpecularTexture(scope).a);\r\n } else {\r\n data.specularWeight = specularFactor.a;\r\n }\r\n data.specularWeight = pb.mul(\r\n data.specularWeight,\r\n pb.float(pb.notEqual(reflectionMode, PBR_REFLECTION_MODE.none))\r\n );\r\n data.f0 = pb.vec4(\r\n pb.mix(\r\n pb.min(pb.mul(this.getF0(scope).rgb, scope.specularColor), pb.vec3(1)),\r\n albedo.rgb,\r\n data.metallic\r\n ),\r\n this.getF0(scope).a\r\n );\r\n data.f90 = pb.vec3(1);\r\n data.diffuse = pb.vec4(pb.mix(albedo.rgb, pb.vec3(0), data.metallic), albedo.a);\r\n super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);\r\n }\r\n calculateReflectionMode(scope: PBInsideFunctionScope) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zReflectionMode : scope.zReflectionMode) as PBShaderExp;\r\n }\r\n calculateAnisotropy(scope: PBInsideFunctionScope) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zAnisotropy : scope.zAnisotropy) as PBShaderExp;\r\n }\r\n calculateAnisotropyDirection(scope: PBInsideFunctionScope) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zAnisotropyDirection : scope.zAnisotropyDirection) as PBShaderExp;\r\n }\r\n } as unknown as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n}\r\n"],"names":["PBR_REFLECTION_MODE","none","ggx","anisotropic","glint","mixinPBRMetallicRoughness","BaseCls","pbrMetallicRoughnessMixed","S","applyMaterialMixins","mixinPBRCommon","mixinLight","mixinTextureProps","METALLIC_UNIFORM","defineInstanceUniform","ROUGHNESS_UNIFORM","SPECULAR_FACTOR_UNFORM","REFLECTION_MODE_UNIFORM","ANISOTROPY_UNIFORM","ANISOTROPY_DIRECTION_UNIFORM","ANISOTROPY_DIRECTION_SCALE_BIAS_UNIFORM","_metallic","_roughness","_specularFactor","_reflectionMode","_anisotropy","_anisotropyDirection","_anisotropyDirectionScaleBias","Vector4","one","Vector2","copyFrom","other","metallic","roughness","specularFactor","reflectionMode","anisotropy","anisotropyDirection","anisotropyDirectionScaleBias","val","uniformChanged","equalsTo","set","directLighting","scope","lightDir","lightColor","normal","viewVec","commonData","diffuseScale","specularScale","sourceRadiusFactor","outColor","pb","$builder","that","instancing","drawContext","materialFlags","MaterialVaryingFlags","INSTANCING","funcName","func","vec3","getCommonDatasStruct","float","inout","$l","$inputs","zReflectionMode","zAnisotropy","zAnisotropyDirection","zAnisotropyDirectionScaleBias","H","normalize","add","L","NoH","clamp","dot","NoL","NoV","$if","greaterThan","VoH","schlickFresnel","fresnelSchlick","data","f0","rgb","f90","iridescence","F","mix","iridescenceFresnel","iridescenceFactor","x","specularRoughness","alphaRoughness","mul","Dggx","distributionGGX","D","equal","dirAngle","Math","PI","anisotropyDirectionTexture","dirSample","sampleAnisotropyDirectionTexture","r","y","anisoAngle","up","t0","cross","lessThan","length","b0","tangent","cos","sin","bitangent","ToH","BoH","at","max","ab","sub","anisoDenom","pow","div","$elseif","glintNoise","fract","glintMask","smoothStep","V","visGGX","specular","specularWeight","sheen","sheenAlbedoScaling","iridescenceFresnelMax","g","b","diffuseBRDF","diffuse","transmission","renderPass","type","RENDER_PASS_TYPE_LIGHT","transmissionRay","getVolumeTransmissionRay","thicknessFactor","a","pointToLight","transmittedLight","getPunctualRadianceTransmission","applyVolumeAttenuation","attenuationColor","attenuationDistance","transmissionFactor","sheenD","D_Charlie","sheenRoughness","sheenV","V_Ashikhmin","sheenColor","clearcoat","ccFactor","ccNormal","ccF0","ccNoV","$g","clamped","min","calculateAnisotropyDirectionScaleBias","PBRLight","worldPos","albedo","TBN","outRoughness","mat3","vec4","out","pbrData","getCommonData","lightingColor","emissiveColor","calculateEmissiveColor","indirectLighting","forEachLight","posRange","dirCutoff","colorIntensity","extra","shadow","LIGHT_TYPE_RECT","directRectLight","$else","LIGHT_TYPE_POINT","z","distance","xyz","lightAtten","calculateLightAttenuation","calculateLightDirection","calculateShadow","$return","getGlobalScope","vertexShader","needFragmentColor","$outputs","zMetallic","getInstancedUniform","zRoughness","zSpecularFactor","fragmentShader","uniform","vec2","applyUniformValues","bindGroup","ctx","pass","setValue","calculateMetallic","_albedo","_normal","calculateRoughness","calculateSpecularFactor","calculateCommonData","calculateReflectionMode","metallicRoughnessTexture","metallicRoughnessSample","sampleMetallicRoughnessTexture","ShaderHelper","getCameraRoughnessFactor","specularColorTexture","specularColor","sampleSpecularColorTexture","specularTexture","sampleSpecularTexture","notEqual","getF0","calculateAnisotropy","calculateAnisotropyDirection"],"mappings":";;;;;;;;AAsBA,MAAMA,mBAAyD,GAAA;IAC7DC,IAA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I,CAACnI,EAAAA,CAAGwC,GAAG,CAACuF,MAAAA,CAAO3F,GAAG,EAAEpC,EAAAA,CAAGU,IAAI,CAAC,CAAA,CAAA,EAAIwB,KAAKxD,QAAQ,CAAA,EAAGqJ,OAAOzB,CAAC,CAAA;AAC9E,YAAA,KAAK,CAAC4E,mBAAoB5L,CAAAA,KAAAA,EAAOyI,MAAQtI,EAAAA,MAAAA,EAAQC,SAASsI,GAAK9F,EAAAA,IAAAA,CAAAA;AACjE;AACAiJ,QAAAA,uBAAAA,CAAwB7L,KAA4B,EAAE;AACpD,YAAA,MAAMa,UAAa,GAAA,CAAC,EAAE,IAAI,CAACC,WAAW,CAACC,aAAa,GAAGC,oBAAqBC,CAAAA,UAAU,CAAD;AACrF,YAAA,OAAQJ,aAAab,KAAMyB,CAAAA,OAAO,CAACC,eAAe,GAAG1B,MAAM0B,eAAe;AAC5E;AACAgL,QAAAA,mBAAAA,CAAoB1M,KAA4B,EAAE;AAChD,YAAA,MAAMa,UAAa,GAAA,CAAC,EAAE,IAAI,CAACC,WAAW,CAACC,aAAa,GAAGC,oBAAqBC,CAAAA,UAAU,CAAD;AACrF,YAAA,OAAQJ,aAAab,KAAMyB,CAAAA,OAAO,CAACE,WAAW,GAAG3B,MAAM2B,WAAW;AACpE;AACAgL,QAAAA,4BAAAA,CAA6B3M,KAA4B,EAAE;AACzD,YAAA,MAAMa,UAAa,GAAA,CAAC,EAAE,IAAI,CAACC,WAAW,CAACC,aAAa,GAAGC,oBAAqBC,CAAAA,UAAU,CAAD;AACrF,YAAA,OAAQJ,aAAab,KAAMyB,CAAAA,OAAO,CAACG,oBAAoB,GAAG5B,MAAM4B,oBAAoB;AACtF;AACF,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"pbrmetallicroughness.js","sources":["../../../../src/material/mixins/lightmodel/pbrmetallicroughness.ts"],"sourcesContent":["import type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport type { MeshMaterial } from '../../meshmaterial';\r\nimport { applyMaterialMixins } from '../../meshmaterial';\r\nimport type { TextureMixinInstanceTypes } from '../texture';\r\nimport { mixinTextureProps } from '../texture';\r\nimport type { IMixinPBRCommon } from '../pbr/common';\r\nimport { mixinPBRCommon } from '../pbr/common';\r\nimport type { DrawContext } from '../../../render';\r\nimport type { Immutable } from '@zephyr3d/base';\r\nimport { Vector2, Vector4 } from '@zephyr3d/base';\r\nimport type { IMixinLight } from '../lit';\r\nimport { mixinLight } from '../lit';\r\nimport { ShaderHelper } from '../../shader/helper';\r\nimport {\r\n LIGHT_TYPE_POINT,\r\n LIGHT_TYPE_RECT,\r\n MaterialVaryingFlags,\r\n RENDER_PASS_TYPE_LIGHT\r\n} from '../../../values';\r\n\r\nexport type PBRReflectionMode = 'none' | 'ggx' | 'anisotropic' | 'glint';\r\n\r\nconst PBR_REFLECTION_MODE: Record<PBRReflectionMode, number> = {\r\n none: 0,\r\n ggx: 1,\r\n anisotropic: 2,\r\n glint: 3\r\n};\r\n\r\n/**\r\n * Interface for PBRMetallicRoughness lighting model mixin\r\n * @public\r\n */\r\nexport type IMixinPBRMetallicRoughness = {\r\n metallic: number;\r\n roughness: number;\r\n specularFactor: Vector4;\r\n reflectionMode: PBRReflectionMode;\r\n anisotropy: number;\r\n anisotropyDirection: number;\r\n anisotropyDirectionScaleBias: Vector2;\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ): PBShaderExp;\r\n calculateMetallic(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateRoughness(scope: PBInsideFunctionScope, albedo: PBShaderExp, normal: PBShaderExp): PBShaderExp;\r\n calculateSpecularFactor(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp\r\n ): PBShaderExp;\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ): void;\r\n} & IMixinPBRCommon &\r\n IMixinLight &\r\n TextureMixinInstanceTypes<\r\n ['metallicRoughness', 'occlusion', 'specular', 'specularColor', 'anisotropyDirection']\r\n >;\r\n\r\n/**\r\n * PBRMetallicRoughness lighting model mixin\r\n * @param BaseCls - Class to mix in\r\n * @returns Mixed class\r\n * @public\r\n */\r\nexport function mixinPBRMetallicRoughness<T extends typeof MeshMaterial>(BaseCls: T) {\r\n if ((BaseCls as any).pbrMetallicRoughnessMixed) {\r\n return BaseCls as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n }\r\n const S = applyMaterialMixins(\r\n BaseCls,\r\n mixinPBRCommon,\r\n mixinLight,\r\n mixinTextureProps('metallicRoughness'),\r\n mixinTextureProps('specular'),\r\n mixinTextureProps('specularColor'),\r\n mixinTextureProps('anisotropyDirection')\r\n );\r\n const METALLIC_UNIFORM = S.defineInstanceUniform('metallic', 'float', 'Metallic');\r\n const ROUGHNESS_UNIFORM = S.defineInstanceUniform('roughness', 'float', 'Roughness');\r\n const SPECULAR_FACTOR_UNFORM = S.defineInstanceUniform('specularFactor', 'rgba', 'SpecularFactor');\r\n\r\n return class extends S {\r\n static readonly pbrMetallicRoughnessMixed = true;\r\n private _metallic: number;\r\n private _roughness: number;\r\n private readonly _specularFactor: Vector4;\r\n private _reflectionMode: PBRReflectionMode;\r\n private _anisotropy: number;\r\n private _anisotropyDirection: number;\r\n private readonly _anisotropyDirectionScaleBias: Vector2;\r\n constructor() {\r\n super();\r\n this._metallic = 1;\r\n this._roughness = 1;\r\n this._specularFactor = Vector4.one();\r\n this._reflectionMode = 'ggx';\r\n this._anisotropy = 0.75;\r\n this._anisotropyDirection = 0;\r\n this._anisotropyDirectionScaleBias = new Vector2(1, 0);\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.metallic = other.metallic;\r\n this.roughness = other.roughness;\r\n this.specularFactor = other.specularFactor;\r\n this.reflectionMode = other.reflectionMode;\r\n this.anisotropy = other.anisotropy;\r\n this.anisotropyDirection = other.anisotropyDirection;\r\n this.anisotropyDirectionScaleBias = other.anisotropyDirectionScaleBias;\r\n }\r\n get metallic() {\r\n return this._metallic;\r\n }\r\n set metallic(val) {\r\n if (val !== this._metallic) {\r\n this._metallic = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get roughness() {\r\n return this._roughness;\r\n }\r\n set roughness(val) {\r\n if (val !== this._roughness) {\r\n this._roughness = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get specularFactor(): Immutable<Vector4> {\r\n return this._specularFactor;\r\n }\r\n set specularFactor(val: Immutable<Vector4>) {\r\n if (!val.equalsTo(this._specularFactor)) {\r\n this._specularFactor.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n directLighting(\r\n scope: PBInsideFunctionScope,\r\n lightDir: PBShaderExp,\r\n lightColor: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n commonData: PBShaderExp,\r\n diffuseScale: PBShaderExp,\r\n specularScale: PBShaderExp,\r\n sourceRadiusFactor: PBShaderExp,\r\n outColor: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const that = this as any;\r\n const funcName = 'Z_PBRMR_DirectLighting';\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('L'),\r\n pb.vec3('lightColor'),\r\n pb.vec3('normal'),\r\n pb.vec3('viewVec'),\r\n that.getCommonDatasStruct(scope)('data'),\r\n pb.float('diffuseScale'),\r\n pb.float('specularScale'),\r\n pb.float('sourceRadiusFactor'),\r\n pb.vec3('outColor').inout()\r\n ],\r\n function () {\r\n this.$l.reflectionMode = this.zReflectionMode;\r\n this.$l.anisotropy = this.zAnisotropy;\r\n this.$l.anisotropyDirection = this.zAnisotropyDirection;\r\n this.$l.anisotropyDirectionScaleBias = this.zAnisotropyDirectionScaleBias;\r\n this.$l.H = pb.normalize(pb.add(this.viewVec, this.L));\r\n this.$l.NoH = pb.clamp(pb.dot(this.normal, this.H), 0, 1);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.L), 0, 1);\r\n this.$l.NoV = pb.clamp(pb.dot(this.normal, this.viewVec), 0, 1);\r\n this.$if(pb.greaterThan(this.NoL, 0), function () {\r\n this.$l.VoH = pb.clamp(pb.dot(this.viewVec, this.H), 0, 1);\r\n this.$l.schlickFresnel = that.fresnelSchlick(this, this.VoH, this.data.f0.rgb, this.data.f90);\r\n if (that.iridescence) {\r\n this.$l.F = pb.mix(\r\n this.schlickFresnel,\r\n this.data.iridescenceFresnel,\r\n this.data.iridescenceFactor.x\r\n );\r\n } else {\r\n this.$l.F = this.schlickFresnel;\r\n }\r\n this.$l.specularRoughness = pb.clamp(pb.add(this.data.roughness, this.sourceRadiusFactor), 0, 1);\r\n this.$l.alphaRoughness = pb.mul(this.specularRoughness, this.specularRoughness);\r\n this.$l.Dggx = that.distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.$l.D = this.Dggx;\r\n this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.anisotropic), function () {\r\n this.$l.dirAngle = pb.mul(this.anisotropyDirection, Math.PI / 180);\r\n if (that.anisotropyDirectionTexture) {\r\n this.$l.dirSample = that.sampleAnisotropyDirectionTexture(this);\r\n this.$l.dirAngle = pb.mul(\r\n pb.add(\r\n pb.mul(this.dirSample.r, this.anisotropyDirectionScaleBias.x),\r\n this.anisotropyDirectionScaleBias.y\r\n ),\r\n Math.PI / 180\r\n );\r\n }\r\n this.$l.anisoAngle = this.dirAngle;\r\n this.$l.up = pb.vec3(0, 1, 0);\r\n this.$l.t0 = pb.normalize(pb.cross(this.up, this.normal));\r\n this.$if(pb.lessThan(pb.length(this.t0), 0.001), function () {\r\n this.t0 = pb.normalize(pb.cross(pb.vec3(1, 0, 0), this.normal));\r\n });\r\n this.$l.b0 = pb.normalize(pb.cross(this.normal, this.t0));\r\n this.$l.tangent = pb.normalize(\r\n pb.add(pb.mul(this.t0, pb.cos(this.anisoAngle)), pb.mul(this.b0, pb.sin(this.anisoAngle)))\r\n );\r\n this.$l.bitangent = pb.normalize(pb.cross(this.normal, this.tangent));\r\n this.$l.ToH = pb.dot(this.tangent, this.H);\r\n this.$l.BoH = pb.dot(this.bitangent, this.H);\r\n this.$l.at = pb.max(pb.mul(this.alphaRoughness, pb.add(1, this.anisotropy)), 0.0001);\r\n this.$l.ab = pb.max(pb.mul(this.alphaRoughness, pb.sub(1, this.anisotropy)), 0.0001);\r\n this.$l.anisoDenom = pb.mul(\r\n Math.PI,\r\n this.at,\r\n this.ab,\r\n pb.pow(\r\n pb.add(\r\n pb.div(pb.mul(this.ToH, this.ToH), pb.mul(this.at, this.at)),\r\n pb.div(pb.mul(this.BoH, this.BoH), pb.mul(this.ab, this.ab)),\r\n pb.mul(this.NoH, this.NoH)\r\n ),\r\n 2\r\n )\r\n );\r\n this.D = pb.div(1, pb.max(this.anisoDenom, 0.0001));\r\n }).$elseif(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.glint), function () {\r\n this.$l.glintNoise = pb.fract(\r\n pb.mul(\r\n pb.sin(pb.add(pb.dot(this.H, pb.vec3(127.1, 311.7, 74.7)), pb.mul(this.NoH, 43.1))),\r\n 43758.5453\r\n )\r\n );\r\n this.$l.glintMask = pb.smoothStep(0.97, 1, this.glintNoise);\r\n this.D = pb.mul(this.Dggx, pb.add(1, pb.mul(this.glintMask, 8)));\r\n });\r\n this.$l.V = that.visGGX(this, this.NoV, this.NoL, this.alphaRoughness);\r\n this.$l.specular = pb.mul(\r\n this.lightColor,\r\n this.D,\r\n this.V,\r\n this.F,\r\n this.data.specularWeight,\r\n this.specularScale\r\n );\r\n if (that.sheen) {\r\n this.specular = pb.mul(this.specular, this.data.sheenAlbedoScaling);\r\n }\r\n this.$if(pb.equal(this.reflectionMode, PBR_REFLECTION_MODE.none), function () {\r\n this.specular = pb.vec3(0);\r\n });\r\n this.outColor = pb.add(this.outColor, this.specular);\r\n if (that.iridescence) {\r\n this.$l.iridescenceFresnelMax = pb.vec3(\r\n pb.max(\r\n pb.max(this.data.iridescenceFresnel.r, this.data.iridescenceFresnel.g),\r\n this.data.iridescenceFresnel.b\r\n )\r\n );\r\n this.F = pb.mix(this.schlickFresnel, this.iridescenceFresnelMax, this.data.iridescenceFactor.x);\r\n }\r\n this.$l.diffuseBRDF = pb.mul(\r\n pb.sub(pb.vec3(1), pb.mul(this.F, this.data.specularWeight)),\r\n pb.div(this.data.diffuse.rgb, Math.PI)\r\n );\r\n this.$l.diffuse = pb.mul(\r\n this.lightColor,\r\n pb.max(this.diffuseBRDF, pb.vec3(0)),\r\n this.diffuseScale\r\n );\r\n if (that.transmission && that.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n this.$l.transmissionRay = that.getVolumeTransmissionRay(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.data.thicknessFactor,\r\n this.data.f0.a\r\n );\r\n this.$l.pointToLight = pb.normalize(pb.sub(this.L, this.transmissionRay));\r\n this.$l.transmittedLight = pb.mul(\r\n this.lightColor,\r\n that.getPunctualRadianceTransmission(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pointToLight,\r\n this.alphaRoughness,\r\n this.data.f0.rgb,\r\n this.data.f90.rgb,\r\n this.data.diffuse.rgb,\r\n this.data.f0.a\r\n )\r\n );\r\n this.transmittedLight = that.applyVolumeAttenuation(\r\n this,\r\n this.transmittedLight,\r\n pb.length(this.transmissionRay),\r\n this.data.attenuationColor,\r\n this.data.attenuationDistance\r\n );\r\n this.diffuse = pb.mix(this.diffuse, this.transmittedLight, this.data.transmissionFactor);\r\n }\r\n if (that.sheen) {\r\n this.diffuse = pb.mul(this.diffuse, this.data.sheenAlbedoScaling);\r\n }\r\n this.outColor = pb.add(this.outColor, this.diffuse);\r\n if (that.sheen) {\r\n this.$l.sheenD = that.D_Charlie(this, this.NoH, this.data.sheenRoughness);\r\n this.$l.sheenV = that.V_Ashikhmin(this, this.NoL, this.NoV);\r\n this.outColor = pb.add(\r\n this.outColor,\r\n pb.mul(this.lightColor, this.data.sheenColor, this.sheenD, this.sheenV)\r\n );\r\n }\r\n if (that.clearcoat) {\r\n this.alphaRoughness = pb.mul(this.data.ccFactor.y, this.data.ccFactor.y);\r\n this.NoH = pb.clamp(pb.dot(this.data.ccNormal, this.H), 0, 1);\r\n this.NoL = pb.clamp(pb.dot(this.data.ccNormal, this.L), 0, 1);\r\n this.ccF0 = pb.vec3(pb.pow(pb.div(pb.sub(this.data.f0.a, 1), pb.add(this.data.f0.a, 1)), 2));\r\n this.F = that.fresnelSchlick(this, this.VoH, this.ccF0, pb.vec3(1));\r\n this.D = that.distributionGGX(this, this.NoH, this.alphaRoughness);\r\n this.V = that.visGGX(this, this.data.ccNoV, this.NoL, this.alphaRoughness);\r\n this.outColor = pb.add(this.outColor, pb.mul(this.D, this.V, this.F, this.data.ccFactor.x));\r\n }\r\n });\r\n }\r\n );\r\n scope.$g[funcName](\r\n lightDir,\r\n lightColor,\r\n normal,\r\n viewVec,\r\n commonData,\r\n diffuseScale,\r\n specularScale,\r\n sourceRadiusFactor,\r\n outColor\r\n );\r\n }\r\n get reflectionMode() {\r\n return this._reflectionMode;\r\n }\r\n set reflectionMode(val: PBRReflectionMode) {\r\n if (val !== this._reflectionMode) {\r\n this._reflectionMode = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropy() {\r\n return this._anisotropy;\r\n }\r\n set anisotropy(val) {\r\n const clamped = Math.max(-0.95, Math.min(0.95, val));\r\n if (clamped !== this._anisotropy) {\r\n this._anisotropy = clamped;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirection() {\r\n return this._anisotropyDirection;\r\n }\r\n set anisotropyDirection(val) {\r\n if (val !== this._anisotropyDirection) {\r\n this._anisotropyDirection = val;\r\n this.uniformChanged();\r\n }\r\n }\r\n get anisotropyDirectionScaleBias(): Immutable<Vector2> {\r\n return this._anisotropyDirectionScaleBias;\r\n }\r\n set anisotropyDirectionScaleBias(val: Immutable<Vector2>) {\r\n if (!val.equalsTo(this._anisotropyDirectionScaleBias)) {\r\n this._anisotropyDirectionScaleBias.set(val);\r\n this.uniformChanged();\r\n }\r\n }\r\n calculateAnisotropyDirectionScaleBias(scope: PBInsideFunctionScope) {\r\n return scope.zAnisotropyDirectionScaleBias as PBShaderExp;\r\n }\r\n PBRLight(\r\n scope: PBInsideFunctionScope,\r\n worldPos: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n albedo: PBShaderExp,\r\n TBN: PBShaderExp,\r\n outRoughness?: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const funcName = 'Z_PBRMetallicRoughnessLight';\r\n const that = this;\r\n pb.func(\r\n funcName,\r\n [\r\n pb.vec3('worldPos'),\r\n pb.vec3('normal'),\r\n pb.mat3('TBN'),\r\n pb.vec3('viewVec'),\r\n pb.vec4('albedo'),\r\n ...(outRoughness ? [pb.vec4('outRoughness').out()] : [])\r\n ],\r\n function () {\r\n this.$l.pbrData = that.getCommonData(this, this.albedo, this.normal, this.viewVec, this.TBN);\r\n this.$l.lightingColor = pb.vec3(0);\r\n this.$l.emissiveColor = that.calculateEmissiveColor(this);\r\n if (outRoughness) {\r\n that.indirectLighting(\r\n this,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.lightingColor,\r\n this.outRoughness\r\n );\r\n } else {\r\n that.indirectLighting(this, this.normal, this.viewVec, this.pbrData, this.lightingColor);\r\n }\r\n that.forEachLight(this, function (type, posRange, dirCutoff, colorIntensity, extra, shadow) {\r\n this.$if(pb.equal(type, LIGHT_TYPE_RECT), function () {\r\n that.directRectLight(\r\n this,\r\n this.worldPos,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n posRange,\r\n dirCutoff,\r\n extra,\r\n colorIntensity,\r\n this.lightingColor\r\n );\r\n }).$else(function () {\r\n this.$l.diffuse = pb.vec3();\r\n this.$l.specular = pb.vec3();\r\n this.$l.diffuseScale = pb.float(1);\r\n this.$l.specularScale = pb.float(1);\r\n this.$l.sourceRadiusFactor = pb.float(0);\r\n this.$if(pb.equal(type, LIGHT_TYPE_POINT), function () {\r\n this.diffuseScale = extra.x;\r\n this.specularScale = extra.y;\r\n this.sourceRadiusFactor = pb.div(\r\n extra.z,\r\n pb.max(pb.distance(posRange.xyz, this.worldPos), 0.0001)\r\n );\r\n });\r\n this.$l.lightAtten = that.calculateLightAttenuation(\r\n this,\r\n type,\r\n this.worldPos,\r\n posRange,\r\n dirCutoff\r\n );\r\n this.$l.lightDir = that.calculateLightDirection(this, type, this.worldPos, posRange, dirCutoff);\r\n this.$l.NoL = pb.clamp(pb.dot(this.normal, this.lightDir), 0, 1);\r\n this.$l.lightColor = pb.mul(colorIntensity.rgb, colorIntensity.a, this.lightAtten, this.NoL);\r\n if (shadow) {\r\n this.lightColor = pb.mul(\r\n this.lightColor,\r\n that.calculateShadow(this, this.worldPos, this.NoL)\r\n );\r\n }\r\n that.directLighting(\r\n this,\r\n this.lightDir,\r\n this.lightColor,\r\n this.normal,\r\n this.viewVec,\r\n this.pbrData,\r\n this.diffuseScale,\r\n this.specularScale,\r\n this.sourceRadiusFactor,\r\n this.lightingColor\r\n );\r\n });\r\n });\r\n this.$return(pb.add(this.lightingColor, this.emissiveColor));\r\n }\r\n );\r\n return (\r\n outRoughness\r\n ? pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo, outRoughness)\r\n : pb.getGlobalScope()[funcName](worldPos, normal, TBN, viewVec, albedo)\r\n ) as PBShaderExp;\r\n }\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n if (this.needFragmentColor() && this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {\r\n scope.$outputs.zMetallic = this.getInstancedUniform(scope, METALLIC_UNIFORM);\r\n scope.$outputs.zRoughness = this.getInstancedUniform(scope, ROUGHNESS_UNIFORM);\r\n scope.$outputs.zSpecularFactor = this.getInstancedUniform(scope, SPECULAR_FACTOR_UNFORM);\r\n }\r\n }\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n if (this.needFragmentColor()) {\r\n const pb = scope.$builder;\r\n if (!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n scope.zMetallic = pb.float().uniform(2);\r\n scope.zRoughness = pb.float().uniform(2);\r\n scope.zSpecularFactor = pb.vec4().uniform(2);\r\n }\r\n scope.zReflectionMode = pb.float().uniform(2);\r\n scope.zAnisotropy = pb.float().uniform(2);\r\n scope.zAnisotropyDirection = pb.float().uniform(2);\r\n scope.zAnisotropyDirectionScaleBias = pb.vec2().uniform(2);\r\n }\r\n }\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (this.needFragmentColor(ctx)) {\r\n if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n bindGroup.setValue('zMetallic', this._metallic);\r\n bindGroup.setValue('zRoughness', this._roughness);\r\n bindGroup.setValue('zSpecularFactor', this._specularFactor);\r\n bindGroup.setValue('zReflectionMode', PBR_REFLECTION_MODE[this._reflectionMode]);\r\n bindGroup.setValue('zAnisotropy', this._anisotropy);\r\n bindGroup.setValue('zAnisotropyDirection', this._anisotropyDirection);\r\n bindGroup.setValue('zAnisotropyDirectionScaleBias', this._anisotropyDirectionScaleBias);\r\n }\r\n }\r\n }\r\n calculateMetallic(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zMetallic : scope.zMetallic) as PBShaderExp;\r\n }\r\n calculateRoughness(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zRoughness : scope.zRoughness) as PBShaderExp;\r\n }\r\n calculateSpecularFactor(scope: PBInsideFunctionScope, _albedo: PBShaderExp, _normal: PBShaderExp) {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSpecularFactor : scope.zSpecularFactor) as PBShaderExp;\r\n }\r\n calculateCommonData(\r\n scope: PBInsideFunctionScope,\r\n albedo: PBShaderExp,\r\n normal: PBShaderExp,\r\n viewVec: PBShaderExp,\r\n TBN: PBShaderExp,\r\n data: PBShaderExp\r\n ) {\r\n const pb = scope.$builder;\r\n const metallic = this.calculateMetallic(scope, albedo, normal);\r\n const roughness = this.calculateRoughness(scope, albedo, normal);\r\n const specularFactor = this.calculateSpecularFactor(scope, albedo, normal);\r\n const reflectionMode = this.calculateReflectionMode(scope) as PBShaderExp;\r\n if (this.metallicRoughnessTexture) {\r\n scope.$l.metallicRoughnessSample = this.sampleMetallicRoughnessTexture(scope);\r\n data.metallic = pb.mul(metallic, scope.metallicRoughnessSample.z);\r\n data.roughness = pb.mul(roughness, scope.metallicRoughnessSample.y);\r\n } else {\r\n data.metallic = metallic;\r\n data.roughness = roughness;\r\n }\r\n data.roughness = pb.mul(data.roughness, ShaderHelper.getCameraRoughnessFactor(scope));\r\n if (this.specularColorTexture) {\r\n scope.$l.specularColor = pb.mul(specularFactor.rgb, this.sampleSpecularColorTexture(scope).rgb);\r\n } else {\r\n scope.$l.specularColor = specularFactor.rgb;\r\n }\r\n if (this.specularTexture) {\r\n data.specularWeight = pb.mul(specularFactor.a, this.sampleSpecularTexture(scope).a);\r\n } else {\r\n data.specularWeight = specularFactor.a;\r\n }\r\n data.specularWeight = pb.mul(\r\n data.specularWeight,\r\n pb.float(pb.notEqual(reflectionMode, PBR_REFLECTION_MODE.none))\r\n );\r\n data.f0 = pb.vec4(\r\n pb.mix(\r\n pb.min(pb.mul(this.getF0(scope).rgb, scope.specularColor), pb.vec3(1)),\r\n albedo.rgb,\r\n data.metallic\r\n ),\r\n this.getF0(scope).a\r\n );\r\n data.f90 = pb.vec3(1);\r\n data.diffuse = pb.vec4(pb.mix(albedo.rgb, pb.vec3(0), data.metallic), albedo.a);\r\n super.calculateCommonData(scope, albedo, normal, viewVec, TBN, data);\r\n }\r\n calculateReflectionMode(scope: PBInsideFunctionScope) {\r\n return scope.zReflectionMode as PBShaderExp;\r\n }\r\n calculateAnisotropy(scope: PBInsideFunctionScope) {\r\n return scope.zAnisotropy as PBShaderExp;\r\n }\r\n calculateAnisotropyDirection(scope: PBInsideFunctionScope) {\r\n return scope.zAnisotropyDirection as PBShaderExp;\r\n }\r\n } as unknown as T & { new (...args: any[]): IMixinPBRMetallicRoughness };\r\n}\r\n"],"names":["PBR_REFLECTION_MODE","none","ggx","anisotropic","glint","mixinPBRMetallicRoughness","BaseCls","pbrMetallicRoughnessMixed","S","applyMaterialMixins","mixinPBRCommon","mixinLight","mixinTextureProps","METALLIC_UNIFORM","defineInstanceUniform","ROUGHNESS_UNIFORM","SPECULAR_FACTOR_UNFORM","_metallic","_roughness","_specularFactor","_reflectionMode","_anisotropy","_anisotropyDirection","_anisotropyDirectionScaleBias","Vector4","one","Vector2","copyFrom","other","metallic","roughness","specularFactor","reflectionMode","anisotropy","anisotropyDirection","anisotropyDirectionScaleBias","val","uniformChanged","equalsTo","set","directLighting","scope","lightDir","lightColor","normal","viewVec","commonData","diffuseScale","specularScale","sourceRadiusFactor","outColor","pb","$builder","that","funcName","func","vec3","getCommonDatasStruct","float","inout","$l","zReflectionMode","zAnisotropy","zAnisotropyDirection","zAnisotropyDirectionScaleBias","H","normalize","add","L","NoH","clamp","dot","NoL","NoV","$if","greaterThan","VoH","schlickFresnel","fresnelSchlick","data","f0","rgb","f90","iridescence","F","mix","iridescenceFresnel","iridescenceFactor","x","specularRoughness","alphaRoughness","mul","Dggx","distributionGGX","D","equal","dirAngle","Math","PI","anisotropyDirectionTexture","dirSample","sampleAnisotropyDirectionTexture","r","y","anisoAngle","up","t0","cross","lessThan","length","b0","tangent","cos","sin","bitangent","ToH","BoH","at","max","ab","sub","anisoDenom","pow","div","$elseif","glintNoise","fract","glintMask","smoothStep","V","visGGX","specular","specularWeight","sheen","sheenAlbedoScaling","iridescenceFresnelMax","g","b","diffuseBRDF","diffuse","transmission","drawContext","renderPass","type","RENDER_PASS_TYPE_LIGHT","transmissionRay","getVolumeTransmissionRay","thicknessFactor","a","pointToLight","transmittedLight","getPunctualRadianceTransmission","applyVolumeAttenuation","attenuationColor","attenuationDistance","transmissionFactor","sheenD","D_Charlie","sheenRoughness","sheenV","V_Ashikhmin","sheenColor","clearcoat","ccFactor","ccNormal","ccF0","ccNoV","$g","clamped","min","calculateAnisotropyDirectionScaleBias","PBRLight","worldPos","albedo","TBN","outRoughness","mat3","vec4","out","pbrData","getCommonData","lightingColor","emissiveColor","calculateEmissiveColor","indirectLighting","forEachLight","posRange","dirCutoff","colorIntensity","extra","shadow","LIGHT_TYPE_RECT","directRectLight","$else","LIGHT_TYPE_POINT","z","distance","xyz","lightAtten","calculateLightAttenuation","calculateLightDirection","calculateShadow","$return","getGlobalScope","vertexShader","needFragmentColor","materialFlags","MaterialVaryingFlags","INSTANCING","$outputs","zMetallic","getInstancedUniform","zRoughness","zSpecularFactor","fragmentShader","uniform","vec2","applyUniformValues","bindGroup","ctx","pass","setValue","calculateMetallic","_albedo","_normal","instancing","$inputs","calculateRoughness","calculateSpecularFactor","calculateCommonData","calculateReflectionMode","metallicRoughnessTexture","metallicRoughnessSample","sampleMetallicRoughnessTexture","ShaderHelper","getCameraRoughnessFactor","specularColorTexture","specularColor","sampleSpecularColorTexture","specularTexture","sampleSpecularTexture","notEqual","getF0","calculateAnisotropy","calculateAnisotropyDirection"],"mappings":";;;;;;;;AAsBA,MAAMA,mBAAyD,GAAA;IAC7DC,IAAM,EAAA,CAAA;IACNC,GAAK,EAAA,CAAA;IACLC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K,CAACiF,mBAAoB5L,CAAAA,KAAAA,EAAOoI,MAAQjI,EAAAA,MAAAA,EAAQC,SAASiI,GAAK/F,EAAAA,IAAAA,CAAAA;AACjE;AACAuJ,QAAAA,uBAAAA,CAAwB7L,KAA4B,EAAE;AACpD,YAAA,OAAOA,MAAMoB,eAAe;AAC9B;AACAsL,QAAAA,mBAAAA,CAAoB1M,KAA4B,EAAE;AAChD,YAAA,OAAOA,MAAMqB,WAAW;AAC1B;AACAsL,QAAAA,4BAAAA,CAA6B3M,KAA4B,EAAE;AACzD,YAAA,OAAOA,MAAMsB,oBAAoB;AACnC;AACF,KAAA;AACF;;;;"}
@@ -13,10 +13,6 @@ import { Vector3 } from '@zephyr3d/base';
13
13
  /** @internal */ static FEATURE_VERTEX_NORMAL = this.defineFeature();
14
14
  /** @internal */ static FEATURE_VERTEX_TANGENT = this.defineFeature();
15
15
  /** @internal */ static FEATURE_SUBSURFACE_SCATTERING = this.defineFeature();
16
- /** @internal */ static SUBSURFACE_COLOR_UNIFORM = this.defineInstanceUniform('subsurfaceColor', 'rgb', 'SubsurfaceColor');
17
- /** @internal */ static SUBSURFACE_SCALE_UNIFORM = this.defineInstanceUniform('subsurfaceScale', 'float', 'SubsurfaceScale');
18
- /** @internal */ static SUBSURFACE_POWER_UNIFORM = this.defineInstanceUniform('subsurfacePower', 'float', 'SubsurfacePower');
19
- /** @internal */ static SUBSURFACE_INTENSITY_UNIFORM = this.defineInstanceUniform('subsurfaceIntensity', 'float', 'SubsurfaceIntensity');
20
16
  _subsurfaceColor;
21
17
  _subsurfaceScale;
22
18
  _subsurfacePower;
@@ -143,17 +139,11 @@ import { Vector3 } from '@zephyr3d/base';
143
139
  scope.$outputs.wBinormal = pb.mul(pb.cross(scope.$outputs.wNorm, scope.$outputs.wTangent), scope.oTangent.w);
144
140
  }
145
141
  }
146
- if (this.subsurfaceScattering && this.needFragmentColor() && this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {
147
- scope.$outputs.zSubsurfaceColor = this.getInstancedUniform(scope, PBRMetallicRoughnessMaterial.SUBSURFACE_COLOR_UNIFORM);
148
- scope.$outputs.zSubsurfaceScale = this.getInstancedUniform(scope, PBRMetallicRoughnessMaterial.SUBSURFACE_SCALE_UNIFORM);
149
- scope.$outputs.zSubsurfacePower = this.getInstancedUniform(scope, PBRMetallicRoughnessMaterial.SUBSURFACE_POWER_UNIFORM);
150
- scope.$outputs.zSubsurfaceIntensity = this.getInstancedUniform(scope, PBRMetallicRoughnessMaterial.SUBSURFACE_INTENSITY_UNIFORM);
151
- }
152
142
  }
153
143
  fragmentShader(scope) {
154
144
  super.fragmentShader(scope);
155
145
  const pb = scope.$builder;
156
- if (this.subsurfaceScattering && this.needFragmentColor() && this.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT && !(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)) {
146
+ if (this.subsurfaceScattering && this.needFragmentColor() && this.drawContext.renderPass.type === RENDER_PASS_TYPE_LIGHT) {
157
147
  scope.zSubsurfaceColor = pb.vec3().uniform(2);
158
148
  scope.zSubsurfaceScale = pb.float().uniform(2);
159
149
  scope.zSubsurfacePower = pb.float().uniform(2);
@@ -1 +1 @@
1
- {"version":3,"file":"pbrmr.js","sources":["../../src/material/pbrmr.ts"],"sourcesContent":["import { MeshMaterial, applyMaterialMixins } from './meshmaterial';\r\nimport { mixinVertexColor } from './mixins/vertexcolor';\r\nimport type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport { mixinPBRMetallicRoughness } from './mixins/lightmodel/pbrmetallicroughness';\r\nimport { mixinTextureProps } from './mixins/texture';\r\nimport { ShaderHelper } from './shader/helper';\r\nimport { MaterialVaryingFlags, RENDER_PASS_TYPE_LIGHT } from '../values';\r\nimport type { Clonable, Immutable } from '@zephyr3d/base';\r\nimport { Vector3 } from '@zephyr3d/base';\r\nimport type { DrawContext } from '../render';\r\n\r\n/**\r\n * PBRMetallicRoughnessMaterial class\r\n * @public\r\n */\r\nexport class PBRMetallicRoughnessMaterial\r\n extends applyMaterialMixins(\r\n MeshMaterial,\r\n mixinPBRMetallicRoughness,\r\n mixinVertexColor,\r\n mixinTextureProps('subsurface')\r\n )\r\n implements Clonable<PBRMetallicRoughnessMaterial>\r\n{\r\n /** @internal */\r\n private static readonly FEATURE_VERTEX_NORMAL = this.defineFeature();\r\n /** @internal */\r\n private static readonly FEATURE_VERTEX_TANGENT = this.defineFeature();\r\n /** @internal */\r\n private static readonly FEATURE_SUBSURFACE_SCATTERING = this.defineFeature();\r\n /** @internal */\r\n private static readonly SUBSURFACE_COLOR_UNIFORM = this.defineInstanceUniform(\r\n 'subsurfaceColor',\r\n 'rgb',\r\n 'SubsurfaceColor'\r\n );\r\n /** @internal */\r\n private static readonly SUBSURFACE_SCALE_UNIFORM = this.defineInstanceUniform(\r\n 'subsurfaceScale',\r\n 'float',\r\n 'SubsurfaceScale'\r\n );\r\n /** @internal */\r\n private static readonly SUBSURFACE_POWER_UNIFORM = this.defineInstanceUniform(\r\n 'subsurfacePower',\r\n 'float',\r\n 'SubsurfacePower'\r\n );\r\n /** @internal */\r\n private static readonly SUBSURFACE_INTENSITY_UNIFORM = this.defineInstanceUniform(\r\n 'subsurfaceIntensity',\r\n 'float',\r\n 'SubsurfaceIntensity'\r\n );\r\n private readonly _subsurfaceColor: Vector3;\r\n private _subsurfaceScale: number;\r\n private _subsurfacePower: number;\r\n private _subsurfaceIntensity: number;\r\n /**\r\n * Creates an instance of PBRMetallicRoughnessMaterial class\r\n */\r\n constructor() {\r\n super();\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.useFeature(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_NORMAL, true);\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_SUBSURFACE_SCATTERING, false);\r\n this.transmission = false;\r\n this.transmissionFactor = 0.2;\r\n this.thicknessFactor = 0.35;\r\n this.attenuationColor = new Vector3(1, 0.5, 0.4);\r\n this.attenuationDistance = 0.6;\r\n }\r\n clone() {\r\n const other = new PBRMetallicRoughnessMaterial();\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.vertexNormal = other.vertexNormal;\r\n this.vertexTangent = other.vertexTangent;\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 }\r\n /** true if vertex normal attribute presents */\r\n get vertexNormal() {\r\n return this.featureUsed<boolean>(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_NORMAL);\r\n }\r\n set vertexNormal(val) {\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_NORMAL, !!val);\r\n }\r\n /** true if vertex normal attribute presents */\r\n get vertexTangent() {\r\n return this.featureUsed<boolean>(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_TANGENT);\r\n }\r\n set vertexTangent(val) {\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_TANGENT, !!val);\r\n }\r\n /** true if subsurface scattering is enabled */\r\n get subsurfaceScattering() {\r\n return this.featureUsed<boolean>(PBRMetallicRoughnessMaterial.FEATURE_SUBSURFACE_SCATTERING);\r\n }\r\n set subsurfaceScattering(val) {\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_SUBSURFACE_SCATTERING, !!val);\r\n }\r\n /** subsurface scattering color tint */\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 /** wrap factor for the scattering profile */\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 /** profile exponent for the scattering profile */\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 /** final intensity of scattering contribution */\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 private getSubsurfaceColor(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfaceColor : scope.zSubsurfaceColor) as PBShaderExp;\r\n }\r\n private getSubsurfaceScale(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfaceScale : scope.zSubsurfaceScale) as PBShaderExp;\r\n }\r\n private getSubsurfacePower(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfacePower : scope.zSubsurfacePower) as PBShaderExp;\r\n }\r\n private getSubsurfaceIntensity(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfaceIntensity : scope.zSubsurfaceIntensity) as PBShaderExp;\r\n }\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n const pb = scope.$builder;\r\n const worldMatrix = ShaderHelper.getWorldMatrix(scope);\r\n scope.$l.oPos = ShaderHelper.resolveVertexPosition(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 if (this.transmission) {\r\n scope.$outputs.screenUV = pb.add(pb.mul(pb.div(scope.csPos.xy, scope.csPos.w), 0.5), pb.vec2(0.5));\r\n scope.$outputs.modelScale = pb.vec3(\r\n pb.length(worldMatrix[0].xyz),\r\n pb.length(worldMatrix[1].xyz),\r\n pb.length(worldMatrix[2].xyz)\r\n );\r\n }\r\n if (this.vertexNormal) {\r\n scope.$l.oNorm = ShaderHelper.resolveVertexNormal(scope);\r\n scope.$outputs.wNorm = pb.mul(ShaderHelper.getNormalMatrix(scope), pb.vec4(scope.oNorm, 0)).xyz;\r\n if (this.vertexTangent) {\r\n scope.$l.oTangent = ShaderHelper.resolveVertexTangent(scope);\r\n scope.$outputs.wTangent = pb.mul(\r\n ShaderHelper.getNormalMatrix(scope),\r\n pb.vec4(scope.oTangent.xyz, 0)\r\n ).xyz;\r\n scope.$outputs.wBinormal = pb.mul(\r\n pb.cross(scope.$outputs.wNorm, scope.$outputs.wTangent),\r\n scope.oTangent.w\r\n );\r\n }\r\n }\r\n if (\r\n this.subsurfaceScattering &&\r\n this.needFragmentColor() &&\r\n this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING\r\n ) {\r\n scope.$outputs.zSubsurfaceColor = this.getInstancedUniform(\r\n scope,\r\n PBRMetallicRoughnessMaterial.SUBSURFACE_COLOR_UNIFORM\r\n );\r\n scope.$outputs.zSubsurfaceScale = this.getInstancedUniform(\r\n scope,\r\n PBRMetallicRoughnessMaterial.SUBSURFACE_SCALE_UNIFORM\r\n );\r\n scope.$outputs.zSubsurfacePower = this.getInstancedUniform(\r\n scope,\r\n PBRMetallicRoughnessMaterial.SUBSURFACE_POWER_UNIFORM\r\n );\r\n scope.$outputs.zSubsurfaceIntensity = this.getInstancedUniform(\r\n scope,\r\n PBRMetallicRoughnessMaterial.SUBSURFACE_INTENSITY_UNIFORM\r\n );\r\n }\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 !(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING)\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.$l.albedo = this.calculateAlbedoColor(scope);\r\n if (this.vertexColor) {\r\n scope.albedo = pb.mul(scope.albedo, this.getVertexColor(scope));\r\n }\r\n if (this.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n scope.$l.normalInfo = this.calculateNormalAndTBN(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.$inputs.wNorm,\r\n scope.$inputs.wTangent,\r\n scope.$inputs.wBinormal\r\n );\r\n scope.$l.viewVec = this.calculateViewVector(scope, scope.$inputs.worldPos);\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.normalInfo.normal,\r\n scope.viewVec,\r\n scope.albedo,\r\n scope.normalInfo.TBN,\r\n scope.outRoughness\r\n );\r\n if (this.subsurfaceScattering) {\r\n scope.$l.NoV = pb.clamp(pb.dot(scope.normalInfo.normal, scope.viewVec), 0, 1);\r\n scope.$l.wrapNdotV = pb.clamp(\r\n pb.div(\r\n pb.add(pb.sub(1, scope.NoV), this.getSubsurfaceScale(scope)),\r\n pb.add(1, this.getSubsurfaceScale(scope))\r\n ),\r\n 0,\r\n 1\r\n );\r\n scope.$l.sssFactor = pb.mul(\r\n pb.pow(scope.wrapNdotV, this.getSubsurfacePower(scope)),\r\n this.getSubsurfaceIntensity(scope)\r\n );\r\n if (this.subsurfaceTexture) {\r\n scope.sssFactor = pb.mul(scope.sssFactor, this.sampleSubsurfaceTexture(scope).r);\r\n }\r\n scope.litColor = pb.add(\r\n scope.litColor,\r\n pb.mul(scope.albedo.rgb, this.getSubsurfaceColor(scope), scope.sssFactor)\r\n );\r\n }\r\n /*\r\n scope.outRoughness = pb.vec4(\r\n pb.add(pb.mul(scope.normalInfo.normal, 0.5), pb.vec3(0.5)),\r\n scope.outRoughness.a\r\n );\r\n */\r\n this.outputFragmentColor(\r\n scope,\r\n scope.$inputs.worldPos,\r\n pb.vec4(scope.litColor, scope.albedo.a),\r\n scope.outRoughness,\r\n pb.vec4(pb.add(pb.mul(scope.normalInfo.normal, 0.5), pb.vec3(0.5)), 1)\r\n );\r\n } else {\r\n scope.$l.litColor = this.PBRLight(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.normalInfo.normal,\r\n scope.viewVec,\r\n scope.albedo,\r\n scope.normalInfo.TBN\r\n );\r\n if (this.subsurfaceScattering) {\r\n scope.$l.NoV = pb.clamp(pb.dot(scope.normalInfo.normal, scope.viewVec), 0, 1);\r\n scope.$l.wrapNdotV = pb.clamp(\r\n pb.div(\r\n pb.add(pb.sub(1, scope.NoV), this.getSubsurfaceScale(scope)),\r\n pb.add(1, this.getSubsurfaceScale(scope))\r\n ),\r\n 0,\r\n 1\r\n );\r\n scope.$l.sssFactor = pb.mul(\r\n pb.pow(scope.wrapNdotV, this.getSubsurfacePower(scope)),\r\n this.getSubsurfaceIntensity(scope)\r\n );\r\n if (this.subsurfaceTexture) {\r\n scope.sssFactor = pb.mul(scope.sssFactor, this.sampleSubsurfaceTexture(scope).r);\r\n }\r\n scope.litColor = pb.add(\r\n scope.litColor,\r\n pb.mul(scope.albedo.rgb, this.getSubsurfaceColor(scope), scope.sssFactor)\r\n );\r\n }\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, pb.vec4(scope.litColor, scope.albedo.a));\r\n }\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.albedo);\r\n }\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 (\r\n this.subsurfaceScattering &&\r\n this.needFragmentColor(ctx) &&\r\n ctx.renderPass!.type === RENDER_PASS_TYPE_LIGHT &&\r\n !(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)\r\n ) {\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"],"names":["PBRMetallicRoughnessMaterial","applyMaterialMixins","MeshMaterial","mixinPBRMetallicRoughness","mixinVertexColor","mixinTextureProps","FEATURE_VERTEX_NORMAL","defineFeature","FEATURE_VERTEX_TANGENT","FEATURE_SUBSURFACE_SCATTERING","SUBSURFACE_COLOR_UNIFORM","defineInstanceUniform","SUBSURFACE_SCALE_UNIFORM","SUBSURFACE_POWER_UNIFORM","SUBSURFACE_INTENSITY_UNIFORM","_subsurfaceColor","_subsurfaceScale","_subsurfacePower","_subsurfaceIntensity","Vector3","useFeature","transmission","transmissionFactor","thicknessFactor","attenuationColor","attenuationDistance","clone","other","copyFrom","vertexNormal","vertexTangent","subsurfaceScattering","subsurfaceColor","subsurfaceScale","subsurfacePower","subsurfaceIntensity","featureUsed","val","equalsTo","set","uniformChanged","getSubsurfaceColor","scope","instancing","drawContext","materialFlags","MaterialVaryingFlags","INSTANCING","$inputs","zSubsurfaceColor","getSubsurfaceScale","zSubsurfaceScale","getSubsurfacePower","zSubsurfacePower","getSubsurfaceIntensity","zSubsurfaceIntensity","vertexShader","pb","$builder","worldMatrix","ShaderHelper","getWorldMatrix","$l","oPos","resolveVertexPosition","$outputs","worldPos","mul","vec4","xyz","csPos","getViewProjectionMatrix","setClipSpacePosition","screenUV","add","div","xy","w","vec2","modelScale","vec3","length","oNorm","resolveVertexNormal","wNorm","getNormalMatrix","oTangent","resolveVertexTangent","wTangent","wBinormal","cross","needFragmentColor","getInstancedUniform","fragmentShader","renderPass","type","RENDER_PASS_TYPE_LIGHT","uniform","float","albedo","calculateAlbedoColor","vertexColor","getVertexColor","normalInfo","calculateNormalAndTBN","viewVec","calculateViewVector","SSR_STORE_ROUGHNESS","outRoughness","litColor","PBRLight","normal","TBN","NoV","clamp","dot","wrapNdotV","sub","sssFactor","pow","subsurfaceTexture","sampleSubsurfaceTexture","r","rgb","outputFragmentColor","a","applyUniformValues","bindGroup","ctx","pass","setValue"],"mappings":";;;;;;;;AAWA;;;AAGC,IACM,MAAMA,4BAAAA,SACHC,oBACNC,YACAC,EAAAA,yBAAAA,EACAC,kBACAC,iBAAkB,CAAA,YAAA,CAAA,CAAA,CAAA;AAIpB,qBACA,OAAwBC,qBAAAA,GAAwB,IAAI,CAACC,aAAa,EAAG;AACrE,qBACA,OAAwBC,sBAAAA,GAAyB,IAAI,CAACD,aAAa,EAAG;AACtE,qBACA,OAAwBE,6BAAAA,GAAgC,IAAI,CAACF,aAAa,EAAG;qBAE7E,OAAwBG,wBAA2B,GAAA,IAAI,CAACC,qBAAqB,CAC3E,iBACA,EAAA,KAAA,EACA,iBACA,CAAA;qBAEF,OAAwBC,wBAA2B,GAAA,IAAI,CAACD,qBAAqB,CAC3E,iBACA,EAAA,OAAA,EACA,iBACA,CAAA;qBAEF,OA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GAAAA,CAAInF,aAAa,GAAGC,oBAAAA,CAAqBC,UAAS,CACpD,EAAA;AACAgF,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,kBAAoB,EAAA,IAAI,CAACnH,gBAAgB,CAAA;AAC5DgH,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,kBAAoB,EAAA,IAAI,CAAClH,gBAAgB,CAAA;AAC5D+G,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,kBAAoB,EAAA,IAAI,CAACjH,gBAAgB,CAAA;AAC5D8G,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,sBAAwB,EAAA,IAAI,CAAChH,oBAAoB,CAAA;AACtE;AACF;AACF;;;;"}
1
+ {"version":3,"file":"pbrmr.js","sources":["../../src/material/pbrmr.ts"],"sourcesContent":["import { MeshMaterial, applyMaterialMixins } from './meshmaterial';\r\nimport { mixinVertexColor } from './mixins/vertexcolor';\r\nimport type { BindGroup, PBFunctionScope, PBInsideFunctionScope, PBShaderExp } from '@zephyr3d/device';\r\nimport { mixinPBRMetallicRoughness } from './mixins/lightmodel/pbrmetallicroughness';\r\nimport { mixinTextureProps } from './mixins/texture';\r\nimport { ShaderHelper } from './shader/helper';\r\nimport { MaterialVaryingFlags, RENDER_PASS_TYPE_LIGHT } from '../values';\r\nimport type { Clonable, Immutable } from '@zephyr3d/base';\r\nimport { Vector3 } from '@zephyr3d/base';\r\nimport type { DrawContext } from '../render';\r\n\r\n/**\r\n * PBRMetallicRoughnessMaterial class\r\n * @public\r\n */\r\nexport class PBRMetallicRoughnessMaterial\r\n extends applyMaterialMixins(\r\n MeshMaterial,\r\n mixinPBRMetallicRoughness,\r\n mixinVertexColor,\r\n mixinTextureProps('subsurface')\r\n )\r\n implements Clonable<PBRMetallicRoughnessMaterial>\r\n{\r\n /** @internal */\r\n private static readonly FEATURE_VERTEX_NORMAL = this.defineFeature();\r\n /** @internal */\r\n private static readonly FEATURE_VERTEX_TANGENT = this.defineFeature();\r\n /** @internal */\r\n private static readonly FEATURE_SUBSURFACE_SCATTERING = this.defineFeature();\r\n private readonly _subsurfaceColor: Vector3;\r\n private _subsurfaceScale: number;\r\n private _subsurfacePower: number;\r\n private _subsurfaceIntensity: number;\r\n /**\r\n * Creates an instance of PBRMetallicRoughnessMaterial class\r\n */\r\n constructor() {\r\n super();\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.useFeature(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_NORMAL, true);\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_SUBSURFACE_SCATTERING, false);\r\n this.transmission = false;\r\n this.transmissionFactor = 0.2;\r\n this.thicknessFactor = 0.35;\r\n this.attenuationColor = new Vector3(1, 0.5, 0.4);\r\n this.attenuationDistance = 0.6;\r\n }\r\n clone() {\r\n const other = new PBRMetallicRoughnessMaterial();\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.vertexNormal = other.vertexNormal;\r\n this.vertexTangent = other.vertexTangent;\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 }\r\n /** true if vertex normal attribute presents */\r\n get vertexNormal() {\r\n return this.featureUsed<boolean>(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_NORMAL);\r\n }\r\n set vertexNormal(val) {\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_NORMAL, !!val);\r\n }\r\n /** true if vertex normal attribute presents */\r\n get vertexTangent() {\r\n return this.featureUsed<boolean>(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_TANGENT);\r\n }\r\n set vertexTangent(val) {\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_VERTEX_TANGENT, !!val);\r\n }\r\n /** true if subsurface scattering is enabled */\r\n get subsurfaceScattering() {\r\n return this.featureUsed<boolean>(PBRMetallicRoughnessMaterial.FEATURE_SUBSURFACE_SCATTERING);\r\n }\r\n set subsurfaceScattering(val) {\r\n this.useFeature(PBRMetallicRoughnessMaterial.FEATURE_SUBSURFACE_SCATTERING, !!val);\r\n }\r\n /** subsurface scattering color tint */\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 /** wrap factor for the scattering profile */\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 /** profile exponent for the scattering profile */\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 /** final intensity of scattering contribution */\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 private getSubsurfaceColor(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfaceColor : scope.zSubsurfaceColor) as PBShaderExp;\r\n }\r\n private getSubsurfaceScale(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfaceScale : scope.zSubsurfaceScale) as PBShaderExp;\r\n }\r\n private getSubsurfacePower(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfacePower : scope.zSubsurfacePower) as PBShaderExp;\r\n }\r\n private getSubsurfaceIntensity(scope: PBInsideFunctionScope): PBShaderExp {\r\n const instancing = !!(this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING);\r\n return (instancing ? scope.$inputs.zSubsurfaceIntensity : scope.zSubsurfaceIntensity) as PBShaderExp;\r\n }\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n const pb = scope.$builder;\r\n const worldMatrix = ShaderHelper.getWorldMatrix(scope);\r\n scope.$l.oPos = ShaderHelper.resolveVertexPosition(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 if (this.transmission) {\r\n scope.$outputs.screenUV = pb.add(pb.mul(pb.div(scope.csPos.xy, scope.csPos.w), 0.5), pb.vec2(0.5));\r\n scope.$outputs.modelScale = pb.vec3(\r\n pb.length(worldMatrix[0].xyz),\r\n pb.length(worldMatrix[1].xyz),\r\n pb.length(worldMatrix[2].xyz)\r\n );\r\n }\r\n if (this.vertexNormal) {\r\n scope.$l.oNorm = ShaderHelper.resolveVertexNormal(scope);\r\n scope.$outputs.wNorm = pb.mul(ShaderHelper.getNormalMatrix(scope), pb.vec4(scope.oNorm, 0)).xyz;\r\n if (this.vertexTangent) {\r\n scope.$l.oTangent = ShaderHelper.resolveVertexTangent(scope);\r\n scope.$outputs.wTangent = pb.mul(\r\n ShaderHelper.getNormalMatrix(scope),\r\n pb.vec4(scope.oTangent.xyz, 0)\r\n ).xyz;\r\n scope.$outputs.wBinormal = pb.mul(\r\n pb.cross(scope.$outputs.wNorm, scope.$outputs.wTangent),\r\n scope.oTangent.w\r\n );\r\n }\r\n }\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.$l.albedo = this.calculateAlbedoColor(scope);\r\n if (this.vertexColor) {\r\n scope.albedo = pb.mul(scope.albedo, this.getVertexColor(scope));\r\n }\r\n if (this.drawContext.renderPass!.type === RENDER_PASS_TYPE_LIGHT) {\r\n scope.$l.normalInfo = this.calculateNormalAndTBN(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.$inputs.wNorm,\r\n scope.$inputs.wTangent,\r\n scope.$inputs.wBinormal\r\n );\r\n scope.$l.viewVec = this.calculateViewVector(scope, scope.$inputs.worldPos);\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.normalInfo.normal,\r\n scope.viewVec,\r\n scope.albedo,\r\n scope.normalInfo.TBN,\r\n scope.outRoughness\r\n );\r\n if (this.subsurfaceScattering) {\r\n scope.$l.NoV = pb.clamp(pb.dot(scope.normalInfo.normal, scope.viewVec), 0, 1);\r\n scope.$l.wrapNdotV = pb.clamp(\r\n pb.div(\r\n pb.add(pb.sub(1, scope.NoV), this.getSubsurfaceScale(scope)),\r\n pb.add(1, this.getSubsurfaceScale(scope))\r\n ),\r\n 0,\r\n 1\r\n );\r\n scope.$l.sssFactor = pb.mul(\r\n pb.pow(scope.wrapNdotV, this.getSubsurfacePower(scope)),\r\n this.getSubsurfaceIntensity(scope)\r\n );\r\n if (this.subsurfaceTexture) {\r\n scope.sssFactor = pb.mul(scope.sssFactor, this.sampleSubsurfaceTexture(scope).r);\r\n }\r\n scope.litColor = pb.add(\r\n scope.litColor,\r\n pb.mul(scope.albedo.rgb, this.getSubsurfaceColor(scope), scope.sssFactor)\r\n );\r\n }\r\n /*\r\n scope.outRoughness = pb.vec4(\r\n pb.add(pb.mul(scope.normalInfo.normal, 0.5), pb.vec3(0.5)),\r\n scope.outRoughness.a\r\n );\r\n */\r\n this.outputFragmentColor(\r\n scope,\r\n scope.$inputs.worldPos,\r\n pb.vec4(scope.litColor, scope.albedo.a),\r\n scope.outRoughness,\r\n pb.vec4(pb.add(pb.mul(scope.normalInfo.normal, 0.5), pb.vec3(0.5)), 1)\r\n );\r\n } else {\r\n scope.$l.litColor = this.PBRLight(\r\n scope,\r\n scope.$inputs.worldPos,\r\n scope.normalInfo.normal,\r\n scope.viewVec,\r\n scope.albedo,\r\n scope.normalInfo.TBN\r\n );\r\n if (this.subsurfaceScattering) {\r\n scope.$l.NoV = pb.clamp(pb.dot(scope.normalInfo.normal, scope.viewVec), 0, 1);\r\n scope.$l.wrapNdotV = pb.clamp(\r\n pb.div(\r\n pb.add(pb.sub(1, scope.NoV), this.getSubsurfaceScale(scope)),\r\n pb.add(1, this.getSubsurfaceScale(scope))\r\n ),\r\n 0,\r\n 1\r\n );\r\n scope.$l.sssFactor = pb.mul(\r\n pb.pow(scope.wrapNdotV, this.getSubsurfacePower(scope)),\r\n this.getSubsurfaceIntensity(scope)\r\n );\r\n if (this.subsurfaceTexture) {\r\n scope.sssFactor = pb.mul(scope.sssFactor, this.sampleSubsurfaceTexture(scope).r);\r\n }\r\n scope.litColor = pb.add(\r\n scope.litColor,\r\n pb.mul(scope.albedo.rgb, this.getSubsurfaceColor(scope), scope.sssFactor)\r\n );\r\n }\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, pb.vec4(scope.litColor, scope.albedo.a));\r\n }\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.worldPos, scope.albedo);\r\n }\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 (\r\n this.subsurfaceScattering &&\r\n this.needFragmentColor(ctx) &&\r\n ctx.renderPass!.type === RENDER_PASS_TYPE_LIGHT &&\r\n !(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)\r\n ) {\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"],"names":["PBRMetallicRoughnessMaterial","applyMaterialMixins","MeshMaterial","mixinPBRMetallicRoughness","mixinVertexColor","mixinTextureProps","FEATURE_VERTEX_NORMAL","defineFeature","FEATURE_VERTEX_TANGENT","FEATURE_SUBSURFACE_SCATTERING","_subsurfaceColor","_subsurfaceScale","_subsurfacePower","_subsurfaceIntensity","Vector3","useFeature","transmission","transmissionFactor","thicknessFactor","attenuationColor","attenuationDistance","clone","other","copyFrom","vertexNormal","vertexTangent","subsurfaceScattering","subsurfaceColor","subsurfaceScale","subsurfacePower","subsurfaceIntensity","featureUsed","val","equalsTo","set","uniformChanged","getSubsurfaceColor","scope","instancing","drawContext","materialFlags","MaterialVaryingFlags","INSTANCING","$inputs","zSubsurfaceColor","getSubsurfaceScale","zSubsurfaceScale","getSubsurfacePower","zSubsurfacePower","getSubsurfaceIntensity","zSubsurfaceIntensity","vertexShader","pb","$builder","worldMatrix","ShaderHelper","getWorldMatrix","$l","oPos","resolveVertexPosition","$outputs","worldPos","mul","vec4","xyz","csPos","getViewProjectionMatrix","setClipSpacePosition","screenUV","add","div","xy","w","vec2","modelScale","vec3","length","oNorm","resolveVertexNormal","wNorm","getNormalMatrix","oTangent","resolveVertexTangent","wTangent","wBinormal","cross","fragmentShader","needFragmentColor","renderPass","type","RENDER_PASS_TYPE_LIGHT","uniform","float","albedo","calculateAlbedoColor","vertexColor","getVertexColor","normalInfo","calculateNormalAndTBN","viewVec","calculateViewVector","SSR_STORE_ROUGHNESS","outRoughness","litColor","PBRLight","normal","TBN","NoV","clamp","dot","wrapNdotV","sub","sssFactor","pow","subsurfaceTexture","sampleSubsurfaceTexture","r","rgb","outputFragmentColor","a","applyUniformValues","bindGroup","ctx","pass","setValue"],"mappings":";;;;;;;;AAWA;;;AAGC,IACM,MAAMA,4BAAAA,SACHC,oBACNC,YACAC,EAAAA,yBAAAA,EACAC,kBACAC,iBAAkB,CAAA,YAAA,CAAA,CAAA,CAAA;AAIpB,qBACA,OAAwBC,qBAAAA,GAAwB,IAAI,CAACC,aAAa,EAAG;AACrE,qBACA,OAAwBC,sBAAAA,GAAyB,IAAI,CAACD,aAAa,EAAG;AACtE,qBACA,OAAwBE,6BAAAA,GAAgC,IAAI,CAACF,aAAa,EAAG;IAC5DG,gBAA0B;IACnCC,gBAAyB;IACzBC,gBAAyB;IACzBC,oBAA6B;AACrC;;AAEC,MACD,WAAc,EAAA;QACZ,KAAK,EAAA;AACL,QAAA,IAAI,CAACH,gBAAgB,GAAG,IAAII,OAAAA,CAAQ,GAAG,GAAK,EAAA,GAAA,CAAA;QAC5C,IAAI,CAACH,gBAAgB,GAAG,GAAA;QACxB,IAAI,CAACC,gBAAgB,GAAG,GAAA;QACxB,IAAI,CAACC,oBAAoB,GAAG,GAAA;AAC5B,QAAA,IAAI,CAACE,UAAU,CAACf,4BAAAA,CAA6BM,qBAAqB,EAAE,IAAA,CAAA;AACpE,QAAA,IAAI,CAACS,UAAU,CAACf,4BAAAA,CAA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C5D+G,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,kBAAoB,EAAA,IAAI,CAACjH,gBAAgB,CAAA;AAC5D8G,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,kBAAoB,EAAA,IAAI,CAAChH,gBAAgB,CAAA;AAC5D6G,YAAAA,SAAAA,CAAUG,QAAQ,CAAC,sBAAwB,EAAA,IAAI,CAAC/G,oBAAoB,CAAA;AACtE;AACF;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zephyr3d/scene",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Scene API for zephyr3d",
5
5
  "homepage": "https://github.com/gavinyork/zephyr3d#readme",
6
6
  "type": "module",