@hology/core 0.0.272 → 0.0.274

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/effects/sequence/sequence-player.js +1 -1
  2. package/dist/effects/vfx/gpu-sprite-runtime.js +1 -1
  3. package/dist/effects/vfx/gpu-vfx-world-service.js +1 -1
  4. package/dist/effects/vfx/rates.d.ts +2 -0
  5. package/dist/effects/vfx/rates.js +1 -1
  6. package/dist/effects/vfx/vfx-actor.d.ts +2 -1
  7. package/dist/effects/vfx/vfx-actor.js +1 -1
  8. package/dist/effects/vfx/vfx-asset.d.ts +10 -1
  9. package/dist/effects/vfx/vfx-backend-partition.d.ts +8 -0
  10. package/dist/effects/vfx/vfx-backend-partition.js +4 -0
  11. package/dist/effects/vfx/vfx-materializer.js +1 -1
  12. package/dist/effects/vfx/vfx-render-preparation.js +1 -1
  13. package/dist/effects/vfx/vfx-renderers.d.ts +27 -2
  14. package/dist/effects/vfx/vfx-renderers.js +1 -1
  15. package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts +2 -0
  16. package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
  17. package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts +19 -0
  18. package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -1
  19. package/dist/gameplay/actors/builtin/water-spline-volume-actor.d.ts +10 -0
  20. package/dist/gameplay/actors/builtin/water-spline-volume-actor.js +1 -1
  21. package/dist/gameplay/actors/builtin/water-volume-actor.d.ts +3 -1
  22. package/dist/gameplay/actors/builtin/water-volume-actor.js +1 -1
  23. package/dist/gameplay/actors/camera/first-person-camera-component.js +1 -1
  24. package/dist/gameplay/actors/camera/third-person-camera-component.d.ts +7 -0
  25. package/dist/gameplay/actors/camera/third-person-camera-component.js +1 -1
  26. package/dist/gameplay/ai/behavior-tree/move.d.ts +5 -0
  27. package/dist/gameplay/ai/behavior-tree/move.js +1 -1
  28. package/dist/gameplay/ai/behavior-tree/move.test.d.ts +2 -0
  29. package/dist/gameplay/ai/behavior-tree/move.test.js +4 -0
  30. package/dist/gameplay/animation/root-motion.js +1 -1
  31. package/dist/gameplay/input/input-service.d.ts +9 -1
  32. package/dist/gameplay/input/input-service.js +1 -1
  33. package/dist/gameplay/services/physics/physics-system.d.ts +2 -0
  34. package/dist/gameplay/services/physics/physics-system.js +1 -1
  35. package/dist/gameplay/services/render.d.ts +4 -1
  36. package/dist/gameplay/services/render.js +1 -1
  37. package/dist/gameplay/services/world.d.ts +5 -0
  38. package/dist/rendering/node-material-webgpu-resolver.js +1 -1
  39. package/dist/rendering/webgpu-experimental-backend.d.ts +4 -2
  40. package/dist/rendering/webgpu-experimental-backend.js +1 -1
  41. package/dist/rendering.d.ts +17 -2
  42. package/dist/rendering.js +1 -1
  43. package/dist/scene/asset-resource-loader.d.ts +4 -0
  44. package/dist/scene/asset-resource-loader.js +1 -1
  45. package/dist/scene/collision/collision-shape-import.js +1 -1
  46. package/dist/scene/collision/rapier-shape.js +1 -1
  47. package/dist/scene/landscape/landscape-geometry.d.ts +24 -0
  48. package/dist/scene/landscape/landscape-geometry.js +4 -0
  49. package/dist/scene/landscape/landscape-manager.d.ts +1 -0
  50. package/dist/scene/landscape/landscape-manager.js +1 -1
  51. package/dist/scene/materializer.d.ts +7 -1
  52. package/dist/scene/materializer.js +1 -1
  53. package/dist/scene/scene-data-service.d.ts +2 -1
  54. package/dist/scene/scene-data-service.js +1 -1
  55. package/dist/scene/sky.d.ts +2 -0
  56. package/dist/scene/sky.js +1 -1
  57. package/dist/shader/graph/compiler.js +1 -1
  58. package/dist/shader/graph/registry.js +1 -1
  59. package/dist/shader/parameter.js +1 -1
  60. package/dist/shader/sprite-shader.js +1 -1
  61. package/dist/shader-nodes/depth.d.ts +6 -4
  62. package/dist/shader-nodes/depth.js +1 -1
  63. package/dist/shader-nodes/index.d.ts +2 -1
  64. package/dist/shader-nodes/index.js +1 -1
  65. package/dist/shader-nodes/surface-reflection.d.ts +9 -0
  66. package/dist/shader-nodes/surface-reflection.js +4 -0
  67. package/dist/shader-nodes/water-volume.d.ts +6 -2
  68. package/dist/shader-nodes/water-volume.js +1 -1
  69. package/dist/test/asset-resource-loader-texture-array.test.js +1 -1
  70. package/dist/test/character-movement-solve.test.js +1 -1
  71. package/dist/test/collision-shape-import.test.js +1 -1
  72. package/dist/test/first-person-camera-component.test.js +1 -1
  73. package/dist/test/frame-stats.test.js +1 -1
  74. package/dist/test/gpu-sprite-compiler.test.js +1 -1
  75. package/dist/test/input.test.js +1 -1
  76. package/dist/test/landscape-geometry.test.d.ts +2 -0
  77. package/dist/test/landscape-geometry.test.js +4 -0
  78. package/dist/test/material-assignment.test.js +1 -1
  79. package/dist/test/materializer-dynamic-transform.test.js +1 -1
  80. package/dist/test/materializer-prefetch.test.js +1 -1
  81. package/dist/test/net-character-movement.test.js +1 -1
  82. package/dist/test/node-material-webgpu-resolver.test.js +1 -1
  83. package/dist/test/parameter-definition.test.js +1 -1
  84. package/dist/test/physics-hitstop.test.d.ts +2 -0
  85. package/dist/test/physics-hitstop.test.js +4 -0
  86. package/dist/test/physics-ray-object.test.js +1 -1
  87. package/dist/test/post-process-effect.test.js +1 -1
  88. package/dist/test/rapier-trimesh.test.d.ts +2 -0
  89. package/dist/test/rapier-trimesh.test.js +4 -0
  90. package/dist/test/sequence-animation-retiming.test.js +1 -1
  91. package/dist/test/sequence-vfx.test.js +1 -1
  92. package/dist/test/surface-reflection.test.d.ts +2 -0
  93. package/dist/test/surface-reflection.test.js +4 -0
  94. package/dist/test/vfx-backend-partition.test.d.ts +2 -0
  95. package/dist/test/vfx-backend-partition.test.js +4 -0
  96. package/dist/test/vfx-playback-transform.test.js +1 -1
  97. package/dist/test/vfx-render-preparation.test.js +1 -1
  98. package/dist/test/water-spline-volume-actor.test.js +1 -1
  99. package/dist/utils/mesh.d.ts +1 -1
  100. package/dist/utils/mesh.js +1 -1
  101. package/dist/utils/three/frame-stats.d.ts +8 -0
  102. package/dist/utils/three/frame-stats.js +1 -1
  103. package/package.json +2 -2
  104. package/tsconfig.tsbuildinfo +1 -1
