@hology/core 0.0.242 → 0.0.244
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.
- package/dist/effects/vfx/gpu-sprite-runtime.js +1 -1
- package/dist/effects/vfx/gpu-sprite-scheduler-runtime.js +1 -1
- package/dist/effects/vfx/gpu-sprite-world-runtime.js +1 -1
- package/dist/effects/vfx/initializsers.d.ts +7 -1
- package/dist/effects/vfx/initializsers.js +1 -1
- package/dist/effects/vfx/vfx-materializer.js +1 -1
- package/dist/rendering/node-material-webgpu-resolver.d.ts +5 -3
- package/dist/rendering/node-material-webgpu-resolver.js +1 -1
- package/dist/scene/materializer.js +1 -1
- package/dist/scene/model.d.ts +2 -0
- package/dist/scene/storage/storage.d.ts +7 -0
- package/dist/scene/storage/storage.js +1 -1
- package/dist/shader/graph/compiler.d.ts +35 -0
- package/dist/shader/graph/compiler.js +1 -1
- package/dist/shader/graph/model.d.ts +3 -3
- package/dist/shader/graph/registry.js +1 -1
- package/dist/test/gpu-sprite-compiler.test.js +1 -1
- package/dist/test/node-material-webgpu-resolver.test.js +1 -1
- package/dist/test/shader-graph.test.js +1 -1
- package/dist/test/vfx-world-space-emitter-rotation.test.js +1 -1
- package/package.json +3 -3
- package/tsconfig.tsbuildinfo +1 -1
package/dist/scene/model.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare class ObjectStorage<T extends StorageEntity> {
|
|
|
16
16
|
private filePathFn?;
|
|
17
17
|
private serializer;
|
|
18
18
|
private path;
|
|
19
|
+
private getAllInFlight;
|
|
19
20
|
private basePathUpdates;
|
|
20
21
|
private basePath;
|
|
21
22
|
private loaded;
|
|
@@ -54,6 +55,7 @@ export declare class ObjectStorage<T extends StorageEntity> {
|
|
|
54
55
|
private reloadSubdirectory;
|
|
55
56
|
private readFileIfExists;
|
|
56
57
|
getAll(relativePath?: string): Promise<T[]>;
|
|
58
|
+
private getAllUncached;
|
|
57
59
|
private getObjectFilePaths;
|
|
58
60
|
get(id: string): Promise<T>;
|
|
59
61
|
save(obj: T): Promise<T>;
|
|
@@ -89,6 +91,11 @@ export type StorageWatchEvent<T> = {
|
|
|
89
91
|
object: T | null;
|
|
90
92
|
path: string;
|
|
91
93
|
filename: string;
|
|
94
|
+
} | {
|
|
95
|
+
event: "resource-change";
|
|
96
|
+
object: null;
|
|
97
|
+
path: string;
|
|
98
|
+
filename: string;
|
|
92
99
|
};
|
|
93
100
|
export declare function defaultSerializer<T>(obj: Partial<T>): string;
|
|
94
101
|
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{randomUUID as e}from"../../utils/uuid.js";import{pathJoin as t}from"../../utils/files.js";import{EMPTY as a,filter as i,firstValueFrom as n,from as s,map as r,merge as h,mergeAll as o,mergeMap as l,Observable as c,of as d,startWith as u,Subject as p,switchMap as f,tap as w}from"rxjs";import{sleepDelay as m}from"../../utils/async.js";import{parseStorageJson as y,serializeStorageJson as v}from"./packed-json.js";export{decodeStorageValue,parseStorageJson,serializeStorageJson}from"./packed-json.js";const x={},j={},b={},g={};null==x.read&&window.require&&(Object.assign(x,window.require("fs")),Object.assign(j,x.promises),Object.assign(b,window.require("path")),Object.assign(g,window.require("chokidar")));const I=null!=x.existsSync;let P=0,F=0;const O=[];async function S(e){await function(){if(P<32)return P++,Promise.resolve();return new Promise(e=>O.push(e))}();try{return await e()}finally{!function(){const e=O[F];if(null==e)return O.length=0,F=0,void P--;F++,F>64&&2*F>O.length&&(O.splice(0,F),F=0);e()}()}}function C(e){return S(()=>j.readFile(e))}function E(){if(I){const e="--path=",t=window.process.argv.find(t=>t.startsWith(e));return t?t.substring(e.length):""}return""}const A=/^[A-Z]:/;function k(...e){return 0===e.length?"":A.test(e[0])||I?b.join(...e):t(...e)}export class ObjectStorage{get pathResources(){return k(this.path+"-resources")}constructor(e,t,a=defaultSerializer){this.name=e,this.filePathFn=t,this.serializer=a,this.basePathUpdates=new p,this.basePath=this.basePathUpdates.pipe(r(e=>k(E(),e)),w(e=>{this.path=k(e,this.name),this.cachedIndex=null,this.loadingIndex=null,D(this.path),this.determineIfMetaFileShouldBeCreated()})),this.loaded=n(this.basePath),this.cachedIndex=null,this.loadingIndex=null,this.shouldCreateIndex=!1}setBasePath(e){this.basePathUpdates.next(e)}async determineIfMetaFileShouldBeCreated(){if(I)try{const e=["vite.renderer.config.ts","vite.config.ts"];for(const t of e){const e=k(E(),t);if(!await U(e))continue;if((await C(e)).toString().includes("hologyBuild"))return void(this.shouldCreateIndex=!1)}this.shouldCreateIndex=!0}catch(e){console.warn("Failed to read vite config to determine if meta files should be created")}}async createFolder(e,t=""){K(),await j.mkdir(b.join(this.path,t,e),{recursive:!0})}async deleteFolderForceDangerous(e){await j.rm(b.join(this.path,e),{recursive:!0,force:!0})}async moveFolder(e,t){if(K(),""==e)return void console.warn("Can not move a folder in root");const a=b.resolve(b.join(this.path,t),b.basename(e));if(await $(a)){if(a!==b.resolve(this.path,e))throw new Error("Can not move to directory as a file already exists with the same name")}else{if(function(e,t){const a=b.resolve(e),i=b.resolve(t),n=b.normalize(a)+b.sep;return(b.normalize(i)+b.sep).startsWith(n)}(b.join(this.path,e),b.join(this.path,t)))throw new Error("Can not move a folder into a folder it contains");await j.rename(b.join(this.path,e),a)}}async renameFolder(e,t){await j.rename(b.join(this.path,e),b.resolve(b.dirname(b.join(this.path,e)),t))}async moveToFolder(e,t){if(K(),(e.path??"")===t)return e;const a={...e,path:t};await this.assertObjectFilePathAvailable(a,e.id);const i=this.privateObjectPath(a);return await j.rename(this.privateObjectPath(e),i),await this.addOrUpdateIndexEntry(a),a}getAbsolutePath(e=""){return b.join(this.path,e)}getResourceAbsolutePath(e=""){return b.join(this.pathResources,e)}watchFolders(){return s(this.loaded).pipe(f(()=>s(D(this.path))),f(()=>this.watchDir(this.path).pipe(i(e=>!e.filename.endsWith(".json")),u(null),f(()=>s(j.readdir(this.path,{recursive:!0,withFileTypes:!0}))),r(e=>Array.from(new Set(e.filter(e=>e.isDirectory()).map(e=>b.relative(this.path,b.join(e.parentPath,e.name)).replace(/^\.$/,"")).values()))))))}watch(){K();const e=s(this.loaded).pipe(f(()=>s(D(this.pathResources))),f(()=>this.watchDir(this.pathResources)),l(e=>{if(null==e||!["add","change","unlink"].includes(e.event))return a;const t=b.basename(e.filename);return s(this.getAll()).pipe(l(e=>{const i=e.filter(e=>e.fileKey===t);return 0===i.length?a:s(i).pipe(l(e=>{const t=this.privateObjectRelativePath(e);return s(this.readFileIfExists(t)).pipe(r(a=>({event:"change",object:a,path:e.path,filename:t})))}))}))})),t=s(this.loaded).pipe(f(()=>this.watchDir(this.path)),i(e=>"_meta.json"!==e.filename),l(e=>{const t={event:e.event,path:b.dirname(e.filename).replace(/^\.$/,""),filename:b.basename(e.filename)};return e.filename.endsWith(".json")?"unlink"!==e.event?s(this.readFileIfExists(e.filename)).pipe(w(e=>{null!=e&&(null==this.cachedIndex&&(this.cachedIndex={}),this.cachedIndex[e.id]={id:e.id,name:e.name??e.id,path:e.path},this.persistIndex())}),r(e=>({object:e,...t}))):d({object:null,...t}).pipe(w(()=>{const t=Object.keys(this.cachedIndex??{}).find(t=>this.privateObjectRelativePath(this.cachedIndex[t])===e.filename);t&&this.removeIndexEntry(t)})):"change"===e.event?s(this.reloadSubdirectory(e.filename)).pipe(o(),r(e=>({object:e,...t}))):a}));return h(t,e)}async reloadSubdirectory(e){return(await this.getAll(e)).filter(t=>t.path.startsWith(e))}async readFileIfExists(e){const t=k(this.path,e);for(let a=0;a<3;a++)try{const a=await C(t);return{...y(a.toString()),path:b.dirname(e).replace(/^\.$/,""),filename:b.basename(e)}}catch(e){if(2===a)return console.error("Could not read file at "+t,e),null;await m(50*(a+1))}return null}async getAll(e){if(I){await this.loaded,await D(this.path);const t=await this.getObjectFilePaths(e??""),a=null==e||""===e,i=[];for(let e=0;e<t.length;e+=32){const a=Math.min(32,t.length-e),n=await Promise.all(Array.from({length:a},(a,i)=>{const n=t[e+i];return C(k(this.path,n)).then(e=>({...y(e.toString()),path:b.dirname(n).replace(/^\.$/,""),filename:b.basename(n)}))}));i.push(...n)}return a&&(this.cachedIndex=z(i),await this.persistIndex()),i}const t=await this.loadIndex();return Promise.all(Object.keys(t).map(e=>this.get(e)))}async getObjectFilePaths(e){const t=this.path,a=b.join(t,e),i=[];return await async function e(a){const n=await j.readdir(a,{withFileTypes:!0});for(const s of n){const n=b.join(a,s.name);s.isDirectory()?await e(n):s.isFile()&&s.name.endsWith(".json")&&!/^[\._]/.test(s.name)&&i.push(b.relative(t,n))}}(a),i}async get(e){const t=await this.loadIndex(),a=t[e]??Object.values(t).find(t=>t.name===e);if(null==a)return;const i=this.privateObjectPath(a);if(!I)return y(await(await fetch(i)).text());return await U(i)?{...y((await C(i)).toString()),path:a.path??"",filename:b.basename(this.privateObjectRelativePath(a))}:null}async save(e){if(K(),await this.loaded,null==e.path){const t=(await this.loadIndex())[e.id];null!=t?.path&&(e={...e,path:t.path})}return await this.assertObjectFilePathAvailable(e,e.id),await j.writeFile(this.privateObjectPath(e),this.serialize(e)),await this.addOrUpdateIndexEntry(e),e}async rename(e,t){const a={...e,name:t};await this.assertObjectFilePathAvailable(a,e.id);const i=this.privateObjectPath(e),n=this.privateObjectPath(a);try{await j.rename(i,n)}catch(e){console.error(e),console.warn("Rename failed, retrying",{currentPath:i,newPath:n}),await m(400),await j.rename(i,n)}return await this.save(a),a}async delete(e){await j.unlink(this.privateObjectPath(e)),this.removeIndexEntry(e.id)}async create(t){K(),await this.loaded,t.id=e();const a=this.privateObjectPath(t);if(await this.assertObjectFilePathAvailable(t),await $(a))throw Error(`Can not create because a file already exists at ${a}`);return await j.writeFile(a,this.serialize(t)),await this.addOrUpdateIndexEntry(t),t}prepareCreate(t){return K(),t.id=e(),t}serialize(e){return this.serializer(e)}async addOrUpdateIndexEntry(e){null==this.cachedIndex&&await this.loadIndex(),this.cachedIndex[e.id]={id:e.id,name:e.name??e.id,path:e.path},await this.persistIndex()}removeIndexEntry(e){null!=this.cachedIndex&&delete this.cachedIndex[e],this.persistIndex()}async persistIndex(){I&&this.shouldCreateIndex&&null!=this.cachedIndex&&await j.writeFile(this.indexFilePath,JSON.stringify(this.cachedIndex,null,2))}get indexFilePath(){return k(this.path,"_meta.json")}async loadIndex(){if(null!=this.cachedIndex)return this.cachedIndex;this.loadingIndex??(this.loadingIndex=this.createIndex());try{return await this.loadingIndex}finally{this.loadingIndex=null}}async createIndex(){if(I){const e=await this.getAll();this.cachedIndex=z(e),await this.persistIndex()}else this.cachedIndex=await(await fetch(this.indexFilePath)).json();return this.cachedIndex}async ensureResourceDir(){await D(k(this.path+"-resources"))}async saveFile(e,t){return K(),await D(k(this.path+"-resources")),j.copyFile(t.path,k(this.path+"-resources",e.fileKey))}async saveExtraFile(e,t){return K(),await D(k(this.path+"-resources")),j.copyFile(e,k(this.path+"-resources",t))}getAssetPath(e){return window&&"function"==typeof window.require?window.require("path").join(this.path+"-resources",e.fileKey):k(this.path+"-resources",e.fileKey)}async replaceFile(e,t){if(await U(t))return j.copyFile(t,k(this.path+"-resources",e.fileKey));console.error("Failed to replace file using path "+t)}async deleteFile(e){if(null==e)return;K();const t=k(this.path+"-resources",e);return await U(t)?j.unlink(t):void 0}privateObjectPath(e){return k(this.path,this.privateObjectRelativePath(e))}privateObjectRelativePath(e){return this.filePathFn?k(e.path??"",this.filePathFn(e)):k(e.path??"",tokenizeName(e.name??e.id)+".json")}async assertObjectFilePathAvailable(e,t){const a=await this.findObjectFilePathCollision(e,t);if(null!=a)throw Error(`Can not save "${e.name??e.id}" because "${a.name}" already uses the same storage file name. Use a name that differs beyond letter casing.`)}async findObjectFilePathCollision(e,t){const a=R(this.privateObjectRelativePath(e)),i=await this.loadIndex();return Object.values(i).find(e=>e.id!==t&&R(this.privateObjectRelativePath(e))===a)??null}watchDir(e){return new c(t=>{if("win32"===process.platform&&I){const a=x.watch(e,{recursive:!0},(a,i)=>{if(i){const n=b.join(e,i);x.access(n,x.constants.F_OK,e=>{const n=e?"unlink":"rename"===a?"add":"change";t.next({event:n,filename:i})})}});return()=>a.close()}const a=g.watch(e,{cwd:e,ignoreInitial:!0,disableGlobbing:!0});return a.on("all",(e,a,i)=>{t.next({event:e,filename:a})}),a.on("error",()=>{}),()=>{a.close()}})}}export function tokenizeName(e){return e.trim().replace(/\s/g,"_").replace(/[^a-z0-9_\-\.]/gi,"")}function R(e){return e.replace(/\\/g,"/").toLowerCase()}function z(e){const t={};for(const a of e)t[a.id]={id:a.id,name:a.name??a.id,path:a.path};return t}async function D(e){I&&(await U(e)||await j.mkdir(e,{recursive:!0}))}function U(e){return!!I&&new Promise(function(t,a){x.exists(e,function(e){t(e)})})}function K(){if(!I)throw new Error("Must have direct access to filesystem")}async function $(e){try{await j.access(e,j.constants.F_OK)}catch(e){return!1}return!0}export function defaultSerializer(e){const t={...e};return delete t.path,delete t.filename,v(t)}/*
|
|
1
|
+
import{randomUUID as e}from"../../utils/uuid.js";import{pathJoin as t}from"../../utils/files.js";import{EMPTY as a,filter as i,firstValueFrom as n,from as s,map as r,merge as h,mergeAll as l,mergeMap as o,Observable as c,of as d,startWith as u,Subject as p,switchMap as f,tap as w}from"rxjs";import{sleepDelay as m}from"../../utils/async.js";import{parseStorageJson as y,serializeStorageJson as g}from"./packed-json.js";export{decodeStorageValue,parseStorageJson,serializeStorageJson}from"./packed-json.js";const v={},x={},j={},b={};null==v.read&&window.require&&(Object.assign(v,window.require("fs")),Object.assign(x,v.promises),Object.assign(j,window.require("path")),Object.assign(b,window.require("chokidar")));const I=null!=v.existsSync;let F=0,P=0;const O=[];async function A(e){await function(){if(F<32)return F++,Promise.resolve();return new Promise(e=>O.push(e))}();try{return await e()}finally{!function(){const e=O[P];if(null==e)return O.length=0,P=0,void F--;P++,P>64&&2*P>O.length&&(O.splice(0,P),P=0);e()}()}}function S(e){return A(()=>x.readFile(e))}function C(){if(I){const e="--path=",t=window.process.argv.find(t=>t.startsWith(e));return t?t.substring(e.length):""}return""}const E=/^[A-Z]:/;function k(...e){return 0===e.length?"":E.test(e[0])||I?j.join(...e):t(...e)}export class ObjectStorage{get pathResources(){return k(this.path+"-resources")}constructor(e,t,a=defaultSerializer){this.name=e,this.filePathFn=t,this.serializer=a,this.getAllInFlight=new Map,this.basePathUpdates=new p,this.basePath=this.basePathUpdates.pipe(r(e=>k(C(),e)),w(e=>{this.path=k(e,this.name),this.getAllInFlight.clear(),this.cachedIndex=null,this.loadingIndex=null,U(this.path),this.determineIfMetaFileShouldBeCreated()})),this.loaded=n(this.basePath),this.cachedIndex=null,this.loadingIndex=null,this.shouldCreateIndex=!1}setBasePath(e){this.basePathUpdates.next(e)}async determineIfMetaFileShouldBeCreated(){if(I)try{const e=["vite.renderer.config.ts","vite.config.ts"];for(const t of e){const e=k(C(),t);if(!await D(e))continue;if((await S(e)).toString().includes("hologyBuild"))return void(this.shouldCreateIndex=!1)}this.shouldCreateIndex=!0}catch(e){console.warn("Failed to read vite config to determine if meta files should be created")}}async createFolder(e,t=""){$(),await x.mkdir(j.join(this.path,t,e),{recursive:!0})}async deleteFolderForceDangerous(e){await x.rm(j.join(this.path,e),{recursive:!0,force:!0})}async moveFolder(e,t){if($(),""==e)return void console.warn("Can not move a folder in root");const a=j.resolve(j.join(this.path,t),j.basename(e));if(await _(a)){if(a!==j.resolve(this.path,e))throw new Error("Can not move to directory as a file already exists with the same name")}else{if(function(e,t){const a=j.resolve(e),i=j.resolve(t),n=j.normalize(a)+j.sep;return(j.normalize(i)+j.sep).startsWith(n)}(j.join(this.path,e),j.join(this.path,t)))throw new Error("Can not move a folder into a folder it contains");await x.rename(j.join(this.path,e),a)}}async renameFolder(e,t){await x.rename(j.join(this.path,e),j.resolve(j.dirname(j.join(this.path,e)),t))}async moveToFolder(e,t){if($(),(e.path??"")===t)return e;const a={...e,path:t};await this.assertObjectFilePathAvailable(a,e.id);const i=this.privateObjectPath(a);return await x.rename(this.privateObjectPath(e),i),await this.addOrUpdateIndexEntry(a),a}getAbsolutePath(e=""){return j.join(this.path,e)}getResourceAbsolutePath(e=""){return j.join(this.pathResources,e)}watchFolders(){return s(this.loaded).pipe(f(()=>s(U(this.path))),f(()=>this.watchDir(this.path).pipe(i(e=>!e.filename.endsWith(".json")),u(null),f(()=>s(x.readdir(this.path,{recursive:!0,withFileTypes:!0}))),r(e=>Array.from(new Set(e.filter(e=>e.isDirectory()).map(e=>j.relative(this.path,j.join(e.parentPath,e.name)).replace(/^\.$/,"")).values()))))))}watch(){$();const e=s(this.loaded).pipe(f(()=>s(U(this.pathResources))),f(()=>this.watchDir(this.pathResources)),i(e=>null!=e&&["add","change","unlink"].includes(e.event)),r(e=>({event:"resource-change",object:null,path:j.dirname(e.filename).replace(/^\.$/,""),filename:j.basename(e.filename)}))),t=s(this.loaded).pipe(f(()=>this.watchDir(this.path)),i(e=>"_meta.json"!==e.filename),o(e=>{const t={event:e.event,path:j.dirname(e.filename).replace(/^\.$/,""),filename:j.basename(e.filename)};return e.filename.endsWith(".json")?"unlink"!==e.event?s(this.readFileIfExists(e.filename)).pipe(w(e=>{null!=e&&(null==this.cachedIndex&&(this.cachedIndex={}),this.cachedIndex[e.id]={id:e.id,name:e.name??e.id,path:e.path},this.persistIndex())}),r(e=>({object:e,...t}))):d({object:null,...t}).pipe(w(()=>{const t=Object.keys(this.cachedIndex??{}).find(t=>this.privateObjectRelativePath(this.cachedIndex[t])===e.filename);t&&this.removeIndexEntry(t)})):"change"===e.event?s(this.reloadSubdirectory(e.filename)).pipe(l(),r(e=>({object:e,...t}))):a}));return h(t,e)}async reloadSubdirectory(e){return(await this.getAll(e)).filter(t=>t.path.startsWith(e))}async readFileIfExists(e){const t=k(this.path,e);for(let a=0;a<3;a++)try{const a=await S(t);return{...y(a.toString()),path:j.dirname(e).replace(/^\.$/,""),filename:j.basename(e)}}catch(e){if(2===a)return console.error("Could not read file at "+t,e),null;await m(50*(a+1))}return null}async getAll(e){if(!I)return this.getAllUncached(e);const t=e??"",a=this.getAllInFlight.get(t);if(null!=a)return(await a).slice();const i=this.getAllUncached(e);this.getAllInFlight.set(t,i);try{return(await i).slice()}finally{this.getAllInFlight.get(t)===i&&this.getAllInFlight.delete(t)}}async getAllUncached(e){if(I){await this.loaded,await U(this.path);const t=await this.getObjectFilePaths(e??""),a=null==e||""===e,i=[];for(let e=0;e<t.length;e+=32){const a=Math.min(32,t.length-e),n=await Promise.all(Array.from({length:a},(a,i)=>{const n=t[e+i];return S(k(this.path,n)).then(e=>({...y(e.toString()),path:j.dirname(n).replace(/^\.$/,""),filename:j.basename(n)}))}));i.push(...n)}return a&&(this.cachedIndex=R(i),await this.persistIndex()),i}const t=await this.loadIndex();return Promise.all(Object.keys(t).map(e=>this.get(e)))}async getObjectFilePaths(e){const t=this.path,a=j.join(t,e),i=[];return await async function e(a){const n=await x.readdir(a,{withFileTypes:!0});for(const s of n){const n=j.join(a,s.name);s.isDirectory()?await e(n):s.isFile()&&s.name.endsWith(".json")&&!/^[\._]/.test(s.name)&&i.push(j.relative(t,n))}}(a),i}async get(e){const t=await this.loadIndex(),a=t[e]??Object.values(t).find(t=>t.name===e);if(null==a)return;const i=this.privateObjectPath(a);if(!I)return y(await(await fetch(i)).text());return await D(i)?{...y((await S(i)).toString()),path:a.path??"",filename:j.basename(this.privateObjectRelativePath(a))}:null}async save(e){if($(),await this.loaded,null==e.path){const t=(await this.loadIndex())[e.id];null!=t?.path&&(e={...e,path:t.path})}return await this.assertObjectFilePathAvailable(e,e.id),await x.writeFile(this.privateObjectPath(e),this.serialize(e)),await this.addOrUpdateIndexEntry(e),e}async rename(e,t){const a={...e,name:t};await this.assertObjectFilePathAvailable(a,e.id);const i=this.privateObjectPath(e),n=this.privateObjectPath(a);try{await x.rename(i,n)}catch(e){console.error(e),console.warn("Rename failed, retrying",{currentPath:i,newPath:n}),await m(400),await x.rename(i,n)}return await this.save(a),a}async delete(e){await x.unlink(this.privateObjectPath(e)),this.removeIndexEntry(e.id)}async create(t){$(),await this.loaded,t.id=e();const a=this.privateObjectPath(t);if(await this.assertObjectFilePathAvailable(t),await _(a))throw Error(`Can not create because a file already exists at ${a}`);return await x.writeFile(a,this.serialize(t)),await this.addOrUpdateIndexEntry(t),t}prepareCreate(t){return $(),t.id=e(),t}serialize(e){return this.serializer(e)}async addOrUpdateIndexEntry(e){null==this.cachedIndex&&await this.loadIndex(),this.cachedIndex[e.id]={id:e.id,name:e.name??e.id,path:e.path},await this.persistIndex()}removeIndexEntry(e){null!=this.cachedIndex&&delete this.cachedIndex[e],this.persistIndex()}async persistIndex(){I&&this.shouldCreateIndex&&null!=this.cachedIndex&&await x.writeFile(this.indexFilePath,JSON.stringify(this.cachedIndex,null,2))}get indexFilePath(){return k(this.path,"_meta.json")}async loadIndex(){if(null!=this.cachedIndex)return this.cachedIndex;this.loadingIndex??(this.loadingIndex=this.createIndex());try{return await this.loadingIndex}finally{this.loadingIndex=null}}async createIndex(){if(I){const e=await this.getAll();this.cachedIndex=R(e),await this.persistIndex()}else this.cachedIndex=await(await fetch(this.indexFilePath)).json();return this.cachedIndex}async ensureResourceDir(){await U(k(this.path+"-resources"))}async saveFile(e,t){return $(),await U(k(this.path+"-resources")),x.copyFile(t.path,k(this.path+"-resources",e.fileKey))}async saveExtraFile(e,t){return $(),await U(k(this.path+"-resources")),x.copyFile(e,k(this.path+"-resources",t))}getAssetPath(e){return window&&"function"==typeof window.require?window.require("path").join(this.path+"-resources",e.fileKey):k(this.path+"-resources",e.fileKey)}async replaceFile(e,t){if(await D(t))return x.copyFile(t,k(this.path+"-resources",e.fileKey));console.error("Failed to replace file using path "+t)}async deleteFile(e){if(null==e)return;$();const t=k(this.path+"-resources",e);return await D(t)?x.unlink(t):void 0}privateObjectPath(e){return k(this.path,this.privateObjectRelativePath(e))}privateObjectRelativePath(e){return this.filePathFn?k(e.path??"",this.filePathFn(e)):k(e.path??"",tokenizeName(e.name??e.id)+".json")}async assertObjectFilePathAvailable(e,t){const a=await this.findObjectFilePathCollision(e,t);if(null!=a)throw Error(`Can not save "${e.name??e.id}" because "${a.name}" already uses the same storage file name. Use a name that differs beyond letter casing.`)}async findObjectFilePathCollision(e,t){const a=z(this.privateObjectRelativePath(e)),i=await this.loadIndex();return Object.values(i).find(e=>e.id!==t&&z(this.privateObjectRelativePath(e))===a)??null}watchDir(e){return new c(t=>{if("win32"===process.platform&&I){const a=v.watch(e,{recursive:!0},(a,i)=>{if(i){const n=j.join(e,i);v.access(n,v.constants.F_OK,e=>{const n=e?"unlink":"rename"===a?"add":"change";t.next({event:n,filename:i})})}});return()=>a.close()}const a=b.watch(e,{cwd:e,ignoreInitial:!0,disableGlobbing:!0});return a.on("all",(e,a,i)=>{t.next({event:e,filename:a})}),a.on("error",()=>{}),()=>{a.close()}})}}export function tokenizeName(e){return e.trim().replace(/\s/g,"_").replace(/[^a-z0-9_\-\.]/gi,"")}function z(e){return e.replace(/\\/g,"/").toLowerCase()}function R(e){const t={};for(const a of e)t[a.id]={id:a.id,name:a.name??a.id,path:a.path};return t}async function U(e){I&&(await D(e)||await x.mkdir(e,{recursive:!0}))}function D(e){return!!I&&new Promise(function(t,a){v.exists(e,function(e){t(e)})})}function $(){if(!I)throw new Error("Must have direct access to filesystem")}async function _(e){try{await x.access(e,x.constants.F_OK)}catch(e){return!1}return!0}export function defaultSerializer(e){const t={...e};return delete t.path,delete t.filename,g(t)}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -31,6 +31,41 @@ export type ShaderGraphNodeShaderOutput = NodeShaderOutput & {
|
|
|
31
31
|
anisotropy?: FloatNode;
|
|
32
32
|
anisotropyDirection?: Vec2Node;
|
|
33
33
|
bakedLight?: Vec3Node;
|
|
34
|
+
shadowTint?: Vec3Node;
|
|
35
|
+
shadowThreshold?: FloatNode;
|
|
36
|
+
shadowSoftness?: FloatNode;
|
|
37
|
+
specularIntensity?: FloatNode;
|
|
38
|
+
specularToonness?: FloatNode;
|
|
39
|
+
specularThreshold?: FloatNode;
|
|
40
|
+
specularSoftness?: FloatNode;
|
|
41
|
+
environmentSpecularIntensity?: FloatNode;
|
|
42
|
+
skinMask?: FloatNode;
|
|
43
|
+
thickness?: FloatNode;
|
|
44
|
+
subsurfaceColor?: Vec3Node;
|
|
45
|
+
subsurfaceStrength?: FloatNode;
|
|
46
|
+
subsurfaceWrap?: FloatNode;
|
|
47
|
+
backscatterStrength?: FloatNode;
|
|
48
|
+
backscatterPower?: FloatNode;
|
|
49
|
+
faceMask?: FloatNode;
|
|
50
|
+
faceShadow?: FloatNode;
|
|
51
|
+
faceShadowStrength?: FloatNode;
|
|
52
|
+
faceShadowSoftness?: FloatNode;
|
|
53
|
+
faceShadowOffset?: FloatNode;
|
|
54
|
+
eyeMask?: FloatNode;
|
|
55
|
+
irisMask?: FloatNode;
|
|
56
|
+
eyeHighlightMask?: FloatNode;
|
|
57
|
+
eyeLowerLightMask?: FloatNode;
|
|
58
|
+
eyeBrightness?: FloatNode;
|
|
59
|
+
eyeIrisColor?: Vec3Node;
|
|
60
|
+
eyeIrisGlow?: FloatNode;
|
|
61
|
+
eyeHighlightColor?: Vec3Node;
|
|
62
|
+
eyeHighlightStrength?: FloatNode;
|
|
63
|
+
rimMask?: FloatNode;
|
|
64
|
+
rimColor?: Vec3Node;
|
|
65
|
+
rimStrength?: FloatNode;
|
|
66
|
+
rimPower?: FloatNode;
|
|
67
|
+
rimThreshold?: FloatNode;
|
|
68
|
+
rimSoftness?: FloatNode;
|
|
34
69
|
};
|
|
35
70
|
export interface CompiledShaderGraphNode {
|
|
36
71
|
node: ShaderGraphNode;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{BackSide as t,Color as e,DataTexture as a,DoubleSide as r,FrontSide as u,Matrix4 as i,RGBAFormat as o,Texture as n,Vector2 as s,Vector3 as l,Vector4 as p}from"three";import{BooleanNode as c,FloatNode as h,Mat4Node as v,NodeShaderMaterial as y,RgbNode as d,RgbaNode as m,Sampler2DNode as f,Texture2dLookupNode as g,UniformFloatNode as b,Vec2Node as x,Vec3Node as w,Vec4Node as S,abs as T,acos as I,asin as O,attributes as M,atan as N,atan2 as C,autoVarying as E,bulge as G,bool as U,ceil as B,clamp as $,colorToNormal as k,cos as z,cross as A,degrees as V,distance as P,dot as j,exp as D,exp2 as L,float as R,floor as q,fract as F,inversesqrt as _,batchingMatrix as W,colorGradientSampler as H,curveSampler as Y,ifDefApply as J,sampleNamedEasingCurve as K,length as Q,LayerMixMode as X,log as Z,log2 as tt,mat4 as et,max as at,min as rt,mix as ut,mixColorsByLayer as it,particleUniforms as ot,mod as nt,normalize as st,pow as lt,radians as pt,rgba as ct,rgb as ht,saturate as vt,select as yt,sign as dt,sin as mt,smoothstep as ft,sqrt as gt,standardMaterial as bt,scaleTransform as xt,step as wt,tan as St,textureSampler2d as Tt,timeUniforms as It,toonMaterial as Ot,translate as Mt,transformed as Nt,triplanarMapping as Ct,twirl as Et,uniformFloat as Gt,uniforms as Ut,varyingAttributes as Bt,vec2 as $t,vec3 as kt,vec4 as zt,getPaintedMaterialLayerWeight as At}from"../../shader-nodes/index.js";import{SpriteNodeShaderMaterial as Vt,getSpritePosition as Pt}from"../sprite-shader.js";import{oneMinus as jt}from"../../shader-nodes/index.js";import{vectorToRadial as Dt,remap as Lt,hueShift as Rt,blendColor as qt,desaturateColor as Ft}from"../../shader-nodes/math.js";import{rectangleFloat as _t,roundedRectangleFloat as Wt}from"../../shader-nodes/shapes.js";import{edgeDepthEffect as Ht,fresnelEffect as Yt,depthFadeEffect as Jt}from"../../shader-nodes/effects.js";import{fragmentLinearEyeDepth as Kt,sampleSceneDepth as Qt,sampleSceneLinearEyeDepth as Xt,screenUV as Zt,nearUniformName as te,farUniformName as ee}from"../../shader-nodes/depth.js";import{sampleSceneColor as ae}from"../../shader-nodes/scene-sample.js";import{decalDiscard as re,decalUV as ue}from"../../shader-nodes/decal.js";import{sampledSurfaceRejectsDecals as ie}from"../../shader-nodes/material-flags.js";import{Trail as oe,trailUV as ne}from"../../effects/vfx/trail-renderer.js";import{SimplexNoiseNode as se,Voronoi2d as le,rotateAxis as pe}from"../../shader-nodes/index.js";import{flipbookUv as ce}from"../../shader-nodes/texture-sequence.js";import{parallaxOcclusionMapping as he}from"../../shader-nodes/pom.js";import{defaultInlineLiteralValueForPort as ve,inlineLiteralTypeForPort as ye,SHADER_GRAPH_NODE_DEFINITIONS as de}from"./registry.js";import{shaderGraphParameterTypeToValueType as me}from"./parameters.js";import{attributeVec2 as fe,varying as ge,reflect as be,refract as xe,dFdx as we,dFdy as Se,fwidth as Te}from"three-shader-graph";import{decalNormal as Ie}from"../../shader-nodes/decal.js";import{Curve2 as Oe}from"../../utils/curve.js";const Me=(()=>{const t=new a(new Uint8Array([255,255,255,255]),1,1,o);return t.name="Missing shader graph texture parameter fallback",t.needsUpdate=!0,t})(),Ne=new Set;export class ShaderGraphCompileError extends Error{constructor(t,e,a){super(t),this.nodeId=e,this.port=a,this.name="ShaderGraphCompileError"}}export const shaderGraphPostProcessWeightUniformName="hology_post_process_weight";export class ShaderGraphCompiler{constructor(t,e={}){this.graph=t,this.options=e,this.compiled=new Map,this.compiling=new Set,this.nodesById=new Map((t.nodes??[]).map(t=>[t.id,t]))}validate(){this.compile()}compile(){if(1!==this.graph.version)throw new ShaderGraphCompileError(`Unsupported shader graph version ${this.graph.version}`);return this.validateEdges(),this.validateNamedReroutes(),{output:this.compileOutput(),nodes:this.compiled}}validateEdges(){for(const t of this.graph.edges??[]){if(!this.nodesById.has(t.from.nodeId))throw new ShaderGraphCompileError(`Edge references missing source node "${t.from.nodeId}"`,t.from.nodeId,t.from.port);if(!this.nodesById.has(t.to.nodeId))throw new ShaderGraphCompileError(`Edge references missing target node "${t.to.nodeId}"`,t.to.nodeId,t.to.port)}}validateNamedReroutes(){for(const t of this.graph.nodes??[])"utility.namedRerouteUsage"===t.kind&&this.namedRerouteDeclaration(t)}compileOutput(){if("postProcess"===this.graph.target)return this.compilePostProcessOutput();const t=this.graph.outputs?.color,e={color:null!=t?this.toColorOutput(this.resolveOutputBinding(t,"color")):ct("#ffffff",1),transparent:Ge(this.graph)},a=this.graph.outputs?.opacity;null!=a&&(e.opacity=this.expectType(this.resolveOutputBinding(a,"opacity"),["float"],"opacity").value);const r=this.graph.outputs?.roughness;null!=r&&(e.roughness=this.expectType(this.resolveOutputBinding(r,"roughness"),["float"],"roughness").value);const u=this.graph.outputs?.metalness;null!=u&&(e.metalness=this.floatOutput(u,"metalness"));const i=this.graph.outputs?.normal;null!=i&&(e.normal=this.toVec3Output(this.resolveOutputBinding(i,"normal"),"normal"));const o=this.graph.outputs?.emissive;null!=o&&(e.emissive=this.toVec3Output(this.resolveOutputBinding(o,"emissive"),"emissive"));const n=this.graph.outputs?.ambientOcclusion;null!=n&&(e.ambientOcclusion=this.floatOutput(n,"ambientOcclusion"));const s=this.graph.outputs?.ambientOcclusionIntensity;null!=s&&(e.ambientOcclusionIntensity=this.floatOutput(s,"ambientOcclusionIntensity"));const l=this.graph.outputs?.sheenColor;null!=l&&(e.sheenColor=this.toVec3Output(this.resolveOutputBinding(l,"sheenColor"),"sheenColor"));const p=this.graph.outputs?.sheenRoughness;null!=p&&(e.sheenRoughness=this.floatOutput(p,"sheenRoughness"));const c=this.graph.outputs?.anisotropy;null!=c&&(e.anisotropy=this.floatOutput(c,"anisotropy"));const h=this.graph.outputs?.anisotropyDirection;null!=h&&(e.anisotropyDirection=this.expectType(this.resolveOutputBinding(h,"anisotropyDirection"),["vec2"],"anisotropyDirection").value);const v=this.graph.outputs?.bakedLight;null!=v&&(e.bakedLight=this.toVec3Output(this.resolveOutputBinding(v,"bakedLight"),"bakedLight"));const y=this.graph.outputs?.transform;null!=y&&"decal"!==this.graph.target&&(e.transform=this.toMat4Output(this.resolveOutputBinding(y,"transform"),"transform"));const d=this.graph.outputs?.discard;null!=d&&(e.discard=this.expectType(this.resolveOutputBinding(d,"discard"),["boolean"],"discard").value);const m=this.graph.outputs?.transparent;null!=m&&null!=m.value&&(e.transparent=Boolean(m.value));const f=this.graph.outputs?.alphaTest;return null!=f&&null!=f.value?e.alphaTest=Number(f.value):null!=this.graph.materialOptions?.alphaTest&&(e.alphaTest=this.graph.materialOptions.alphaTest),this.applyShadingModel(e)}compilePostProcessOutput(){const t=this.screenUv(),e=this.graph.outputs?.color,a=null!=e?this.toColorOutput(this.resolveOutputBinding(e,"color")):ae(t),r=this.graph.outputs?.opacity;return Ce(a,null!=r?this.expectType(this.resolveOutputBinding(r,"opacity"),["float"],"opacity").value:void 0,t)}screenUv(){return this.options.screenUV??Zt}applyShadingModel(t){const e=null!=t.opacity?function(t,e){if(t instanceof h)return ct(kt(t,t,t),e);if(t instanceof x)return ct(kt(t.x,t.y,0),e);if(t instanceof S)return ct(t.rgb,t.w.multiply(e));return ct(t,e)}(t.color,t.opacity):t.color;switch(this.graph.shadingModel??"standard"){case"standard":{const a={color:ke(e),roughness:t.roughness??R(.5),...null!=t.metalness?{metalness:t.metalness}:{},..."decal"===this.graph.target?{normal:st(ge(Ut.normalMatrix).multiplyVec(Ie))}:{},...null!=t.normal?{normal:t.normal}:{},...null!=t.emissive?{emissive:ze(t.emissive)}:{},...null!=t.ambientOcclusion?{ambientOcclusion:t.ambientOcclusion}:{},...null!=t.ambientOcclusionIntensity?{ambientOcclusionIntensity:t.ambientOcclusionIntensity}:{},...null!=t.sheenColor?{sheenColor:t.sheenColor.rgb}:{},...null!=t.sheenRoughness?{sheenRoughness:t.sheenRoughness}:{},...null!=t.anisotropy?{anisotropy:t.anisotropy}:{},...null!=t.anisotropyDirection?{anisotropyDirection:t.anisotropyDirection}:{},...null!=t.bakedLight?{bakedLight:t.bakedLight}:{}};return{...t,color:bt(a)}}case"toon":{const a={color:ke(e),...null!=t.normal?{normal:t.normal}:{},...null!=t.emissive?{emissive:ze(t.emissive)}:{},...null!=t.ambientOcclusion?{ambientOcclusion:t.ambientOcclusion}:{},...null!=t.ambientOcclusionIntensity?{ambientOcclusionIntensity:t.ambientOcclusionIntensity}:{},...null!=t.bakedLight?{bakedLight:t.bakedLight}:{}};return{...t,color:Ot(a)}}case"unlit":return{...t,color:e}}}compileNode(t){const e=this.compiled.get(t);if(null!=e)return e;const a=this.nodesById.get(t);if(null==a)throw new ShaderGraphCompileError(`Missing shader graph node "${t}"`,t);if(null==de[a.kind])throw new ShaderGraphCompileError(`Unsupported shader graph node "${a.kind}"`,a.id);if(this.compiling.has(t))throw new ShaderGraphCompileError(`Shader graph contains a cycle involving node "${t}"`,t);this.compiling.add(t);try{const e=this.compileNodeInternal(a);return this.compiled.set(t,e),e}finally{this.compiling.delete(t)}}compileNodeInternal(t){switch(t.kind){case"input.parameter":return this.output(t,this.compileParameterNode(t));case"input.slider":return this.output(t,{value:{type:"float",value:R(_e(Ve(t,"value",.5)))}});case"constant.boolean":return this.output(t,{value:{type:"boolean",value:U(Boolean(Ae(t,"value",!1)))}});case"constant.float":return this.output(t,{value:{type:"float",value:R(Ve(t,"value",0))}});case"constant.vec2":return this.output(t,{value:{type:"vec2",value:Ye(Ae(t,"value",[0,0]))}});case"constant.vec3":return this.output(t,{value:{type:"vec3",value:Je(Ae(t,"value",[0,0,0]))}});case"constant.rgba":return this.output(t,{value:{type:"rgba",value:Ke(Ae(t,"value","#ffffff"),Ve(t,"alpha",1))}});case"builtin.uv":{let e;return e="trail"===this.graph.target?ne:"decal"===this.graph.target?ue:this.uvAttribute(t),this.output(t,{value:{type:"vec2",value:!0===Ae(t,"flipY",!1)?$t(e.x,jt(e.y)):e},u:{type:"float",value:e.x},v:{type:"float",value:e.y}})}case"builtin.screenUv":return this.output(t,{value:{type:"vec2",value:this.screenUv()}});case"builtin.color":{const e=E(M.color);return this.output(t,{value:{type:"rgba",value:e},rgb:{type:"rgb",value:e.rgb},r:{type:"float",value:e.r},g:{type:"float",value:e.g},b:{type:"float",value:e.b},a:{type:"float",value:e.a}})}case"builtin.position":{const e=E(M.position);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.worldPosition":{const e=E(Nt.worldPosition);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.objectPosition":{let e=Ut.instanceMatrix.multiplyVec(zt(0,0,0,1));e=J("USE_BATCHING",e,t=>W.multiplyVec(t));const a=E(Ut.modelMatrix.multiplyVec(e).xyz);return this.output(t,{value:{type:"vec3",value:a},x:{type:"float",value:a.x},y:{type:"float",value:a.y},z:{type:"float",value:a.z}})}case"builtin.viewDir":{const e=E(Nt.viewDir);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.normal":{const e=E(M.normal);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.time":return this.output(t,{value:{type:"float",value:It.elapsed}});case"builtin.camera":{const e=Gt(te),a=Gt(ee),r=Ut.cameraPosition;return this.output(t,{position:{type:"vec3",value:r},x:{type:"float",value:r.x},y:{type:"float",value:r.y},z:{type:"float",value:r.z},near:{type:"float",value:e},far:{type:"float",value:a}})}case"builtin.viewMatrix":return this.output(t,{value:{type:"mat4",value:Ut.viewMatrix}});case"builtin.projectionMatrix":return this.output(t,{value:{type:"mat4",value:Ut.projectionMatrix}});case"builtin.modelViewMatrix":return this.output(t,{value:{type:"mat4",value:Ut.modelViewMatrix}});case"builtin.particle":return this.output(t,{energy:{type:"float",value:ot.energy},color:{type:"rgb",value:ot.color},opacity:{type:"float",value:ot.opacity},time:{type:"float",value:ot.time}});case"math.add":case"math.subtract":case"math.multiply":case"math.divide":return this.output(t,{value:this.compileBinaryMath(t)});case"math.oneMinus":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:e.type,value:jt(e.value)}})}case"math.abs":return this.output(t,{value:this.compileUnaryMath(t,T)});case"math.sign":return this.output(t,{value:this.compileUnaryMath(t,dt)});case"math.floor":return this.output(t,{value:this.compileUnaryMath(t,q)});case"math.ceil":return this.output(t,{value:this.compileUnaryMath(t,B)});case"math.fract":return this.output(t,{value:this.compileUnaryMath(t,F)});case"math.sin":return this.output(t,{value:this.compileUnaryMath(t,mt)});case"math.cos":return this.output(t,{value:this.compileUnaryMath(t,z)});case"math.tan":return this.output(t,{value:this.compileUnaryMath(t,St)});case"math.asin":return this.output(t,{value:this.compileUnaryMath(t,O)});case"math.acos":return this.output(t,{value:this.compileUnaryMath(t,I)});case"math.atan":return this.output(t,{value:this.compileUnaryMath(t,N)});case"math.atan2":return this.output(t,{value:this.compileAtan2(t)});case"math.radians":return this.output(t,{value:this.compileUnaryMath(t,pt)});case"math.degrees":return this.output(t,{value:this.compileUnaryMath(t,V)});case"math.sqrt":return this.output(t,{value:this.compileUnaryMath(t,gt)});case"math.inverseSqrt":return this.output(t,{value:this.compileUnaryMath(t,_)});case"math.exp":return this.output(t,{value:this.compileUnaryMath(t,D)});case"math.exp2":return this.output(t,{value:this.compileUnaryMath(t,L)});case"math.log":return this.output(t,{value:this.compileUnaryMath(t,Z)});case"math.log2":return this.output(t,{value:this.compileUnaryMath(t,tt)});case"math.saturate":return this.output(t,{value:this.compileUnaryMath(t,vt)});case"math.length":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:"float",value:Q(e.value)}})}case"math.normalize":return this.output(t,{value:this.compileUnaryMath(t,st)});case"math.clamp":{const e=this.expectNumeric(this.input(t,"value")),a=this.expectNumeric(this.input(t,"min",{type:"float",value:R(0)})),r=this.expectNumeric(this.input(t,"max",{type:"float",value:R(1)}));return this.output(t,{value:{type:e.type,value:$(e.value,a.value,r.value)}})}case"math.min":return this.output(t,{value:this.compileBinaryFunction(t,rt)});case"math.max":return this.output(t,{value:this.compileBinaryFunction(t,at)});case"math.pow":return this.output(t,{value:this.compileBinaryFunction(t,lt)});case"math.mod":return this.output(t,{value:this.compileBinaryFunction(t,nt)});case"math.step":return this.output(t,{value:this.compileBinaryFunction(t,wt,!0)});case"math.smoothstep":{const e=this.expectNumeric(this.input(t,"edge0",{type:"float",value:R(0)})),a=this.expectNumeric(this.input(t,"edge1",{type:"float",value:R(1)})),r=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:r.type,value:ft(e.value,a.value,r.value)}})}case"math.mix":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b")),r=this.expectNumeric(this.input(t,"t",{type:"float",value:R(.5)})),u=Le(e.type,a.type,t.id);return this.output(t,{value:{type:u,value:ut(e.value,a.value,r.value)}})}case"math.remap":{const e=this.expectType(this.input(t,"value"),["float"],t.id,"value").value,a=this.floatInput(t,"inMin",-1),r=this.floatInput(t,"inMax",1),u=this.floatInput(t,"outMin",0),i=this.floatInput(t,"outMax",1);return this.output(t,{value:{type:"float",value:Lt(e,a,r,u,i)}})}case"math.select":{const e=this.boolInput(t,"condition",!1),a=this.expectNumeric(this.input(t,"a")),r=this.expectNumeric(this.input(t,"b")),u=Le(a.type,r.type,t.id);return this.output(t,{value:{type:u,value:yt(e,a.value,r.value)}})}case"math.reflect":{const e=this.expectType(this.input(t,"incident"),["vec2","vec3","vec4","rgb","rgba"],t.id,"incident"),a=this.expectType(this.input(t,"normal"),["vec2","vec3","vec4","rgb","rgba"],t.id,"normal");return this.output(t,{value:{type:e.type,value:be(e.value,a.value)}})}case"math.refract":{const e=this.expectType(this.input(t,"incident"),["vec2","vec3","vec4","rgb","rgba"],t.id,"incident"),a=this.expectType(this.input(t,"normal"),["vec2","vec3","vec4","rgb","rgba"],t.id,"normal"),r=this.floatInput(t,"ior",1.5);return this.output(t,{value:{type:e.type,value:xe(e.value,a.value,r)}})}case"math.derivative":{const e=this.expectNumeric(this.input(t,"value")),a=String(Ae(t,"mode","fwidth"));let r;return r="dFdx"===a?we(e.value):"dFdy"===a?Se(e.value):Te(e.value),this.output(t,{value:{type:e.type,value:r}})}case"layer.mixPainted":return this.output(t,{value:this.compilePaintedLayerMix(t)});case"math.dot":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b"));return Le(e.type,a.type,t.id),this.output(t,{value:{type:"float",value:j(e.value,a.value)}})}case"math.distance":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b"));return Le(e.type,a.type,t.id),this.output(t,{value:{type:"float",value:P(e.value,a.value)}})}case"math.cross":{const e=this.expectType(this.input(t,"a"),["vec3","rgb"],t.id,"a"),a=this.expectType(this.input(t,"b"),["vec3","rgb"],t.id,"b");return this.output(t,{value:{type:"vec3",value:A(e.value,a.value)}})}case"compare.greaterThan":case"compare.greaterThanOrEqual":case"compare.lessThan":case"compare.lessThanOrEqual":case"compare.equal":case"compare.notEqual":return this.output(t,{value:{type:"boolean",value:this.compileComparison(t)}});case"boolean.not":{const e=this.boolInput(t,"value",!1);return this.output(t,{value:{type:"boolean",value:yt(e,U(!1),U(!0))}})}case"boolean.and":return this.output(t,{value:{type:"boolean",value:this.compileBooleanBinary(t,"and")}});case"boolean.or":return this.output(t,{value:{type:"boolean",value:this.compileBooleanBinary(t,"or")}});case"compose.vec2":return this.output(t,{value:{type:"vec2",value:$t(this.floatInput(t,"x",0),this.floatInput(t,"y",0))}});case"compose.vec3":return this.output(t,{value:{type:"vec3",value:kt(this.floatInput(t,"x",0),this.floatInput(t,"y",0),this.floatInput(t,"z",0))}});case"compose.vec4":return this.output(t,{value:{type:"vec4",value:zt(this.floatInput(t,"x",0),this.floatInput(t,"y",0),this.floatInput(t,"z",0),this.floatInput(t,"w",0))}});case"compose.rgba":return this.output(t,{value:{type:"rgba",value:zt(this.floatInput(t,"r",1),this.floatInput(t,"g",1),this.floatInput(t,"b",1),this.floatInput(t,"a",1))}});case"decompose.component":{const e=this.expectNumeric(this.input(t,"value")),a=String(Ae(t,"component","x"));return this.output(t,{value:{type:"float",value:qe(e,a,t.id)}})}case"decompose.split":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,function(t,e){const a={},r=(r,u)=>{a[r]={type:"float",value:qe(t,u,e)}};switch(t.type){case"vec2":return r("x","x"),r("y","y"),r("u","x"),r("v","y"),a;case"vec3":return r("x","x"),r("y","y"),r("z","z"),a;case"rgb":return r("r","r"),r("g","g"),r("b","b"),r("x","x"),r("y","y"),r("z","z"),a;case"vec4":return r("x","x"),r("y","y"),r("z","z"),r("w","w"),a;case"rgba":return r("r","r"),r("g","g"),r("b","b"),r("a","a"),r("x","x"),r("y","y"),r("z","z"),r("w","w"),a;case"float":return a.x={type:"float",value:t.value},a}}(e,t.id))}case"color.gradient":{const e=this.expectType(this.input(t,"t",{type:"float",value:R(.5)}),["float"],t.id,"t"),a=H(function(t){const e=Ae(t,"stops",[]);if(!Array.isArray(e))return[];const a=e.map((t,a)=>{if(null==t||"object"!=typeof t||Array.isArray(t))return;const r=t,u="string"==typeof r.color?r.color:"#ffffff";return{position:We(r.position,Qe(a,e.length)),color:u,alpha:We(r.alpha,1)}}).filter(t=>null!=t);return a.length>0?a:[]}(t)).sample(e.value);return this.output(t,{value:{type:"rgba",value:a}})}case"utility.curve":{const e=this.expectType(this.input(t,"t",{type:"float",value:R(.5)}),["float"],t.id,"t"),a=Ae(t,"curve","Linear"),r=K(a,e.value)??Y(Oe.decode(a)).sample(e.value);return this.output(t,{value:{type:"float",value:r}})}case"utility.namedRerouteDeclaration":return this.output(t,{value:this.input(t,"value")});case"utility.namedRerouteUsage":{const e=this.compileNode(this.namedRerouteDeclaration(t).id);return this.output(t,{value:e.outputs.value})}case"color.hueShift":{const e=this.expectType(this.input(t,"color"),["rgba","rgb","vec4","vec3"],t.id,"color"),a=e.value,r="rgba"===e.type||"vec4"===e.type?a.rgb??a.xyz:a,u=this.floatInput(t,"shift",0),i=Rt(r,u);return"rgba"===e.type||"vec4"===e.type?this.output(t,{value:{type:e.type,value:zt(i,a.a??a.w)}}):this.output(t,{value:{type:e.type,value:i}})}case"color.blend":{const e=this.expectType(this.input(t,"base"),["rgba","rgb","vec4","vec3"],t.id,"base"),a=this.expectType(this.input(t,"blend"),["rgba","rgb","vec4","vec3"],t.id,"blend"),r=String(Ae(t,"mode","multiply")),u=e.value,i=a.value,o="rgba"===e.type||"vec4"===e.type?u.rgb??u.xyz:u,n="rgba"===a.type||"vec4"===a.type?i.rgb??i.xyz:i;let s=qt(o,n,r);if("rgba"===a.type||"vec4"===a.type){const t=i.a??i.w;s=ut(o,s,t)}if("rgba"===e.type||"vec4"===e.type){const a=u.a??u.w;return this.output(t,{value:{type:e.type,value:zt(s,a)}})}return this.output(t,{value:{type:e.type,value:s}})}case"color.desaturate":{const e=this.expectType(this.input(t,"color"),["rgba","rgb","vec4","vec3"],t.id,"color"),a=e.value,r="rgba"===e.type||"vec4"===e.type?a.rgb??a.xyz:a,u=this.floatInput(t,"fraction",1),i=Ft(r,u);return"rgba"===e.type||"vec4"===e.type?this.output(t,{value:{type:e.type,value:zt(i,a.a??a.w)}}):this.output(t,{value:{type:e.type,value:i}})}case"color.unpackNormal":{const e=this.expectType(this.input(t,"color"),["vec3","vec4","rgb","rgba"],t.id,"color"),a=this.floatInput(t,"scale",1),r=this.optionalInput(t,"normal");return this.output(t,{value:{type:"vec3",value:k(e.value,a,r?this.expectType(r,["vec3"],t.id,"normal").value:void 0)}})}case"texture.sampler2d":{const e=this.input(t,"texture");return this.output(t,{value:this.toSampler(e,t.id)})}case"texture.sample2d":{const e=this.toSampler(this.input(t,"sampler"),t.id),a=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv"),r=e.value.sample(a.value);return this.output(t,{rgba:{type:"rgba",value:r},rgb:{type:"rgb",value:r.rgb},r:{type:"float",value:r.r},g:{type:"float",value:r.g},b:{type:"float",value:r.b},a:{type:"float",value:r.a}})}case"texture.triplanarMapping":{const e=this.input(t,"sampler"),a=this.toSampler(e,t.id),r=this.expectType(this.input(t,"scale",{type:"float",value:R(1)}),["float"],t.id,"scale"),u=this.expectType(this.input(t,"normal",{type:"vec3",value:Bt.normal}),["vec3"],t.id,"normal"),i=this.expectType(this.input(t,"position",{type:"vec3",value:Bt.position}),["vec3"],t.id,"position"),o=Ct(a.value,r.value,u.value,i.value);return this.output(t,{rgba:{type:"rgba",value:o},rgb:{type:"rgb",value:o.rgb},r:{type:"float",value:o.r},g:{type:"float",value:o.g},b:{type:"float",value:o.b},a:{type:"float",value:o.a}})}case"scene.sampleColor":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.screenUv()}),["vec2"],t.id,"uv"),a=ae(e.value);return this.output(t,{rgba:{type:"rgba",value:a},rgb:{type:"rgb",value:a.rgb},r:{type:"float",value:a.r},g:{type:"float",value:a.g},b:{type:"float",value:a.b},a:{type:"float",value:a.a}})}case"scene.sampleDepth":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.screenUv()}),["vec2"],t.id,"uv");return this.output(t,{depth:{type:"float",value:Qt(e.value)},linearEyeDepth:{type:"float",value:Xt(e.value)}})}case"scene.fragmentDepth":return this.output(t,{linearEyeDepth:{type:"float",value:Kt}});case"transform.translate":{const e=this.expectType(this.input(t,"offset",{type:"vec3",value:kt(0,0,0)}),["vec3","rgb"],t.id,"offset");return this.output(t,{value:{type:"mat4",value:Mt(e.value)}})}case"transform.scale":{const e=this.expectType(this.input(t,"scale",{type:"vec3",value:kt(1,1,1)}),["vec3","rgb"],t.id,"scale").value;return this.output(t,{value:{type:"mat4",value:xt(e.x,e.y,e.z)}})}case"transform.rotateAxis":{const e=this.expectType(this.input(t,"axis",{type:"vec3",value:kt(0,1,0)}),["vec3","rgb"],t.id,"axis"),a=this.expectType(this.input(t,"angle",{type:"float",value:R(0)}),["float"],t.id,"angle");return this.output(t,{value:{type:"mat4",value:pe(e.value,a.value)}})}case"uv.rotate":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.expectType(this.input(t,"angle",{type:"float",value:R(0)}),["float"],t.id,"angle").value,r=this.expectType(this.input(t,"center",{type:"vec2",value:$t(.5,.5)}),["vec2"],t.id,"center").value;return this.output(t,{value:{type:"vec2",value:Re(e,a,r)}})}case"uv.twirl":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.expectType(this.input(t,"strength",{type:"float",value:R(1)}),["float"],t.id,"strength").value,r=this.expectType(this.input(t,"center",{type:"vec2",value:$t(.5,.5)}),["vec2"],t.id,"center").value,u=this.expectType(this.input(t,"offset",{type:"vec2",value:$t(0,0)}),["vec2"],t.id,"offset").value;return this.output(t,{value:{type:"vec2",value:Et(e,a,r,u)}})}case"uv.radial":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=Dt(e.subtractScalar(.5));return this.output(t,{coords:{type:"vec2",value:a.coords},radius:{type:"float",value:a.radius},angle:{type:"float",value:a.angle}})}case"uv.bulge":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.expectType(this.input(t,"center",{type:"vec2",value:$t(.5,.5)}),["vec2"],t.id,"center").value,r=this.expectType(this.input(t,"power",{type:"float",value:R(1)}),["float"],t.id,"power").value;return this.output(t,{value:{type:"vec2",value:G(e,a,r)}})}case"uv.flipbook":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.floatInput(t,"columns",Ve(t,"columns",1)),r=this.floatInput(t,"rows",Ve(t,"rows",1)),u=this.floatInput(t,"fps",Ve(t,"fps",60)),i=this.expectType(this.input(t,"time",{type:"float",value:It.elapsed}),["float"],t.id,"time").value,o=String(Ae(t,"mode","clamp"));return this.output(t,{value:{type:"vec2",value:ce(e,a,r,i,u,o)}})}case"uv.pom":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.input(t,"heightMap"),r=this.toSampler(a,t.id).value,u=this.floatInput(t,"heightScale",.05),i=Ve(t,"minLayers",8),o=Ve(t,"maxLayers",24);return this.output(t,{value:{type:"vec2",value:he(e,r,u,i,o)}})}case"shape.rectangle":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value;return this.output(t,{value:{type:"float",value:_t(e,this.floatInput(t,"width",.5),this.floatInput(t,"height",.5))}})}case"shape.roundedRectangle":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value;return this.output(t,{value:{type:"float",value:Wt(e,this.floatInput(t,"width",.5),this.floatInput(t,"height",.5),this.floatInput(t,"radius",.1))}})}case"noise.simplex":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.floatInput(t,"scale",8);return this.output(t,{value:{type:"float",value:new se(e.multiplyScalar(a))}})}case"noise.voronoi2d":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.floatInput(t,"scale",8);return this.output(t,{value:{type:"float",value:new le(e.multiplyScalar(a))}})}case"effect.fresnel":return this.output(t,{value:{type:"float",value:E(Yt(this.floatInput(t,"power",1)))}});case"effect.edgeDepth":{const e=this.floatInput(t,"power",1);return this.output(t,{value:{type:"float",value:Ht(e)}})}case"effect.depthFade":{const e=this.floatInput(t,"distance",1);return this.output(t,{value:{type:"float",value:Jt(e)}})}case"util.panner":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"coord"),a=this.expectType(this.input(t,"speed",{type:"vec2",value:$t(0,0)}),["vec2"],t.id,"speed"),r=this.expectType(this.input(t,"tile",{type:"vec2",value:$t(1,1)}),["vec2"],t.id,"tile"),u=this.expectType(this.input(t,"time",{type:"float",value:It.elapsed}),["float"],t.id,"time");return this.output(t,{value:{type:"vec2",value:e.value.multiply(r.value).add(a.value.multiplyScalar(u.value))}})}}}compileParameterNode(t){const e=String(Ae(t,"parameter","")),a=this.graph.parameters?.find(t=>t.name===e||t.id===e);if(null==a)throw new ShaderGraphCompileError(`Parameter "${e}" does not exist`,t.id);const r=me(a.type),u={type:r,value:je(this.options.parameters?.[a.name]??a.defaultValue,r,a.name)};if("sampler2d"!==r)return{value:u};const i=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv"),o=u.value.sample(i.value);return{value:{type:"rgba",value:o},rgb:{type:"rgb",value:o.rgb},r:{type:"float",value:o.r},g:{type:"float",value:o.g},b:{type:"float",value:o.b},a:{type:"float",value:o.a},sampler:u}}compileBinaryMath(t){const e=this.expectBinaryMathValue(this.input(t,"a")),a=this.expectBinaryMathValue(this.input(t,"b")),r=t.kind.split(".")[1];if("mat4"===e.type||"mat4"===a.type)return function(t,e,a,r){if("mat4"===t.type&&"mat4"===e.type&&"divide"!==a)return{type:"mat4",value:De(t.value,e.value,a,r)};if("mat4"===t.type&&"float"===e.type&&("multiply"===a||"divide"===a))return{type:"mat4",value:De(t.value,e.value,a,r)};if("float"===t.type&&"mat4"===e.type&&"multiply"===a)return{type:"mat4",value:De(e.value,t.value,a,r)};if("mat4"===t.type&&"vec4"===e.type&&"multiply"===a)return{type:"vec4",value:t.value.multiplyVec(e.value)};throw new ShaderGraphCompileError(`Cannot ${a} ${t.type} and ${e.type}`,r)}(e,a,r,t.id);if(e.type===a.type)return{type:e.type,value:De(e.value,a.value,r,t.id)};if("float"===e.type&&"float"!==a.type&&"multiply"===r)return{type:a.type,value:De(a.value,e.value,r,t.id)};if("float"!==e.type&&"float"===a.type)return{type:e.type,value:De(e.value,a.value,r,t.id)};throw new ShaderGraphCompileError(`Cannot ${r} ${e.type} and ${a.type}`,t.id)}expectBinaryMathValue(t){if(!Fe(t.type)&&"mat4"!==t.type)throw new ShaderGraphCompileError(`Expected a numeric value but got ${t.type}`);return t}compileUnaryMath(t,e){const a=this.expectNumeric(this.input(t,"value"));return{type:a.type,value:e(a.value)}}compileAtan2(t){const e=this.expectNumeric(this.input(t,"y")),a=this.expectNumeric(this.input(t,"x"));return{type:function(t,e,a){if(t===e)return t;if("rgb"===t&&"vec3"===e||"vec3"===t&&"rgb"===e)return"vec3";if("rgba"===t&&"vec4"===e||"vec4"===t&&"rgba"===e)return"vec4";throw new ShaderGraphCompileError(`Cannot mix ${t} and ${e}`,a)}(e.type,a.type,t.id),value:C(e.value,a.value)}}compileBinaryFunction(t,e,a=!1){const r=this.expectNumeric(this.input(t,"a")),u=this.expectNumeric(this.input(t,"b"));return{type:a&&"float"===u.type?r.type:Le(r.type,u.type,t.id),value:e(r.value,u.value)}}compilePaintedLayerMix(t){const e=this.expectNumeric(this.input(t,"base")),a=[e.value],r=[At(0)];let u=e.type;for(let e=1;e<=8;e++){const i=this.optionalInput(t,`layer${e}`);if(null==i)continue;const o=this.expectNumeric(i);u=Le(u,o.type,t.id),a.push(o.value),r.push(At(e))}return 1===a.length?e:{type:u,value:it({layerColors:a,layerWeights:r,enableNoise:Boolean(Ae(t,"enableNoise",!0)),noiseScale:this.floatInput(t,"noiseScale",Ve(t,"noiseScale",.1)),noiseAmount:this.floatInput(t,"noiseAmount",Ve(t,"noiseAmount",.5)),decay:this.floatInput(t,"softness",Ve(t,"softness",.3)),mode:"hard"===String(Ae(t,"mode","soft"))?X.hard:X.soft})}}defaultUV(){return"trail"===this.graph.target?ne:"decal"===this.graph.target?ue:E(M.uv)}uvAttribute(t){const e=Math.max(0,Math.floor(Ve(t,"channel",0)));return 0===e?Bt.uv:ge(fe(`uv${e}`))}namedRerouteDeclaration(t){const e=String(t.params?.declarationId??"");if(0===e.length)throw new ShaderGraphCompileError("Named reroute usage is missing a declaration",t.id);const a=this.nodesById.get(e);if(null==a)throw new ShaderGraphCompileError(`Named reroute declaration "${e}" does not exist`,t.id);if("utility.namedRerouteDeclaration"!==a.kind)throw new ShaderGraphCompileError(`Node "${e}" is not a named reroute declaration`,t.id);return a}input(t,e,a){const r=t.inputs?.[e];if(null!=r)return this.resolveInput(r,t.id,e);const u=(this.graph.edges??[]).find(a=>a.to.nodeId===t.id&&a.to.port===e);if(null!=u)return this.resolveSocket(u.from,t.id,e);if(null!=a)return a;const i=this.inlineLiteralFallback(t,e);if(null!=i)return i;throw new ShaderGraphCompileError(`Missing input "${e}"`,t.id,e)}optionalInput(t,e){const a=t.inputs?.[e];if(null!=a)return this.resolveInput(a,t.id,e);const r=(this.graph.edges??[]).find(a=>a.to.nodeId===t.id&&a.to.port===e);return null!=r?this.resolveSocket(r.from,t.id,e):void 0}floatInput(t,e,a){return this.expectType(this.input(t,e,{type:"float",value:R(a)}),["float"],t.id,e).value}boolInput(t,e,a){return this.expectType(this.input(t,e,{type:"boolean",value:U(a)}),["boolean"],t.id,e).value}compileComparison(t){const e=this.expectType(this.input(t,"a"),["float"],t.id,"a").value,a=this.expectType(this.input(t,"b"),["float"],t.id,"b").value;switch(t.kind){case"compare.greaterThan":return e.gt(a);case"compare.greaterThanOrEqual":return e.gte(a);case"compare.lessThan":return e.lt(a);case"compare.lessThanOrEqual":return e.lte(a);case"compare.equal":return e.equals(a);case"compare.notEqual":return e.notEquals(a)}throw new ShaderGraphCompileError(`Unsupported comparison node "${t.kind}"`,t.id)}compileBooleanBinary(t,e){const a=this.boolInput(t,"a",!1),r=this.boolInput(t,"b",!1);return"and"===e?a.and(r):a.or(r)}resolveOutputBinding(t,e){if(null!=t.input)return this.resolveSocket(t.input,void 0,e);if(void 0!==t.value)return Pe(t.value);throw new ShaderGraphCompileError(`Output "${e}" is missing an input or value`)}floatOutput(t,e){return this.expectType(this.resolveOutputBinding(t,e),["float"],e).value}resolveInput(t,e,a){return function(t){return null!=t.nodeId}(t)?this.resolveSocket(t,e,a):Pe(t.value,t.valueType)}inlineLiteralFallback(t,e){const a=de[t.kind]?.inputs.find(t=>t.name===e);if(null==a)return;const r=ye(t.kind,a),u=ve(t.kind,a);return null!=r&&void 0!==u?Pe(u,r):void 0}resolveSocket(t,e,a){const r=this.compileNode(t.nodeId).outputs[t.port];if(null==r)throw new ShaderGraphCompileError(`Node "${t.nodeId}" does not have output "${t.port}"`,e??t.nodeId,a??t.port);return r}expectType(t,e,a,r){if(!e.includes(t.type))throw new ShaderGraphCompileError(`Expected ${e.join(" or ")} but got ${t.type}`,a,r);return t}expectNumeric(t){if(!Fe(t.type))throw new ShaderGraphCompileError(`Expected a numeric value but got ${t.type}`);return t}toSampler(t,e){if("sampler2d"===t.type)return t;if("texture2d"===t.type){const a=t.value;if(null==a)throw new ShaderGraphCompileError("Texture input is empty",e);return{type:"sampler2d",value:Tt(a)}}throw new ShaderGraphCompileError(`Expected texture2d or sampler2d but got ${t.type}`,e)}toColorOutput(t){switch(t.type){case"float":case"vec2":case"vec3":case"vec4":case"rgb":case"rgba":return t.value;case"boolean":{const e=yt(t.value,R(1),R(0));return ct(kt(e,e,e),1)}case"mat4":throw new ShaderGraphCompileError("mat4 values cannot be used as color");case"texture2d":case"sampler2d":throw new ShaderGraphCompileError(`${t.type} must be sampled before it can be used as color`)}}toVec3Output(t,e){if("vec3"===t.type||"rgb"===t.type)return t.value;if("vec4"===t.type||"rgba"===t.type)return t.value.xyz;throw new ShaderGraphCompileError(`Output "${e}" expects vec3/rgb but got ${t.type}`)}toMat4Output(t,e){if("mat4"===t.type)return t.value;throw new ShaderGraphCompileError(`Output "${e}" expects mat4 but got ${t.type}`)}output(t,e){return{node:t,outputs:e}}}export function compileShaderGraph(t,e={}){return new ShaderGraphCompiler(t,e).compile()}export function compileShaderGraphPreview(t,e,a={}){if(null==e)return compileShaderGraph(t,a).output;const r=new ShaderGraphCompiler(t,a).compileNode(e),u=Object.values(r.outputs)[0];if(null==u)throw new ShaderGraphCompileError(`Node "${e}" has no previewable output`,e);return{color:Be(u),transparent:"rgba"===u.type||"vec4"===u.type}}export function buildShaderGraphMaterial(t,a={}){if("postProcess"===t.target)return buildShaderGraphPostProcessMaterial(t,a);const r=function(t,e,a){const r=a.alphaTest??t.alphaTest??e.materialOptions?.alphaTest;return null!=r?{...t,alphaTest:r}:t}(null!=a.previewNodeId?compileShaderGraphPreview(t,a.previewNodeId,a):compileShaderGraph(t,a).output,t,a);if("sprite"===t.target)return new Vt({color:r.color,discard:r.discard,alphaTest:r.alphaTest,transparent:r.transparent??!0,position:Pt(new b("rotation",0),new b("screenSpaceSize",0),void 0,!0),uniforms:{color:{value:new e(16777215)}}});if("trail"===t.target){const{position:e}=oe.getTrailShaderNodes(a.trailBillboard??!1),u=new y({...r,position:e});return oe.applyTrailShaderParameters(u),Ue(u,t),u}if("decal"===t.target){const e=re.or(ie),a=null!=r.discard?e.or(r.discard):e,u=new y({...r,transparent:!1,discard:a});return u.userData.isDecal=!0,Ue(u,t),u}const u=new y({transparent:!1,...r});return Ue(u,t),u}export function buildShaderGraphPostProcessMaterial(t,e={}){const a=null!=e.previewNodeId?Ce(compileShaderGraphPreview(t,e.previewNodeId,e).color):compileShaderGraph(t,e).output,r=new y({color:a.color,transparent:!1,fog:!1,lights:!1,outputEncoding:!1});return r.depthWrite=!1,r.depthTest=!1,r.toneMapped=!1,r.userData.isPostProcessShaderGraph=!0,r}export function buildShaderGraphInlinePreviewMaterial(t,e,a={}){const r=compileShaderGraphPreview({...t,target:"surface"},e,a),u=new y({color:r.color,transparent:r.transparent??!1,fog:!1,lights:!1});return u.depthWrite=!1,u.depthTest=!1,u.toneMapped=!1,u}function Ce(t,e,a=Zt){const r=ae(a),u=Gt("hology_post_process_weight",1),i=vt(null!=e?u.multiply(e):u);return{color:ut(r.rgb,Ee(t),i),transparent:!1,...null!=e?{opacity:e}:{}}}function Ee(t){return t instanceof h?kt(t,t,t):t instanceof x?kt(t.x,t.y,0):t instanceof S?t.xyz:t}export function shaderGraphMaterialSideToThree(e){switch(e){case"back":return t;case"double":return r;default:return u}}function Ge(t){return"decal"!==t.target&&(t.materialOptions?.transparent??"sprite"===t.target)}function Ue(t,e){"surface"===e.target&&(t.side=shaderGraphMaterialSideToThree(e.materialOptions?.side)),null!=e.materialOptions?.transparent&&(t.transparent=e.materialOptions.transparent),null!=e.materialOptions?.bloom&&(t.userData.hasBloom=e.materialOptions.bloom)}function Be(t){switch(t.type){case"float":return $e(t.value);case"vec2":{const e=t.value;return ct(kt(e.x,e.y,0),1)}case"vec3":case"rgb":return ct(t.value,1);case"vec4":case"rgba":return t.value;case"boolean":return $e(yt(t.value,R(1),R(0)));case"mat4":throw new ShaderGraphCompileError("mat4 values cannot be previewed as color");case"texture2d":case"sampler2d":throw new ShaderGraphCompileError(`${t.type} nodes require a sampled output to preview`)}}function $e(t){return ct(kt(t,t,t),1)}function ke(t){return t instanceof h?kt(t,t,t).rgb:t instanceof x?kt(t.x,t.y,0).rgb:t}function ze(t){return t.rgb}function Ae(t,e,a){const r=t.params?.[e];return void 0===r?a:r}function Ve(t,e,a){const r=Ae(t,e,a);return"number"==typeof r?r:Number(r??a)}function Pe(t,e){if(null!=(a=t)&&"object"==typeof a&&!Array.isArray(a)&&"value"in a)return Pe(t.value,t.valueType??e);var a;const r=e??function(t){if("boolean"==typeof t)return"boolean";if("number"==typeof t)return"float";if(Array.isArray(t))return 2===t.length?"vec2":3===t.length?"vec3":16===t.length?"mat4":"vec4";return"string"==typeof t?"rgb":"float"}(t);return{type:r,value:je(t,r,"literal")}}function je(t,a,r){switch(a){case"boolean":return t instanceof c?t:U(Boolean(t));case"float":return t instanceof h?t:R(We(t,0));case"vec2":return t instanceof x?t:Ye(t);case"vec3":return t instanceof w?t:Je(t);case"vec4":return t instanceof S?t:function(t){const[e,a,r,u]=He(t,4,1);return zt(e,a,r,u)}(t);case"mat4":return t instanceof v?t:function(t){if(t instanceof i)return et(t);const e=new i;Array.isArray(t)&&16===t.length&&e.fromArray(t.map(t=>We(t,0)));return et(e)}(t);case"rgb":return t instanceof d?t:function(t){if("string"==typeof t||"number"==typeof t||t instanceof e)return ht(t);const[a,r,u]=He(t,3);return kt(a,r,u).rgb}(t);case"rgba":return t instanceof m||t instanceof S?t:Ke(t);case"texture2d":return t;case"sampler2d":return function(t){const e=t;return t instanceof f||t instanceof g||"function"==typeof e?.isSampler2D||!0===e?.isSampler2D}(t)?t:t instanceof n||!0===t?.isTexture?Tt(t):(Ne.has(r)||(Ne.add(r),console.warn(`Shader graph parameter "${r}" is missing a texture value; using a 1x1 white fallback texture.`)),Tt(Me))}}function De(t,e,a,r){const u=`${a}Scalar`;if(e instanceof h&&"function"==typeof t[u])return t[u](e);if("function"==typeof t[a])return t[a](e);throw new ShaderGraphCompileError(`Node does not support ${a}`,r)}function Le(t,e,a){if(t===e)return t;if("rgb"===t&&"vec3"===e||"vec3"===t&&"rgb"===e)return"vec3";if("rgba"===t&&"vec4"===e||"vec4"===t&&"rgba"===e)return"vec4";if("float"===t&&Fe(e))return e;if("float"===e&&Fe(t))return t;throw new ShaderGraphCompileError(`Cannot mix ${t} and ${e}`,a)}function Re(t,e,a){const r=t.subtract(a),u=mt(e),i=z(e);return $t(i.multiply(r.x).subtract(u.multiply(r.y)).add(a.x),u.multiply(r.x).add(i.multiply(r.y)).add(a.y))}function qe(t,e,a){const r=t.value["u"===e?"x":"v"===e?"y":e];if(r instanceof h)return r;throw new ShaderGraphCompileError(`Component "${e}" is not available on ${t.type}`,a)}function Fe(t){return"float"===t||"vec2"===t||"vec3"===t||"vec4"===t||"rgb"===t||"rgba"===t}function _e(t){return Number.isFinite(t)?Math.min(1,Math.max(0,t)):0}function We(t,e){if("number"==typeof t)return t;if("string"==typeof t){const a=parseFloat(t);return Number.isFinite(a)?a:e}return"boolean"==typeof t?t?1:0:e}function He(t,a,r=0){if(Array.isArray(t))return Array.from({length:a},(e,a)=>We(t[a],r));if(t instanceof s||t instanceof l||t instanceof p)return Array.from({length:a},(e,a)=>t.toArray()[a]??r);if(t instanceof e){const e=t.toArray();return Array.from({length:a},(t,a)=>e[a]??(3===a?1:r))}if(null!=t&&"object"==typeof t){const e=t,u=["x","y","z","w"];if(u.some(t=>null!=e[t]))return Array.from({length:a},(t,a)=>We(e[u[a]],r));const i=["r","g","b","a"];if(i.some(t=>null!=e[t]))return Array.from({length:a},(t,a)=>We(e[i[a]],3===a?1:r))}return Array.from({length:a},()=>We(t,r))}function Ye(t){const[e,a]=He(t,2);return $t(e,a)}function Je(t){const[e,a,r]=He(t,3);return kt(e,a,r)}function Ke(t,a=1){if("string"==typeof t||"number"==typeof t||t instanceof e)return ct(t,a);if(t instanceof w)return ct(t,a);const[r,u,i,o]=He(t,4,a);return zt(r,u,i,o)}function Qe(t,e){return e<=1?0:t/(e-1)}/*
|
|
1
|
+
import{BackSide as e,Color as t,DataTexture as a,DoubleSide as r,FrontSide as i,Matrix4 as u,RGBAFormat as o,Texture as n,Vector2 as s,Vector3 as l,Vector4 as p}from"three";import{BooleanNode as c,FloatNode as h,IntNode as v,Mat4Node as y,NodeShaderMaterial as d,RgbNode as m,RgbaNode as f,Sampler2DNode as g,Texture2dLookupNode as b,UniformFloatNode as x,Vec2Node as w,Vec3Node as S,Vec4Node as T,abs as I,acos as M,asin as O,attributes as C,atan as k,atan2 as N,autoVarying as G,bulge as E,bool as U,ceil as B,clamp as $,colorToNormal as P,cos as z,cross as V,degrees as A,distance as L,dot as D,exp as j,exp2 as R,float as q,floor as F,fract as H,inversesqrt as _,batchingMatrix as W,colorGradientSampler as Y,curveSampler as J,ifDefApply as K,sampleNamedEasingCurve as Q,length as X,LayerMixMode as Z,log as ee,log2 as te,mat4 as ae,max as re,min as ie,mix as ue,mixColorsByLayer as oe,particleUniforms as ne,mod as se,normalize as le,pow as pe,radians as ce,rgba as he,rgb as ve,saturate as ye,select as de,sign as me,sin as fe,smoothstep as ge,sqrt as be,standardMaterial as xe,stylizedCharacterMaterial as we,scaleTransform as Se,step as Te,tan as Ie,textureSampler2d as Me,timeUniforms as Oe,toonMaterial as Ce,translate as ke,transformed as Ne,triplanarMapping as Ge,twirl as Ee,uniformFloat as Ue,uniforms as Be,varyingAttributes as $e,vec2 as Pe,vec3 as ze,vec4 as Ve,getPaintedMaterialLayerWeight as Ae}from"../../shader-nodes/index.js";import{isWgslCompiler as Le}from"three-shader-graph";import{SpriteNodeShaderMaterial as De,getSpritePosition as je}from"../sprite-shader.js";import{oneMinus as Re}from"../../shader-nodes/index.js";import{vectorToRadial as qe,remap as Fe,hueShift as He,blendColor as _e,desaturateColor as We}from"../../shader-nodes/math.js";import{rectangleFloat as Ye,roundedRectangleFloat as Je}from"../../shader-nodes/shapes.js";import{edgeDepthEffect as Ke,fresnelEffect as Qe,depthFadeEffect as Xe}from"../../shader-nodes/effects.js";import{fragmentLinearEyeDepth as Ze,sampleSceneDepth as et,sampleSceneLinearEyeDepth as tt,screenUV as at,nearUniformName as rt,farUniformName as it}from"../../shader-nodes/depth.js";import{sampleSceneColor as ut}from"../../shader-nodes/scene-sample.js";import{decalDiscard as ot,decalUV as nt}from"../../shader-nodes/decal.js";import{sampledSurfaceRejectsDecals as st}from"../../shader-nodes/material-flags.js";import{Trail as lt,trailUV as pt}from"../../effects/vfx/trail-renderer.js";import{SimplexNoiseNode as ct,Voronoi2d as ht,rotateAxis as vt}from"../../shader-nodes/index.js";import{flipbookUv as yt}from"../../shader-nodes/texture-sequence.js";import{parallaxOcclusionMapping as dt}from"../../shader-nodes/pom.js";import{defaultInlineLiteralValueForPort as mt,inlineLiteralTypeForPort as ft,SHADER_GRAPH_NODE_DEFINITIONS as gt}from"./registry.js";import{shaderGraphParameterTypeToValueType as bt}from"./parameters.js";import{attributeVec2 as xt,varying as wt,reflect as St,refract as Tt,dFdx as It,dFdy as Mt,fwidth as Ot,uniformAmbient as Ct,uniformDirectionalLights as kt}from"three-shader-graph";import{decalNormal as Nt}from"../../shader-nodes/decal.js";import{Curve2 as Gt}from"../../utils/curve.js";const Et=(()=>{const e=new a(new Uint8Array([255,255,255,255]),1,1,o);return e.name="Missing shader graph texture parameter fallback",e.needsUpdate=!0,e})(),Ut=new Set;const Bt=new class extends v{compile(e){return{out:Le(e)?"i32(rendererDirectionalLightCount())":"NUM_DIR_LIGHTS"}}};export class ShaderGraphCompileError extends Error{constructor(e,t,a){super(e),this.nodeId=t,this.port=a,this.name="ShaderGraphCompileError"}}export const shaderGraphPostProcessWeightUniformName="hology_post_process_weight";export class ShaderGraphCompiler{constructor(e,t={}){this.graph=e,this.options=t,this.compiled=new Map,this.compiling=new Set,this.nodesById=new Map((e.nodes??[]).map(e=>[e.id,e]))}validate(){this.compile()}compile(){if(1!==this.graph.version)throw new ShaderGraphCompileError(`Unsupported shader graph version ${this.graph.version}`);return this.validateEdges(),this.validateNamedReroutes(),{output:this.compileOutput(),nodes:this.compiled}}validateEdges(){for(const e of this.graph.edges??[]){if(!this.nodesById.has(e.from.nodeId))throw new ShaderGraphCompileError(`Edge references missing source node "${e.from.nodeId}"`,e.from.nodeId,e.from.port);if(!this.nodesById.has(e.to.nodeId))throw new ShaderGraphCompileError(`Edge references missing target node "${e.to.nodeId}"`,e.to.nodeId,e.to.port)}}validateNamedReroutes(){for(const e of this.graph.nodes??[])"utility.namedRerouteUsage"===e.kind&&this.namedRerouteDeclaration(e)}compileOutput(){if("postProcess"===this.graph.target)return this.compilePostProcessOutput();const e=this.graph.outputs?.color,t={color:null!=e?this.toColorOutput(this.resolveOutputBinding(e,"color")):he("#ffffff",1),transparent:zt(this.graph)},a=this.graph.outputs?.opacity;null!=a&&(t.opacity=this.expectType(this.resolveOutputBinding(a,"opacity"),["float"],"opacity").value);const r=this.graph.outputs?.roughness;null!=r&&(t.roughness=this.expectType(this.resolveOutputBinding(r,"roughness"),["float"],"roughness").value);const i=this.graph.outputs?.metalness;null!=i&&(t.metalness=this.floatOutput(i,"metalness"));const u=this.graph.outputs?.normal;null!=u&&(t.normal=this.toVec3Output(this.resolveOutputBinding(u,"normal"),"normal"));const o=this.graph.outputs?.emissive;null!=o&&(t.emissive=this.toVec3Output(this.resolveOutputBinding(o,"emissive"),"emissive"));const n=this.graph.outputs?.ambientOcclusion;null!=n&&(t.ambientOcclusion=this.floatOutput(n,"ambientOcclusion"));const s=this.graph.outputs?.ambientOcclusionIntensity;null!=s&&(t.ambientOcclusionIntensity=this.floatOutput(s,"ambientOcclusionIntensity"));const l=this.graph.outputs?.sheenColor;null!=l&&(t.sheenColor=this.toVec3Output(this.resolveOutputBinding(l,"sheenColor"),"sheenColor"));const p=this.graph.outputs?.sheenRoughness;null!=p&&(t.sheenRoughness=this.floatOutput(p,"sheenRoughness"));const c=this.graph.outputs?.anisotropy;null!=c&&(t.anisotropy=this.floatOutput(c,"anisotropy"));const h=this.graph.outputs?.anisotropyDirection;null!=h&&(t.anisotropyDirection=this.expectType(this.resolveOutputBinding(h,"anisotropyDirection"),["vec2"],"anisotropyDirection").value);const v=this.graph.outputs?.bakedLight;null!=v&&(t.bakedLight=this.toVec3Output(this.resolveOutputBinding(v,"bakedLight"),"bakedLight"));const y=["shadowTint","subsurfaceColor","eyeIrisColor","eyeHighlightColor","rimColor"];for(const e of y){const a=this.graph.outputs?.[e];null!=a&&(t[e]=this.toVec3Output(this.resolveOutputBinding(a,e),e))}const d=["shadowThreshold","shadowSoftness","specularIntensity","specularToonness","specularThreshold","specularSoftness","environmentSpecularIntensity","skinMask","thickness","subsurfaceStrength","subsurfaceWrap","faceMask","faceShadow","faceShadowStrength","faceShadowSoftness","faceShadowOffset","rimMask","rimStrength","rimPower","rimThreshold","rimSoftness"];for(const e of d){const a=this.graph.outputs?.[e];null!=a&&(t[e]=this.floatOutput(a,e))}const m=this.graph.outputs?.transform;null!=m&&"decal"!==this.graph.target&&(t.transform=this.toMat4Output(this.resolveOutputBinding(m,"transform"),"transform"));const f=this.graph.outputs?.discard;null!=f&&(t.discard=this.expectType(this.resolveOutputBinding(f,"discard"),["boolean"],"discard").value);const g=this.graph.outputs?.transparent;null!=g&&null!=g.value&&(t.transparent=Boolean(g.value));const b=this.graph.outputs?.alphaTest;return null!=b&&null!=b.value?t.alphaTest=Number(b.value):null!=this.graph.materialOptions?.alphaTest&&(t.alphaTest=this.graph.materialOptions.alphaTest),this.applyShadingModel(t)}compilePostProcessOutput(){const e=this.screenUv(),t=this.graph.outputs?.color,a=null!=t?this.toColorOutput(this.resolveOutputBinding(t,"color")):ut(e),r=this.graph.outputs?.opacity;return $t(a,null!=r?this.expectType(this.resolveOutputBinding(r,"opacity"),["float"],"opacity").value:void 0,e)}screenUv(){return this.options.screenUV??at}applyShadingModel(e){const t=null!=e.opacity?function(e,t){if(e instanceof h)return he(ze(e,e,e),t);if(e instanceof w)return he(ze(e.x,e.y,0),t);if(e instanceof T)return he(e.rgb,e.w.multiply(t));return he(e,t)}(e.color,e.opacity):e.color;switch(this.graph.shadingModel??"standard"){case"standard":{const a={color:Dt(t),roughness:e.roughness??q(.5),...null!=e.metalness?{metalness:e.metalness}:{},..."decal"===this.graph.target?{normal:le(wt(Be.normalMatrix).multiplyVec(Nt))}:{},...null!=e.normal?{normal:e.normal}:{},...null!=e.emissive?{emissive:jt(e.emissive)}:{},...null!=e.ambientOcclusion?{ambientOcclusion:e.ambientOcclusion}:{},...null!=e.ambientOcclusionIntensity?{ambientOcclusionIntensity:e.ambientOcclusionIntensity}:{},...null!=e.sheenColor?{sheenColor:e.sheenColor.rgb}:{},...null!=e.sheenRoughness?{sheenRoughness:e.sheenRoughness}:{},...null!=e.anisotropy?{anisotropy:e.anisotropy}:{},...null!=e.anisotropyDirection?{anisotropyDirection:e.anisotropyDirection}:{},...null!=e.bakedLight?{bakedLight:e.bakedLight}:{}};return{...e,color:xe(a)}}case"toon":{const a={color:Dt(t),...null!=e.normal?{normal:e.normal}:{},...null!=e.emissive?{emissive:jt(e.emissive)}:{},...null!=e.ambientOcclusion?{ambientOcclusion:e.ambientOcclusion}:{},...null!=e.ambientOcclusionIntensity?{ambientOcclusionIntensity:e.ambientOcclusionIntensity}:{},...null!=e.bakedLight?{bakedLight:e.bakedLight}:{}};return{...e,color:Ce(a)}}case"stylizedCharacter":{const a={color:Dt(t),shadowTint:e.shadowTint??ve(9212589),shadowThreshold:e.shadowThreshold??.05,shadowSoftness:e.shadowSoftness??.12,roughness:e.roughness??1,specularIntensity:e.specularIntensity??1,specularToonness:e.specularToonness??.2,specularThreshold:e.specularThreshold??.08,specularSoftness:e.specularSoftness??.025,environmentSpecularIntensity:e.environmentSpecularIntensity??.25,skinMask:e.skinMask??0,thickness:e.thickness??0,subsurfaceColor:e.subsurfaceColor??ve(12209973),subsurfaceStrength:e.subsurfaceStrength??.6,subsurfaceWrap:e.subsurfaceWrap??.25,backscatterStrength:e.backscatterStrength??.75,backscatterPower:e.backscatterPower??3,faceMask:e.faceMask??0,faceShadow:e.faceShadow??.5,faceShadowStrength:e.faceShadowStrength??.2,faceShadowSoftness:e.faceShadowSoftness??.08,faceShadowOffset:e.faceShadowOffset??0,eyeMask:e.eyeMask??0,irisMask:e.irisMask??0,eyeHighlightMask:e.eyeHighlightMask??0,eyeLowerLightMask:e.eyeLowerLightMask??0,eyeBrightness:e.eyeBrightness??1.15,eyeIrisColor:e.eyeIrisColor??ve(6535423),eyeIrisGlow:e.eyeIrisGlow??.18,eyeHighlightColor:e.eyeHighlightColor??ve(16777215),eyeHighlightStrength:e.eyeHighlightStrength??.65,rimMask:e.rimMask??1,rimColor:e.rimColor??ve(12179967),rimStrength:e.rimStrength??.08,rimPower:e.rimPower??2.5,rimThreshold:e.rimThreshold??.45,rimSoftness:e.rimSoftness??.08,...null!=e.normal?{normal:e.normal}:{},...null!=e.emissive?{emissive:jt(e.emissive)}:{},...null!=e.ambientOcclusion?{ambientOcclusion:e.ambientOcclusion}:{},...null!=e.ambientOcclusionIntensity?{ambientOcclusionIntensity:e.ambientOcclusionIntensity}:{},...null!=e.bakedLight?{bakedLight:e.bakedLight}:{}};return{...e,color:we(a)}}case"unlit":return{...e,color:t}}}compileNode(e){const t=this.compiled.get(e);if(null!=t)return t;const a=this.nodesById.get(e);if(null==a)throw new ShaderGraphCompileError(`Missing shader graph node "${e}"`,e);if(null==gt[a.kind])throw new ShaderGraphCompileError(`Unsupported shader graph node "${a.kind}"`,a.id);if(this.compiling.has(e))throw new ShaderGraphCompileError(`Shader graph contains a cycle involving node "${e}"`,e);this.compiling.add(e);try{const t=this.compileNodeInternal(a);return this.compiled.set(e,t),t}finally{this.compiling.delete(e)}}compileNodeInternal(e){switch(e.kind){case"input.parameter":return this.output(e,this.compileParameterNode(e));case"input.slider":return this.output(e,{value:{type:"float",value:q(Qt(qt(e,"value",.5)))}});case"constant.boolean":return this.output(e,{value:{type:"boolean",value:U(Boolean(Rt(e,"value",!1)))}});case"constant.float":return this.output(e,{value:{type:"float",value:q(qt(e,"value",0))}});case"constant.vec2":return this.output(e,{value:{type:"vec2",value:ea(Rt(e,"value",[0,0]))}});case"constant.vec3":return this.output(e,{value:{type:"vec3",value:ta(Rt(e,"value",[0,0,0]))}});case"constant.rgba":return this.output(e,{value:{type:"rgba",value:aa(Rt(e,"value","#ffffff"),qt(e,"alpha",1))}});case"builtin.uv":{let t;return t="trail"===this.graph.target?pt:"decal"===this.graph.target?nt:this.uvAttribute(e),this.output(e,{value:{type:"vec2",value:!0===Rt(e,"flipY",!1)?Pe(t.x,Re(t.y)):t},u:{type:"float",value:t.x},v:{type:"float",value:t.y}})}case"builtin.screenUv":return this.output(e,{value:{type:"vec2",value:this.screenUv()}});case"builtin.color":{const t=G(C.color);return this.output(e,{value:{type:"rgba",value:t},rgb:{type:"rgb",value:t.rgb},r:{type:"float",value:t.r},g:{type:"float",value:t.g},b:{type:"float",value:t.b},a:{type:"float",value:t.a}})}case"builtin.position":{const t=G(C.position);return this.output(e,{value:{type:"vec3",value:t},x:{type:"float",value:t.x},y:{type:"float",value:t.y},z:{type:"float",value:t.z}})}case"builtin.worldPosition":{const t=G(Ne.worldPosition);return this.output(e,{value:{type:"vec3",value:t},x:{type:"float",value:t.x},y:{type:"float",value:t.y},z:{type:"float",value:t.z}})}case"builtin.objectPosition":{let t=Be.instanceMatrix.multiplyVec(Ve(0,0,0,1));t=K("USE_BATCHING",t,e=>W.multiplyVec(e));const a=G(Be.modelMatrix.multiplyVec(t).xyz);return this.output(e,{value:{type:"vec3",value:a},x:{type:"float",value:a.x},y:{type:"float",value:a.y},z:{type:"float",value:a.z}})}case"builtin.viewDir":{const t=G(Ne.viewDir);return this.output(e,{value:{type:"vec3",value:t},x:{type:"float",value:t.x},y:{type:"float",value:t.y},z:{type:"float",value:t.z}})}case"builtin.normal":{const t=G(C.normal);return this.output(e,{value:{type:"vec3",value:t},x:{type:"float",value:t.x},y:{type:"float",value:t.y},z:{type:"float",value:t.z}})}case"builtin.time":return this.output(e,{value:{type:"float",value:Oe.elapsed}});case"builtin.camera":{const t=Ue(rt),a=Ue(it),r=Be.cameraPosition;return this.output(e,{position:{type:"vec3",value:r},x:{type:"float",value:r.x},y:{type:"float",value:r.y},z:{type:"float",value:r.z},near:{type:"float",value:t},far:{type:"float",value:a}})}case"builtin.viewMatrix":return this.output(e,{value:{type:"mat4",value:Be.viewMatrix}});case"builtin.projectionMatrix":return this.output(e,{value:{type:"mat4",value:Be.projectionMatrix}});case"builtin.modelViewMatrix":return this.output(e,{value:{type:"mat4",value:Be.modelViewMatrix}});case"scene.ambientLight":return this.output(e,{color:{type:"rgb",value:Ct}});case"scene.directionalLight":return this.output(e,{color:{type:"rgb",value:kt.sum(e=>e.color).divideScalar(re(q(Bt),q(1)))},direction:{type:"vec3",value:kt.sum(e=>e.direction).divideScalar(re(q(Bt),q(1)))}});case"builtin.particle":return this.output(e,{energy:{type:"float",value:ne.energy},color:{type:"rgb",value:ne.color},opacity:{type:"float",value:ne.opacity},time:{type:"float",value:ne.time}});case"math.add":case"math.subtract":case"math.multiply":case"math.divide":return this.output(e,{value:this.compileBinaryMath(e)});case"math.oneMinus":{const t=this.expectNumeric(this.input(e,"value"));return this.output(e,{value:{type:t.type,value:Re(t.value)}})}case"math.abs":return this.output(e,{value:this.compileUnaryMath(e,I)});case"math.sign":return this.output(e,{value:this.compileUnaryMath(e,me)});case"math.floor":return this.output(e,{value:this.compileUnaryMath(e,F)});case"math.ceil":return this.output(e,{value:this.compileUnaryMath(e,B)});case"math.fract":return this.output(e,{value:this.compileUnaryMath(e,H)});case"math.sin":return this.output(e,{value:this.compileUnaryMath(e,fe)});case"math.cos":return this.output(e,{value:this.compileUnaryMath(e,z)});case"math.tan":return this.output(e,{value:this.compileUnaryMath(e,Ie)});case"math.asin":return this.output(e,{value:this.compileUnaryMath(e,O)});case"math.acos":return this.output(e,{value:this.compileUnaryMath(e,M)});case"math.atan":return this.output(e,{value:this.compileUnaryMath(e,k)});case"math.atan2":return this.output(e,{value:this.compileAtan2(e)});case"math.radians":return this.output(e,{value:this.compileUnaryMath(e,ce)});case"math.degrees":return this.output(e,{value:this.compileUnaryMath(e,A)});case"math.sqrt":return this.output(e,{value:this.compileUnaryMath(e,be)});case"math.inverseSqrt":return this.output(e,{value:this.compileUnaryMath(e,_)});case"math.exp":return this.output(e,{value:this.compileUnaryMath(e,j)});case"math.exp2":return this.output(e,{value:this.compileUnaryMath(e,R)});case"math.log":return this.output(e,{value:this.compileUnaryMath(e,ee)});case"math.log2":return this.output(e,{value:this.compileUnaryMath(e,te)});case"math.saturate":return this.output(e,{value:this.compileUnaryMath(e,ye)});case"math.length":{const t=this.expectNumeric(this.input(e,"value"));return this.output(e,{value:{type:"float",value:X(t.value)}})}case"math.normalize":return this.output(e,{value:this.compileUnaryMath(e,le)});case"math.clamp":{const t=this.expectNumeric(this.input(e,"value")),a=this.expectNumeric(this.input(e,"min",{type:"float",value:q(0)})),r=this.expectNumeric(this.input(e,"max",{type:"float",value:q(1)}));return this.output(e,{value:{type:t.type,value:$(t.value,a.value,r.value)}})}case"math.min":return this.output(e,{value:this.compileBinaryFunction(e,ie)});case"math.max":return this.output(e,{value:this.compileBinaryFunction(e,re)});case"math.pow":return this.output(e,{value:this.compileBinaryFunction(e,pe)});case"math.mod":return this.output(e,{value:this.compileBinaryFunction(e,se)});case"math.step":return this.output(e,{value:this.compileBinaryFunction(e,Te,!0)});case"math.smoothstep":{const t=this.expectNumeric(this.input(e,"edge0",{type:"float",value:q(0)})),a=this.expectNumeric(this.input(e,"edge1",{type:"float",value:q(1)})),r=this.expectNumeric(this.input(e,"value"));return this.output(e,{value:{type:r.type,value:ge(t.value,a.value,r.value)}})}case"math.mix":{const t=this.expectNumeric(this.input(e,"a")),a=this.expectNumeric(this.input(e,"b")),r=this.expectNumeric(this.input(e,"t",{type:"float",value:q(.5)})),i=Wt(t.type,a.type,e.id);return this.output(e,{value:{type:i,value:ue(t.value,a.value,r.value)}})}case"math.remap":{const t=this.expectType(this.input(e,"value"),["float"],e.id,"value").value,a=this.floatInput(e,"inMin",-1),r=this.floatInput(e,"inMax",1),i=this.floatInput(e,"outMin",0),u=this.floatInput(e,"outMax",1);return this.output(e,{value:{type:"float",value:Fe(t,a,r,i,u)}})}case"math.select":{const t=this.boolInput(e,"condition",!1),a=this.expectNumeric(this.input(e,"a")),r=this.expectNumeric(this.input(e,"b")),i=Wt(a.type,r.type,e.id);return this.output(e,{value:{type:i,value:de(t,a.value,r.value)}})}case"math.reflect":{const t=this.expectType(this.input(e,"incident"),["vec2","vec3","vec4","rgb","rgba"],e.id,"incident"),a=this.expectType(this.input(e,"normal"),["vec2","vec3","vec4","rgb","rgba"],e.id,"normal");return this.output(e,{value:{type:t.type,value:St(t.value,a.value)}})}case"math.refract":{const t=this.expectType(this.input(e,"incident"),["vec2","vec3","vec4","rgb","rgba"],e.id,"incident"),a=this.expectType(this.input(e,"normal"),["vec2","vec3","vec4","rgb","rgba"],e.id,"normal"),r=this.floatInput(e,"ior",1.5);return this.output(e,{value:{type:t.type,value:Tt(t.value,a.value,r)}})}case"math.derivative":{const t=this.expectNumeric(this.input(e,"value")),a=String(Rt(e,"mode","fwidth"));let r;return r="dFdx"===a?It(t.value):"dFdy"===a?Mt(t.value):Ot(t.value),this.output(e,{value:{type:t.type,value:r}})}case"layer.mixPainted":return this.output(e,{value:this.compilePaintedLayerMix(e)});case"math.dot":{const t=this.expectNumeric(this.input(e,"a")),a=this.expectNumeric(this.input(e,"b"));return Wt(t.type,a.type,e.id),this.output(e,{value:{type:"float",value:D(t.value,a.value)}})}case"math.distance":{const t=this.expectNumeric(this.input(e,"a")),a=this.expectNumeric(this.input(e,"b"));return Wt(t.type,a.type,e.id),this.output(e,{value:{type:"float",value:L(t.value,a.value)}})}case"math.cross":{const t=this.expectType(this.input(e,"a"),["vec3","rgb"],e.id,"a"),a=this.expectType(this.input(e,"b"),["vec3","rgb"],e.id,"b");return this.output(e,{value:{type:"vec3",value:V(t.value,a.value)}})}case"compare.greaterThan":case"compare.greaterThanOrEqual":case"compare.lessThan":case"compare.lessThanOrEqual":case"compare.equal":case"compare.notEqual":return this.output(e,{value:{type:"boolean",value:this.compileComparison(e)}});case"boolean.not":{const t=this.boolInput(e,"value",!1);return this.output(e,{value:{type:"boolean",value:de(t,U(!1),U(!0))}})}case"boolean.and":return this.output(e,{value:{type:"boolean",value:this.compileBooleanBinary(e,"and")}});case"boolean.or":return this.output(e,{value:{type:"boolean",value:this.compileBooleanBinary(e,"or")}});case"compose.vec2":return this.output(e,{value:{type:"vec2",value:Pe(this.floatInput(e,"x",0),this.floatInput(e,"y",0))}});case"compose.vec3":return this.output(e,{value:{type:"vec3",value:ze(this.floatInput(e,"x",0),this.floatInput(e,"y",0),this.floatInput(e,"z",0))}});case"compose.vec4":return this.output(e,{value:{type:"vec4",value:Ve(this.floatInput(e,"x",0),this.floatInput(e,"y",0),this.floatInput(e,"z",0),this.floatInput(e,"w",0))}});case"compose.rgba":return this.output(e,{value:{type:"rgba",value:Ve(this.floatInput(e,"r",1),this.floatInput(e,"g",1),this.floatInput(e,"b",1),this.floatInput(e,"a",1))}});case"decompose.component":{const t=this.expectNumeric(this.input(e,"value")),a=String(Rt(e,"component","x"));return this.output(e,{value:{type:"float",value:Jt(t,a,e.id)}})}case"decompose.split":{const t=this.expectNumeric(this.input(e,"value"));return this.output(e,function(e,t){const a={},r=(r,i)=>{a[r]={type:"float",value:Jt(e,i,t)}};switch(e.type){case"vec2":return r("x","x"),r("y","y"),r("u","x"),r("v","y"),a;case"vec3":return r("x","x"),r("y","y"),r("z","z"),a;case"rgb":return r("r","r"),r("g","g"),r("b","b"),r("x","x"),r("y","y"),r("z","z"),a;case"vec4":return r("x","x"),r("y","y"),r("z","z"),r("w","w"),a;case"rgba":return r("r","r"),r("g","g"),r("b","b"),r("a","a"),r("x","x"),r("y","y"),r("z","z"),r("w","w"),a;case"float":return a.x={type:"float",value:e.value},a}}(t,e.id))}case"color.gradient":{const t=this.expectType(this.input(e,"t",{type:"float",value:q(.5)}),["float"],e.id,"t"),a=Y(function(e){const t=Rt(e,"stops",[]);if(!Array.isArray(t))return[];const a=t.map((e,a)=>{if(null==e||"object"!=typeof e||Array.isArray(e))return;const r=e,i="string"==typeof r.color?r.color:"#ffffff";return{position:Xt(r.position,ra(a,t.length)),color:i,alpha:Xt(r.alpha,1)}}).filter(e=>null!=e);return a.length>0?a:[]}(e)).sample(t.value);return this.output(e,{value:{type:"rgba",value:a}})}case"utility.curve":{const t=this.expectType(this.input(e,"t",{type:"float",value:q(.5)}),["float"],e.id,"t"),a=Rt(e,"curve","Linear"),r=Q(a,t.value)??J(Gt.decode(a)).sample(t.value);return this.output(e,{value:{type:"float",value:r}})}case"utility.namedRerouteDeclaration":return this.output(e,{value:this.input(e,"value")});case"utility.namedRerouteUsage":{const t=this.compileNode(this.namedRerouteDeclaration(e).id);return this.output(e,{value:t.outputs.value})}case"color.hueShift":{const t=this.expectType(this.input(e,"color"),["rgba","rgb","vec4","vec3"],e.id,"color"),a=t.value,r="rgba"===t.type||"vec4"===t.type?a.rgb??a.xyz:a,i=this.floatInput(e,"shift",0),u=He(r,i);return"rgba"===t.type||"vec4"===t.type?this.output(e,{value:{type:t.type,value:Ve(u,a.a??a.w)}}):this.output(e,{value:{type:t.type,value:u}})}case"color.blend":{const t=this.expectType(this.input(e,"base"),["rgba","rgb","vec4","vec3"],e.id,"base"),a=this.expectType(this.input(e,"blend"),["rgba","rgb","vec4","vec3"],e.id,"blend"),r=String(Rt(e,"mode","multiply")),i=t.value,u=a.value,o="rgba"===t.type||"vec4"===t.type?i.rgb??i.xyz:i,n="rgba"===a.type||"vec4"===a.type?u.rgb??u.xyz:u;let s=_e(o,n,r);if("rgba"===a.type||"vec4"===a.type){const e=u.a??u.w;s=ue(o,s,e)}if("rgba"===t.type||"vec4"===t.type){const a=i.a??i.w;return this.output(e,{value:{type:t.type,value:Ve(s,a)}})}return this.output(e,{value:{type:t.type,value:s}})}case"color.desaturate":{const t=this.expectType(this.input(e,"color"),["rgba","rgb","vec4","vec3"],e.id,"color"),a=t.value,r="rgba"===t.type||"vec4"===t.type?a.rgb??a.xyz:a,i=this.floatInput(e,"fraction",1),u=We(r,i);return"rgba"===t.type||"vec4"===t.type?this.output(e,{value:{type:t.type,value:Ve(u,a.a??a.w)}}):this.output(e,{value:{type:t.type,value:u}})}case"color.unpackNormal":{const t=this.expectType(this.input(e,"color"),["vec3","vec4","rgb","rgba"],e.id,"color"),a=this.floatInput(e,"scale",1),r=this.optionalInput(e,"normal");return this.output(e,{value:{type:"vec3",value:P(t.value,a,r?this.expectType(r,["vec3"],e.id,"normal").value:void 0)}})}case"texture.sampler2d":{const t=this.input(e,"texture");return this.output(e,{value:this.toSampler(t,e.id)})}case"texture.sample2d":{const t=this.toSampler(this.input(e,"sampler"),e.id),a=this.expectType(this.input(e,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],e.id,"uv"),r=t.value.sample(a.value);return this.output(e,{rgba:{type:"rgba",value:r},rgb:{type:"rgb",value:r.rgb},r:{type:"float",value:r.r},g:{type:"float",value:r.g},b:{type:"float",value:r.b},a:{type:"float",value:r.a}})}case"texture.triplanarMapping":{const t=this.input(e,"sampler"),a=this.toSampler(t,e.id),r=this.expectType(this.input(e,"scale",{type:"float",value:q(1)}),["float"],e.id,"scale"),i=this.expectType(this.input(e,"normal",{type:"vec3",value:$e.normal}),["vec3"],e.id,"normal"),u=this.expectType(this.input(e,"position",{type:"vec3",value:$e.position}),["vec3"],e.id,"position"),o=Ge(a.value,r.value,i.value,u.value);return this.output(e,{rgba:{type:"rgba",value:o},rgb:{type:"rgb",value:o.rgb},r:{type:"float",value:o.r},g:{type:"float",value:o.g},b:{type:"float",value:o.b},a:{type:"float",value:o.a}})}case"scene.sampleColor":{const t=this.expectType(this.input(e,"uv",{type:"vec2",value:this.screenUv()}),["vec2"],e.id,"uv"),a=ut(t.value);return this.output(e,{rgba:{type:"rgba",value:a},rgb:{type:"rgb",value:a.rgb},r:{type:"float",value:a.r},g:{type:"float",value:a.g},b:{type:"float",value:a.b},a:{type:"float",value:a.a}})}case"scene.sampleDepth":{const t=this.expectType(this.input(e,"uv",{type:"vec2",value:this.screenUv()}),["vec2"],e.id,"uv");return this.output(e,{depth:{type:"float",value:et(t.value)},linearEyeDepth:{type:"float",value:tt(t.value)}})}case"scene.fragmentDepth":return this.output(e,{linearEyeDepth:{type:"float",value:Ze}});case"transform.translate":{const t=this.expectType(this.input(e,"offset",{type:"vec3",value:ze(0,0,0)}),["vec3","rgb"],e.id,"offset");return this.output(e,{value:{type:"mat4",value:ke(t.value)}})}case"transform.scale":{const t=this.expectType(this.input(e,"scale",{type:"vec3",value:ze(1,1,1)}),["vec3","rgb"],e.id,"scale").value;return this.output(e,{value:{type:"mat4",value:Se(t.x,t.y,t.z)}})}case"transform.rotateAxis":{const t=this.expectType(this.input(e,"axis",{type:"vec3",value:ze(0,1,0)}),["vec3","rgb"],e.id,"axis"),a=this.expectType(this.input(e,"angle",{type:"float",value:q(0)}),["float"],e.id,"angle");return this.output(e,{value:{type:"mat4",value:vt(t.value,a.value)}})}case"uv.rotate":{const t=this.expectType(this.input(e,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],e.id,"uv").value,a=this.expectType(this.input(e,"angle",{type:"float",value:q(0)}),["float"],e.id,"angle").value,r=this.expectType(this.input(e,"center",{type:"vec2",value:Pe(.5,.5)}),["vec2"],e.id,"center").value;return this.output(e,{value:{type:"vec2",value:Yt(t,a,r)}})}case"uv.twirl":{const t=this.expectType(this.input(e,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],e.id,"uv").value,a=this.expectType(this.input(e,"strength",{type:"float",value:q(1)}),["float"],e.id,"strength").value,r=this.expectType(this.input(e,"center",{type:"vec2",value:Pe(.5,.5)}),["vec2"],e.id,"center").value,i=this.expectType(this.input(e,"offset",{type:"vec2",value:Pe(0,0)}),["vec2"],e.id,"offset").value;return this.output(e,{value:{type:"vec2",value:Ee(t,a,r,i)}})}case"uv.radial":{const t=this.expectType(this.input(e,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],e.id,"uv").value,a=qe(t.subtractScalar(.5));return this.output(e,{coords:{type:"vec2",value:a.coords},radius:{type:"float",value:a.radius},angle:{type:"float",value:a.angle}})}case"uv.bulge":{const t=this.expectType(this.input(e,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],e.id,"uv").value,a=this.expectType(this.input(e,"center",{type:"vec2",value:Pe(.5,.5)}),["vec2"],e.id,"center").value,r=this.expectType(this.input(e,"power",{type:"float",value:q(1)}),["float"],e.id,"power").value;return this.output(e,{value:{type:"vec2",value:E(t,a,r)}})}case"uv.flipbook":{const t=this.expectType(this.input(e,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],e.id,"uv").value,a=this.floatInput(e,"columns",qt(e,"columns",1)),r=this.floatInput(e,"rows",qt(e,"rows",1)),i=this.floatInput(e,"fps",qt(e,"fps",60)),u=this.expectType(this.input(e,"time",{type:"float",value:Oe.elapsed}),["float"],e.id,"time").value,o=String(Rt(e,"mode","clamp"));return this.output(e,{value:{type:"vec2",value:yt(t,a,r,u,i,o)}})}case"uv.pom":{const t=this.expectType(this.input(e,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],e.id,"uv").value,a=this.input(e,"heightMap"),r=this.toSampler(a,e.id).value,i=this.floatInput(e,"heightScale",.05),u=qt(e,"minLayers",8),o=qt(e,"maxLayers",24);return this.output(e,{value:{type:"vec2",value:dt(t,r,i,u,o)}})}case"shape.rectangle":{const t=this.expectType(this.input(e,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],e.id,"uv").value;return this.output(e,{value:{type:"float",value:Ye(t,this.floatInput(e,"width",.5),this.floatInput(e,"height",.5))}})}case"shape.roundedRectangle":{const t=this.expectType(this.input(e,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],e.id,"uv").value;return this.output(e,{value:{type:"float",value:Je(t,this.floatInput(e,"width",.5),this.floatInput(e,"height",.5),this.floatInput(e,"radius",.1))}})}case"noise.simplex":{const t=this.expectType(this.input(e,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],e.id,"uv").value,a=this.floatInput(e,"scale",8);return this.output(e,{value:{type:"float",value:new ct(t.multiplyScalar(a))}})}case"noise.voronoi2d":{const t=this.expectType(this.input(e,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],e.id,"uv").value,a=this.floatInput(e,"scale",8);return this.output(e,{value:{type:"float",value:new ht(t.multiplyScalar(a))}})}case"effect.fresnel":return this.output(e,{value:{type:"float",value:G(Qe(this.floatInput(e,"power",1)))}});case"effect.edgeDepth":{const t=this.floatInput(e,"power",1);return this.output(e,{value:{type:"float",value:Ke(t)}})}case"effect.depthFade":{const t=this.floatInput(e,"distance",1);return this.output(e,{value:{type:"float",value:Xe(t)}})}case"util.panner":{const t=this.expectType(this.input(e,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],e.id,"coord"),a=this.expectType(this.input(e,"speed",{type:"vec2",value:Pe(0,0)}),["vec2"],e.id,"speed"),r=this.expectType(this.input(e,"tile",{type:"vec2",value:Pe(1,1)}),["vec2"],e.id,"tile"),i=this.expectType(this.input(e,"time",{type:"float",value:Oe.elapsed}),["float"],e.id,"time");return this.output(e,{value:{type:"vec2",value:t.value.multiply(r.value).add(a.value.multiplyScalar(i.value))}})}}}compileParameterNode(e){const t=String(Rt(e,"parameter","")),a=this.graph.parameters?.find(e=>e.name===t||e.id===t);if(null==a)throw new ShaderGraphCompileError(`Parameter "${t}" does not exist`,e.id);const r=bt(a.type),i={type:r,value:Ht(this.options.parameters?.[a.name]??a.defaultValue,r,a.name)};if("sampler2d"!==r)return{value:i};const u=this.expectType(this.input(e,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],e.id,"uv"),o=i.value.sample(u.value);return{value:{type:"rgba",value:o},rgb:{type:"rgb",value:o.rgb},r:{type:"float",value:o.r},g:{type:"float",value:o.g},b:{type:"float",value:o.b},a:{type:"float",value:o.a},sampler:i}}compileBinaryMath(e){const t=this.expectBinaryMathValue(this.input(e,"a")),a=this.expectBinaryMathValue(this.input(e,"b")),r=e.kind.split(".")[1];if("mat4"===t.type||"mat4"===a.type)return function(e,t,a,r){if("mat4"===e.type&&"mat4"===t.type&&"divide"!==a)return{type:"mat4",value:_t(e.value,t.value,a,r)};if("mat4"===e.type&&"float"===t.type&&("multiply"===a||"divide"===a))return{type:"mat4",value:_t(e.value,t.value,a,r)};if("float"===e.type&&"mat4"===t.type&&"multiply"===a)return{type:"mat4",value:_t(t.value,e.value,a,r)};if("mat4"===e.type&&"vec4"===t.type&&"multiply"===a)return{type:"vec4",value:e.value.multiplyVec(t.value)};throw new ShaderGraphCompileError(`Cannot ${a} ${e.type} and ${t.type}`,r)}(t,a,r,e.id);if(t.type===a.type)return{type:t.type,value:_t(t.value,a.value,r,e.id)};if("float"===t.type&&"float"!==a.type&&"multiply"===r)return{type:a.type,value:_t(a.value,t.value,r,e.id)};if("float"!==t.type&&"float"===a.type)return{type:t.type,value:_t(t.value,a.value,r,e.id)};throw new ShaderGraphCompileError(`Cannot ${r} ${t.type} and ${a.type}`,e.id)}expectBinaryMathValue(e){if(!Kt(e.type)&&"mat4"!==e.type)throw new ShaderGraphCompileError(`Expected a numeric value but got ${e.type}`);return e}compileUnaryMath(e,t){const a=this.expectNumeric(this.input(e,"value"));return{type:a.type,value:t(a.value)}}compileAtan2(e){const t=this.expectNumeric(this.input(e,"y")),a=this.expectNumeric(this.input(e,"x"));return{type:function(e,t,a){if(e===t)return e;if("rgb"===e&&"vec3"===t||"vec3"===e&&"rgb"===t)return"vec3";if("rgba"===e&&"vec4"===t||"vec4"===e&&"rgba"===t)return"vec4";throw new ShaderGraphCompileError(`Cannot mix ${e} and ${t}`,a)}(t.type,a.type,e.id),value:N(t.value,a.value)}}compileBinaryFunction(e,t,a=!1){const r=this.expectNumeric(this.input(e,"a")),i=this.expectNumeric(this.input(e,"b"));return{type:a&&"float"===i.type?r.type:Wt(r.type,i.type,e.id),value:t(r.value,i.value)}}compilePaintedLayerMix(e){const t=this.expectNumeric(this.input(e,"base")),a=[t.value],r=[Ae(0)];let i=t.type;for(let t=1;t<=8;t++){const u=this.optionalInput(e,`layer${t}`);if(null==u)continue;const o=this.expectNumeric(u);i=Wt(i,o.type,e.id),a.push(o.value),r.push(Ae(t))}return 1===a.length?t:{type:i,value:oe({layerColors:a,layerWeights:r,enableNoise:Boolean(Rt(e,"enableNoise",!0)),noiseScale:this.floatInput(e,"noiseScale",qt(e,"noiseScale",.1)),noiseAmount:this.floatInput(e,"noiseAmount",qt(e,"noiseAmount",.5)),decay:this.floatInput(e,"softness",qt(e,"softness",.3)),mode:"hard"===String(Rt(e,"mode","soft"))?Z.hard:Z.soft})}}defaultUV(){return"trail"===this.graph.target?pt:"decal"===this.graph.target?nt:G(C.uv)}uvAttribute(e){const t=Math.max(0,Math.floor(qt(e,"channel",0)));return 0===t?$e.uv:wt(xt(`uv${t}`))}namedRerouteDeclaration(e){const t=String(e.params?.declarationId??"");if(0===t.length)throw new ShaderGraphCompileError("Named reroute usage is missing a declaration",e.id);const a=this.nodesById.get(t);if(null==a)throw new ShaderGraphCompileError(`Named reroute declaration "${t}" does not exist`,e.id);if("utility.namedRerouteDeclaration"!==a.kind)throw new ShaderGraphCompileError(`Node "${t}" is not a named reroute declaration`,e.id);return a}input(e,t,a){const r=e.inputs?.[t];if(null!=r)return this.resolveInput(r,e.id,t);const i=(this.graph.edges??[]).find(a=>a.to.nodeId===e.id&&a.to.port===t);if(null!=i)return this.resolveSocket(i.from,e.id,t);if(null!=a)return a;const u=this.inlineLiteralFallback(e,t);if(null!=u)return u;throw new ShaderGraphCompileError(`Missing input "${t}"`,e.id,t)}optionalInput(e,t){const a=e.inputs?.[t];if(null!=a)return this.resolveInput(a,e.id,t);const r=(this.graph.edges??[]).find(a=>a.to.nodeId===e.id&&a.to.port===t);return null!=r?this.resolveSocket(r.from,e.id,t):void 0}floatInput(e,t,a){return this.expectType(this.input(e,t,{type:"float",value:q(a)}),["float"],e.id,t).value}boolInput(e,t,a){return this.expectType(this.input(e,t,{type:"boolean",value:U(a)}),["boolean"],e.id,t).value}compileComparison(e){const t=this.expectType(this.input(e,"a"),["float"],e.id,"a").value,a=this.expectType(this.input(e,"b"),["float"],e.id,"b").value;switch(e.kind){case"compare.greaterThan":return t.gt(a);case"compare.greaterThanOrEqual":return t.gte(a);case"compare.lessThan":return t.lt(a);case"compare.lessThanOrEqual":return t.lte(a);case"compare.equal":return t.equals(a);case"compare.notEqual":return t.notEquals(a)}throw new ShaderGraphCompileError(`Unsupported comparison node "${e.kind}"`,e.id)}compileBooleanBinary(e,t){const a=this.boolInput(e,"a",!1),r=this.boolInput(e,"b",!1);return"and"===t?a.and(r):a.or(r)}resolveOutputBinding(e,t){if(null!=e.input)return this.resolveSocket(e.input,void 0,t);if(void 0!==e.value)return Ft(e.value);throw new ShaderGraphCompileError(`Output "${t}" is missing an input or value`)}floatOutput(e,t){return this.expectType(this.resolveOutputBinding(e,t),["float"],t).value}resolveInput(e,t,a){return function(e){return null!=e.nodeId}(e)?this.resolveSocket(e,t,a):Ft(e.value,e.valueType)}inlineLiteralFallback(e,t){const a=gt[e.kind]?.inputs.find(e=>e.name===t);if(null==a)return;const r=ft(e.kind,a),i=mt(e.kind,a);return null!=r&&void 0!==i?Ft(i,r):void 0}resolveSocket(e,t,a){const r=this.compileNode(e.nodeId).outputs[e.port];if(null==r)throw new ShaderGraphCompileError(`Node "${e.nodeId}" does not have output "${e.port}"`,t??e.nodeId,a??e.port);return r}expectType(e,t,a,r){if(!t.includes(e.type))throw new ShaderGraphCompileError(`Expected ${t.join(" or ")} but got ${e.type}`,a,r);return e}expectNumeric(e){if(!Kt(e.type))throw new ShaderGraphCompileError(`Expected a numeric value but got ${e.type}`);return e}toSampler(e,t){if("sampler2d"===e.type)return e;if("texture2d"===e.type){const a=e.value;if(null==a)throw new ShaderGraphCompileError("Texture input is empty",t);return{type:"sampler2d",value:Me(a)}}throw new ShaderGraphCompileError(`Expected texture2d or sampler2d but got ${e.type}`,t)}toColorOutput(e){switch(e.type){case"float":case"vec2":case"vec3":case"vec4":case"rgb":case"rgba":return e.value;case"boolean":{const t=de(e.value,q(1),q(0));return he(ze(t,t,t),1)}case"mat4":throw new ShaderGraphCompileError("mat4 values cannot be used as color");case"texture2d":case"sampler2d":throw new ShaderGraphCompileError(`${e.type} must be sampled before it can be used as color`)}}toVec3Output(e,t){if("vec3"===e.type||"rgb"===e.type)return e.value;if("vec4"===e.type||"rgba"===e.type)return e.value.xyz;throw new ShaderGraphCompileError(`Output "${t}" expects vec3/rgb but got ${e.type}`)}toMat4Output(e,t){if("mat4"===e.type)return e.value;throw new ShaderGraphCompileError(`Output "${t}" expects mat4 but got ${e.type}`)}output(e,t){return{node:e,outputs:t}}}export function compileShaderGraph(e,t={}){return new ShaderGraphCompiler(e,t).compile()}export function compileShaderGraphPreview(e,t,a={}){if(null==t)return compileShaderGraph(e,a).output;const r=new ShaderGraphCompiler(e,a).compileNode(t),i=Object.values(r.outputs)[0];if(null==i)throw new ShaderGraphCompileError(`Node "${t}" has no previewable output`,t);return{color:At(i),transparent:"rgba"===i.type||"vec4"===i.type}}export function buildShaderGraphMaterial(e,a={}){if("postProcess"===e.target)return buildShaderGraphPostProcessMaterial(e,a);const r=function(e,t,a){const r=a.alphaTest??e.alphaTest??t.materialOptions?.alphaTest;return null!=r?{...e,alphaTest:r}:e}(null!=a.previewNodeId?compileShaderGraphPreview(e,a.previewNodeId,a):compileShaderGraph(e,a).output,e,a);if("sprite"===e.target)return new De({color:r.color,discard:r.discard,alphaTest:r.alphaTest,transparent:r.transparent??!0,position:je(new x("rotation",0),new x("screenSpaceSize",0),void 0,!0),uniforms:{color:{value:new t(16777215)}}});if("trail"===e.target){const{position:t}=lt.getTrailShaderNodes(a.trailBillboard??!1),i=new d({...r,position:t});return lt.applyTrailShaderParameters(i),Vt(i,e),i}if("decal"===e.target){const t=ot.or(st),a=null!=r.discard?t.or(r.discard):t,i=new d({...r,transparent:!1,discard:a});return i.userData.isDecal=!0,Vt(i,e),i}const i=new d({transparent:!1,...r});return Vt(i,e),i}export function buildShaderGraphPostProcessMaterial(e,t={}){const a=null!=t.previewNodeId?$t(compileShaderGraphPreview(e,t.previewNodeId,t).color):compileShaderGraph(e,t).output,r=new d({color:a.color,transparent:!1,fog:!1,lights:!1,outputEncoding:!1});return r.depthWrite=!1,r.depthTest=!1,r.toneMapped=!1,r.userData.isPostProcessShaderGraph=!0,r}export function buildShaderGraphInlinePreviewMaterial(e,t,a={}){const r=compileShaderGraphPreview({...e,target:"surface"},t,a),i=new d({color:r.color,transparent:r.transparent??!1,fog:!1,lights:!1});return i.depthWrite=!1,i.depthTest=!1,i.toneMapped=!1,i}function $t(e,t,a=at){const r=ut(a),i=Ue("hology_post_process_weight",1),u=ye(null!=t?i.multiply(t):i);return{color:ue(r.rgb,Pt(e),u),transparent:!1,...null!=t?{opacity:t}:{}}}function Pt(e){return e instanceof h?ze(e,e,e):e instanceof w?ze(e.x,e.y,0):e instanceof T?e.xyz:e}export function shaderGraphMaterialSideToThree(t){switch(t){case"back":return e;case"double":return r;default:return i}}function zt(e){return"decal"!==e.target&&(e.materialOptions?.transparent??"sprite"===e.target)}function Vt(e,t){"surface"===t.target&&(e.side=shaderGraphMaterialSideToThree(t.materialOptions?.side)),null!=t.materialOptions?.transparent&&(e.transparent=t.materialOptions.transparent),null!=t.materialOptions?.bloom&&(e.userData.hasBloom=t.materialOptions.bloom)}function At(e){switch(e.type){case"float":return Lt(e.value);case"vec2":{const t=e.value;return he(ze(t.x,t.y,0),1)}case"vec3":case"rgb":return he(e.value,1);case"vec4":case"rgba":return e.value;case"boolean":return Lt(de(e.value,q(1),q(0)));case"mat4":throw new ShaderGraphCompileError("mat4 values cannot be previewed as color");case"texture2d":case"sampler2d":throw new ShaderGraphCompileError(`${e.type} nodes require a sampled output to preview`)}}function Lt(e){return he(ze(e,e,e),1)}function Dt(e){return e instanceof h?ze(e,e,e).rgb:e instanceof w?ze(e.x,e.y,0).rgb:e}function jt(e){return e.rgb}function Rt(e,t,a){const r=e.params?.[t];return void 0===r?a:r}function qt(e,t,a){const r=Rt(e,t,a);return"number"==typeof r?r:Number(r??a)}function Ft(e,t){if(null!=(a=e)&&"object"==typeof a&&!Array.isArray(a)&&"value"in a)return Ft(e.value,e.valueType??t);var a;const r=t??function(e){if("boolean"==typeof e)return"boolean";if("number"==typeof e)return"float";if(Array.isArray(e))return 2===e.length?"vec2":3===e.length?"vec3":16===e.length?"mat4":"vec4";return"string"==typeof e?"rgb":"float"}(e);return{type:r,value:Ht(e,r,"literal")}}function Ht(e,a,r){switch(a){case"boolean":return e instanceof c?e:U(Boolean(e));case"float":return e instanceof h?e:q(Xt(e,0));case"vec2":return e instanceof w?e:ea(e);case"vec3":return e instanceof S?e:ta(e);case"vec4":return e instanceof T?e:function(e){const[t,a,r,i]=Zt(e,4,1);return Ve(t,a,r,i)}(e);case"mat4":return e instanceof y?e:function(e){if(e instanceof u)return ae(e);const t=new u;Array.isArray(e)&&16===e.length&&t.fromArray(e.map(e=>Xt(e,0)));return ae(t)}(e);case"rgb":return e instanceof m?e:function(e){if("string"==typeof e||"number"==typeof e||e instanceof t)return ve(e);const[a,r,i]=Zt(e,3);return ze(a,r,i).rgb}(e);case"rgba":return e instanceof f||e instanceof T?e:aa(e);case"texture2d":return e;case"sampler2d":return function(e){const t=e;return e instanceof g||e instanceof b||"function"==typeof t?.isSampler2D||!0===t?.isSampler2D}(e)?e:e instanceof n||!0===e?.isTexture?Me(e):(Ut.has(r)||(Ut.add(r),console.warn(`Shader graph parameter "${r}" is missing a texture value; using a 1x1 white fallback texture.`)),Me(Et))}}function _t(e,t,a,r){const i=`${a}Scalar`;if(t instanceof h&&"function"==typeof e[i])return e[i](t);if("function"==typeof e[a])return e[a](t);throw new ShaderGraphCompileError(`Node does not support ${a}`,r)}function Wt(e,t,a){if(e===t)return e;if("rgb"===e&&"vec3"===t||"vec3"===e&&"rgb"===t)return"vec3";if("rgba"===e&&"vec4"===t||"vec4"===e&&"rgba"===t)return"vec4";if("float"===e&&Kt(t))return t;if("float"===t&&Kt(e))return e;throw new ShaderGraphCompileError(`Cannot mix ${e} and ${t}`,a)}function Yt(e,t,a){const r=e.subtract(a),i=fe(t),u=z(t);return Pe(u.multiply(r.x).subtract(i.multiply(r.y)).add(a.x),i.multiply(r.x).add(u.multiply(r.y)).add(a.y))}function Jt(e,t,a){const r=e.value["u"===t?"x":"v"===t?"y":t];if(r instanceof h)return r;throw new ShaderGraphCompileError(`Component "${t}" is not available on ${e.type}`,a)}function Kt(e){return"float"===e||"vec2"===e||"vec3"===e||"vec4"===e||"rgb"===e||"rgba"===e}function Qt(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function Xt(e,t){if("number"==typeof e)return e;if("string"==typeof e){const a=parseFloat(e);return Number.isFinite(a)?a:t}return"boolean"==typeof e?e?1:0:t}function Zt(e,a,r=0){if(Array.isArray(e))return Array.from({length:a},(t,a)=>Xt(e[a],r));if(e instanceof s||e instanceof l||e instanceof p)return Array.from({length:a},(t,a)=>e.toArray()[a]??r);if(e instanceof t){const t=e.toArray();return Array.from({length:a},(e,a)=>t[a]??(3===a?1:r))}if(null!=e&&"object"==typeof e){const t=e,i=["x","y","z","w"];if(i.some(e=>null!=t[e]))return Array.from({length:a},(e,a)=>Xt(t[i[a]],r));const u=["r","g","b","a"];if(u.some(e=>null!=t[e]))return Array.from({length:a},(e,a)=>Xt(t[u[a]],3===a?1:r))}return Array.from({length:a},()=>Xt(e,r))}function ea(e){const[t,a]=Zt(e,2);return Pe(t,a)}function ta(e){const[t,a,r]=Zt(e,3);return ze(t,a,r)}function aa(e,a=1){if("string"==typeof e||"number"==typeof e||e instanceof t)return he(e,a);if(e instanceof S)return he(e,a);const[r,i,u,o]=Zt(e,4,a);return Ve(r,i,u,o)}function ra(e,t){return t<=1?0:e/(t-1)}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export type ShaderGraphTarget = 'surface' | 'sprite' | 'decal' | 'trail' | 'postProcess';
|
|
2
|
-
export type ShaderGraphShadingModel = 'standard' | 'toon' | 'unlit';
|
|
2
|
+
export type ShaderGraphShadingModel = 'standard' | 'toon' | 'stylizedCharacter' | 'unlit';
|
|
3
3
|
export type ShaderGraphMaterialSide = 'front' | 'back' | 'double';
|
|
4
4
|
export type ShaderGraphValueType = 'boolean' | 'float' | 'vec2' | 'vec3' | 'vec4' | 'mat4' | 'rgb' | 'rgba' | 'texture2d' | 'sampler2d';
|
|
5
5
|
export declare const ShaderGraphParameterTypes: readonly ["float", "boolean", "vec2", "vec3", "vec4", "color", "texture"];
|
|
6
6
|
export type ShaderGraphParameterType = (typeof ShaderGraphParameterTypes)[number];
|
|
7
|
-
export type ShaderGraphNodeKind = 'input.parameter' | 'input.slider' | 'constant.boolean' | 'constant.float' | 'constant.vec2' | 'constant.vec3' | 'constant.rgba' | 'builtin.uv' | 'builtin.screenUv' | 'builtin.color' | 'builtin.position' | 'builtin.worldPosition' | 'builtin.objectPosition' | 'builtin.normal' | 'builtin.time' | 'builtin.camera' | 'builtin.viewMatrix' | 'builtin.projectionMatrix' | 'builtin.modelViewMatrix' | 'builtin.particle' | 'math.add' | 'math.subtract' | 'math.multiply' | 'math.divide' | 'math.oneMinus' | 'math.abs' | 'math.sign' | 'math.floor' | 'math.ceil' | 'math.fract' | 'math.sin' | 'math.cos' | 'math.tan' | 'math.asin' | 'math.acos' | 'math.atan' | 'math.atan2' | 'math.radians' | 'math.degrees' | 'math.sqrt' | 'math.inverseSqrt' | 'math.exp' | 'math.exp2' | 'math.log' | 'math.log2' | 'math.saturate' | 'math.length' | 'math.normalize' | 'math.clamp' | 'math.min' | 'math.max' | 'math.pow' | 'math.mod' | 'math.step' | 'math.smoothstep' | 'math.mix' | 'math.select' | 'layer.mixPainted' | 'math.dot' | 'math.distance' | 'math.cross' | 'compare.greaterThan' | 'compare.greaterThanOrEqual' | 'compare.lessThan' | 'compare.lessThanOrEqual' | 'compare.equal' | 'compare.notEqual' | 'boolean.not' | 'boolean.and' | 'boolean.or' | 'compose.vec2' | 'compose.vec3' | 'compose.vec4' | 'compose.rgba' | 'decompose.component' | 'decompose.split' | 'texture.sampler2d' | 'texture.sample2d' | 'texture.triplanarMapping' | 'scene.sampleColor' | 'scene.sampleDepth' | 'scene.fragmentDepth' | 'color.gradient' | 'utility.curve' | 'utility.namedRerouteDeclaration' | 'utility.namedRerouteUsage' | 'transform.translate' | 'transform.scale' | 'transform.rotateAxis' | 'uv.rotate' | 'uv.twirl' | 'uv.radial' | 'uv.bulge' | 'shape.rectangle' | 'shape.roundedRectangle' | 'noise.simplex' | 'noise.voronoi2d' | 'effect.fresnel' | 'effect.edgeDepth' | 'effect.depthFade' | 'util.panner' | 'uv.flipbook' | 'math.remap' | 'color.hueShift' | 'color.blend' | 'color.blend' | 'color.desaturate' | 'builtin.viewDir' | 'uv.pom' | 'math.reflect' | 'math.refract' | 'math.derivative' | 'color.unpackNormal';
|
|
7
|
+
export type ShaderGraphNodeKind = 'input.parameter' | 'input.slider' | 'constant.boolean' | 'constant.float' | 'constant.vec2' | 'constant.vec3' | 'constant.rgba' | 'builtin.uv' | 'builtin.screenUv' | 'builtin.color' | 'builtin.position' | 'builtin.worldPosition' | 'builtin.objectPosition' | 'builtin.normal' | 'builtin.time' | 'builtin.camera' | 'builtin.viewMatrix' | 'builtin.projectionMatrix' | 'builtin.modelViewMatrix' | 'builtin.particle' | 'math.add' | 'math.subtract' | 'math.multiply' | 'math.divide' | 'math.oneMinus' | 'math.abs' | 'math.sign' | 'math.floor' | 'math.ceil' | 'math.fract' | 'math.sin' | 'math.cos' | 'math.tan' | 'math.asin' | 'math.acos' | 'math.atan' | 'math.atan2' | 'math.radians' | 'math.degrees' | 'math.sqrt' | 'math.inverseSqrt' | 'math.exp' | 'math.exp2' | 'math.log' | 'math.log2' | 'math.saturate' | 'math.length' | 'math.normalize' | 'math.clamp' | 'math.min' | 'math.max' | 'math.pow' | 'math.mod' | 'math.step' | 'math.smoothstep' | 'math.mix' | 'math.select' | 'layer.mixPainted' | 'math.dot' | 'math.distance' | 'math.cross' | 'compare.greaterThan' | 'compare.greaterThanOrEqual' | 'compare.lessThan' | 'compare.lessThanOrEqual' | 'compare.equal' | 'compare.notEqual' | 'boolean.not' | 'boolean.and' | 'boolean.or' | 'compose.vec2' | 'compose.vec3' | 'compose.vec4' | 'compose.rgba' | 'decompose.component' | 'decompose.split' | 'texture.sampler2d' | 'texture.sample2d' | 'texture.triplanarMapping' | 'scene.sampleColor' | 'scene.sampleDepth' | 'scene.fragmentDepth' | 'scene.ambientLight' | 'scene.directionalLight' | 'color.gradient' | 'utility.curve' | 'utility.namedRerouteDeclaration' | 'utility.namedRerouteUsage' | 'transform.translate' | 'transform.scale' | 'transform.rotateAxis' | 'uv.rotate' | 'uv.twirl' | 'uv.radial' | 'uv.bulge' | 'shape.rectangle' | 'shape.roundedRectangle' | 'noise.simplex' | 'noise.voronoi2d' | 'effect.fresnel' | 'effect.edgeDepth' | 'effect.depthFade' | 'util.panner' | 'uv.flipbook' | 'math.remap' | 'color.hueShift' | 'color.blend' | 'color.blend' | 'color.desaturate' | 'builtin.viewDir' | 'uv.pom' | 'math.reflect' | 'math.refract' | 'math.derivative' | 'color.unpackNormal';
|
|
8
8
|
export type ShaderGraphSerializableValue = null | boolean | number | string | ShaderGraphSerializableValue[] | {
|
|
9
9
|
[key: string]: ShaderGraphSerializableValue;
|
|
10
10
|
};
|
|
@@ -35,7 +35,7 @@ export interface ShaderGraphNode {
|
|
|
35
35
|
params?: Record<string, ShaderGraphSerializableValue>;
|
|
36
36
|
inputs?: Record<string, ShaderGraphInput>;
|
|
37
37
|
}
|
|
38
|
-
export type ShaderGraphOutputSlot = 'color' | 'opacity' | 'roughness' | 'metalness' | 'normal' | 'emissive' | 'ambientOcclusion' | 'ambientOcclusionIntensity' | 'sheenColor' | 'sheenRoughness' | 'anisotropy' | 'anisotropyDirection' | 'bakedLight' | 'transform' | 'discard' | 'transparent' | 'alphaTest';
|
|
38
|
+
export type ShaderGraphOutputSlot = 'color' | 'opacity' | 'roughness' | 'metalness' | 'normal' | 'emissive' | 'ambientOcclusion' | 'ambientOcclusionIntensity' | 'sheenColor' | 'sheenRoughness' | 'anisotropy' | 'anisotropyDirection' | 'bakedLight' | 'shadowTint' | 'shadowThreshold' | 'shadowSoftness' | 'specularIntensity' | 'specularToonness' | 'specularThreshold' | 'specularSoftness' | 'environmentSpecularIntensity' | 'skinMask' | 'thickness' | 'subsurfaceColor' | 'subsurfaceStrength' | 'subsurfaceWrap' | 'backscatterStrength' | 'backscatterPower' | 'faceMask' | 'faceShadow' | 'faceShadowStrength' | 'faceShadowSoftness' | 'faceShadowOffset' | 'eyeMask' | 'irisMask' | 'eyeHighlightMask' | 'eyeLowerLightMask' | 'eyeBrightness' | 'eyeIrisColor' | 'eyeIrisGlow' | 'eyeHighlightColor' | 'eyeHighlightStrength' | 'rimMask' | 'rimColor' | 'rimStrength' | 'rimPower' | 'rimThreshold' | 'rimSoftness' | 'transform' | 'discard' | 'transparent' | 'alphaTest';
|
|
39
39
|
export interface ShaderGraphOutputBinding {
|
|
40
40
|
input?: ShaderGraphSocketRef;
|
|
41
41
|
value?: ShaderGraphSerializableValue;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const SHADER_GRAPH_NODE_DEFINITIONS={"input.parameter":{kind:"input.parameter",label:"Parameter",category:"Inputs",inputs:[],outputs:[{name:"value",type:"dynamic"}]},"input.slider":{kind:"input.slider",label:"Slider",category:"Inputs",inputs:[],outputs:[{name:"value",type:"float"}]},"constant.boolean":{kind:"constant.boolean",label:"Boolean",category:"Inputs",inputs:[],outputs:[{name:"value",type:"boolean"}]},"constant.float":{kind:"constant.float",label:"Float",category:"Inputs",inputs:[],outputs:[{name:"value",type:"float"}]},"constant.vec2":{kind:"constant.vec2",label:"Vec2",category:"Inputs",inputs:[],outputs:[{name:"value",type:"vec2"}]},"constant.vec3":{kind:"constant.vec3",label:"Vec3",category:"Inputs",inputs:[],outputs:[{name:"value",type:"vec3"}]},"constant.rgba":{kind:"constant.rgba",label:"Color",category:"Inputs",inputs:[],outputs:[{name:"value",type:"rgba"}]},"builtin.uv":{kind:"builtin.uv",label:"UV",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec2"},{name:"u",type:"float"},{name:"v",type:"float"}]},"builtin.screenUv":{kind:"builtin.screenUv",label:"Screen UV",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec2"}]},"builtin.color":{kind:"builtin.color",label:"Color Attribute",category:"Attributes",inputs:[],outputs:[{name:"value",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"builtin.position":{kind:"builtin.position",label:"Position Attribute",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.worldPosition":{kind:"builtin.worldPosition",label:"World Position",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.objectPosition":{kind:"builtin.objectPosition",label:"Object Position",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.normal":{kind:"builtin.normal",label:"Normal Attribute",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.particle":{kind:"builtin.particle",label:"Particle",category:"Attributes",inputs:[],outputs:[{name:"energy",type:"float"},{name:"color",type:"rgb"},{name:"opacity",type:"float"},{name:"time",type:"float"}]},"builtin.time":{kind:"builtin.time",label:"Time",category:"Inputs",inputs:[],outputs:[{name:"value",type:"float"}]},"builtin.viewDir":{kind:"builtin.viewDir",label:"View Direction",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.camera":{kind:"builtin.camera",label:"Camera",category:"Inputs",inputs:[],outputs:[{name:"position",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"},{name:"near",type:"float"},{name:"far",type:"float"}]},"builtin.viewMatrix":{kind:"builtin.viewMatrix",label:"View Matrix",category:"Inputs",inputs:[],outputs:[{name:"value",type:"mat4"}]},"builtin.projectionMatrix":{kind:"builtin.projectionMatrix",label:"Projection Matrix",category:"Inputs",inputs:[],outputs:[{name:"value",type:"mat4"}]},"builtin.modelViewMatrix":{kind:"builtin.modelViewMatrix",label:"Model View Matrix",category:"Inputs",inputs:[],outputs:[{name:"value",type:"mat4"}]},"math.add":{kind:"math.add",label:"Add",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.subtract":{kind:"math.subtract",label:"Subtract",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.multiply":{kind:"math.multiply",label:"Multiply",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.divide":{kind:"math.divide",label:"Divide",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.oneMinus":{kind:"math.oneMinus",label:"One Minus",category:"Math",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.abs":e("math.abs","Abs","Math"),"math.sign":e("math.sign","Sign","Math"),"math.floor":e("math.floor","Floor","Math"),"math.ceil":e("math.ceil","Ceil","Math"),"math.fract":e("math.fract","Fract","Math"),"math.sin":e("math.sin","Sine","Trigonometry"),"math.cos":e("math.cos","Cosine","Trigonometry"),"math.tan":e("math.tan","Tangent","Trigonometry"),"math.asin":e("math.asin","Arc Sine","Trigonometry"),"math.acos":e("math.acos","Arc Cosine","Trigonometry"),"math.atan":e("math.atan","Arc Tangent","Trigonometry"),"math.atan2":{kind:"math.atan2",label:"Arc Tangent 2",category:"Trigonometry",inputs:[{name:"y",type:"dynamic"},{name:"x",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.radians":e("math.radians","Radians","Trigonometry"),"math.degrees":e("math.degrees","Degrees","Trigonometry"),"math.sqrt":e("math.sqrt","Square Root","Math"),"math.inverseSqrt":e("math.inverseSqrt","Inverse Square Root","Math"),"math.exp":e("math.exp","Exp","Math"),"math.exp2":e("math.exp2","Exp2","Math"),"math.log":e("math.log","Log","Math"),"math.log2":e("math.log2","Log2","Math"),"math.saturate":e("math.saturate","Saturate","Math"),"math.length":{kind:"math.length",label:"Length",category:"Vectors",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"math.normalize":e("math.normalize","Normalize","Vectors"),"math.clamp":{kind:"math.clamp",label:"Clamp",category:"Math",inputs:[{name:"value",type:"dynamic"},{name:"min",type:"dynamic",defaultValue:0},{name:"max",type:"dynamic",defaultValue:1}],outputs:[{name:"value",type:"dynamic"}]},"math.min":t("math.min","Min"),"math.max":t("math.max","Max"),"math.pow":t("math.pow","Power"),"math.mod":t("math.mod","Modulo"),"math.step":t("math.step","Step"),"math.smoothstep":{kind:"math.smoothstep",label:"Smoothstep",category:"Math",inputs:[{name:"edge0",type:"dynamic",defaultValue:0},{name:"edge1",type:"dynamic",defaultValue:1},{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.mix":{kind:"math.mix",label:"Mix",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"},{name:"t",type:"dynamic",defaultValue:.5}],outputs:[{name:"value",type:"dynamic"}]},"math.remap":{kind:"math.remap",label:"Remap",category:"Math",inputs:[{name:"value",type:"float"},{name:"inMin",type:"float",defaultValue:-1},{name:"inMax",type:"float",defaultValue:1},{name:"outMin",type:"float",defaultValue:0},{name:"outMax",type:"float",defaultValue:1}],outputs:[{name:"value",type:"float"}]},"math.reflect":{kind:"math.reflect",label:"Reflect",category:"Math",inputs:[{name:"incident",type:"dynamic"},{name:"normal",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.refract":{kind:"math.refract",label:"Refract",category:"Math",inputs:[{name:"incident",type:"dynamic"},{name:"normal",type:"dynamic"},{name:"ior",type:"float",defaultValue:1.5}],outputs:[{name:"value",type:"dynamic"}]},"math.derivative":{kind:"math.derivative",label:"Derivative",category:"Math",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.select":{kind:"math.select",label:"Select",category:"Math",inputs:[{name:"condition",type:"boolean"},{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"layer.mixPainted":{kind:"layer.mixPainted",label:"Mix Painted Layers",category:"Layers",inputs:[{name:"base",type:"dynamic"},...Array.from({length:8},(e,t)=>({name:`layer${t+1}`,label:`Layer ${t+1}`,type:"dynamic",optional:!0})),{name:"softness",type:"float",optional:!0},{name:"noiseScale",label:"Noise Scale",type:"float",optional:!0},{name:"noiseAmount",label:"Noise Amount",type:"float",optional:!0}],outputs:[{name:"value",type:"dynamic"}]},"math.dot":{kind:"math.dot",label:"Dot Product",category:"Vectors",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"math.distance":{kind:"math.distance",label:"Distance",category:"Vectors",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"math.cross":{kind:"math.cross",label:"Cross Product",category:"Vectors",inputs:[{name:"a",type:"vec3"},{name:"b",type:"vec3"}],outputs:[{name:"value",type:"vec3"}]},"compare.greaterThan":a("compare.greaterThan","Greater Than"),"compare.greaterThanOrEqual":a("compare.greaterThanOrEqual","Greater Than Or Equal"),"compare.lessThan":a("compare.lessThan","Less Than"),"compare.lessThanOrEqual":a("compare.lessThanOrEqual","Less Than Or Equal"),"compare.equal":a("compare.equal","Equal"),"compare.notEqual":a("compare.notEqual","Not Equal"),"boolean.not":{kind:"boolean.not",label:"Not",category:"Boolean",inputs:[{name:"value",type:"boolean"}],outputs:[{name:"value",type:"boolean"}]},"boolean.and":n("boolean.and","And"),"boolean.or":n("boolean.or","Or"),"compose.vec2":{kind:"compose.vec2",label:"Compose Vec2",category:"Vectors",inputs:[{name:"x",type:"float"},{name:"y",type:"float"}],outputs:[{name:"value",type:"vec2"}]},"compose.vec3":{kind:"compose.vec3",label:"Compose Vec3",category:"Vectors",inputs:[{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}],outputs:[{name:"value",type:"vec3"}]},"compose.vec4":{kind:"compose.vec4",label:"Compose Vec4",category:"Vectors",inputs:[{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"},{name:"w",type:"float"}],outputs:[{name:"value",type:"vec4"}]},"compose.rgba":{kind:"compose.rgba",label:"Compose RGBA",category:"Color",inputs:[{name:"r",type:"float",defaultValue:1},{name:"g",type:"float",defaultValue:1},{name:"b",type:"float",defaultValue:1},{name:"a",type:"float",defaultValue:1}],outputs:[{name:"value",type:"rgba"}]},"decompose.component":{kind:"decompose.component",label:"Component",category:"Vectors",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"decompose.split":{kind:"decompose.split",label:"Split Components",category:"Vectors",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"},{name:"w",type:"float"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"},{name:"u",type:"float"},{name:"v",type:"float"}]},"color.gradient":{kind:"color.gradient",label:"Gradient",category:"Color",inputs:[{name:"t",type:"float",defaultValue:.5}],outputs:[{name:"value",type:"rgba"}]},"utility.curve":{kind:"utility.curve",label:"Curve",category:"Utilities",inputs:[{name:"t",type:"float",defaultValue:.5}],outputs:[{name:"value",type:"float"}]},"utility.namedRerouteDeclaration":{kind:"utility.namedRerouteDeclaration",label:"Named Reroute Declaration",category:"Utilities",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"utility.namedRerouteUsage":{kind:"utility.namedRerouteUsage",label:"Named Reroute Usage",category:"Utilities",inputs:[],outputs:[{name:"value",type:"dynamic"}]},"color.hueShift":{kind:"color.hueShift",label:"Hue Shift",category:"Color",inputs:[{name:"color",type:"dynamic"},{name:"shift",type:"float"}],outputs:[{name:"value",type:"dynamic"}]},"color.blend":{kind:"color.blend",label:"Blend Colors",category:"Color",inputs:[{name:"base",type:"dynamic"},{name:"blend",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"color.desaturate":{kind:"color.desaturate",label:"Desaturate",category:"Color",inputs:[{name:"color",type:"dynamic"},{name:"fraction",type:"float",defaultValue:1}],outputs:[{name:"value",type:"dynamic"}]},"color.unpackNormal":{kind:"color.unpackNormal",label:"Unpack Normal",category:"Textures",inputs:[{name:"color",type:"dynamic"},{name:"scale",type:"float",defaultValue:1},{name:"normal",type:"vec3",optional:!0,inlineLiteral:!1}],outputs:[{name:"value",type:"vec3"}]},"texture.sampler2d":{kind:"texture.sampler2d",label:"Sampler 2D",category:"Texture",inputs:[{name:"texture",type:"texture2d"}],outputs:[{name:"value",type:"sampler2d"}]},"texture.sample2d":{kind:"texture.sample2d",label:"Sample Texture 2D",category:"Textures",inputs:[{name:"sampler",type:"sampler2d"},{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"rgba",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"texture.triplanarMapping":{kind:"texture.triplanarMapping",label:"Triplanar Mapping",category:"Textures",inputs:[{name:"sampler",type:"sampler2d"},{name:"scale",type:"float",defaultValue:1},{name:"normal",type:"vec3",inlineLiteral:!1},{name:"position",type:"vec3",inlineLiteral:!1}],outputs:[{name:"rgba",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"scene.sampleColor":{kind:"scene.sampleColor",label:"Sample Scene Color",category:"Texture",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"rgba",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"scene.sampleDepth":{kind:"scene.sampleDepth",label:"Sample Scene Depth",category:"Texture",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"depth",type:"float"},{name:"linearEyeDepth",type:"float"}]},"scene.fragmentDepth":{kind:"scene.fragmentDepth",label:"Fragment Depth",category:"Texture",inputs:[],outputs:[{name:"linearEyeDepth",type:"float"}]},"transform.translate":{kind:"transform.translate",label:"Translate",category:"Transform",inputs:[{name:"offset",type:"vec3",defaultValue:[0,0,0]}],outputs:[{name:"value",type:"mat4"}]},"transform.scale":{kind:"transform.scale",label:"Scale",category:"Transform",inputs:[{name:"scale",type:"vec3",defaultValue:[1,1,1]}],outputs:[{name:"value",type:"mat4"}]},"transform.rotateAxis":{kind:"transform.rotateAxis",label:"Rotate Axis",category:"Transform",inputs:[{name:"axis",type:"vec3",defaultValue:[0,1,0]},{name:"angle",type:"float",defaultValue:0}],outputs:[{name:"value",type:"mat4"}]},"uv.rotate":{kind:"uv.rotate",label:"Rotate UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"angle",type:"float",defaultValue:0},{name:"center",type:"vec2",optional:!0,defaultValue:[.5,.5]}],outputs:[{name:"value",type:"vec2"}]},"uv.twirl":{kind:"uv.twirl",label:"Twirl UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"strength",type:"float",defaultValue:1},{name:"center",type:"vec2",optional:!0,defaultValue:[.5,.5]},{name:"offset",type:"vec2",optional:!0,defaultValue:[0,0]}],outputs:[{name:"value",type:"vec2"}]},"uv.radial":{kind:"uv.radial",label:"Radial UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"coords",type:"vec2"},{name:"radius",type:"float"},{name:"angle",type:"float"}]},"uv.bulge":{kind:"uv.bulge",label:"Bulge UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"center",type:"vec2",optional:!0,defaultValue:[.5,.5]},{name:"power",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"vec2"}]},"uv.flipbook":{kind:"uv.flipbook",label:"Flipbook UV",category:"UV",inputs:[{name:"uv",type:"vec2",optional:!0,inlineLiteral:!1},{name:"columns",type:"float",optional:!0,defaultValue:1},{name:"rows",type:"float",optional:!0,defaultValue:1},{name:"fps",type:"float",optional:!0,defaultValue:60},{name:"time",type:"float",optional:!0,inlineLiteral:!1}],outputs:[{name:"value",type:"vec2"}]},"uv.pom":{kind:"uv.pom",label:"Parallax Occlusion",category:"UV",inputs:[{name:"uv",type:"vec2",optional:!0,inlineLiteral:!1},{name:"heightMap",type:"sampler2d"},{name:"heightScale",type:"float",optional:!0,defaultValue:.05}],outputs:[{name:"value",type:"vec2"}]},"shape.rectangle":{kind:"shape.rectangle",label:"Rectangle",category:"Shapes",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"width",type:"float",defaultValue:.5},{name:"height",type:"float",defaultValue:.5}],outputs:[{name:"value",type:"float"}]},"shape.roundedRectangle":{kind:"shape.roundedRectangle",label:"Rounded Rectangle",category:"Shapes",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"width",type:"float",defaultValue:.5},{name:"height",type:"float",defaultValue:.5},{name:"radius",type:"float",defaultValue:.1}],outputs:[{name:"value",type:"float"}]},"noise.simplex":{kind:"noise.simplex",label:"Simplex Noise",category:"Noise",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"scale",type:"float",optional:!0,defaultValue:8}],outputs:[{name:"value",type:"float"}]},"noise.voronoi2d":{kind:"noise.voronoi2d",label:"Voronoi",category:"Noise",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"scale",type:"float",optional:!0,defaultValue:8}],outputs:[{name:"value",type:"float"}]},"effect.fresnel":{kind:"effect.fresnel",label:"Fresnel",category:"Effects",inputs:[{name:"power",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"float"}]},"effect.edgeDepth":{kind:"effect.edgeDepth",label:"Edge Depth",category:"Effects",inputs:[{name:"power",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"float"}]},"effect.depthFade":{kind:"effect.depthFade",label:"Depth Fade",category:"Effects",inputs:[{name:"distance",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"float"}]},"util.panner":{kind:"util.panner",label:"Panner",category:"Utilities",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"speed",type:"vec2",defaultValue:[0,0]},{name:"tile",type:"vec2",defaultValue:[1,1]},{name:"time",type:"float",optional:!0,inlineLiteral:!1}],outputs:[{name:"value",type:"vec2"}]}};export const SHADER_GRAPH_NODE_KINDS=Object.keys(SHADER_GRAPH_NODE_DEFINITIONS);function e(e,t,a){return{kind:e,label:t,category:a,inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]}}function t(e,t){return{kind:e,label:t,category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]}}function a(e,t){return{kind:e,label:t,category:"Comparison",inputs:[{name:"a",type:"float"},{name:"b",type:"float"}],outputs:[{name:"value",type:"boolean"}]}}function n(e,t){return{kind:e,label:t,category:"Boolean",inputs:[{name:"a",type:"boolean"},{name:"b",type:"boolean"}],outputs:[{name:"value",type:"boolean"}]}}export function inlineLiteralTypeForPort(e,t){if(!1!==t.inlineLiteral)return"float"===t.type||"vec2"===t.type||"vec3"===t.type||"vec4"===t.type?t.type:"dynamic"===t.type&&function(e){return e.startsWith("math.")&&"math.reflect"!==e&&"math.refract"!==e}(e)?"float":void 0}export function defaultInlineLiteralValueForPort(e,t){const a=inlineLiteralTypeForPort(e,t);if(null!=a){if(void 0!==t.defaultValue)return l(t.defaultValue);if("math.multiply"===e)return 1;switch(a){case"float":return 0;case"vec2":return[0,0];case"vec3":return[0,0,0];case"vec4":return[0,0,0,1]}}}function l(e){return Array.isArray(e)?e.map(e=>l(e)):null!=e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,l(t)])):e}/*
|
|
1
|
+
export const SHADER_GRAPH_NODE_DEFINITIONS={"input.parameter":{kind:"input.parameter",label:"Parameter",category:"Inputs",inputs:[],outputs:[{name:"value",type:"dynamic"}]},"input.slider":{kind:"input.slider",label:"Slider",category:"Inputs",inputs:[],outputs:[{name:"value",type:"float"}]},"constant.boolean":{kind:"constant.boolean",label:"Boolean",category:"Inputs",inputs:[],outputs:[{name:"value",type:"boolean"}]},"constant.float":{kind:"constant.float",label:"Float",category:"Inputs",inputs:[],outputs:[{name:"value",type:"float"}]},"constant.vec2":{kind:"constant.vec2",label:"Vec2",category:"Inputs",inputs:[],outputs:[{name:"value",type:"vec2"}]},"constant.vec3":{kind:"constant.vec3",label:"Vec3",category:"Inputs",inputs:[],outputs:[{name:"value",type:"vec3"}]},"constant.rgba":{kind:"constant.rgba",label:"Color",category:"Inputs",inputs:[],outputs:[{name:"value",type:"rgba"}]},"builtin.uv":{kind:"builtin.uv",label:"UV",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec2"},{name:"u",type:"float"},{name:"v",type:"float"}]},"builtin.screenUv":{kind:"builtin.screenUv",label:"Screen UV",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec2"}]},"builtin.color":{kind:"builtin.color",label:"Color Attribute",category:"Attributes",inputs:[],outputs:[{name:"value",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"builtin.position":{kind:"builtin.position",label:"Position Attribute",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.worldPosition":{kind:"builtin.worldPosition",label:"World Position",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.objectPosition":{kind:"builtin.objectPosition",label:"Object Position",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.normal":{kind:"builtin.normal",label:"Normal Attribute",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.particle":{kind:"builtin.particle",label:"Particle",category:"Attributes",inputs:[],outputs:[{name:"energy",type:"float"},{name:"color",type:"rgb"},{name:"opacity",type:"float"},{name:"time",type:"float"}]},"builtin.time":{kind:"builtin.time",label:"Time",category:"Inputs",inputs:[],outputs:[{name:"value",type:"float"}]},"builtin.viewDir":{kind:"builtin.viewDir",label:"View Direction",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.camera":{kind:"builtin.camera",label:"Camera",category:"Inputs",inputs:[],outputs:[{name:"position",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"},{name:"near",type:"float"},{name:"far",type:"float"}]},"builtin.viewMatrix":{kind:"builtin.viewMatrix",label:"View Matrix",category:"Inputs",inputs:[],outputs:[{name:"value",type:"mat4"}]},"builtin.projectionMatrix":{kind:"builtin.projectionMatrix",label:"Projection Matrix",category:"Inputs",inputs:[],outputs:[{name:"value",type:"mat4"}]},"builtin.modelViewMatrix":{kind:"builtin.modelViewMatrix",label:"Model View Matrix",category:"Inputs",inputs:[],outputs:[{name:"value",type:"mat4"}]},"scene.ambientLight":{kind:"scene.ambientLight",label:"Ambient Light",category:"Scene",inputs:[],outputs:[{name:"color",type:"rgb"}]},"scene.directionalLight":{kind:"scene.directionalLight",label:"Directional Light",category:"Scene",inputs:[],outputs:[{name:"color",type:"rgb"},{name:"direction",type:"vec3"}]},"math.add":{kind:"math.add",label:"Add",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.subtract":{kind:"math.subtract",label:"Subtract",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.multiply":{kind:"math.multiply",label:"Multiply",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.divide":{kind:"math.divide",label:"Divide",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.oneMinus":{kind:"math.oneMinus",label:"One Minus",category:"Math",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.abs":e("math.abs","Abs","Math"),"math.sign":e("math.sign","Sign","Math"),"math.floor":e("math.floor","Floor","Math"),"math.ceil":e("math.ceil","Ceil","Math"),"math.fract":e("math.fract","Fract","Math"),"math.sin":e("math.sin","Sine","Trigonometry"),"math.cos":e("math.cos","Cosine","Trigonometry"),"math.tan":e("math.tan","Tangent","Trigonometry"),"math.asin":e("math.asin","Arc Sine","Trigonometry"),"math.acos":e("math.acos","Arc Cosine","Trigonometry"),"math.atan":e("math.atan","Arc Tangent","Trigonometry"),"math.atan2":{kind:"math.atan2",label:"Arc Tangent 2",category:"Trigonometry",inputs:[{name:"y",type:"dynamic"},{name:"x",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.radians":e("math.radians","Radians","Trigonometry"),"math.degrees":e("math.degrees","Degrees","Trigonometry"),"math.sqrt":e("math.sqrt","Square Root","Math"),"math.inverseSqrt":e("math.inverseSqrt","Inverse Square Root","Math"),"math.exp":e("math.exp","Exp","Math"),"math.exp2":e("math.exp2","Exp2","Math"),"math.log":e("math.log","Log","Math"),"math.log2":e("math.log2","Log2","Math"),"math.saturate":e("math.saturate","Saturate","Math"),"math.length":{kind:"math.length",label:"Length",category:"Vectors",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"math.normalize":e("math.normalize","Normalize","Vectors"),"math.clamp":{kind:"math.clamp",label:"Clamp",category:"Math",inputs:[{name:"value",type:"dynamic"},{name:"min",type:"dynamic",defaultValue:0},{name:"max",type:"dynamic",defaultValue:1}],outputs:[{name:"value",type:"dynamic"}]},"math.min":t("math.min","Min"),"math.max":t("math.max","Max"),"math.pow":t("math.pow","Power"),"math.mod":t("math.mod","Modulo"),"math.step":t("math.step","Step"),"math.smoothstep":{kind:"math.smoothstep",label:"Smoothstep",category:"Math",inputs:[{name:"edge0",type:"dynamic",defaultValue:0},{name:"edge1",type:"dynamic",defaultValue:1},{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.mix":{kind:"math.mix",label:"Mix",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"},{name:"t",type:"dynamic",defaultValue:.5}],outputs:[{name:"value",type:"dynamic"}]},"math.remap":{kind:"math.remap",label:"Remap",category:"Math",inputs:[{name:"value",type:"float"},{name:"inMin",type:"float",defaultValue:-1},{name:"inMax",type:"float",defaultValue:1},{name:"outMin",type:"float",defaultValue:0},{name:"outMax",type:"float",defaultValue:1}],outputs:[{name:"value",type:"float"}]},"math.reflect":{kind:"math.reflect",label:"Reflect",category:"Math",inputs:[{name:"incident",type:"dynamic"},{name:"normal",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.refract":{kind:"math.refract",label:"Refract",category:"Math",inputs:[{name:"incident",type:"dynamic"},{name:"normal",type:"dynamic"},{name:"ior",type:"float",defaultValue:1.5}],outputs:[{name:"value",type:"dynamic"}]},"math.derivative":{kind:"math.derivative",label:"Derivative",category:"Math",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.select":{kind:"math.select",label:"Select",category:"Math",inputs:[{name:"condition",type:"boolean"},{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"layer.mixPainted":{kind:"layer.mixPainted",label:"Mix Painted Layers",category:"Layers",inputs:[{name:"base",type:"dynamic"},...Array.from({length:8},(e,t)=>({name:`layer${t+1}`,label:`Layer ${t+1}`,type:"dynamic",optional:!0})),{name:"softness",type:"float",optional:!0},{name:"noiseScale",label:"Noise Scale",type:"float",optional:!0},{name:"noiseAmount",label:"Noise Amount",type:"float",optional:!0}],outputs:[{name:"value",type:"dynamic"}]},"math.dot":{kind:"math.dot",label:"Dot Product",category:"Vectors",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"math.distance":{kind:"math.distance",label:"Distance",category:"Vectors",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"math.cross":{kind:"math.cross",label:"Cross Product",category:"Vectors",inputs:[{name:"a",type:"vec3"},{name:"b",type:"vec3"}],outputs:[{name:"value",type:"vec3"}]},"compare.greaterThan":a("compare.greaterThan","Greater Than"),"compare.greaterThanOrEqual":a("compare.greaterThanOrEqual","Greater Than Or Equal"),"compare.lessThan":a("compare.lessThan","Less Than"),"compare.lessThanOrEqual":a("compare.lessThanOrEqual","Less Than Or Equal"),"compare.equal":a("compare.equal","Equal"),"compare.notEqual":a("compare.notEqual","Not Equal"),"boolean.not":{kind:"boolean.not",label:"Not",category:"Boolean",inputs:[{name:"value",type:"boolean"}],outputs:[{name:"value",type:"boolean"}]},"boolean.and":n("boolean.and","And"),"boolean.or":n("boolean.or","Or"),"compose.vec2":{kind:"compose.vec2",label:"Compose Vec2",category:"Vectors",inputs:[{name:"x",type:"float"},{name:"y",type:"float"}],outputs:[{name:"value",type:"vec2"}]},"compose.vec3":{kind:"compose.vec3",label:"Compose Vec3",category:"Vectors",inputs:[{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}],outputs:[{name:"value",type:"vec3"}]},"compose.vec4":{kind:"compose.vec4",label:"Compose Vec4",category:"Vectors",inputs:[{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"},{name:"w",type:"float"}],outputs:[{name:"value",type:"vec4"}]},"compose.rgba":{kind:"compose.rgba",label:"Compose RGBA",category:"Color",inputs:[{name:"r",type:"float",defaultValue:1},{name:"g",type:"float",defaultValue:1},{name:"b",type:"float",defaultValue:1},{name:"a",type:"float",defaultValue:1}],outputs:[{name:"value",type:"rgba"}]},"decompose.component":{kind:"decompose.component",label:"Component",category:"Vectors",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"decompose.split":{kind:"decompose.split",label:"Split Components",category:"Vectors",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"},{name:"w",type:"float"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"},{name:"u",type:"float"},{name:"v",type:"float"}]},"color.gradient":{kind:"color.gradient",label:"Gradient",category:"Color",inputs:[{name:"t",type:"float",defaultValue:.5}],outputs:[{name:"value",type:"rgba"}]},"utility.curve":{kind:"utility.curve",label:"Curve",category:"Utilities",inputs:[{name:"t",type:"float",defaultValue:.5}],outputs:[{name:"value",type:"float"}]},"utility.namedRerouteDeclaration":{kind:"utility.namedRerouteDeclaration",label:"Named Reroute Declaration",category:"Utilities",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"utility.namedRerouteUsage":{kind:"utility.namedRerouteUsage",label:"Named Reroute Usage",category:"Utilities",inputs:[],outputs:[{name:"value",type:"dynamic"}]},"color.hueShift":{kind:"color.hueShift",label:"Hue Shift",category:"Color",inputs:[{name:"color",type:"dynamic"},{name:"shift",type:"float"}],outputs:[{name:"value",type:"dynamic"}]},"color.blend":{kind:"color.blend",label:"Blend Colors",category:"Color",inputs:[{name:"base",type:"dynamic"},{name:"blend",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"color.desaturate":{kind:"color.desaturate",label:"Desaturate",category:"Color",inputs:[{name:"color",type:"dynamic"},{name:"fraction",type:"float",defaultValue:1}],outputs:[{name:"value",type:"dynamic"}]},"color.unpackNormal":{kind:"color.unpackNormal",label:"Unpack Normal",category:"Textures",inputs:[{name:"color",type:"dynamic"},{name:"scale",type:"float",defaultValue:1},{name:"normal",type:"vec3",optional:!0,inlineLiteral:!1}],outputs:[{name:"value",type:"vec3"}]},"texture.sampler2d":{kind:"texture.sampler2d",label:"Sampler 2D",category:"Texture",inputs:[{name:"texture",type:"texture2d"}],outputs:[{name:"value",type:"sampler2d"}]},"texture.sample2d":{kind:"texture.sample2d",label:"Sample Texture 2D",category:"Textures",inputs:[{name:"sampler",type:"sampler2d"},{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"rgba",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"texture.triplanarMapping":{kind:"texture.triplanarMapping",label:"Triplanar Mapping",category:"Textures",inputs:[{name:"sampler",type:"sampler2d"},{name:"scale",type:"float",defaultValue:1},{name:"normal",type:"vec3",inlineLiteral:!1},{name:"position",type:"vec3",inlineLiteral:!1}],outputs:[{name:"rgba",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"scene.sampleColor":{kind:"scene.sampleColor",label:"Sample Scene Color",category:"Texture",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"rgba",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"scene.sampleDepth":{kind:"scene.sampleDepth",label:"Sample Scene Depth",category:"Texture",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"depth",type:"float"},{name:"linearEyeDepth",type:"float"}]},"scene.fragmentDepth":{kind:"scene.fragmentDepth",label:"Fragment Depth",category:"Texture",inputs:[],outputs:[{name:"linearEyeDepth",type:"float"}]},"transform.translate":{kind:"transform.translate",label:"Translate",category:"Transform",inputs:[{name:"offset",type:"vec3",defaultValue:[0,0,0]}],outputs:[{name:"value",type:"mat4"}]},"transform.scale":{kind:"transform.scale",label:"Scale",category:"Transform",inputs:[{name:"scale",type:"vec3",defaultValue:[1,1,1]}],outputs:[{name:"value",type:"mat4"}]},"transform.rotateAxis":{kind:"transform.rotateAxis",label:"Rotate Axis",category:"Transform",inputs:[{name:"axis",type:"vec3",defaultValue:[0,1,0]},{name:"angle",type:"float",defaultValue:0}],outputs:[{name:"value",type:"mat4"}]},"uv.rotate":{kind:"uv.rotate",label:"Rotate UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"angle",type:"float",defaultValue:0},{name:"center",type:"vec2",optional:!0,defaultValue:[.5,.5]}],outputs:[{name:"value",type:"vec2"}]},"uv.twirl":{kind:"uv.twirl",label:"Twirl UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"strength",type:"float",defaultValue:1},{name:"center",type:"vec2",optional:!0,defaultValue:[.5,.5]},{name:"offset",type:"vec2",optional:!0,defaultValue:[0,0]}],outputs:[{name:"value",type:"vec2"}]},"uv.radial":{kind:"uv.radial",label:"Radial UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"coords",type:"vec2"},{name:"radius",type:"float"},{name:"angle",type:"float"}]},"uv.bulge":{kind:"uv.bulge",label:"Bulge UV",category:"UV",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"center",type:"vec2",optional:!0,defaultValue:[.5,.5]},{name:"power",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"vec2"}]},"uv.flipbook":{kind:"uv.flipbook",label:"Flipbook UV",category:"UV",inputs:[{name:"uv",type:"vec2",optional:!0,inlineLiteral:!1},{name:"columns",type:"float",optional:!0,defaultValue:1},{name:"rows",type:"float",optional:!0,defaultValue:1},{name:"fps",type:"float",optional:!0,defaultValue:60},{name:"time",type:"float",optional:!0,inlineLiteral:!1}],outputs:[{name:"value",type:"vec2"}]},"uv.pom":{kind:"uv.pom",label:"Parallax Occlusion",category:"UV",inputs:[{name:"uv",type:"vec2",optional:!0,inlineLiteral:!1},{name:"heightMap",type:"sampler2d"},{name:"heightScale",type:"float",optional:!0,defaultValue:.05}],outputs:[{name:"value",type:"vec2"}]},"shape.rectangle":{kind:"shape.rectangle",label:"Rectangle",category:"Shapes",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"width",type:"float",defaultValue:.5},{name:"height",type:"float",defaultValue:.5}],outputs:[{name:"value",type:"float"}]},"shape.roundedRectangle":{kind:"shape.roundedRectangle",label:"Rounded Rectangle",category:"Shapes",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"width",type:"float",defaultValue:.5},{name:"height",type:"float",defaultValue:.5},{name:"radius",type:"float",defaultValue:.1}],outputs:[{name:"value",type:"float"}]},"noise.simplex":{kind:"noise.simplex",label:"Simplex Noise",category:"Noise",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"scale",type:"float",optional:!0,defaultValue:8}],outputs:[{name:"value",type:"float"}]},"noise.voronoi2d":{kind:"noise.voronoi2d",label:"Voronoi",category:"Noise",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"scale",type:"float",optional:!0,defaultValue:8}],outputs:[{name:"value",type:"float"}]},"effect.fresnel":{kind:"effect.fresnel",label:"Fresnel",category:"Effects",inputs:[{name:"power",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"float"}]},"effect.edgeDepth":{kind:"effect.edgeDepth",label:"Edge Depth",category:"Effects",inputs:[{name:"power",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"float"}]},"effect.depthFade":{kind:"effect.depthFade",label:"Depth Fade",category:"Effects",inputs:[{name:"distance",type:"float",optional:!0,defaultValue:1}],outputs:[{name:"value",type:"float"}]},"util.panner":{kind:"util.panner",label:"Panner",category:"Utilities",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1},{name:"speed",type:"vec2",defaultValue:[0,0]},{name:"tile",type:"vec2",defaultValue:[1,1]},{name:"time",type:"float",optional:!0,inlineLiteral:!1}],outputs:[{name:"value",type:"vec2"}]}};export const SHADER_GRAPH_NODE_KINDS=Object.keys(SHADER_GRAPH_NODE_DEFINITIONS);function e(e,t,a){return{kind:e,label:t,category:a,inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]}}function t(e,t){return{kind:e,label:t,category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]}}function a(e,t){return{kind:e,label:t,category:"Comparison",inputs:[{name:"a",type:"float"},{name:"b",type:"float"}],outputs:[{name:"value",type:"boolean"}]}}function n(e,t){return{kind:e,label:t,category:"Boolean",inputs:[{name:"a",type:"boolean"},{name:"b",type:"boolean"}],outputs:[{name:"value",type:"boolean"}]}}export function inlineLiteralTypeForPort(e,t){if(!1!==t.inlineLiteral)return"float"===t.type||"vec2"===t.type||"vec3"===t.type||"vec4"===t.type?t.type:"dynamic"===t.type&&function(e){return e.startsWith("math.")&&"math.reflect"!==e&&"math.refract"!==e}(e)?"float":void 0}export function defaultInlineLiteralValueForPort(e,t){const a=inlineLiteralTypeForPort(e,t);if(null!=a){if(void 0!==t.defaultValue)return l(t.defaultValue);if("math.multiply"===e)return 1;switch(a){case"float":return 0;case"vec2":return[0,0];case"vec3":return[0,0,0];case"vec4":return[0,0,0,1]}}}function l(e){return Array.isArray(e)?e.map(e=>l(e)):null!=e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,l(t)])):e}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|