@@ -23,8 +23,9 @@ export declare class SceneDataService implements SceneDataProvider {
23
23
  * @param remote Whether the update is made by a synchronization service. This
24
24
  * is forwarded in onUpdate callbacks so they can decide if they should ignore the events
25
25
  * to avoid infite loops by differentiating between updates made locally and remotely.
26
+ * @param recreate Rebuild the rendered object and its authored descendants instead of applying an incremental update.
26
27
  */
27
- updateObject(object: SceneObject, remote?: boolean): void;
28
+ updateObject(object: SceneObject, remote?: boolean, recreate?: boolean): void;
28
29
  findObjectById(id: string): SceneObject;
29
30
  findAncestorsById(id: string): SceneObject[];
30
31
  /**
@@ -1,4 +1,4 @@
1
- import{BehaviorSubject as e}from"rxjs";import{Matrix4 as t,Vector3 as s,Quaternion as i,Euler as n,NoToneMapping as o}from"three";export class SceneDataService{constructor(){this.objects=[],this.callbacks=[],this.createCallbacks=[],this.removeCallbacks=[],this.objectChange=new e([])}initiate(e){this.objects=e??[],this.objectChange.next(this.objects)}createDefaultObjects(){this.objects.some(e=>"global_fog"===e.type)||this.objects.unshift(createInitialFog());this.objects.some(e=>"sky"===e.type)||this.objects.unshift(createInitialSky())}removeOnUpdateCallback(e){this.callbacks.splice(this.callbacks.indexOf(e),1)}onCreate(e){this.createCallbacks.push(e)}onUpdate(e){this.callbacks.push(e)}onRemove(e){this.removeCallbacks.push(e)}getObjects(){return this.objects}getObjectsRecursive(){const e=[],t=this.objects.slice();for(;t.length>0;){const s=t.pop();e.push(s),null!=s.children&&t.push(...s.children)}return e}addObject(e,t=!1){this.objects.push(e),this.createCallbacks.forEach(s=>s(e,t)),this.objectChange.next(this.objects)}updateObject(e,t=!1){const s=this.findObjectById(e.id);s?(Object.assign(s,e),this.callbacks.forEach(s=>s(e,t))):this.addObject(e),this.objectChange.next(this.objects)}findObjectById(e){const t=[...this.objects];for(;t.length>0;){const s=t.pop();if(s.id===e)return s;s.children&&t.push(...s.children)}}findAncestorsById(e){const t=this.findParentById(e);return null==t?[]:[t,...this.findAncestorsById(t.id)]}findParentById(e){return this._findParentById(e,this.objects)}_findParentById(e,t,s=null){return t.some(t=>t.id===e)?s:t.filter(e=>null!=e.children).map(t=>this._findParentById(e,t.children,t)).find(e=>null!=e)}updateParent(e,o){const r=this.findParentById(e.id);if("sky"!==e.type&&"directional"!==e.light?.type&&"ambient"!==e.light?.type&&null!=e.position){const c=null!=o?this.getMatrixWorld(o).invert():(new t).identity();null!=r&&c.multiply(this.getMatrixWorld(r));const l=this.getLocalMatrix(e),a=c.multiply(l),h=new s,d=new i,b=new s;a.decompose(h,d,b),e.position=h.toArray(),e.rotation=(new n).setFromQuaternion(d).toArray(),e.scale=b.toArray()}this.removeRecursive(e.id,r?.children??this.objects),null!=r?r.children=r.children.slice():this.objects=this.objects.slice(),null!=o?(o.children??(o.children=[]),o.children.push(e),o.children=o.children.slice()):(this.objects.push(e),this.objects=this.objects.slice()),this.objectChange.next(this.objects),this.callbacks.forEach(t=>t(e,!1))}getMatrixWorld(e){const t=this.findAncestorsById(e.id).reverse();t.push(e);const s=this.getLocalMatrix(t.shift());for(const e of t){const t=this.getLocalMatrix(e);s.multiply(t)}return s}getLocalMatrix(e){const o=new t,r=(new s).fromArray(e.position),c=(new i).setFromEuler((new n).fromArray(e.rotation)),l=(new s).fromArray(e.scale);return o.compose(r,c,l),o}removeObjectById(e,t=!1){const s=this.findObjectById(e);this.removeObject(s,t)}removeObject(e,t=!1){this.removeRecursive(e.id,this.objects),this.removeCallbacks.forEach(s=>s(e,t)),this.objectChange.next([...this.objects])}removeRecursive(e,t){const s=t.findIndex(t=>t.id===e);if(s>-1)t.splice(s,1);else for(const s of t)null!=s.children&&this.removeRecursive(e,s.children??[])}save(){}serialize(){return JSON.stringify(this.objects)}}export function createInitialFog(){return{id:"auto-global-fog",name:"Global fog",type:"global_fog",fog:{type:"density",color:"#b8f8ff",density:.005,near:100,far:1e3}}}export function createInitialSky(){return{id:"auto-sky",name:"Sky",type:"sky",sky:{materialId:null}}}export function createWorldEnvironment(){return{id:"auto-world-env",name:"World Environment",type:"world_env",worldEnv:{ao:{enabled:!1,blendIntensity:1,radius:.25,distanceExponent:1,thickness:1,distanceFallOff:1,scale:1,samples:16,onlyAO:!1},toneMapping:{mapping:o,exposure:1},environment:{textureId:null,intensity:1}}}}/*
1
+ import{BehaviorSubject as e}from"rxjs";import{Matrix4 as t,Vector3 as s,Quaternion as i,Euler as n,NoToneMapping as o}from"three";export class SceneDataService{constructor(){this.objects=[],this.callbacks=[],this.createCallbacks=[],this.removeCallbacks=[],this.objectChange=new e([])}initiate(e){this.objects=e??[],this.objectChange.next(this.objects)}createDefaultObjects(){this.objects.some(e=>"global_fog"===e.type)||this.objects.unshift(createInitialFog());this.objects.some(e=>"sky"===e.type)||this.objects.unshift(createInitialSky())}removeOnUpdateCallback(e){this.callbacks.splice(this.callbacks.indexOf(e),1)}onCreate(e){this.createCallbacks.push(e)}onUpdate(e){this.callbacks.push(e)}onRemove(e){this.removeCallbacks.push(e)}getObjects(){return this.objects}getObjectsRecursive(){const e=[],t=this.objects.slice();for(;t.length>0;){const s=t.pop();e.push(s),null!=s.children&&t.push(...s.children)}return e}addObject(e,t=!1){this.objects.push(e),this.createCallbacks.forEach(s=>s(e,t)),this.objectChange.next(this.objects)}updateObject(e,t=!1,s=!1){const i=this.findObjectById(e.id);i?(Object.assign(i,e),this.callbacks.forEach(i=>i(e,t,s))):this.addObject(e),this.objectChange.next(this.objects)}findObjectById(e){const t=[...this.objects];for(;t.length>0;){const s=t.pop();if(s.id===e)return s;s.children&&t.push(...s.children)}}findAncestorsById(e){const t=this.findParentById(e);return null==t?[]:[t,...this.findAncestorsById(t.id)]}findParentById(e){return this._findParentById(e,this.objects)}_findParentById(e,t,s=null){return t.some(t=>t.id===e)?s:t.filter(e=>null!=e.children).map(t=>this._findParentById(e,t.children,t)).find(e=>null!=e)}updateParent(e,o){const r=this.findParentById(e.id);if("sky"!==e.type&&"directional"!==e.light?.type&&"ambient"!==e.light?.type&&null!=e.position){const c=null!=o?this.getMatrixWorld(o).invert():(new t).identity();null!=r&&c.multiply(this.getMatrixWorld(r));const l=this.getLocalMatrix(e),a=c.multiply(l),h=new s,d=new i,b=new s;a.decompose(h,d,b),e.position=h.toArray(),e.rotation=(new n).setFromQuaternion(d).toArray(),e.scale=b.toArray()}this.removeRecursive(e.id,r?.children??this.objects),null!=r?r.children=r.children.slice():this.objects=this.objects.slice(),null!=o?(o.children??(o.children=[]),o.children.push(e),o.children=o.children.slice()):(this.objects.push(e),this.objects=this.objects.slice()),this.objectChange.next(this.objects),this.callbacks.forEach(t=>t(e,!1))}getMatrixWorld(e){const t=this.findAncestorsById(e.id).reverse();t.push(e);const s=this.getLocalMatrix(t.shift());for(const e of t){const t=this.getLocalMatrix(e);s.multiply(t)}return s}getLocalMatrix(e){const o=new t,r=(new s).fromArray(e.position),c=(new i).setFromEuler((new n).fromArray(e.rotation)),l=(new s).fromArray(e.scale);return o.compose(r,c,l),o}removeObjectById(e,t=!1){const s=this.findObjectById(e);this.removeObject(s,t)}removeObject(e,t=!1){this.removeRecursive(e.id,this.objects),this.removeCallbacks.forEach(s=>s(e,t)),this.objectChange.next([...this.objects])}removeRecursive(e,t){const s=t.findIndex(t=>t.id===e);if(s>-1)t.splice(s,1);else for(const s of t)null!=s.children&&this.removeRecursive(e,s.children??[])}save(){}serialize(){return JSON.stringify(this.objects)}}export function createInitialFog(){return{id:"auto-global-fog",name:"Global fog",type:"global_fog",fog:{type:"density",color:"#b8f8ff",density:.005,near:100,far:1e3}}}export function createInitialSky(){return{id:"auto-sky",name:"Sky",type:"sky",sky:{materialId:null}}}export function createWorldEnvironment(){return{id:"auto-world-env",name:"World Environment",type:"world_env",worldEnv:{ao:{enabled:!1,blendIntensity:1,radius:.25,distanceExponent:1,thickness:1,distanceFallOff:1,scale:1,samples:16,onlyAO:!1},toneMapping:{mapping:o,exposure:1},environment:{textureId:null,intensity:1}}}}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -2,6 +2,8 @@ import * as THREE from "three";
2
2
  import { NodeShaderMaterial } from 'three-shader-graph';
3
3
  export declare function basicSceneSetup(scene: THREE.Scene): void;
4
4
  export declare const ambientLightName = "default_ambient";
5
+ export declare const skyPosition: import("three-shader-graph").Vec4Node;
6
+ export declare function applySkyMaterialSettings(material: THREE.Material, fog?: boolean): void;
5
7
  export declare const defaultSkyMaterial: NodeShaderMaterial;
6
8
  export declare function createSky(): THREE.Mesh<THREE.SphereGeometry, NodeShaderMaterial, THREE.Object3DEventMap>;
7
9
  //# sourceMappingURL=sky.d.ts.map
package/dist/scene/sky.js CHANGED
@@ -1,4 +1,4 @@
1
- import*as e from"three";import{AmbientLight as a,FogExp2 as t}from"three";import{attributes as r,NodeShaderMaterial as o,uniforms as i,vec4 as n,varyingVec3 as s,float as h,normalize as d,rgb as m,mix as c,max as w,pow as p}from"three-shader-graph";export function basicSceneSetup(r){!function(t){new a(16777215,.5);var r=new e.HemisphereLight(16777215,273,.5*Math.PI);r.name=ambientLightName,r.position.set(0,100,0),t.add(r);new e.HemisphereLightHelper(r,10);var o=new e.DirectionalLight(16777215,.7);o.position.set(-30,50,30),o.castShadow=!0,o.shadow.mapSize.width=2048,o.shadow.mapSize.height=2048;var i=250;o.shadow.normalBias=.3,o.shadow.camera.left=-i,o.shadow.camera.right=i,o.shadow.camera.top=i,o.shadow.camera.bottom=-i,o.shadow.camera.far=500,o.shadow.bias=-5e-4;new e.DirectionalLightHelper(o,10);var n=new e.PointLight(16777215,1,50);n.castShadow=!0,n.position.set(0,40,0),n.shadow.camera.near=1,n.shadow.camera.far=60,n.shadow.bias=-.005}(r),function(e){e.fog=new t(l,f)}(r)}export const ambientLightName="default_ambient";const l=157554,f=.005;export const defaultSkyMaterial=function(){const a=h(5),t=h(.6),l=new e.Color(16777215),f=new e.Color(13431551),g=s(i.modelMatrix.multiplyVec(n(r.position,1)).xyz),u=d(g.addScalar(a)).y,S=w(p(w(u,h(0)),h(t)),h(0)),y=n(c(m("#"+f.getHexString()),m("#"+l.getHexString()),S),h(1)),b=new o({color:y.rgba});return b.side=e.BackSide,b.depthTest=!0,b.depthWrite=!1,b.transparent=!0,b.name="default sky",b}();export function createSky(){var a=new e.SphereGeometry(300,10,15),t=new e.Mesh(a,defaultSkyMaterial);return t.renderOrder=-999,t.raycast=()=>{},t.name="default_sky",t}/*
1
+ import*as e from"three";import{AmbientLight as t,FogExp2 as a}from"three";import{attributes as o,NodeShaderMaterial as r,uniforms as i,vec4 as n,varyingVec3 as s,float as h,normalize as p,rgb as c,mix as d,max as m,pow as l}from"three-shader-graph";export function basicSceneSetup(o){!function(a){new t(16777215,.5);var o=new e.HemisphereLight(16777215,273,.5*Math.PI);o.name=ambientLightName,o.position.set(0,100,0),a.add(o);new e.HemisphereLightHelper(o,10);var r=new e.DirectionalLight(16777215,.7);r.position.set(-30,50,30),r.castShadow=!0,r.shadow.mapSize.width=2048,r.shadow.mapSize.height=2048;var i=250;r.shadow.normalBias=.3,r.shadow.camera.left=-i,r.shadow.camera.right=i,r.shadow.camera.top=i,r.shadow.camera.bottom=-i,r.shadow.camera.far=500,r.shadow.bias=-5e-4;new e.DirectionalLightHelper(r,10);var n=new e.PointLight(16777215,1,50);n.castShadow=!0,n.position.set(0,40,0),n.shadow.camera.near=1,n.shadow.camera.far=60,n.shadow.bias=-.005}(o),function(e){e.fog=new a(w,u)}(o)}export const ambientLightName="default_ambient";const w=157554,u=.005;const f=i.modelViewMatrix.multiplyVec(n(o.position,0)),g=i.projectionMatrix.multiplyVec(n(f.xyz,1));export const skyPosition=n(g.x,g.y,g.w,g.w);export function applySkyMaterialSettings(t,a=!1){t.userData.isSky=!0,t.side=e.BackSide,"fog"in t&&(t.fog=a),t.depthTest=!0,t.depthFunc=e.LessEqualDepth,t.depthWrite=!1,t.transparent=!0,t.alphaTest=0}export const defaultSkyMaterial=function(){const t=h(5),a=h(.6),w=new e.Color(16777215),u=new e.Color(13431551),f=s(i.modelMatrix.multiplyVec(n(o.position,0)).xyz),g=p(f.addScalar(t)).y,y=m(l(m(g,h(0)),h(a)),h(0)),S=n(d(c("#"+u.getHexString()),c("#"+w.getHexString()),y),h(1)),x=new r({color:S.rgba,position:skyPosition,fog:!0});return applySkyMaterialSettings(x,!0),x.name="default sky",x}();export function createSky(){var t=new e.SphereGeometry(300,10,15),a=new e.Mesh(t,defaultSkyMaterial);return a.userData.sceneCapture=!1,a.frustumCulled=!1,a.renderOrder=-1/0,a.raycast=()=>{},a.name="default_sky",a}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,4 +1,4 @@
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 s,Vector2 as n,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 z,cos as P,cross as V,degrees as A,distance as L,dot as j,exp as D,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 se,mod as ne,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,transpose as Me,textureSampler2d as Oe,timeUniforms as Ce,toonMaterial as ke,translate as Ne,transformed as Ge,triplanarMapping as Ee,twirl as Ue,uniformFloat as Be,uniforms as $e,varyingAttributes as ze,vec2 as Pe,vec3 as Ve,vec4 as Ae,getPaintedMaterialLayerWeight as Le}from"../../shader-nodes/index.js";import{isWgslCompiler as je}from"three-shader-graph";import{SpriteNodeShaderMaterial as De,getSpritePosition as Re}from"../sprite-shader.js";import{oneMinus as qe}from"../../shader-nodes/index.js";import{vectorToRadial as Fe,remap as He,hueShift as _e,blendColor as We,desaturateColor as Ye}from"../../shader-nodes/math.js";import{rectangleFloat as Je,roundedRectangleFloat as Ke}from"../../shader-nodes/shapes.js";import{edgeDepthEffect as Qe,fresnelEffect as Xe,depthFadeEffect as Ze}from"../../shader-nodes/effects.js";import{depthNormal as et,fragmentLinearEyeDepth as tt,sampleSceneDepth as at,sampleSceneLinearEyeDepth as rt,screenUV as it,nearUniformName as ut,farUniformName as ot}from"../../shader-nodes/depth.js";import{sampleSceneColor as st}from"../../shader-nodes/scene-sample.js";import{decalDiscard as nt,decalUV as lt}from"../../shader-nodes/decal.js";import{sampledSurfaceRejectsDecals as pt}from"../../shader-nodes/material-flags.js";import{Trail as ct,trailUV as ht}from"../../effects/vfx/trail-renderer.js";import{SimplexNoiseNode as vt,Voronoi2d as yt,rotateAxis as dt}from"../../shader-nodes/index.js";import{flipbookUv as mt}from"../../shader-nodes/texture-sequence.js";import{parallaxOcclusionMapping as ft}from"../../shader-nodes/pom.js";import{defaultInlineLiteralValueForPort as gt,inlineLiteralTypeForPort as bt,SHADER_GRAPH_NODE_DEFINITIONS as xt}from"./registry.js";import{shaderGraphParameterTypeToValueType as wt}from"./parameters.js";import{attributeVec2 as St,varying as Tt,reflect as It,refract as Mt,dFdx as Ot,dFdy as Ct,fwidth as kt,uniformAmbient as Nt,uniformDirectionalLights as Gt}from"three-shader-graph";import{decalNormal as Et}from"../../shader-nodes/decal.js";import{Curve2 as Ut}from"../../utils/curve.js";import{waterVolumeDistance as Bt,waterVolumeMask as $t}from"../../shader-nodes/water-volume.js";const zt=(()=>{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})(),Pt=new Set;const Vt=new class extends v{compile(e){return{out:je(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:jt(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 s=this.graph.outputs?.ambientOcclusion;null!=s&&(t.ambientOcclusion=this.floatOutput(s,"ambientOcclusion"));const n=this.graph.outputs?.ambientOcclusionIntensity;null!=n&&(t.ambientOcclusionIntensity=this.floatOutput(n,"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")):st(e),r=this.graph.outputs?.opacity;return At(a,null!=r?this.expectType(this.resolveOutputBinding(r,"opacity"),["float"],"opacity").value:void 0,e)}screenUv(){return this.options.screenUV??it}applyShadingModel(e){const t=null!=e.opacity?function(e,t){if(e instanceof h)return he(Ve(e,e,e),t);if(e instanceof w)return he(Ve(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:Ft(t),roughness:e.roughness??q(.5),...null!=e.metalness?{metalness:e.metalness}:{},..."decal"===this.graph.target?{normal:le(Tt($e.normalMatrix).multiplyVec(Et))}:{},...null!=e.normal?{normal:e.normal}:{},...null!=e.emissive?{emissive:Ht(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:Ft(t),...null!=e.normal?{normal:e.normal}:{},...null!=e.emissive?{emissive:Ht(e.emissive)}:{},...null!=e.ambientOcclusion?{ambientOcclusion:e.ambientOcclusion}:{},...null!=e.ambientOcclusionIntensity?{ambientOcclusionIntensity:e.ambientOcclusionIntensity}:{},...null!=e.bakedLight?{bakedLight:e.bakedLight}:{}};return{...e,color:ke(a)}}case"stylizedCharacter":{const a={color:Ft(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:Ht(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==xt[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(ta(Wt(e,"value",.5)))}});case"constant.boolean":return this.output(e,{value:{type:"boolean",value:U(Boolean(_t(e,"value",!1)))}});case"constant.float":return this.output(e,{value:{type:"float",value:q(Wt(e,"value",0))}});case"constant.vec2":return this.output(e,{value:{type:"vec2",value:ia(_t(e,"value",[0,0]))}});case"constant.vec3":return this.output(e,{value:{type:"vec3",value:ua(_t(e,"value",[0,0,0]))}});case"constant.rgba":return this.output(e,{value:{type:"rgba",value:oa(_t(e,"value","#ffffff"),Wt(e,"alpha",1))}});case"builtin.uv":{let t;return t="trail"===this.graph.target?ht:"decal"===this.graph.target?lt:this.uvAttribute(e),this.output(e,{value:{type:"vec2",value:!0===_t(e,"flipY",!1)?Pe(t.x,qe(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(Ge.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.worldNormal":{const t="decal"===this.graph.target?le(et):le(G(Me($e.viewMatrix).multiplyVec(Ae(Ge.normal,0)).xyz));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=$e.instanceMatrix.multiplyVec(Ae(0,0,0,1));t=K("USE_BATCHING",t,e=>W.multiplyVec(e));const a=G($e.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(Ge.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:Ce.elapsed}});case"builtin.camera":{const t=Be(ut),a=Be(ot),r=$e.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:$e.viewMatrix}});case"builtin.projectionMatrix":return this.output(e,{value:{type:"mat4",value:$e.projectionMatrix}});case"builtin.modelViewMatrix":return this.output(e,{value:{type:"mat4",value:$e.modelViewMatrix}});case"scene.ambientLight":return this.output(e,{color:{type:"rgb",value:Nt}});case"scene.directionalLight":return this.output(e,{color:{type:"rgb",value:Gt.sum(e=>e.color).divideScalar(re(q(Vt),q(1)))},direction:{type:"vec3",value:Gt.sum(e=>e.direction).divideScalar(re(q(Vt),q(1)))}});case"builtin.particle":return this.output(e,{energy:{type:"float",value:se.energy},color:{type:"rgb",value:se.color},opacity:{type:"float",value:se.opacity},time:{type:"float",value:se.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:qe(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,P)});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,D)});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,ne)});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=Qt(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:He(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=Qt(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:It(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:Mt(t.value,a.value,r)}})}case"math.derivative":{const t=this.expectNumeric(this.input(e,"value")),a=String(_t(e,"mode","fwidth"));let r;return r="dFdx"===a?Ot(t.value):"dFdy"===a?Ct(t.value):kt(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 Qt(t.type,a.type,e.id),this.output(e,{value:{type:"float",value:j(t.value,a.value)}})}case"math.distance":{const t=this.expectNumeric(this.input(e,"a")),a=this.expectNumeric(this.input(e,"b"));return Qt(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:Ve(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:Ae(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:Ae(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(_t(e,"component","x"));return this.output(e,{value:{type:"float",value:Zt(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:Zt(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=_t(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:aa(r.position,sa(a,t.length)),color:i,alpha:aa(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=_t(e,"curve","Linear"),r=Q(a,t.value)??J(Ut.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=_e(r,i);return"rgba"===t.type||"vec4"===t.type?this.output(e,{value:{type:t.type,value:Ae(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(_t(e,"mode","multiply")),i=t.value,u=a.value,o="rgba"===t.type||"vec4"===t.type?i.rgb??i.xyz:i,s="rgba"===a.type||"vec4"===a.type?u.rgb??u.xyz:u;let n=We(o,s,r);if("rgba"===a.type||"vec4"===a.type){const e=u.a??u.w;n=ue(o,n,e)}if("rgba"===t.type||"vec4"===t.type){const a=i.a??i.w;return this.output(e,{value:{type:t.type,value:Ae(n,a)}})}return this.output(e,{value:{type:t.type,value:n}})}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=Ye(r,i);return"rgba"===t.type||"vec4"===t.type?this.output(e,{value:{type:t.type,value:Ae(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:z(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:ze.normal}),["vec3"],e.id,"normal"),u=this.expectType(this.input(e,"position",{type:"vec3",value:ze.position}),["vec3"],e.id,"position"),o=Ee(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=st(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:at(t.value)},linearEyeDepth:{type:"float",value:rt(t.value)}})}case"scene.fragmentDepth":return this.output(e,{linearEyeDepth:{type:"float",value:tt}});case"scene.waterVolume":return this.output(e,{mask:{type:"float",value:$t},distance:{type:"float",value:Bt}});case"transform.translate":{const t=this.expectType(this.input(e,"offset",{type:"vec3",value:Ve(0,0,0)}),["vec3","rgb"],e.id,"offset");return this.output(e,{value:{type:"mat4",value:Ne(t.value)}})}case"transform.scale":{const t=this.expectType(this.input(e,"scale",{type:"vec3",value:Ve(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:Ve(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:dt(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:Xt(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:Ue(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=Fe(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",Wt(e,"columns",1)),r=this.floatInput(e,"rows",Wt(e,"rows",1)),i=this.floatInput(e,"fps",Wt(e,"fps",60)),u=this.expectType(this.input(e,"time",{type:"float",value:Ce.elapsed}),["float"],e.id,"time").value,o=String(_t(e,"mode","clamp"));return this.output(e,{value:{type:"vec2",value:mt(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=Wt(e,"minLayers",8),o=Wt(e,"maxLayers",24);return this.output(e,{value:{type:"vec2",value:ft(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:Je(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:Ke(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 vt(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 yt(t.multiplyScalar(a))}})}case"effect.fresnel":return this.output(e,{value:{type:"float",value:G(Xe(this.floatInput(e,"power",1)))}});case"effect.edgeDepth":{const t=this.floatInput(e,"power",1);return this.output(e,{value:{type:"float",value:Qe(t)}})}case"effect.depthFade":{const t=this.floatInput(e,"distance",1);return this.output(e,{value:{type:"float",value:Ze(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:Ce.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(_t(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=wt(a.type),i={type:r,value:Jt(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:Kt(e.value,t.value,a,r)};if("mat4"===e.type&&"float"===t.type&&("multiply"===a||"divide"===a))return{type:"mat4",value:Kt(e.value,t.value,a,r)};if("float"===e.type&&"mat4"===t.type&&"multiply"===a)return{type:"mat4",value:Kt(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:Kt(t.value,a.value,r,e.id)};if("float"===t.type&&"float"!==a.type&&"multiply"===r)return{type:a.type,value:Kt(a.value,t.value,r,e.id)};if("float"!==t.type&&"float"===a.type)return{type:t.type,value:Kt(t.value,a.value,r,e.id)};throw new ShaderGraphCompileError(`Cannot ${r} ${t.type} and ${a.type}`,e.id)}expectBinaryMathValue(e){if(!ea(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:Qt(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=[Le(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=Qt(i,o.type,e.id),a.push(o.value),r.push(Le(t))}return 1===a.length?t:{type:i,value:oe({layerColors:a,layerWeights:r,enableNoise:Boolean(_t(e,"enableNoise",!0)),noiseScale:this.floatInput(e,"noiseScale",Wt(e,"noiseScale",.1)),noiseAmount:this.floatInput(e,"noiseAmount",Wt(e,"noiseAmount",.5)),decay:this.floatInput(e,"softness",Wt(e,"softness",.3)),mode:"hard"===String(_t(e,"mode","soft"))?Z.hard:Z.soft})}}defaultUV(){return"trail"===this.graph.target?ht:"decal"===this.graph.target?lt:G(C.uv)}uvAttribute(e){const t=Math.max(0,Math.floor(Wt(e,"channel",0)));return 0===t?ze.uv:Tt(St(`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 Yt(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):Yt(e.value,e.valueType)}inlineLiteralFallback(e,t){const a=xt[e.kind]?.inputs.find(e=>e.name===t);if(null==a)return;const r=bt(e.kind,a),i=gt(e.kind,a);return null!=r&&void 0!==i?Yt(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(!ea(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:Oe(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(Ve(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:Rt(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:Re(new x("rotation",0),new x("screenSpaceSize",0),void 0,!0),uniforms:{color:{value:new t(16777215)}}});if("trail"===e.target){const{position:t}=ct.getTrailShaderNodes(a.trailBillboard??!1),i=new d({...r,position:t});return ct.applyTrailShaderParameters(i),Dt(i,e),i}if("decal"===e.target){const t=nt.or(pt),a=null!=r.discard?t.or(r.discard):t,i=new d({...r,transparent:!1,discard:a});return i.userData.isDecal=!0,Dt(i,e),i}const i=new d({transparent:!1,...r});return Dt(i,e),i}export function buildShaderGraphPostProcessMaterial(e,t={}){const a=null!=t.previewNodeId?At(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 At(e,t,a=it){const r=st(a),i=Be("hology_post_process_weight",1),u=ye(null!=t?i.multiply(t):i);return{color:ue(r.rgb,Lt(e),u),transparent:!1,...null!=t?{opacity:t}:{}}}function Lt(e){return e instanceof h?Ve(e,e,e):e instanceof w?Ve(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 jt(e){return"decal"!==e.target&&(e.materialOptions?.transparent??"sprite"===e.target)}function Dt(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 Rt(e){switch(e.type){case"float":return qt(e.value);case"vec2":{const t=e.value;return he(Ve(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 qt(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 qt(e){return he(Ve(e,e,e),1)}function Ft(e){return e instanceof h?Ve(e,e,e).rgb:e instanceof w?Ve(e.x,e.y,0).rgb:e}function Ht(e){return e.rgb}function _t(e,t,a){const r=e.params?.[t];return void 0===r?a:r}function Wt(e,t,a){const r=_t(e,t,a);return"number"==typeof r?r:Number(r??a)}function Yt(e,t){if(null!=(a=e)&&"object"==typeof a&&!Array.isArray(a)&&"value"in a)return Yt(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:Jt(e,r,"literal")}}function Jt(e,a,r){switch(a){case"boolean":return e instanceof c?e:U(Boolean(e));case"float":return e instanceof h?e:q(aa(e,0));case"vec2":return e instanceof w?e:ia(e);case"vec3":return e instanceof S?e:ua(e);case"vec4":return e instanceof T?e:function(e){const[t,a,r,i]=ra(e,4,1);return Ae(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=>aa(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]=ra(e,3);return Ve(a,r,i).rgb}(e);case"rgba":return e instanceof f||e instanceof T?e:oa(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 s||!0===e?.isTexture?Oe(e):(Pt.has(r)||(Pt.add(r),console.warn(`Shader graph parameter "${r}" is missing a texture value; using a 1x1 white fallback texture.`)),Oe(zt))}}function Kt(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 Qt(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&&ea(t))return t;if("float"===t&&ea(e))return e;throw new ShaderGraphCompileError(`Cannot mix ${e} and ${t}`,a)}function Xt(e,t,a){const r=e.subtract(a),i=fe(t),u=P(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 Zt(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 ea(e){return"float"===e||"vec2"===e||"vec3"===e||"vec4"===e||"rgb"===e||"rgba"===e}function ta(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function aa(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 ra(e,a,r=0){if(Array.isArray(e))return Array.from({length:a},(t,a)=>aa(e[a],r));if(e instanceof n||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)=>aa(t[i[a]],r));const u=["r","g","b","a"];if(u.some(e=>null!=t[e]))return Array.from({length:a},(e,a)=>aa(t[u[a]],3===a?1:r))}return Array.from({length:a},()=>aa(e,r))}function ia(e){const[t,a]=ra(e,2);return Pe(t,a)}function ua(e){const[t,a,r]=ra(e,3);return Ve(t,a,r)}function oa(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]=ra(e,4,a);return Ae(r,i,u,o)}function sa(e,t){return t<=1?0:e/(t-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 s,Vector2 as n,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 z,cos as P,cross as V,degrees as A,distance as L,dot as j,exp as D,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 se,mod as ne,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,transpose as Me,textureSampler2d as Oe,timeUniforms as Ce,toonMaterial as ke,translate as Ne,transformed as Ge,triplanarMapping as Ee,twirl as Ue,uniformFloat as Be,uniforms as $e,varyingAttributes as ze,vec2 as Pe,vec3 as Ve,vec4 as Ae,getPaintedMaterialLayerWeight as Le}from"../../shader-nodes/index.js";import{isWgslCompiler as je}from"three-shader-graph";import{SpriteNodeShaderMaterial as De,getSpritePosition as Re}from"../sprite-shader.js";import{oneMinus as qe}from"../../shader-nodes/index.js";import{vectorToRadial as Fe,remap as He,hueShift as _e,blendColor as We,desaturateColor as Ye}from"../../shader-nodes/math.js";import{rectangleFloat as Je,roundedRectangleFloat as Ke}from"../../shader-nodes/shapes.js";import{edgeDepthEffect as Qe,fresnelEffect as Xe,depthFadeEffect as Ze}from"../../shader-nodes/effects.js";import{depthNormal as et,fragmentLinearEyeDepth as tt,sampleSceneDepth as at,sampleSceneLinearEyeDepth as rt,screenUV as it,nearUniformName as ut,farUniformName as ot}from"../../shader-nodes/depth.js";import{sampleSceneColor as st}from"../../shader-nodes/scene-sample.js";import{decalDiscard as nt,decalUV as lt}from"../../shader-nodes/decal.js";import{sampledSurfaceRejectsDecals as pt}from"../../shader-nodes/material-flags.js";import{Trail as ct,trailUV as ht}from"../../effects/vfx/trail-renderer.js";import{SimplexNoiseNode as vt,Voronoi2d as yt,rotateAxis as dt}from"../../shader-nodes/index.js";import{flipbookUv as mt}from"../../shader-nodes/texture-sequence.js";import{parallaxOcclusionMapping as ft}from"../../shader-nodes/pom.js";import{defaultInlineLiteralValueForPort as gt,inlineLiteralTypeForPort as bt,SHADER_GRAPH_NODE_DEFINITIONS as xt}from"./registry.js";import{shaderGraphParameterTypeToValueType as wt}from"./parameters.js";import{attributeVec2 as St,varying as Tt,reflect as It,refract as Mt,dFdx as Ot,dFdy as Ct,fwidth as kt,uniformAmbient as Nt,uniformDirectionalLights as Gt}from"three-shader-graph";import{decalNormal as Et}from"../../shader-nodes/decal.js";import{Curve2 as Ut}from"../../utils/curve.js";import{sampleWaterVolume as Bt}from"../../shader-nodes/water-volume.js";const $t=(()=>{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})(),zt=new Set;const Pt=new class extends v{compile(e){return{out:je(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:Lt(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 s=this.graph.outputs?.ambientOcclusion;null!=s&&(t.ambientOcclusion=this.floatOutput(s,"ambientOcclusion"));const n=this.graph.outputs?.ambientOcclusionIntensity;null!=n&&(t.ambientOcclusionIntensity=this.floatOutput(n,"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")):st(e),r=this.graph.outputs?.opacity;return Vt(a,null!=r?this.expectType(this.resolveOutputBinding(r,"opacity"),["float"],"opacity").value:void 0,e)}screenUv(){return this.options.screenUV??it}applyShadingModel(e){const t=null!=e.opacity?function(e,t){if(e instanceof h)return he(Ve(e,e,e),t);if(e instanceof w)return he(Ve(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:qt(t),roughness:e.roughness??q(.5),...null!=e.metalness?{metalness:e.metalness}:{},..."decal"===this.graph.target?{normal:le(Tt($e.normalMatrix).multiplyVec(Et))}:{},...null!=e.normal?{normal:e.normal}:{},...null!=e.emissive?{emissive:Ft(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:qt(t),...null!=e.normal?{normal:e.normal}:{},...null!=e.emissive?{emissive:Ft(e.emissive)}:{},...null!=e.ambientOcclusion?{ambientOcclusion:e.ambientOcclusion}:{},...null!=e.ambientOcclusionIntensity?{ambientOcclusionIntensity:e.ambientOcclusionIntensity}:{},...null!=e.bakedLight?{bakedLight:e.bakedLight}:{}};return{...e,color:ke(a)}}case"stylizedCharacter":{const a={color:qt(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:Ft(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==xt[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(ea(_t(e,"value",.5)))}});case"constant.boolean":return this.output(e,{value:{type:"boolean",value:U(Boolean(Ht(e,"value",!1)))}});case"constant.float":return this.output(e,{value:{type:"float",value:q(_t(e,"value",0))}});case"constant.vec2":return this.output(e,{value:{type:"vec2",value:ra(Ht(e,"value",[0,0]))}});case"constant.vec3":return this.output(e,{value:{type:"vec3",value:ia(Ht(e,"value",[0,0,0]))}});case"constant.rgba":return this.output(e,{value:{type:"rgba",value:ua(Ht(e,"value","#ffffff"),_t(e,"alpha",1))}});case"builtin.uv":{let t;return t="trail"===this.graph.target?ht:"decal"===this.graph.target?lt:this.uvAttribute(e),this.output(e,{value:{type:"vec2",value:!0===Ht(e,"flipY",!1)?Pe(t.x,qe(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(Ge.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.worldNormal":{const t="decal"===this.graph.target?le(et):le(G(Me($e.viewMatrix).multiplyVec(Ae(Ge.normal,0)).xyz));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=$e.instanceMatrix.multiplyVec(Ae(0,0,0,1));t=K("USE_BATCHING",t,e=>W.multiplyVec(e));const a=G($e.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(Ge.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:Ce.elapsed}});case"builtin.camera":{const t=Be(ut),a=Be(ot),r=$e.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:$e.viewMatrix}});case"builtin.projectionMatrix":return this.output(e,{value:{type:"mat4",value:$e.projectionMatrix}});case"builtin.modelViewMatrix":return this.output(e,{value:{type:"mat4",value:$e.modelViewMatrix}});case"scene.ambientLight":return this.output(e,{color:{type:"rgb",value:Nt}});case"scene.directionalLight":return this.output(e,{color:{type:"rgb",value:Gt.sum(e=>e.color).divideScalar(re(q(Pt),q(1)))},direction:{type:"vec3",value:Gt.sum(e=>e.direction).divideScalar(re(q(Pt),q(1)))}});case"builtin.particle":return this.output(e,{energy:{type:"float",value:se.energy},color:{type:"rgb",value:se.color},opacity:{type:"float",value:se.opacity},time:{type:"float",value:se.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:qe(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,P)});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,D)});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,ne)});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=Kt(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:He(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=Kt(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:It(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:Mt(t.value,a.value,r)}})}case"math.derivative":{const t=this.expectNumeric(this.input(e,"value")),a=String(Ht(e,"mode","fwidth"));let r;return r="dFdx"===a?Ot(t.value):"dFdy"===a?Ct(t.value):kt(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 Kt(t.type,a.type,e.id),this.output(e,{value:{type:"float",value:j(t.value,a.value)}})}case"math.distance":{const t=this.expectNumeric(this.input(e,"a")),a=this.expectNumeric(this.input(e,"b"));return Kt(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:Ve(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:Ae(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:Ae(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(Ht(e,"component","x"));return this.output(e,{value:{type:"float",value:Xt(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:Xt(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=Ht(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:ta(r.position,oa(a,t.length)),color:i,alpha:ta(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=Ht(e,"curve","Linear"),r=Q(a,t.value)??J(Ut.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=_e(r,i);return"rgba"===t.type||"vec4"===t.type?this.output(e,{value:{type:t.type,value:Ae(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(Ht(e,"mode","multiply")),i=t.value,u=a.value,o="rgba"===t.type||"vec4"===t.type?i.rgb??i.xyz:i,s="rgba"===a.type||"vec4"===a.type?u.rgb??u.xyz:u;let n=We(o,s,r);if("rgba"===a.type||"vec4"===a.type){const e=u.a??u.w;n=ue(o,n,e)}if("rgba"===t.type||"vec4"===t.type){const a=i.a??i.w;return this.output(e,{value:{type:t.type,value:Ae(n,a)}})}return this.output(e,{value:{type:t.type,value:n}})}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=Ye(r,i);return"rgba"===t.type||"vec4"===t.type?this.output(e,{value:{type:t.type,value:Ae(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:z(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:ze.normal}),["vec3"],e.id,"normal"),u=this.expectType(this.input(e,"position",{type:"vec3",value:ze.position}),["vec3"],e.id,"position"),o=Ee(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=st(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:at(t.value)},linearEyeDepth:{type:"float",value:rt(t.value)}})}case"scene.fragmentDepth":return this.output(e,{linearEyeDepth:{type:"float",value:tt}});case"scene.waterVolume":{const t=this.expectType(this.input(e,"uv",{type:"vec2",value:this.screenUv()}),["vec2"],e.id,"uv"),a=Bt(t.value);return this.output(e,{mask:{type:"float",value:a.mask},distance:{type:"float",value:a.distance}})}case"transform.translate":{const t=this.expectType(this.input(e,"offset",{type:"vec3",value:Ve(0,0,0)}),["vec3","rgb"],e.id,"offset");return this.output(e,{value:{type:"mat4",value:Ne(t.value)}})}case"transform.scale":{const t=this.expectType(this.input(e,"scale",{type:"vec3",value:Ve(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:Ve(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:dt(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:Qt(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:Ue(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=Fe(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",_t(e,"columns",1)),r=this.floatInput(e,"rows",_t(e,"rows",1)),i=this.floatInput(e,"fps",_t(e,"fps",60)),u=this.expectType(this.input(e,"time",{type:"float",value:Ce.elapsed}),["float"],e.id,"time").value,o=String(Ht(e,"mode","clamp"));return this.output(e,{value:{type:"vec2",value:mt(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=_t(e,"minLayers",8),o=_t(e,"maxLayers",24);return this.output(e,{value:{type:"vec2",value:ft(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:Je(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:Ke(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 vt(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 yt(t.multiplyScalar(a))}})}case"effect.fresnel":return this.output(e,{value:{type:"float",value:G(Xe(this.floatInput(e,"power",1)))}});case"effect.edgeDepth":{const t=this.floatInput(e,"power",1);return this.output(e,{value:{type:"float",value:Qe(t)}})}case"effect.depthFade":{const t=this.floatInput(e,"distance",1);return this.output(e,{value:{type:"float",value:Ze(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:Ce.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(Ht(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=wt(a.type),i={type:r,value:Yt(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:Jt(e.value,t.value,a,r)};if("mat4"===e.type&&"float"===t.type&&("multiply"===a||"divide"===a))return{type:"mat4",value:Jt(e.value,t.value,a,r)};if("float"===e.type&&"mat4"===t.type&&"multiply"===a)return{type:"mat4",value:Jt(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:Jt(t.value,a.value,r,e.id)};if("float"===t.type&&"float"!==a.type&&"multiply"===r)return{type:a.type,value:Jt(a.value,t.value,r,e.id)};if("float"!==t.type&&"float"===a.type)return{type:t.type,value:Jt(t.value,a.value,r,e.id)};throw new ShaderGraphCompileError(`Cannot ${r} ${t.type} and ${a.type}`,e.id)}expectBinaryMathValue(e){if(!Zt(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:Kt(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=[Le(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=Kt(i,o.type,e.id),a.push(o.value),r.push(Le(t))}return 1===a.length?t:{type:i,value:oe({layerColors:a,layerWeights:r,enableNoise:Boolean(Ht(e,"enableNoise",!0)),noiseScale:this.floatInput(e,"noiseScale",_t(e,"noiseScale",.1)),noiseAmount:this.floatInput(e,"noiseAmount",_t(e,"noiseAmount",.5)),decay:this.floatInput(e,"softness",_t(e,"softness",.3)),mode:"hard"===String(Ht(e,"mode","soft"))?Z.hard:Z.soft})}}defaultUV(){return"trail"===this.graph.target?ht:"decal"===this.graph.target?lt:G(C.uv)}uvAttribute(e){const t=Math.max(0,Math.floor(_t(e,"channel",0)));return 0===t?ze.uv:Tt(St(`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 Wt(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):Wt(e.value,e.valueType)}inlineLiteralFallback(e,t){const a=xt[e.kind]?.inputs.find(e=>e.name===t);if(null==a)return;const r=bt(e.kind,a),i=gt(e.kind,a);return null!=r&&void 0!==i?Wt(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(!Zt(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:Oe(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(Ve(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:Dt(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:Re(new x("rotation",0),new x("screenSpaceSize",0),void 0,!0),uniforms:{color:{value:new t(16777215)}}});if("trail"===e.target){const{position:t}=ct.getTrailShaderNodes(a.trailBillboard??!1),i=new d({...r,position:t});return ct.applyTrailShaderParameters(i),jt(i,e),i}if("decal"===e.target){const t=nt.or(pt),a=null!=r.discard?t.or(r.discard):t,i=new d({...r,transparent:!1,discard:a});return i.userData.isDecal=!0,jt(i,e),i}const i=new d({transparent:!1,...r});return jt(i,e),i}export function buildShaderGraphPostProcessMaterial(e,t={}){const a=null!=t.previewNodeId?Vt(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 Vt(e,t,a=it){const r=st(a),i=Be("hology_post_process_weight",1),u=ye(null!=t?i.multiply(t):i);return{color:ue(r.rgb,At(e),u),transparent:!1,...null!=t?{opacity:t}:{}}}function At(e){return e instanceof h?Ve(e,e,e):e instanceof w?Ve(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 Lt(e){return"decal"!==e.target&&(e.materialOptions?.transparent??"sprite"===e.target)}function jt(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 Dt(e){switch(e.type){case"float":return Rt(e.value);case"vec2":{const t=e.value;return he(Ve(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 Rt(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 Rt(e){return he(Ve(e,e,e),1)}function qt(e){return e instanceof h?Ve(e,e,e).rgb:e instanceof w?Ve(e.x,e.y,0).rgb:e}function Ft(e){return e.rgb}function Ht(e,t,a){const r=e.params?.[t];return void 0===r?a:r}function _t(e,t,a){const r=Ht(e,t,a);return"number"==typeof r?r:Number(r??a)}function Wt(e,t){if(null!=(a=e)&&"object"==typeof a&&!Array.isArray(a)&&"value"in a)return Wt(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:Yt(e,r,"literal")}}function Yt(e,a,r){switch(a){case"boolean":return e instanceof c?e:U(Boolean(e));case"float":return e instanceof h?e:q(ta(e,0));case"vec2":return e instanceof w?e:ra(e);case"vec3":return e instanceof S?e:ia(e);case"vec4":return e instanceof T?e:function(e){const[t,a,r,i]=aa(e,4,1);return Ae(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=>ta(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]=aa(e,3);return Ve(a,r,i).rgb}(e);case"rgba":return e instanceof f||e instanceof T?e:ua(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 s||!0===e?.isTexture?Oe(e):(zt.has(r)||(zt.add(r),console.warn(`Shader graph parameter "${r}" is missing a texture value; using a 1x1 white fallback texture.`)),Oe($t))}}function Jt(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 Kt(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&&Zt(t))return t;if("float"===t&&Zt(e))return e;throw new ShaderGraphCompileError(`Cannot mix ${e} and ${t}`,a)}function Qt(e,t,a){const r=e.subtract(a),i=fe(t),u=P(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 Xt(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 Zt(e){return"float"===e||"vec2"===e||"vec3"===e||"vec4"===e||"rgb"===e||"rgba"===e}function ea(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function ta(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 aa(e,a,r=0){if(Array.isArray(e))return Array.from({length:a},(t,a)=>ta(e[a],r));if(e instanceof n||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)=>ta(t[i[a]],r));const u=["r","g","b","a"];if(u.some(e=>null!=t[e]))return Array.from({length:a},(e,a)=>ta(t[u[a]],3===a?1:r))}return Array.from({length:a},()=>ta(e,r))}function ra(e){const[t,a]=aa(e,2);return Pe(t,a)}function ia(e){const[t,a,r]=aa(e,3);return Ve(t,a,r)}function ua(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]=aa(e,4,a);return Ae(r,i,u,o)}function oa(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,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.worldNormal":{kind:"builtin.worldNormal",label:"World Normal",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"}]},"scene.waterVolume":{kind:"scene.waterVolume",label:"Water Volume",category:"Texture",inputs:[],outputs:[{name:"mask",type:"float"},{name:"distance",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.worldNormal":{kind:"builtin.worldNormal",label:"World Normal",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"}]},"scene.waterVolume":{kind:"scene.waterVolume",label:"Water Volume",category:"Texture",inputs:[{name:"uv",type:"vec2",inlineLiteral:!1}],outputs:[{name:"mask",type:"float"},{name:"distance",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
  */
@@ -1,4 +1,4 @@
1
- import"reflect-metadata";import{reflect as e,decorateProperty as t}from"@plumier/reflect";import{ArrayMap as n}from"../utils/collections.js";Symbol("format");const r=Symbol("parameterDefinition"),a=Symbol("dataAssetDefinition");export function shaderParameterUniformName(e){return`pu_${e}`}class i{constructor(e){this.options=e,this.isParameterDecorator=!0}}new Map;const o=new n,s=new Map,f=new Map,l=new WeakMap,p=new Map,u=new Map,c=new WeakMap;export function ParameterDefinition(e,t={}){return function(n){registerParameterDefinition(e??n.name,n,t)}}export function DataAssetDefinition(e,t={}){return function(n){registerDataAssetDefinition(e??n.name,n,t)}}export function registerParameterDefinition(e,t,n={}){if(null==e||""===e.trim())throw new Error("Parameter definition id must be a non-empty string");const a=s.get(e);null!=a&&a!==t&&console.warn(`Replacing parameter definition "${e}"`,{existing:a,type:t}),s.set(e,t),f.set(e,{id:e,type:t,...!0===n.abstract?{abstract:!0}:{}}),l.set(t,e),Reflect.defineMetadata(r,f.get(e),t)}export function getParameterDefinitionType(e){return s.get(e)}export function registerDataAssetDefinition(e,t,n={}){if(null==e||""===e.trim())throw new Error("Data asset definition id must be a non-empty string");const r=p.get(e);null!=r&&r!==t&&console.warn(`Replacing data asset definition "${e}"`,{existing:r,type:t}),p.set(e,t),u.set(e,{id:e,type:t,...!0===n.abstract?{abstract:!0}:{}}),c.set(t,e),Reflect.defineMetadata(a,u.get(e),t)}export function getDataAssetDefinitionType(e){return p.get(e)}export function getAssignableDataAssetDefinitions(e,t={}){if(null==e)return[];const n=getDataAssetDefinitionId(e);return Array.from(p.entries()).filter(([,t])=>isParameterDefinitionAssignableTo(t,e)).filter(([e])=>!0===t.includeAbstract||!isDataAssetDefinitionAbstract(e)).map(([e,t])=>({id:e,type:t,label:getParameterDefinitionDisplayName(t)})).sort((e,t)=>e.id===n?-1:t.id===n?1:e.label.localeCompare(t.label))}export function getDataAssetDefinitions(e={}){return Array.from(p.entries()).filter(([t])=>!0===e.includeAbstract||!isDataAssetDefinitionAbstract(t)).map(([e,t])=>({id:e,type:t,label:getParameterDefinitionDisplayName(t)})).sort((e,t)=>e.label.localeCompare(t.label))}export function getAssignableParameterDefinitions(e,t={}){if(null==e)return[];const n=getParameterDefinitionId(e);return Array.from(s.entries()).filter(([,t])=>isParameterDefinitionAssignableTo(t,e)).filter(([e])=>!0===t.includeAbstract||!isParameterDefinitionAbstract(e)).map(([e,t])=>({id:e,type:t,label:getParameterDefinitionDisplayName(t)})).sort((e,t)=>e.id===n?-1:t.id===n?1:e.label.localeCompare(t.label))}export function isParameterDefinitionAssignableTo(e,t){return null!=e&&null!=t&&(e===t||e.prototype instanceof t)}export function isParameterDefinitionStructAssignableTo(e,t){return null!=e&&null!=t&&(e===t||isParameterDefinitionAssignableTo(getParameterDefinitionType(e),getParameterDefinitionType(t)))}export function isParameterDefinitionAbstract(e){if(null==e)return!1;const t="string"==typeof e?f.get(e):getParameterDefinitionInfo(e);return!0===t?.abstract}export function isDataAssetDefinitionAbstract(e){if(null==e)return!1;const t="string"==typeof e?u.get(e):getDataAssetDefinitionInfo(e);return!0===t?.abstract}export function getParameterDefinitionDisplayName(e){return("string"==typeof e?e:e.name).replace(/Definition$/,"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/[_-]+/g," ").trim().split(/\s+/).filter(e=>e.length>0).map(e=>e.length<=2&&e===e.toUpperCase()?e:e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}export function getParameterDefinitionId(e){if(null!=e)return l.get(e)??Reflect.getMetadata(r,e)?.id}export function getDataAssetDefinitionId(e){if(null!=e)return c.get(e)??Reflect.getMetadata(a,e)?.id}export function getParameterDefinitionInfo(e){if(null==e)return;const t=getParameterDefinitionId(e);return null!=t?f.get(t)??Reflect.getMetadata(r,e)??{id:t,type:e}:void 0}export function resolveParameterType(e){if(null!=e)return"function"==typeof e&&null==e.prototype?e():e}function m(e,t){const{enum:n,...r}=e,a=n??t;if(null==a||r.options?.length>0)return r;const i=function(e){return Object.entries(e).filter(([e])=>!function(e){return""!==e.trim()&&String(Number(e))===e}(e)).map(([e,t])=>({name:getParameterDefinitionDisplayName(e),value:t}))}(a);return{...r,type:r.type??g(i),defaultValue:void 0!==r.defaultValue?r.defaultValue:i[0]?.value,options:i}}function g(e){const t=new Set(e.map(e=>typeof e.value));if(1===t.size)return t.has("number")?Number:t.has("string")?String:void 0}export function getDataAssetDefinitionInfo(e){if(null==e)return;const t=getDataAssetDefinitionId(e);return null!=t?u.get(t)??Reflect.getMetadata(a,e)??{id:t,type:e}:void 0}export function Parameter(e){return function(n,r,a){if(a&&"object"==typeof a&&"field"===a.kind)return o.push(n,{name:r,options:e??{}}),a.addInitializer&&a.addInitializer(function(){}),Reflect.defineMetadata("isParameterDecorator",!0,n,r),void Reflect.defineMetadata("parameterOptions",e,n,r);if(null!=n){o.push(n.constructor,{name:r,options:e??{}});try{t(new i(e))(n,r,a)}catch(e){console.warn("Failed to decorate method ",n,r,a)}}}}export function extractShaderParameters(e){if(null==e)return[];const t=o.get(e).map(({name:t,options:n})=>{const r=Reflect.getMetadata("parameter:enum",e.prototype,t),a=Reflect.getMetadata("parameter:array",e.prototype,t),i=Reflect.getMetadata("parameter:arrayElementType",e.prototype,t),o=Reflect.getMetadata("parameter:dataAssetOf",e.prototype,t),s=m(n,r),f=Reflect.getMetadata("design:type",e.prototype,t),l=!0===s.array||!0===a||f===Array,p=resolveParameterType(s.type)??(l?i:void 0)??f,u=Reflect.getMetadata("prefab:type",e.prototype,t);return s.prefabOf??(s.prefabOf=u),s.dataAssetOf??(s.dataAssetOf=o),s.array=l,{name:t,type:p,options:s,definition:getParameterDefinitionInfo(p)}});return[...extractShaderParameters(Object.getPrototypeOf(e)).filter(e=>t.every(t=>t.name!==e.name)),...t]}export function ParameterCategory(e){}/*
1
+ import"reflect-metadata";import{reflect as e,decorateProperty as t}from"@plumier/reflect";import{ArrayMap as n}from"../utils/collections.js";Symbol("format");const r=Symbol("parameterDefinition"),a=Symbol("dataAssetDefinition");export function shaderParameterUniformName(e){return`pu_${e}`}class i{constructor(e){this.options=e,this.isParameterDecorator=!0}}new Map;const o=new n,s=new Map,f=new Map,l=new WeakMap,p=new Map,u=new Map,c=new WeakMap;export function ParameterDefinition(e,t={}){return function(n){registerParameterDefinition(e??n.name,n,t)}}export function DataAssetDefinition(e,t={}){return function(n){registerDataAssetDefinition(e??n.name,n,t)}}export function registerParameterDefinition(e,t,n={}){if(null==e||""===e.trim())throw new Error("Parameter definition id must be a non-empty string");const a=s.get(e);null!=a&&a!==t&&console.warn(`Replacing parameter definition "${e}"`,{existing:a,type:t}),s.set(e,t),f.set(e,{id:e,type:t,...!0===n.abstract?{abstract:!0}:{}}),l.set(t,e),Reflect.defineMetadata(r,f.get(e),t)}export function getParameterDefinitionType(e){return s.get(e)}export function registerDataAssetDefinition(e,t,n={}){if(null==e||""===e.trim())throw new Error("Data asset definition id must be a non-empty string");const r=p.get(e);null!=r&&r!==t&&console.warn(`Replacing data asset definition "${e}"`,{existing:r,type:t}),p.set(e,t),u.set(e,{id:e,type:t,...!0===n.abstract?{abstract:!0}:{}}),c.set(t,e),Reflect.defineMetadata(a,u.get(e),t)}export function getDataAssetDefinitionType(e){return p.get(e)}export function getAssignableDataAssetDefinitions(e,t={}){if(null==e)return[];const n=getDataAssetDefinitionId(e);return Array.from(p.entries()).filter(([,t])=>isParameterDefinitionAssignableTo(t,e)).filter(([e])=>!0===t.includeAbstract||!isDataAssetDefinitionAbstract(e)).map(([e,t])=>({id:e,type:t,label:getParameterDefinitionDisplayName(t)})).sort((e,t)=>e.id===n?-1:t.id===n?1:e.label.localeCompare(t.label))}export function getDataAssetDefinitions(e={}){return Array.from(p.entries()).filter(([t])=>!0===e.includeAbstract||!isDataAssetDefinitionAbstract(t)).map(([e,t])=>({id:e,type:t,label:getParameterDefinitionDisplayName(t)})).sort((e,t)=>e.label.localeCompare(t.label))}export function getAssignableParameterDefinitions(e,t={}){if(null==e)return[];const n=getParameterDefinitionId(e);return Array.from(s.entries()).filter(([,t])=>isParameterDefinitionAssignableTo(t,e)).filter(([e])=>!0===t.includeAbstract||!isParameterDefinitionAbstract(e)).map(([e,t])=>({id:e,type:t,label:getParameterDefinitionDisplayName(t)})).sort((e,t)=>e.id===n?-1:t.id===n?1:e.label.localeCompare(t.label))}export function isParameterDefinitionAssignableTo(e,t){return null!=e&&null!=t&&(e===t||e.prototype instanceof t)}export function isParameterDefinitionStructAssignableTo(e,t){return null!=e&&null!=t&&(e===t||isParameterDefinitionAssignableTo(getParameterDefinitionType(e),getParameterDefinitionType(t)))}export function isParameterDefinitionAbstract(e){if(null==e)return!1;const t="string"==typeof e?f.get(e):getParameterDefinitionInfo(e);return!0===t?.abstract}export function isDataAssetDefinitionAbstract(e){if(null==e)return!1;const t="string"==typeof e?u.get(e):getDataAssetDefinitionInfo(e);return!0===t?.abstract}export function getParameterDefinitionDisplayName(e){return("string"==typeof e?e:e.name).replace(/Definition$/,"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/[_-]+/g," ").trim().split(/\s+/).filter(e=>e.length>0).map(e=>e.length<=2&&e===e.toUpperCase()?e:e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}export function getParameterDefinitionId(e){if(null!=e)return l.get(e)??Reflect.getMetadata(r,e)?.id}export function getDataAssetDefinitionId(e){if(null!=e)return c.get(e)??Reflect.getMetadata(a,e)?.id}export function getParameterDefinitionInfo(e){if(null==e)return;const t=getParameterDefinitionId(e);return null!=t?f.get(t)??Reflect.getMetadata(r,e)??{id:t,type:e}:void 0}export function resolveParameterType(e){if(null!=e)return"function"==typeof e&&null==e.prototype?e():e}function m(e){return Object.entries(e).filter(([e])=>!function(e){return""!==e.trim()&&String(Number(e))===e}(e)).map(([e,t])=>({name:getParameterDefinitionDisplayName(e),value:t}))}function g(e){const t=new Set(e.map(e=>typeof e.value));if(1===t.size)return t.has("number")?Number:t.has("string")?String:void 0}export function getDataAssetDefinitionInfo(e){if(null==e)return;const t=getDataAssetDefinitionId(e);return null!=t?u.get(t)??Reflect.getMetadata(a,e)??{id:t,type:e}:void 0}export function Parameter(e){return function(n,r,a){if(a&&"object"==typeof a&&"field"===a.kind)return o.push(n,{name:r,options:e??{}}),a.addInitializer&&a.addInitializer(function(){}),Reflect.defineMetadata("isParameterDecorator",!0,n,r),void Reflect.defineMetadata("parameterOptions",e,n,r);if(null!=n){o.push(n.constructor,{name:r,options:e??{}});try{t(new i(e))(n,r,a)}catch(e){console.warn("Failed to decorate method ",n,r,a)}}}}export function extractShaderParameters(e){if(null==e)return[];const t=o.get(e).map(({name:t,options:n})=>{const r=Reflect.getMetadata("parameter:enum",e.prototype,t),a=Reflect.getMetadata("parameter:array",e.prototype,t),i=Reflect.getMetadata("parameter:arrayElementType",e.prototype,t),o=Reflect.getMetadata("parameter:dataAssetOf",e.prototype,t),s=null!=i&&"object"==typeof i&&Object.values(i).length>0&&Object.values(i).every(e=>"string"==typeof e||"number"==typeof e)?i:void 0,f=function(e,t){const{enum:n,...r}=e,a=n??t;if(null==a||r.options?.length>0)return r;const i=m(a);return{...r,type:r.type??g(i),defaultValue:void 0!==r.defaultValue?r.defaultValue:i[0]?.value,options:i}}(n,r??s),l=Reflect.getMetadata("design:type",e.prototype,t),p=!0===f.array||!0===a||l===Array,u=resolveParameterType(f.type)??(p?null!=s?g(m(s)):i:void 0)??l,c=Reflect.getMetadata("prefab:type",e.prototype,t);return f.prefabOf??(f.prefabOf=c),f.dataAssetOf??(f.dataAssetOf=o),f.array=p,{name:t,type:u,options:f,definition:getParameterDefinitionInfo(u)}});return[...extractShaderParameters(Object.getPrototypeOf(e)).filter(e=>t.every(t=>t.name!==e.name)),...t]}export function ParameterCategory(e){}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,4 +1,4 @@
1
- import{__decorate as e,__metadata as t}from"tslib";import*as i from"three";import{attributeFloat as r,attributes as o,batchingMatrix as a,ConstantMat4Node as s,cos as l,float as n,ifDefApply as p,length as c,mix as u,normalize as d,rgba as h,sin as S,step as m,textureSampler2d as y,UniformFloatNode as x,uniforms as v,varying as f,varyingAttributes as g,vec2 as z,vec3 as w,vec4 as M}from"three-shader-graph";import{depthSampler as b,NodeShaderMaterial as N,projectedSceneDepth as F,projectedSceneUV as T}from"../shader-nodes/index.js";import{Parameter as R,Shader as k}from"./shader.js";export const identityTransform=new s(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);const C=p("USE_BATCHING",identityTransform,e=>a);export class SpriteNodeShader extends k{constructor(){super(...arguments),this.instanced=!1}build(){const e=this.output(),t=new x("rotation",0),r=new x("screenSpaceSize",0),o=getSpritePosition(t,r,new x("lockYAxis",0),this.instanced),a=new SpriteNodeShaderMaterial({color:e.color,discard:e.discard,alphaTest:e.alphaTest,transparent:e.transparent??!0,position:o,uniforms:{color:{value:new i.Color(0)}}});return a.spriteRotationNode=t,a.spriteScreenSpaceSizeNode=r,a}}export class SpriteShader extends SpriteNodeShader{constructor(){super(...arguments),this.color=new i.Color("#FFFFFF"),this.opacity=1,this.intensity=1,this.rotation=0,this.lockY=!1,this.screenSpaceSize=0,this.lenseFlare=!1,this.occlusionRadius=.2}output(){let e=n(this.opacity);this.alphaMap&&(e=e.multiply(y(this.alphaMap).sample(g.uv).r));let t=h(this.color,e);if(this.map&&(t=t.multiply(y(this.map).sample(g.uv))),null!=this.intensity&&1!==this.intensity&&(t=h(t.rgb.multiplyScalar(this.intensity),t.a)),this.lenseFlare){const e=n(this.occlusionRadius),i=Y(V(w(0,0,0))),r=Y(V(w(e.multiply(-1),0,0))),o=Y(V(w(e,0,0))),a=Y(V(w(0,e,0))),s=Y(V(w(0,e.multiply(-1),0))),l=i.add(r).add(o).add(a).add(s).divide(5),p=f(l);return{color:h(t.rgb,t.a.multiply(p))}}return{color:t,alphaTest:this.alphaTest}}build(){const e=super.build();return e.rotation=this.rotation,this.lenseFlare&&(e.depthTest=!1,e.depthWrite=!1),this.lockY&&(e.defines.LOCK_Y_AXIS=""),e.uniforms.lockYAxis.value=this.lockY?1:0,null!=this.screenSpaceSize&&this.screenSpaceSize>0&&(e.defines.SCREEN_SPACE_SIZE=""),e.uniforms.screenSpaceSize.value=this.screenSpaceSize,e}}function V(e){let t=v.instanceMatrix.multiplyVec(M(e,1));return t=p("USE_BATCHING",t,e=>a.multiplyVec(e)),v.modelMatrix.multiplyVec(t)}function Y(e){const t=v.projectionMatrix.multiplyVec(v.viewMatrix.multiplyVec(e)),i=t.xyz.divideScalar(t.w),r=T(i.xy),o=b.sample(r).x,a=F(i.z),s=m(a,o.add(n(1e-4))),l=m(n(0),t.w);return s.multiply(l)}e([R(),t("design:type",i.Color)],SpriteShader.prototype,"color",void 0),e([R({range:[0,1]}),t("design:type",Number)],SpriteShader.prototype,"opacity",void 0),e([R({range:[0,10]}),t("design:type",Number)],SpriteShader.prototype,"intensity",void 0),e([R(),t("design:type",Number)],SpriteShader.prototype,"rotation",void 0),e([R(),t("design:type",i.Texture)],SpriteShader.prototype,"map",void 0),e([R(),t("design:type",i.Texture)],SpriteShader.prototype,"alphaMap",void 0),e([R({help:"Sprite will rotate around Y axis to face camera"}),t("design:type",Boolean)],SpriteShader.prototype,"lockY",void 0),e([R({range:[0,1],help:"0 = Perspective (gets smaller with distance), 1 = Screen Space (constant size)"}),t("design:type",Number)],SpriteShader.prototype,"screenSpaceSize",void 0),e([R({help:"Make the sprite behave as a lense flare that appear in front of geometry if center is visible.",label:"Lens Flare"}),t("design:type",Boolean)],SpriteShader.prototype,"lenseFlare",void 0),e([R({range:[0,2],help:"The radius of the occlusion check. Larger radius will make the sprite fade out more gradually.",requires:{lenseFlare:!0}}),t("design:type",Number)],SpriteShader.prototype,"occlusionRadius",void 0);export function getSpritePosition(e,t=n(0),i=n(0),a=!1){const s=a?r("rotation"):e,p=v.modelMatrix.multiply(C).multiply(v.instanceMatrix),h=p.multiplyVec(M(0,0,0,1)).xyz,y=z(c(p.col(0).xyz),c(p.col(1).xyz)),x=c(h.subtract(v.cameraPosition)),f=y.multiplyScalar(u(n(1),x,t)),g=w(v.viewMatrix.col(0).x,v.viewMatrix.col(1).x,v.viewMatrix.col(2).x),b=w(v.viewMatrix.col(0).y,v.viewMatrix.col(1).y,v.viewMatrix.col(2).y),N=d(w(v.cameraPosition.x.subtract(h.x),0,v.cameraPosition.z.subtract(h.z))),F=d(w(N.z,0,N.x.multiply(-1))),T=m(n(.5),i),R=u(g,F,T),k=u(b,w(0,1,0),T),V=o.position.xy.multiply(f),Y=z(l(s).multiply(V.x).subtract(S(s).multiply(V.y)),S(s).multiply(V.x).add(l(s).multiply(V.y))),P=h.add(R.multiplyScalar(Y.x)).add(k.multiplyScalar(Y.y));return v.projectionMatrix.multiplyVec(v.viewMatrix.multiplyVec(M(P,1)))}export class SpriteNodeShaderMaterial extends N{get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new i.Color(e)}get rotation(){return this.uniforms.rotation.value}set rotation(e){this.spriteRotationNode&&(this.spriteRotationNode.value=e),this.uniforms.rotation.value=e}get screenSpaceSize(){return this.uniforms.screenSpaceSize.value}set screenSpaceSize(e){this.spriteScreenSpaceSizeNode&&(this.spriteScreenSpaceSizeNode.value=e),this.uniforms.screenSpaceSize.value=e}get occlusionRadius(){return this.uniforms.occlusionRadius.value}set occlusionRadius(e){this.uniforms.occlusionRadius.value=e}}/*
1
+ import{__decorate as e,__metadata as t}from"tslib";import*as i from"three";import{attributeFloat as r,attributes as o,batchingMatrix as a,ConstantMat4Node as s,cos as n,float as l,FloatNode as p,ifDefApply as c,length as u,Mat4Node as d,mix as h,normalize as S,rgba as m,shaderFunction as y,sin as x,step as v,textureSampler2d as f,UniformFloatNode as M,uniforms as g,varying as z,varyingAttributes as w,vec2 as b,vec3 as N,Vec3Node as R,vec4 as j,Vec4Node as k}from"three-shader-graph";import{depthSampler as F,NodeShaderMaterial as T,projectedSceneDepth as P,projectedSceneUV as Y}from"../shader-nodes/index.js";import{Parameter as A,Shader as C}from"./shader.js";export const identityTransform=new s(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);const V=c("USE_BATCHING",identityTransform,e=>a);export class SpriteNodeShader extends C{constructor(){super(...arguments),this.instanced=!1}build(){const e=this.output(),t=new M("rotation",0),r=new M("screenSpaceSize",0),o=getSpritePosition(t,r,new M("lockYAxis",0),this.instanced),a=new SpriteNodeShaderMaterial({color:e.color,discard:e.discard,alphaTest:e.alphaTest,transparent:e.transparent??!0,position:o,uniforms:{color:{value:new i.Color(0)}}});return a.spriteRotationNode=t,a.spriteScreenSpaceSizeNode=r,a}}export class SpriteShader extends SpriteNodeShader{constructor(){super(...arguments),this.color=new i.Color("#FFFFFF"),this.opacity=1,this.intensity=1,this.rotation=0,this.lockY=!1,this.screenSpaceSize=0,this.lenseFlare=!1,this.occlusionRadius=.2}output(){let e=l(this.opacity);this.alphaMap&&(e=e.multiply(f(this.alphaMap).sample(w.uv).r));let t=m(this.color,e);if(this.map&&(t=t.multiply(f(this.map).sample(w.uv))),null!=this.intensity&&1!==this.intensity&&(t=m(t.rgb.multiplyScalar(this.intensity),t.a)),this.lenseFlare){const e=l(this.occlusionRadius),i=I(E(N(0,0,0))),r=I(E(N(e.multiply(-1),0,0))),o=I(E(N(e,0,0))),a=I(E(N(0,e,0))),s=I(E(N(0,e.multiply(-1),0))),n=i.add(r).add(o).add(a).add(s).divide(5),p=z(n);return{color:m(t.rgb,t.a.multiply(p))}}return{color:t,alphaTest:this.alphaTest}}build(){const e=super.build();return e.rotation=this.rotation,this.lenseFlare&&(e.depthTest=!1,e.depthWrite=!1),this.lockY&&(e.defines.LOCK_Y_AXIS=""),e.uniforms.lockYAxis.value=this.lockY?1:0,null!=this.screenSpaceSize&&this.screenSpaceSize>0&&(e.defines.SCREEN_SPACE_SIZE=""),e.uniforms.screenSpaceSize.value=this.screenSpaceSize,e}}function E(e){let t=g.instanceMatrix.multiplyVec(j(e,1));return t=c("USE_BATCHING",t,e=>a.multiplyVec(e)),g.modelMatrix.multiplyVec(t)}e([A(),t("design:type",i.Color)],SpriteShader.prototype,"color",void 0),e([A({range:[0,1]}),t("design:type",Number)],SpriteShader.prototype,"opacity",void 0),e([A({range:[0,10]}),t("design:type",Number)],SpriteShader.prototype,"intensity",void 0),e([A(),t("design:type",Number)],SpriteShader.prototype,"rotation",void 0),e([A(),t("design:type",i.Texture)],SpriteShader.prototype,"map",void 0),e([A(),t("design:type",i.Texture)],SpriteShader.prototype,"alphaMap",void 0),e([A({help:"Sprite will rotate around Y axis to face camera"}),t("design:type",Boolean)],SpriteShader.prototype,"lockY",void 0),e([A({range:[0,1],help:"0 = Perspective (gets smaller with distance), 1 = Screen Space (constant size)"}),t("design:type",Number)],SpriteShader.prototype,"screenSpaceSize",void 0),e([A({help:"Make the sprite behave as a lense flare that appear in front of geometry if center is visible.",label:"Lens Flare"}),t("design:type",Boolean)],SpriteShader.prototype,"lenseFlare",void 0),e([A({range:[0,2],help:"The radius of the occlusion check. Larger radius will make the sprite fade out more gradually.",requires:{lenseFlare:!0}}),t("design:type",Number)],SpriteShader.prototype,"occlusionRadius",void 0);const _=y({worldPosition:k,viewMatrix:d,projectionMatrix:d},k,({worldPosition:e,viewMatrix:t,projectionMatrix:i})=>{const r=i.multiplyVec(t.multiplyVec(e)),o=r.xyz.divideScalar(r.w);return j(Y(o.xy),b(P(o.z),r.w))}),B=y({projected:k,sceneDepth:p},p,({projected:e,sceneDepth:t})=>v(e.z,t.add(l(1e-4))).multiply(v(l(0),e.w)));function I(e){const t=_({worldPosition:e,viewMatrix:g.viewMatrix,projectionMatrix:g.projectionMatrix});return B({projected:t,sceneDepth:F.sample(t.xy).x})}const D=y({finalModelMatrix:d,viewMatrix:d,projectionMatrix:d,cameraPosition:R,position:R,spriteRotation:p,screenSpaceSize:p,lockYAxis:p},k,({finalModelMatrix:e,viewMatrix:t,projectionMatrix:i,cameraPosition:r,position:o,spriteRotation:a,screenSpaceSize:s,lockYAxis:p})=>{const c=e.multiplyVec(j(0,0,0,1)).xyz,d=b(u(e.col(0).xyz),u(e.col(1).xyz)),m=u(c.subtract(r)),y=d.multiplyScalar(h(l(1),m,s)),f=N(t.col(0).x,t.col(1).x,t.col(2).x),M=N(t.col(0).y,t.col(1).y,t.col(2).y),g=S(N(r.x.subtract(c.x),0,r.z.subtract(c.z))),z=S(N(g.z,0,g.x.multiply(-1))),w=v(l(.5),p),R=h(f,z,w),k=h(M,N(0,1,0),w),F=o.xy.multiply(y),T=b(n(a).multiply(F.x).subtract(x(a).multiply(F.y)),x(a).multiply(F.x).add(n(a).multiply(F.y))),P=c.add(R.multiplyScalar(T.x)).add(k.multiplyScalar(T.y));return i.multiplyVec(t.multiplyVec(j(P,1)))});export function getSpritePosition(e,t=l(0),i=l(0),a=!1){const s=a?r("rotation"):e,n=g.modelMatrix.multiply(V).multiply(g.instanceMatrix);return D({finalModelMatrix:n,viewMatrix:g.viewMatrix,projectionMatrix:g.projectionMatrix,cameraPosition:g.cameraPosition,position:o.position,spriteRotation:s,screenSpaceSize:t,lockYAxis:i})}export class SpriteNodeShaderMaterial extends T{get color(){return this.uniforms.color.value}set color(e){this.uniforms.color.value=new i.Color(e)}get rotation(){return this.uniforms.rotation.value}set rotation(e){this.spriteRotationNode&&(this.spriteRotationNode.value=e),this.uniforms.rotation.value=e}get screenSpaceSize(){return this.uniforms.screenSpaceSize.value}set screenSpaceSize(e){this.spriteScreenSpaceSizeNode&&(this.spriteScreenSpaceSizeNode.value=e),this.uniforms.screenSpaceSize.value=e}get occlusionRadius(){return this.uniforms.occlusionRadius.value}set occlusionRadius(e){this.uniforms.occlusionRadius.value=e}}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,6 +1,6 @@
1
1
  import type { WebGLRenderer } from "three";
2
- import { FloatNode, Mat4Node, Vec2Node } from "three-shader-graph";
3
- import type { Compiler, Vec3Node } from "three-shader-graph";
2
+ import { FloatNode, Mat4Node, Vec2Node, Vec3Node } from "three-shader-graph";
3
+ import type { Compiler } from "three-shader-graph";
4
4
  export declare function supportsDepthTextureExtension(renderer: WebGLRenderer): boolean;
5
5
  export declare const depthUniformName = "hology_depth_map";
6
6
  export declare const resolutionUniformName = "hology_resolution";
@@ -20,8 +20,10 @@ declare class ScreenUvNode extends Vec2Node {
20
20
  }
21
21
  export declare const screenUV: ScreenUvNode;
22
22
  export declare const linearEyeDepth: FloatNode;
23
- /** Reconstructs scene world position without relying on renderer camera builtins. */
24
- export declare function depthWorldPositionFromInverseViewProjection(inverseViewProjection: Mat4Node, uv?: Vec2Node): Vec3Node;
23
+ /** Reconstructs the scene position at a UV, including refracted scene samples. */
24
+ export declare function sampleSceneWorldPosition(uv?: Vec2Node): Vec3Node;
25
+ /** Reconstructs world position at scene depth (or an explicit depth) without renderer camera builtins. */
26
+ export declare function depthWorldPositionFromInverseViewProjection(inverseViewProjection: Mat4Node, uv?: Vec2Node, depth?: FloatNode): Vec3Node;
25
27
  /** Converts projected NDC XY to the UV convention used by scene textures. */
26
28
  export declare function projectedSceneUV(ndc: Vec2Node): Vec2Node;
27
29
  /** Converts projected NDC Z to the depth-buffer convention of the active backend. */