@hology/core 0.0.227 → 0.0.228

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 (51) hide show
  1. package/dist/effects/vfx/trail-renderer.js +1 -1
  2. package/dist/effects/vfx/vfx-materializer.js +1 -1
  3. package/dist/effects/vfx/vfx-renderers.js +1 -1
  4. package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -1
  5. package/dist/gameplay/initiate.d.ts +5 -1
  6. package/dist/gameplay/initiate.js +1 -1
  7. package/dist/gameplay/services/physics/physics-system.d.ts +1 -0
  8. package/dist/gameplay/services/physics/physics-system.js +1 -1
  9. package/dist/gameplay/services/pointer-events.d.ts +2 -0
  10. package/dist/rendering/environment.d.ts +8 -0
  11. package/dist/rendering/environment.js +4 -0
  12. package/dist/rendering/node-material-webgpu-resolver.d.ts +80 -0
  13. package/dist/rendering/node-material-webgpu-resolver.js +4 -0
  14. package/dist/rendering/post-process-effect.d.ts +4 -2
  15. package/dist/rendering/post-process-effect.js +1 -1
  16. package/dist/rendering/webgpu-experimental-backend.d.ts +104 -0
  17. package/dist/rendering/webgpu-experimental-backend.js +4 -0
  18. package/dist/rendering.d.ts +53 -1
  19. package/dist/rendering.js +1 -1
  20. package/dist/scene/materializer.d.ts +47 -2
  21. package/dist/scene/materializer.js +1 -1
  22. package/dist/scene/objects/shapes.d.ts +1 -2
  23. package/dist/scene/objects/shapes.js +1 -1
  24. package/dist/scene/sky.js +1 -1
  25. package/dist/shader/builtin/lambert-shader.d.ts +7 -6
  26. package/dist/shader/builtin/lambert-shader.js +1 -1
  27. package/dist/shader/builtin/landscape-composite-shader.js +1 -1
  28. package/dist/shader/graph/compiler.d.ts +3 -0
  29. package/dist/shader/graph/compiler.js +1 -1
  30. package/dist/shader/sprite-shader.d.ts +5 -2
  31. package/dist/shader/sprite-shader.js +1 -1
  32. package/dist/shader-nodes/depth.d.ts +17 -6
  33. package/dist/shader-nodes/depth.js +1 -1
  34. package/dist/shader-nodes/dither.js +1 -1
  35. package/dist/shader-nodes/glsl-node.js +1 -1
  36. package/dist/shader-nodes/index.d.ts +2 -1
  37. package/dist/shader-nodes/index.js +1 -1
  38. package/dist/shader-nodes/particle.d.ts +10 -4
  39. package/dist/shader-nodes/particle.js +1 -1
  40. package/dist/shader-nodes/pom.d.ts +3 -2
  41. package/dist/shader-nodes/pom.js +1 -1
  42. package/dist/shader-nodes/wgsl-node.d.ts +17 -0
  43. package/dist/shader-nodes/wgsl-node.js +4 -0
  44. package/dist/test/node-material-webgpu-resolver.test.d.ts +2 -0
  45. package/dist/test/node-material-webgpu-resolver.test.js +4 -0
  46. package/dist/test/post-process-effect.test.js +1 -1
  47. package/dist/test/shader-graph.test.js +1 -1
  48. package/dist/test/webgpu-experimental-backend.test.d.ts +2 -0
  49. package/dist/test/webgpu-experimental-backend.test.js +4 -0
  50. package/package.json +11 -4
  51. package/tsconfig.tsbuildinfo +1 -1
@@ -1,4 +1,4 @@
1
- import{BoxCollisionShape as e,CapsuleCollisionShape as t,ConeCollisionShape as r,ConvexPolyhedronCollisionShape as s,CylinderCollisionShape as n,PlaneCollisionShape as i,SphereCollisionShape as o,TrimeshCollisionShape as a}from"../collision/collision-shape.js";import{BoxGeometry as m,PlaneGeometry as h,Vector3 as l,CylinderGeometry as c,SphereGeometry as g,Euler as p,TorusGeometry as u,ConeGeometry as d,CircleGeometry as w,CapsuleGeometry as y}from"three";import{rampGeometry as S}from"./ramp-geometry.js";import{RoundedBoxGeometry as f}from"three/examples/jsm/geometries/RoundedBoxGeometry.js";import{TextGeometry as x}from"three/examples/jsm/geometries/TextGeometry.js";import{Font as b}from"three/examples/jsm/loaders/FontLoader.js";import*as j from"three/examples/fonts/helvetiker_regular.typeface.json";import{createSpiralStairsGeometry as L,createStairsGeometry as z}from"./stairs-geometry.js";function E(e){return{type:"number",default:e}}function k(e){return{type:"number",default:e,float:!0}}function v(e){return{type:"boolean",default:e}}function B(e,t){const r={};for(let s in t)null==e[s]?r[s]=t[s].default:r[s]=e[s];return r}const G={box:{geometry:()=>new m(1,1,1),collision:()=>new e(new l(1,1,1))},ramp:{geometry:()=>S(),collision:()=>new s(S())},plane:new class{constructor(){this.parameters={widthSegments:E(1),heightSegments:E(1)}}geometry(e={}){const t=B(e,this.parameters);return new h(1,1,t.widthSegments,t.heightSegments)}collision(e={}){return new i(1,1)}},cylinder:new class{constructor(){this.parameters={radialSegments:E(12),heightSegments:E(1),openEnded:v(!1)}}geometry(e={}){const t=B(e,this.parameters);return new c(.5,.5,1,t.radialSegments,t.heightSegments,t.openEnded)}collision(e={}){const t=B(e,this.parameters);return new n(.5,.5,1,t.radialSegments,new p(0,1,0))}},sphere:new class{constructor(){this.parameters={withSegments:E(12),heightSegments:E(12)}}geometry(e={}){const t=B(e,this.parameters);return new g(.5,t.withSegments,t.heightSegments)}collision(){return new o(.5)}},torus:new class{constructor(){this.parameters={radius:k(1),tube:k(.3),radialSegments:E(16),tubularSegments:E(50)}}geometry(e={}){const t=B(e,this.parameters);return new u(t.radius,t.tube,t.radialSegments,t.tubularSegments)}collision(e={}){return new a(this.geometry(e))}},cone:new class{constructor(){this.parameters={radialSegments:E(12),heightSegments:E(1),openEnded:v(!1)}}geometry(e={}){const t=B(e,this.parameters);return new d(.5,1,t.radialSegments,t.heightSegments)}collision(e={}){return new r(1,.5)}},circle:new class{constructor(){this.parameters={segments:E(32)}}geometry(e={}){const t=B(e,this.parameters);return new w(.5,t.segments)}collision(e={}){return new a(this.geometry(e))}},capsule:new class{constructor(){this.parameters={radius:k(.5),length:k(1),capSegments:E(8),radialSegments:E(32)}}geometry(e={}){const t=B(e,this.parameters);return new y(t.radius,t.length,t.capSegments,t.radialSegments)}collision(e={}){const r=B(e,this.parameters);return new t(r.length,r.radius)}},roundedBox:new class{constructor(){this.parameters={width:k(1),height:k(1),depth:k(1),segments:E(4),radius:k(.1)}}geometry(e={}){const t=B(e,this.parameters);return new f(t.width,t.height,t.depth,t.segments,t.radius)}collision(t={}){const r=B(t,this.parameters);return new e(new l(r.width,r.height,r.depth))}},text:new class{constructor(){var e;this.parameters={text:(e="Text",{type:"string",default:e}),size:k(1),depth:k(.2)}}geometry(e={}){const t=B(e,this.parameters);return new x(t.text,{font:new b(j),size:t.size,height:t.depth})}collision(e={}){return B(e,this.parameters).text.trim().length,null}},stairs:new class{constructor(){this.parameters={floating:v(!1),width:k(1),height:k(.25),depth:k(.25),steps:E(4)}}geometry(e={}){const t=B(e,this.parameters);return z(t.floating,t.steps,t.depth,t.height,t.width)}collision(e={}){return new a(this.geometry(e))}},stairsSpiral:new class{constructor(){this.parameters={floating:v(!1),width:k(1),height:k(.25),steps:E(4),degrees:E(90),radius:k(.2),flipped:v(!1)}}geometry(e={}){const t=B(e,this.parameters);return L(t.floating,t.steps,t.height,t.width,t.degrees,t.radius,t.flipped)}collision(e={}){return new a(this.geometry(e))}}};export const ShapeLibrary=G;export const ShapeLibraryKeys=Object.keys(ShapeLibrary);/*
1
+ import{BoxCollisionShape as e,CapsuleCollisionShape as t,ConeCollisionShape as r,ConvexPolyhedronCollisionShape as s,CylinderCollisionShape as n,PlaneCollisionShape as i,SphereCollisionShape as o,TrimeshCollisionShape as a}from"../collision/collision-shape.js";import{BoxGeometry as m,PlaneGeometry as h,Vector3 as l,CylinderGeometry as c,SphereGeometry as g,Euler as p,TorusGeometry as u,ConeGeometry as d,CircleGeometry as w,CapsuleGeometry as y}from"three";import{rampGeometry as f}from"./ramp-geometry.js";import{RoundedBoxGeometry as S}from"three/examples/jsm/geometries/RoundedBoxGeometry.js";import{TextGeometry as x}from"three/examples/jsm/geometries/TextGeometry.js";import{Font as j}from"three/examples/jsm/loaders/FontLoader.js";import*as b from"three/examples/fonts/helvetiker_regular.typeface.json";import{createSpiralStairsGeometry as L,createStairsGeometry as z}from"./stairs-geometry.js";import{BufferGeometryUtils as E}from"three/examples/jsm/Addons.js";function k(e){return{type:"number",default:e}}function v(e){return{type:"number",default:e,float:!0}}function B(e){return{type:"boolean",default:e}}function G(e,t){const r={};for(let s in t)null==e[s]?r[s]=t[s].default:r[s]=e[s];return r}const T={box:{geometry:()=>new m(1,1,1),collision:()=>new e(new l(1,1,1))},ramp:{geometry:()=>f(),collision:()=>new s(f())},plane:new class{constructor(){this.parameters={widthSegments:k(1),heightSegments:k(1)}}geometry(e={}){const t=G(e,this.parameters);return new h(1,1,t.widthSegments,t.heightSegments)}collision(e={}){return new i(1,1)}},cylinder:new class{constructor(){this.parameters={radialSegments:k(12),heightSegments:k(1),openEnded:B(!1)}}geometry(e={}){const t=G(e,this.parameters);return new c(.5,.5,1,t.radialSegments,t.heightSegments,t.openEnded)}collision(e={}){const t=G(e,this.parameters);return new n(.5,.5,1,t.radialSegments,new p(0,1,0))}},sphere:new class{constructor(){this.parameters={withSegments:k(12),heightSegments:k(12)}}geometry(e={}){const t=G(e,this.parameters);return new g(.5,t.withSegments,t.heightSegments)}collision(){return new o(.5)}},torus:new class{constructor(){this.parameters={radius:v(1),tube:v(.3),radialSegments:k(16),tubularSegments:k(50)}}geometry(e={}){const t=G(e,this.parameters);return new u(t.radius,t.tube,t.radialSegments,t.tubularSegments)}collision(e={}){return new a(this.geometry(e))}},cone:new class{constructor(){this.parameters={radialSegments:k(12),heightSegments:k(1),openEnded:B(!1)}}geometry(e={}){const t=G(e,this.parameters);return new d(.5,1,t.radialSegments,t.heightSegments)}collision(e={}){return new r(1,.5)}},circle:new class{constructor(){this.parameters={segments:k(32)}}geometry(e={}){const t=G(e,this.parameters);return new w(.5,t.segments)}collision(e={}){return new a(this.geometry(e))}},capsule:new class{constructor(){this.parameters={radius:v(.5),length:v(1),capSegments:k(8),radialSegments:k(32)}}geometry(e={}){const t=G(e,this.parameters);return new y(t.radius,t.length,t.capSegments,t.radialSegments)}collision(e={}){const r=G(e,this.parameters);return new t(r.length,r.radius)}},roundedBox:new class{constructor(){this.parameters={width:v(1),height:v(1),depth:v(1),segments:k(4),radius:v(.1)}}geometry(e={}){const t=G(e,this.parameters),r=new S(t.width,t.height,t.depth,t.segments,t.radius);return E.mergeVertices(r)}collision(t={}){const r=G(t,this.parameters);return new e(new l(r.width,r.height,r.depth))}},text:new class{constructor(){var e;this.parameters={text:(e="Text",{type:"string",default:e}),size:v(1),depth:v(.2)}}geometry(e={}){const t=G(e,this.parameters);return new x(t.text,{font:new j(b),size:t.size,height:t.depth})}collision(e={}){return G(e,this.parameters).text.trim().length,null}},stairs:new class{constructor(){this.parameters={floating:B(!1),width:v(1),height:v(.25),depth:v(.25),steps:k(4)}}geometry(e={}){const t=G(e,this.parameters);return z(t.floating,t.steps,t.depth,t.height,t.width)}collision(e={}){return new a(this.geometry(e))}},stairsSpiral:new class{constructor(){this.parameters={floating:B(!1),width:v(1),height:v(.25),steps:k(4),degrees:k(90),radius:v(.2),flipped:B(!1)}}geometry(e={}){const t=G(e,this.parameters);return L(t.floating,t.steps,t.height,t.width,t.degrees,t.radius,t.flipped)}collision(e={}){return new a(this.geometry(e))}}};export const ShapeLibrary=T;export const ShapeLibraryKeys=Object.keys(ShapeLibrary);/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
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=!1,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 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}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,18 +1,19 @@
1
1
  import { Color, Material, Texture, Vector2 } from 'three';
2
2
  import { Shader } from '../shader.js';
3
+ import { Sampler2DNode } from 'three-shader-graph';
3
4
  export declare class LambertShader extends Shader {
4
5
  color: Color;
5
- map?: Texture;
6
+ map?: Sampler2DNode;
6
7
  opacity: number;
7
- alphaMap?: Texture;
8
+ alphaMap?: Sampler2DNode;
8
9
  emissive?: Color;
9
10
  emissiveIntensity?: number;
10
- emissiveMap?: Texture;
11
- lightMap?: Texture;
11
+ emissiveMap?: Sampler2DNode;
12
+ lightMap?: Sampler2DNode;
12
13
  lightMapIntensity?: number;
13
- aoMap?: Texture;
14
+ aoMap?: Sampler2DNode;
14
15
  aoMapIntensity?: number;
15
- normalMap?: Texture;
16
+ normalMap?: Sampler2DNode;
16
17
  normalScale?: Vector2;
17
18
  envMap?: Texture;
18
19
  vertexColor?: boolean;
@@ -1,4 +1,4 @@
1
- import{__decorate as e,__metadata as t}from"tslib";import{Color as a,Texture as o,Vector2 as i,MeshLambertMaterial as p}from"three";import{Shader as r}from"../shader.js";import{Parameter as s}from"../parameter.js";import{removeObjectUndefined as l}from"../../utils/collections.js";import*as n from"three";export class LambertShader extends r{constructor(){super(...arguments),this.color=new a("#FFFFFF"),this.opacity=1,this.normalScale=new i(1,1),this.vertexColor=!1}build(){return null!=this.map&&(this.map.colorSpace=n.SRGBColorSpace),null!=this.normalMap&&(this.normalMap.colorSpace=n.LinearSRGBColorSpace),null!=this.aoMap&&(this.aoMap.colorSpace=n.LinearSRGBColorSpace),null!=this.emissiveMap&&(this.emissiveMap.colorSpace=n.SRGBColorSpace),null!=this.alphaMap&&(this.alphaMap.colorSpace=n.LinearSRGBColorSpace),null!=this.lightMap&&(this.lightMap.colorSpace=n.LinearSRGBColorSpace),new p(l({color:this.color,opacity:this.opacity,emissive:this.emissive,emissiveIntensity:this.emissiveIntensity,emissiveMap:this.emissiveMap,map:this.map,lightMap:this.lightMap,lightMapIntensity:this.lightMapIntensity,aoMap:this.aoMap,aoMapIntensity:this.aoMapIntensity,normalMap:this.normalMap,normalScale:this.normalScale,alphaMap:this.alphaMap,envMap:this.envMap,vertexColors:this.vertexColor}))}}e([s(),t("design:type",a)],LambertShader.prototype,"color",void 0),e([s({label:"Color Map"}),t("design:type",o)],LambertShader.prototype,"map",void 0),e([s({range:[0,1]}),t("design:type",Number)],LambertShader.prototype,"opacity",void 0),e([s(),t("design:type",o)],LambertShader.prototype,"alphaMap",void 0),e([s(),t("design:type",a)],LambertShader.prototype,"emissive",void 0),e([s({range:[0,1]}),t("design:type",Number)],LambertShader.prototype,"emissiveIntensity",void 0),e([s(),t("design:type",o)],LambertShader.prototype,"emissiveMap",void 0),e([s(),t("design:type",o)],LambertShader.prototype,"lightMap",void 0),e([s(),t("design:type",Number)],LambertShader.prototype,"lightMapIntensity",void 0),e([s(),t("design:type",o)],LambertShader.prototype,"aoMap",void 0),e([s(),t("design:type",Number)],LambertShader.prototype,"aoMapIntensity",void 0),e([s(),t("design:type",o)],LambertShader.prototype,"normalMap",void 0),e([s(),t("design:type",i)],LambertShader.prototype,"normalScale",void 0),e([s(),t("design:type",o)],LambertShader.prototype,"envMap",void 0),e([s(),t("design:type",Boolean)],LambertShader.prototype,"vertexColor",void 0);/*
1
+ import{__decorate as e,__metadata as t}from"tslib";import{Color as a,Texture as o,Vector2 as i}from"three";import{Shader as r}from"../shader.js";import{Parameter as p}from"../parameter.js";import*as s from"three";import{attributes as l,colorToNormal as n,NodeShaderMaterial as m,Sampler2DNode as h,lambertMaterial as d,UniformSampler2d as y,uniformFloat as c,uniformVec3 as v,varying as M,varyingAttributes as S,varyingTransformed as g,UniformVec3Node as u}from"three-shader-graph";import{createPlaceholderTexture as b}from"../../utils/three/placeholder-texture.js";const L=b();export class LambertShader extends r{constructor(){super(...arguments),this.color=new a("#FFFFFF"),this.map=new y("map",L),this.opacity=1,this.alphaMap=new y("alphaMap",L),this.emissiveMap=new y("emissiveMap",L),this.lightMap=new y("lightMap",L),this.aoMap=new y("aoMap",L),this.normalMap=new y("normalMap",L),this.normalScale=new i(1,1),this.vertexColor=!1}build(){f(this.map,s.SRGBColorSpace),f(this.alphaMap,s.LinearSRGBColorSpace),f(this.aoMap,s.LinearSRGBColorSpace),f(this.emissiveMap,s.SRGBColorSpace),f(this.normalMap,s.LinearSRGBColorSpace),f(this.lightMap,s.LinearSRGBColorSpace);const e=S.uv;let t=c("opacity",this.opacity),o=new u("color",(new s.Vector3).setFromColor(this.color),void 0,!1).rgb;if(C(this.map)){const a=this.map.sample(e);o=o.multiply(a.rgb),t=t.multiply(a.a)}C(this.alphaMap)&&(t=t.multiply(this.alphaMap.sample(e).r)),!0===this.vertexColor&&(o=o.multiply(M(l.color.rgb)));let i=null;C(this.lightMap)&&(i=this.lightMap.sample(e).rgb.multiplyScalar(c("lightMapIntensity",this.lightMapIntensity??1)));let r=g.normal;C(this.normalMap)&&(r=n(this.normalMap.sample(e),c("normalScale",this.normalScale?.x??1)));let p=null;C(this.aoMap)&&(p=this.aoMap.sample(e).r);const h=c("aoMapIntensity",this.aoMapIntensity??1);let y=v("emissive",(new s.Vector3).setFromColor(this.emissive??new a(0))).rgb;C(this.emissiveMap)&&(y=y.multiply(this.emissiveMap.sample(e).rgb));const b=c("emissiveIntensity",this.emissiveIntensity??1),L=new m({color:d({color:o.rgba(t),ambientOcclusion:p,ambientOcclusionIntensity:h}),opacity:t,normal:r,emissive:y.multiplyScalar(b)});return L.vertexColors=!0===this.vertexColor,L}}function C(e){return null!=e&&(!(e instanceof y)||null!=e.value&&e.value!==L)}function f(e,t){null!=e&&(e instanceof o?e.colorSpace=t:e instanceof y&&null!=e.value&&(e.value.colorSpace=t))}e([p(),t("design:type",a)],LambertShader.prototype,"color",void 0),e([p({label:"Color Map"}),t("design:type",h)],LambertShader.prototype,"map",void 0),e([p({range:[0,1]}),t("design:type",Number)],LambertShader.prototype,"opacity",void 0),e([p(),t("design:type",h)],LambertShader.prototype,"alphaMap",void 0),e([p(),t("design:type",a)],LambertShader.prototype,"emissive",void 0),e([p({range:[0,1]}),t("design:type",Number)],LambertShader.prototype,"emissiveIntensity",void 0),e([p(),t("design:type",h)],LambertShader.prototype,"emissiveMap",void 0),e([p(),t("design:type",h)],LambertShader.prototype,"lightMap",void 0),e([p(),t("design:type",Number)],LambertShader.prototype,"lightMapIntensity",void 0),e([p(),t("design:type",h)],LambertShader.prototype,"aoMap",void 0),e([p(),t("design:type",Number)],LambertShader.prototype,"aoMapIntensity",void 0),e([p(),t("design:type",h)],LambertShader.prototype,"normalMap",void 0),e([p(),t("design:type",i)],LambertShader.prototype,"normalScale",void 0),e([p(),t("design:type",o)],LambertShader.prototype,"envMap",void 0),e([p(),t("design:type",Boolean)],LambertShader.prototype,"vertexColor",void 0);/*
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 s}from"tslib";import{Material as t,MathUtils as a,MeshBasicMaterial as o,MeshLambertMaterial as l,MeshStandardMaterial as i}from"three";import{cos as r,float as n,mix as p,rgb as h,standardMaterial as u,step as m,varyingAttributes as c,SimplexNoiseNode as d,varying as y,uniforms as f,vec4 as M,attributes as g,smoothstep as b,textureSampler2d as S,rgba as v,NodeShaderMaterial as A,varyingTransformed as w,colorToNormal as C}from"three-shader-graph";import{LayerMixMode as L,mixColorsByLayer as N}from"../../shader-nodes/layers.js";import{Parameter as j}from"../parameter.js";import{NodeShader as x}from"../shader.js";import{ParallaxStandardMaterial as R}from"./standard-shader.js";import{parallaxOcclusionMapping as T}from"../../shader-nodes/pom.js";import{applyUvTiling as B}from"./../../shader/uv-nodes.js";const D=y(f.modelMatrix.multiplyVec(M(g.position,1)).xz),O=new i({color:"gray"});export class LandscapeCompositeShader extends x{constructor(){super(...arguments),this.layers=[],this.transition=L.soft,this.noiseScale=1,this.noiseAmount=.2,this.softness=.3,this.enableSlope=!1,this.slopeAngle=35}build(){const e=super.build();return e.userData.surfaceByLayer=this.layers.map(e=>e?.userData.surface),e}output(){if(0===this.layers.length)return{color:u({color:h("gray")}),landscape:!0};for(let e=0;e<this.layers.length;e++){null==this.layers[e]&&(console.warn("One of the layers in the landscape composite shader is null or undefined. This layer will be rendered as gray. Please make sure to assign a material to all layers.",this.layers),this.layers[e]=O);this.layers[e]instanceof i||this.layers[e]instanceof l||this.layers[e]instanceof o||this.layers[e]instanceof A||(console.warn("One of the layers in the landscape composite shader is not a supported material. This layer will be rendered as gray. Please use a supported material.",this.layers[e]),this.layers[e]=O)}const e=new Map,s=new P,t=c.uv;function y(s,t){let a=t;if(s instanceof R&&null!=s.heightMap){let o=e.get(s);null==o&&(o=T(t,S(s.heightMap),n(s.heightScale??1)),e.set(s,o)),a=o}return a}const f=this.layers.map(e=>{if(e instanceof i||e instanceof l||e instanceof o){let s=v(e.color,1);return null!=e.map&&(s=s.multiply(S(e.map).sample(y(e,B(t,e.map))))),s}return e instanceof A&&null!=e.outputAlbedo?e.outputAlbedo.rgba(1):v("white")}),M=this.layers.map(e=>{if(e instanceof i||e instanceof l){if(null!=e.normalMap)return C(S(e.normalMap).sample(y(e,B(t,e.normalMap))),e.normalScale?.x??1)}else if(e instanceof A&&null!=e.outputNormal)return e.outputNormal;return w.normal}),g=this.layers.map(e=>{let a=n(1);return e instanceof i?(a=n(e.roughness??1),null!=e.roughnessMap&&(a=a.multiply(s.get(e.roughnessMap,y(e,B(t,e.roughnessMap))).g))):e instanceof A&&null!=e.outputRoughness&&(a=e.outputRoughness),a}),j=this.layers.map(e=>{let a=n(0);return e instanceof i?(a=n(e.metalness??0),null!=e.metalnessMap&&(a=a.multiply(s.get(e.metalnessMap,y(e,B(t,e.metalnessMap))).b))):e instanceof A&&null!=e.outputMetalness&&(a=e.outputMetalness),a});let x,k,z,H;if(this.enableSlope&&null!=this.slopeMaterial)if(this.slopeMaterial instanceof i){const e=y(this.slopeMaterial,t);x=v(this.slopeMaterial.color,1),null!=this.slopeMaterial.map&&(x=x.multiply(s.get(this.slopeMaterial.map,B(e,this.slopeMaterial.map)))),k=w.normal,null!=this.slopeMaterial.normalMap&&(k=C(s.get(this.slopeMaterial.normalMap,B(e,this.slopeMaterial.normalMap)),this.slopeMaterial.normalScale?.x??1)),z=n(this.slopeMaterial.roughness??1),null!=this.slopeMaterial.roughnessMap&&(z=z.multiply(s.get(this.slopeMaterial.roughnessMap,B(e,this.slopeMaterial.roughnessMap)).g)),H=n(this.slopeMaterial.metalness??0),null!=this.slopeMaterial.metalnessMap&&(H=H.multiply(s.get(this.slopeMaterial.metalnessMap,B(e,this.slopeMaterial.metalnessMap)).b))}else this.slopeMaterial instanceof A&&(x=this.slopeMaterial.outputAlbedo.rgba(1)??v("white"),k=this.slopeMaterial.outputNormal??w.normal,z=this.slopeMaterial.outputRoughness??n(1),H=this.slopeMaterial.outputMetalness??n(0));const V=(e,s)=>{const t=N({layerColors:e.slice(0,8),noiseScale:this.noiseScale,noiseAmount:this.noiseAmount,mode:this.transition,decay:this.softness}),o=n(this.noiseAmount).multiply(n(.1)),l=n(this.noiseScale),i=new d(D.multiplyScalar(l)).multiply(n(2)).subtract(n(1)).multiply(o),h=n(a.degToRad(this.slopeAngle)).add(i.multiply(n(.1)));let u=p(t,s,m(h,r(c.normal.y)));if(this.transition==L.soft){const e=h,a=n(this.softness).divide(n(2)),o=e.subtract(a),l=e.add(a);u=p(t,s,b(o,l,r(c.normal.y)))}return this.enableSlope&&null!=s?u:t},q=V(f,x),E=V(M,k),F=V(g,z),G=V(j,H);return{color:u({color:q,normal:E,roughness:F,metalness:G}),landscape:!0}}}e([j({type:t}),s("design:type",Array)],LandscapeCompositeShader.prototype,"layers",void 0),e([j({options:[{value:L.hard,name:"Hard"},{value:L.soft,name:"Soft"}]}),s("design:type",Number)],LandscapeCompositeShader.prototype,"transition",void 0),e([j(),s("design:type",Number)],LandscapeCompositeShader.prototype,"noiseScale",void 0),e([j(),s("design:type",Number)],LandscapeCompositeShader.prototype,"noiseAmount",void 0),e([j(),s("design:type",Number)],LandscapeCompositeShader.prototype,"softness",void 0),e([j(),s("design:type",Boolean)],LandscapeCompositeShader.prototype,"enableSlope",void 0),e([j(),s("design:type",t)],LandscapeCompositeShader.prototype,"slopeMaterial",void 0),e([j(),s("design:type",Number)],LandscapeCompositeShader.prototype,"slopeAngle",void 0);class P{constructor(){this.cache=new Map}get(e,s){return this.cache.has(e)||this.cache.set(e,S(e).sample(s)),this.cache.get(e)}}/*
1
+ import{__decorate as e,__metadata as s}from"tslib";import{Material as t,MathUtils as a,MeshBasicMaterial as o,MeshLambertMaterial as l,MeshStandardMaterial as i}from"three";import{cos as r,float as n,mix as p,rgb as h,standardMaterial as u,step as m,varyingAttributes as c,SimplexNoiseNode as d,varying as y,uniforms as f,vec4 as M,attributes as g,smoothstep as b,textureSampler2d as S,rgba as v,NodeShaderMaterial as w,varyingTransformed as A,colorToNormal as C,RendererWorldNormalNode as L,RendererWorldPositionNode as N}from"three-shader-graph";import{LayerMixMode as x,mixColorsByLayer as j}from"../../shader-nodes/layers.js";import{Parameter as R}from"../parameter.js";import{NodeShader as T}from"../shader.js";import{ParallaxStandardMaterial as z}from"./standard-shader.js";import{parallaxOcclusionMapping as B}from"../../shader-nodes/pom.js";import{applyUvTiling as D}from"./../../shader/uv-nodes.js";const O=y(new N(f.modelMatrix.multiplyVec(M(g.position,1)).xyz).xz),P=new L(A.normal),k=new i({color:"gray"});export class LandscapeCompositeShader extends T{constructor(){super(...arguments),this.layers=[],this.transition=x.soft,this.noiseScale=1,this.noiseAmount=.2,this.softness=.3,this.enableSlope=!1,this.slopeAngle=35}build(){const e=super.build();return e.userData.surfaceByLayer=this.layers.map(e=>e?.userData.surface),e}output(){if(0===this.layers.length)return{color:u({color:h("gray")}),landscape:!0};for(let e=0;e<this.layers.length;e++){null==this.layers[e]&&(console.warn("One of the layers in the landscape composite shader is null or undefined. This layer will be rendered as gray. Please make sure to assign a material to all layers.",this.layers),this.layers[e]=k);this.layers[e]instanceof i||this.layers[e]instanceof l||this.layers[e]instanceof o||this.layers[e]instanceof w||(console.warn("One of the layers in the landscape composite shader is not a supported material. This layer will be rendered as gray. Please use a supported material.",this.layers[e]),this.layers[e]=k)}const e=new Map,s=new H,t=c.uv;function y(s,t){let a=t;if(s instanceof z&&null!=s.heightMap){let o=e.get(s);null==o&&(o=B(t,S(s.heightMap),n(s.heightScale??1)),e.set(s,o)),a=o}return a}const f=this.layers.map(e=>{if(e instanceof i||e instanceof l||e instanceof o){let s=v(e.color,1);return null!=e.map&&(s=s.multiply(S(e.map).sample(y(e,D(t,e.map))))),s}return e instanceof w&&null!=e.outputAlbedo?e.outputAlbedo.rgba(1):v("white")}),M=this.layers.map(e=>{if(e instanceof i||e instanceof l){if(null!=e.normalMap)return C(S(e.normalMap).sample(y(e,D(t,e.normalMap))),e.normalScale?.x??1)}else if(e instanceof w&&null!=e.outputNormal)return e.outputNormal;return P}),g=this.layers.map(e=>{let a=n(1);return e instanceof i?(a=n(e.roughness??1),null!=e.roughnessMap&&(a=a.multiply(s.get(e.roughnessMap,y(e,D(t,e.roughnessMap))).g))):e instanceof w&&null!=e.outputRoughness&&(a=e.outputRoughness),a}),A=this.layers.map(e=>{let a=n(0);return e instanceof i?(a=n(e.metalness??0),null!=e.metalnessMap&&(a=a.multiply(s.get(e.metalnessMap,y(e,D(t,e.metalnessMap))).b))):e instanceof w&&null!=e.outputMetalness&&(a=e.outputMetalness),a});let L,N,R,T;if(this.enableSlope&&null!=this.slopeMaterial)if(this.slopeMaterial instanceof i){const e=y(this.slopeMaterial,t);L=v(this.slopeMaterial.color,1),null!=this.slopeMaterial.map&&(L=L.multiply(s.get(this.slopeMaterial.map,D(e,this.slopeMaterial.map)))),N=P,null!=this.slopeMaterial.normalMap&&(N=C(s.get(this.slopeMaterial.normalMap,D(e,this.slopeMaterial.normalMap)),this.slopeMaterial.normalScale?.x??1)),R=n(this.slopeMaterial.roughness??1),null!=this.slopeMaterial.roughnessMap&&(R=R.multiply(s.get(this.slopeMaterial.roughnessMap,D(e,this.slopeMaterial.roughnessMap)).g)),T=n(this.slopeMaterial.metalness??0),null!=this.slopeMaterial.metalnessMap&&(T=T.multiply(s.get(this.slopeMaterial.metalnessMap,D(e,this.slopeMaterial.metalnessMap)).b))}else this.slopeMaterial instanceof w&&(L=this.slopeMaterial.outputAlbedo.rgba(1)??v("white"),N=this.slopeMaterial.outputNormal??P,R=this.slopeMaterial.outputRoughness??n(1),T=this.slopeMaterial.outputMetalness??n(0));const V=(e,s)=>{const t=j({layerColors:e.slice(0,8),noiseScale:this.noiseScale,noiseAmount:this.noiseAmount,mode:this.transition,decay:this.softness}),o=n(this.noiseAmount).multiply(n(.1)),l=n(this.noiseScale),i=new d(O.multiplyScalar(l)).multiply(n(2)).subtract(n(1)).multiply(o),h=n(a.degToRad(this.slopeAngle)).add(i.multiply(n(.1)));let u=p(t,s,m(h,r(c.normal.y)));if(this.transition==x.soft){const e=h,a=n(this.softness).divide(n(2)),o=e.subtract(a),l=e.add(a);u=p(t,s,b(o,l,r(c.normal.y)))}return this.enableSlope&&null!=s?u:t},q=V(f,L),E=V(M,N),F=V(g,R),G=V(A,T);return{color:u({color:q,normal:E,roughness:F,metalness:G}),landscape:!0}}}e([R({type:t}),s("design:type",Array)],LandscapeCompositeShader.prototype,"layers",void 0),e([R({options:[{value:x.hard,name:"Hard"},{value:x.soft,name:"Soft"}]}),s("design:type",Number)],LandscapeCompositeShader.prototype,"transition",void 0),e([R(),s("design:type",Number)],LandscapeCompositeShader.prototype,"noiseScale",void 0),e([R(),s("design:type",Number)],LandscapeCompositeShader.prototype,"noiseAmount",void 0),e([R(),s("design:type",Number)],LandscapeCompositeShader.prototype,"softness",void 0),e([R(),s("design:type",Boolean)],LandscapeCompositeShader.prototype,"enableSlope",void 0),e([R(),s("design:type",t)],LandscapeCompositeShader.prototype,"slopeMaterial",void 0),e([R(),s("design:type",Number)],LandscapeCompositeShader.prototype,"slopeAngle",void 0);class H{constructor(){this.cache=new Map}get(e,s){return this.cache.has(e)||this.cache.set(e,S(e).sample(s)),this.cache.get(e)}}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -9,6 +9,8 @@ export declare class ShaderGraphCompileError extends Error {
9
9
  }
10
10
  export interface ShaderGraphCompileOptions {
11
11
  parameters?: Record<string, unknown>;
12
+ /** Overrides builtin.screenUv when compiling for a fullscreen-pass ABI. */
13
+ screenUV?: Vec2Node;
12
14
  }
13
15
  interface ShaderGraphMaterialBuildOptions extends ShaderGraphCompileOptions {
14
16
  previewNodeId?: string;
@@ -51,6 +53,7 @@ export declare class ShaderGraphCompiler {
51
53
  private validateNamedReroutes;
52
54
  private compileOutput;
53
55
  private compilePostProcessOutput;
56
+ private screenUv;
54
57
  private applyShadingModel;
55
58
  compileNode(id: string): CompiledShaderGraphNode;
56
59
  private compileNodeInternal;
@@ -1,4 +1,4 @@
1
- import{BackSide as t,Color as e,DataTexture as a,DoubleSide as r,FrontSide as u,Matrix4 as i,RGBAFormat as o,Texture as n,Vector2 as s,Vector3 as l,Vector4 as p}from"three";import{BooleanNode as c,FloatNode as h,Mat4Node as v,NodeShaderMaterial as y,RgbNode as d,RgbaNode as m,Sampler2DNode as f,Texture2dLookupNode as g,UniformFloatNode as b,Vec2Node as x,Vec3Node as w,Vec4Node as S,abs as T,acos as I,asin as O,attributes as M,atan as N,atan2 as C,autoVarying as E,bulge as G,bool as U,ceil as B,clamp as $,colorToNormal as k,cos as z,cross as A,degrees as P,distance as V,dot as j,exp as D,exp2 as L,float as R,floor as q,fract as F,inversesqrt as _,batchingMatrix as W,colorGradientSampler as H,curveSampler as Y,ifDefApply as J,sampleNamedEasingCurve as K,length as Q,LayerMixMode as X,log as Z,log2 as tt,mat4 as et,max as at,min as rt,mix as ut,mixColorsByLayer as it,particleUniforms as ot,mod as nt,normalize as st,pow as lt,radians as pt,rgba as ct,rgb as ht,saturate as vt,select as yt,sign as dt,sin as mt,smoothstep as ft,sqrt as gt,standardMaterial as bt,scaleTransform as xt,step as wt,tan as St,textureSampler2d as Tt,timeUniforms as It,toonMaterial as Ot,translate as Mt,transformed as Nt,triplanarMapping as Ct,twirl as Et,uniformFloat as Gt,uniforms as Ut,varyingAttributes as Bt,vec2 as $t,vec3 as kt,vec4 as zt,getPaintedMaterialLayerWeight as At}from"../../shader-nodes/index.js";import{SpriteNodeShaderMaterial as Pt,getSpritePosition as Vt}from"../sprite-shader.js";import{oneMinus as jt}from"../../shader-nodes/index.js";import{vectorToRadial as Dt,remap as Lt,hueShift as Rt,blendColor as qt,desaturateColor as Ft}from"../../shader-nodes/math.js";import{rectangleFloat as _t,roundedRectangleFloat as Wt}from"../../shader-nodes/shapes.js";import{edgeDepthEffect as Ht,fresnelEffect as Yt,depthFadeEffect as Jt}from"../../shader-nodes/effects.js";import{fragmentLinearEyeDepth as Kt,sampleSceneDepth as Qt,sampleSceneLinearEyeDepth as Xt,screenUV as Zt,nearUniformName as te,farUniformName as ee}from"../../shader-nodes/depth.js";import{sampleSceneColor as ae}from"../../shader-nodes/scene-sample.js";import{decalDiscard as re,decalUV as ue}from"../../shader-nodes/decal.js";import{Trail as ie,trailUV as oe}from"../../effects/vfx/trail-renderer.js";import{SimplexNoiseNode as ne,Voronoi2d as se,rotateAxis as le}from"../../shader-nodes/index.js";import{flipbookUv as pe}from"../../shader-nodes/texture-sequence.js";import{parallaxOcclusionMapping as ce}from"../../shader-nodes/pom.js";import{defaultInlineLiteralValueForPort as he,inlineLiteralTypeForPort as ve,SHADER_GRAPH_NODE_DEFINITIONS as ye}from"./registry.js";import{shaderGraphParameterTypeToValueType as de}from"./parameters.js";import{attributeVec2 as me,varying as fe,reflect as ge,refract as be,dFdx as xe,dFdy as we,fwidth as Se}from"three-shader-graph";import{decalNormal as Te}from"../../shader-nodes/decal.js";import{Curve2 as Ie}from"../../utils/curve.js";const Oe=(()=>{const t=new a(new Uint8Array([255,255,255,255]),1,1,o);return t.name="Missing shader graph texture parameter fallback",t.needsUpdate=!0,t})(),Me=new Set;export class ShaderGraphCompileError extends Error{constructor(t,e,a){super(t),this.nodeId=e,this.port=a,this.name="ShaderGraphCompileError"}}export const shaderGraphPostProcessWeightUniformName="hology_post_process_weight";export class ShaderGraphCompiler{constructor(t,e={}){this.graph=t,this.options=e,this.compiled=new Map,this.compiling=new Set,this.nodesById=new Map((t.nodes??[]).map(t=>[t.id,t]))}validate(){this.compile()}compile(){if(1!==this.graph.version)throw new ShaderGraphCompileError(`Unsupported shader graph version ${this.graph.version}`);return this.validateEdges(),this.validateNamedReroutes(),{output:this.compileOutput(),nodes:this.compiled}}validateEdges(){for(const t of this.graph.edges??[]){if(!this.nodesById.has(t.from.nodeId))throw new ShaderGraphCompileError(`Edge references missing source node "${t.from.nodeId}"`,t.from.nodeId,t.from.port);if(!this.nodesById.has(t.to.nodeId))throw new ShaderGraphCompileError(`Edge references missing target node "${t.to.nodeId}"`,t.to.nodeId,t.to.port)}}validateNamedReroutes(){for(const t of this.graph.nodes??[])"utility.namedRerouteUsage"===t.kind&&this.namedRerouteDeclaration(t)}compileOutput(){if("postProcess"===this.graph.target)return this.compilePostProcessOutput();const t=this.graph.outputs?.color,e={color:null!=t?this.toColorOutput(this.resolveOutputBinding(t,"color")):ct("#ffffff",1),transparent:Ee(this.graph)},a=this.graph.outputs?.opacity;null!=a&&(e.opacity=this.expectType(this.resolveOutputBinding(a,"opacity"),["float"],"opacity").value);const r=this.graph.outputs?.roughness;null!=r&&(e.roughness=this.expectType(this.resolveOutputBinding(r,"roughness"),["float"],"roughness").value);const u=this.graph.outputs?.metalness;null!=u&&(e.metalness=this.floatOutput(u,"metalness"));const i=this.graph.outputs?.normal;null!=i&&(e.normal=this.toVec3Output(this.resolveOutputBinding(i,"normal"),"normal"));const o=this.graph.outputs?.emissive;null!=o&&(e.emissive=this.toVec3Output(this.resolveOutputBinding(o,"emissive"),"emissive"));const n=this.graph.outputs?.ambientOcclusion;null!=n&&(e.ambientOcclusion=this.floatOutput(n,"ambientOcclusion"));const s=this.graph.outputs?.ambientOcclusionIntensity;null!=s&&(e.ambientOcclusionIntensity=this.floatOutput(s,"ambientOcclusionIntensity"));const l=this.graph.outputs?.sheenColor;null!=l&&(e.sheenColor=this.toVec3Output(this.resolveOutputBinding(l,"sheenColor"),"sheenColor"));const p=this.graph.outputs?.sheenRoughness;null!=p&&(e.sheenRoughness=this.floatOutput(p,"sheenRoughness"));const c=this.graph.outputs?.anisotropy;null!=c&&(e.anisotropy=this.floatOutput(c,"anisotropy"));const h=this.graph.outputs?.anisotropyDirection;null!=h&&(e.anisotropyDirection=this.expectType(this.resolveOutputBinding(h,"anisotropyDirection"),["vec2"],"anisotropyDirection").value);const v=this.graph.outputs?.bakedLight;null!=v&&(e.bakedLight=this.toVec3Output(this.resolveOutputBinding(v,"bakedLight"),"bakedLight"));const y=this.graph.outputs?.transform;null!=y&&"decal"!==this.graph.target&&(e.transform=this.toMat4Output(this.resolveOutputBinding(y,"transform"),"transform"));const d=this.graph.outputs?.discard;null!=d&&(e.discard=this.expectType(this.resolveOutputBinding(d,"discard"),["boolean"],"discard").value);const m=this.graph.outputs?.transparent;null!=m&&null!=m.value&&(e.transparent=Boolean(m.value));const f=this.graph.outputs?.alphaTest;return null!=f&&null!=f.value?e.alphaTest=Number(f.value):null!=this.graph.materialOptions?.alphaTest&&(e.alphaTest=this.graph.materialOptions.alphaTest),this.applyShadingModel(e)}compilePostProcessOutput(){const t=this.graph.outputs?.color,e=null!=t?this.toColorOutput(this.resolveOutputBinding(t,"color")):ae(Zt),a=this.graph.outputs?.opacity;return Ne(e,null!=a?this.expectType(this.resolveOutputBinding(a,"opacity"),["float"],"opacity").value:void 0)}applyShadingModel(t){const e=null!=t.opacity?function(t,e){if(t instanceof h)return ct(kt(t,t,t),e);if(t instanceof x)return ct(kt(t.x,t.y,0),e);if(t instanceof S)return ct(t.rgb,t.w.multiply(e));return ct(t,e)}(t.color,t.opacity):t.color;switch(this.graph.shadingModel??"standard"){case"standard":{const a={color:$e(e),roughness:t.roughness??R(.5),...null!=t.metalness?{metalness:t.metalness}:{},..."decal"===this.graph.target?{normal:st(fe(Ut.normalMatrix).multiplyVec(Te))}:{},...null!=t.normal?{normal:t.normal}:{},...null!=t.emissive?{emissive:ke(t.emissive)}:{},...null!=t.ambientOcclusion?{ambientOcclusion:t.ambientOcclusion}:{},...null!=t.ambientOcclusionIntensity?{ambientOcclusionIntensity:t.ambientOcclusionIntensity}:{},...null!=t.sheenColor?{sheenColor:t.sheenColor.rgb}:{},...null!=t.sheenRoughness?{sheenRoughness:t.sheenRoughness}:{},...null!=t.anisotropy?{anisotropy:t.anisotropy}:{},...null!=t.anisotropyDirection?{anisotropyDirection:t.anisotropyDirection}:{},...null!=t.bakedLight?{bakedLight:t.bakedLight}:{}};return{...t,color:bt(a)}}case"toon":{const a={color:$e(e),...null!=t.normal?{normal:t.normal}:{},...null!=t.emissive?{emissive:ke(t.emissive)}:{},...null!=t.ambientOcclusion?{ambientOcclusion:t.ambientOcclusion}:{},...null!=t.ambientOcclusionIntensity?{ambientOcclusionIntensity:t.ambientOcclusionIntensity}:{},...null!=t.bakedLight?{bakedLight:t.bakedLight}:{}};return{...t,color:Ot(a)}}case"unlit":return{...t,color:e}}}compileNode(t){const e=this.compiled.get(t);if(null!=e)return e;const a=this.nodesById.get(t);if(null==a)throw new ShaderGraphCompileError(`Missing shader graph node "${t}"`,t);if(null==ye[a.kind])throw new ShaderGraphCompileError(`Unsupported shader graph node "${a.kind}"`,a.id);if(this.compiling.has(t))throw new ShaderGraphCompileError(`Shader graph contains a cycle involving node "${t}"`,t);this.compiling.add(t);try{const e=this.compileNodeInternal(a);return this.compiled.set(t,e),e}finally{this.compiling.delete(t)}}compileNodeInternal(t){switch(t.kind){case"input.parameter":return this.output(t,this.compileParameterNode(t));case"input.slider":return this.output(t,{value:{type:"float",value:R(Fe(Ae(t,"value",.5)))}});case"constant.boolean":return this.output(t,{value:{type:"boolean",value:U(Boolean(ze(t,"value",!1)))}});case"constant.float":return this.output(t,{value:{type:"float",value:R(Ae(t,"value",0))}});case"constant.vec2":return this.output(t,{value:{type:"vec2",value:He(ze(t,"value",[0,0]))}});case"constant.vec3":return this.output(t,{value:{type:"vec3",value:Ye(ze(t,"value",[0,0,0]))}});case"constant.rgba":return this.output(t,{value:{type:"rgba",value:Je(ze(t,"value","#ffffff"),Ae(t,"alpha",1))}});case"builtin.uv":{let e;return e="trail"===this.graph.target?oe:"decal"===this.graph.target?ue:this.uvAttribute(t),this.output(t,{value:{type:"vec2",value:!0===ze(t,"flipY",!1)?$t(e.x,jt(e.y)):e},u:{type:"float",value:e.x},v:{type:"float",value:e.y}})}case"builtin.screenUv":return this.output(t,{value:{type:"vec2",value:Zt}});case"builtin.color":{const e=E(M.color);return this.output(t,{value:{type:"rgba",value:e},rgb:{type:"rgb",value:e.rgb},r:{type:"float",value:e.r},g:{type:"float",value:e.g},b:{type:"float",value:e.b},a:{type:"float",value:e.a}})}case"builtin.position":{const e=E(M.position);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.worldPosition":{const e=E(Nt.worldPosition);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.objectPosition":{let e=Ut.instanceMatrix.multiplyVec(zt(0,0,0,1));e=J("USE_BATCHING",e,t=>W.multiplyVec(t));const a=E(Ut.modelMatrix.multiplyVec(e).xyz);return this.output(t,{value:{type:"vec3",value:a},x:{type:"float",value:a.x},y:{type:"float",value:a.y},z:{type:"float",value:a.z}})}case"builtin.viewDir":{const e=E(Nt.viewDir);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.normal":{const e=E(M.normal);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.time":return this.output(t,{value:{type:"float",value:It.elapsed}});case"builtin.camera":{const e=Gt(te),a=Gt(ee),r=Ut.cameraPosition;return this.output(t,{position:{type:"vec3",value:r},x:{type:"float",value:r.x},y:{type:"float",value:r.y},z:{type:"float",value:r.z},near:{type:"float",value:e},far:{type:"float",value:a}})}case"builtin.viewMatrix":return this.output(t,{value:{type:"mat4",value:Ut.viewMatrix}});case"builtin.projectionMatrix":return this.output(t,{value:{type:"mat4",value:Ut.projectionMatrix}});case"builtin.modelViewMatrix":return this.output(t,{value:{type:"mat4",value:Ut.modelViewMatrix}});case"builtin.particle":return this.output(t,{energy:{type:"float",value:ot.energy},color:{type:"rgb",value:ot.color},opacity:{type:"float",value:ot.opacity},time:{type:"float",value:ot.time}});case"math.add":case"math.subtract":case"math.multiply":case"math.divide":return this.output(t,{value:this.compileBinaryMath(t)});case"math.oneMinus":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:e.type,value:jt(e.value)}})}case"math.abs":return this.output(t,{value:this.compileUnaryMath(t,T)});case"math.sign":return this.output(t,{value:this.compileUnaryMath(t,dt)});case"math.floor":return this.output(t,{value:this.compileUnaryMath(t,q)});case"math.ceil":return this.output(t,{value:this.compileUnaryMath(t,B)});case"math.fract":return this.output(t,{value:this.compileUnaryMath(t,F)});case"math.sin":return this.output(t,{value:this.compileUnaryMath(t,mt)});case"math.cos":return this.output(t,{value:this.compileUnaryMath(t,z)});case"math.tan":return this.output(t,{value:this.compileUnaryMath(t,St)});case"math.asin":return this.output(t,{value:this.compileUnaryMath(t,O)});case"math.acos":return this.output(t,{value:this.compileUnaryMath(t,I)});case"math.atan":return this.output(t,{value:this.compileUnaryMath(t,N)});case"math.atan2":return this.output(t,{value:this.compileAtan2(t)});case"math.radians":return this.output(t,{value:this.compileUnaryMath(t,pt)});case"math.degrees":return this.output(t,{value:this.compileUnaryMath(t,P)});case"math.sqrt":return this.output(t,{value:this.compileUnaryMath(t,gt)});case"math.inverseSqrt":return this.output(t,{value:this.compileUnaryMath(t,_)});case"math.exp":return this.output(t,{value:this.compileUnaryMath(t,D)});case"math.exp2":return this.output(t,{value:this.compileUnaryMath(t,L)});case"math.log":return this.output(t,{value:this.compileUnaryMath(t,Z)});case"math.log2":return this.output(t,{value:this.compileUnaryMath(t,tt)});case"math.saturate":return this.output(t,{value:this.compileUnaryMath(t,vt)});case"math.length":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:"float",value:Q(e.value)}})}case"math.normalize":return this.output(t,{value:this.compileUnaryMath(t,st)});case"math.clamp":{const e=this.expectNumeric(this.input(t,"value")),a=this.expectNumeric(this.input(t,"min",{type:"float",value:R(0)})),r=this.expectNumeric(this.input(t,"max",{type:"float",value:R(1)}));return this.output(t,{value:{type:e.type,value:$(e.value,a.value,r.value)}})}case"math.min":return this.output(t,{value:this.compileBinaryFunction(t,rt)});case"math.max":return this.output(t,{value:this.compileBinaryFunction(t,at)});case"math.pow":return this.output(t,{value:this.compileBinaryFunction(t,lt)});case"math.mod":return this.output(t,{value:this.compileBinaryFunction(t,nt)});case"math.step":return this.output(t,{value:this.compileBinaryFunction(t,wt,!0)});case"math.smoothstep":{const e=this.expectNumeric(this.input(t,"edge0",{type:"float",value:R(0)})),a=this.expectNumeric(this.input(t,"edge1",{type:"float",value:R(1)})),r=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:r.type,value:ft(e.value,a.value,r.value)}})}case"math.mix":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b")),r=this.expectNumeric(this.input(t,"t",{type:"float",value:R(.5)})),u=De(e.type,a.type,t.id);return this.output(t,{value:{type:u,value:ut(e.value,a.value,r.value)}})}case"math.remap":{const e=this.expectType(this.input(t,"value"),["float"],t.id,"value").value,a=this.floatInput(t,"inMin",-1),r=this.floatInput(t,"inMax",1),u=this.floatInput(t,"outMin",0),i=this.floatInput(t,"outMax",1);return this.output(t,{value:{type:"float",value:Lt(e,a,r,u,i)}})}case"math.select":{const e=this.boolInput(t,"condition",!1),a=this.expectNumeric(this.input(t,"a")),r=this.expectNumeric(this.input(t,"b")),u=De(a.type,r.type,t.id);return this.output(t,{value:{type:u,value:yt(e,a.value,r.value)}})}case"math.reflect":{const e=this.expectType(this.input(t,"incident"),["vec2","vec3","vec4","rgb","rgba"],t.id,"incident"),a=this.expectType(this.input(t,"normal"),["vec2","vec3","vec4","rgb","rgba"],t.id,"normal");return this.output(t,{value:{type:e.type,value:ge(e.value,a.value)}})}case"math.refract":{const e=this.expectType(this.input(t,"incident"),["vec2","vec3","vec4","rgb","rgba"],t.id,"incident"),a=this.expectType(this.input(t,"normal"),["vec2","vec3","vec4","rgb","rgba"],t.id,"normal"),r=this.floatInput(t,"ior",1.5);return this.output(t,{value:{type:e.type,value:be(e.value,a.value,r)}})}case"math.derivative":{const e=this.expectNumeric(this.input(t,"value")),a=String(ze(t,"mode","fwidth"));let r;return r="dFdx"===a?xe(e.value):"dFdy"===a?we(e.value):Se(e.value),this.output(t,{value:{type:e.type,value:r}})}case"layer.mixPainted":return this.output(t,{value:this.compilePaintedLayerMix(t)});case"math.dot":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b"));return De(e.type,a.type,t.id),this.output(t,{value:{type:"float",value:j(e.value,a.value)}})}case"math.distance":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b"));return De(e.type,a.type,t.id),this.output(t,{value:{type:"float",value:V(e.value,a.value)}})}case"math.cross":{const e=this.expectType(this.input(t,"a"),["vec3","rgb"],t.id,"a"),a=this.expectType(this.input(t,"b"),["vec3","rgb"],t.id,"b");return this.output(t,{value:{type:"vec3",value:A(e.value,a.value)}})}case"compare.greaterThan":case"compare.greaterThanOrEqual":case"compare.lessThan":case"compare.lessThanOrEqual":case"compare.equal":case"compare.notEqual":return this.output(t,{value:{type:"boolean",value:this.compileComparison(t)}});case"boolean.not":{const e=this.boolInput(t,"value",!1);return this.output(t,{value:{type:"boolean",value:yt(e,U(!1),U(!0))}})}case"boolean.and":return this.output(t,{value:{type:"boolean",value:this.compileBooleanBinary(t,"and")}});case"boolean.or":return this.output(t,{value:{type:"boolean",value:this.compileBooleanBinary(t,"or")}});case"compose.vec2":return this.output(t,{value:{type:"vec2",value:$t(this.floatInput(t,"x",0),this.floatInput(t,"y",0))}});case"compose.vec3":return this.output(t,{value:{type:"vec3",value:kt(this.floatInput(t,"x",0),this.floatInput(t,"y",0),this.floatInput(t,"z",0))}});case"compose.vec4":return this.output(t,{value:{type:"vec4",value:zt(this.floatInput(t,"x",0),this.floatInput(t,"y",0),this.floatInput(t,"z",0),this.floatInput(t,"w",0))}});case"compose.rgba":return this.output(t,{value:{type:"rgba",value:zt(this.floatInput(t,"r",1),this.floatInput(t,"g",1),this.floatInput(t,"b",1),this.floatInput(t,"a",1))}});case"decompose.component":{const e=this.expectNumeric(this.input(t,"value")),a=String(ze(t,"component","x"));return this.output(t,{value:{type:"float",value:Re(e,a,t.id)}})}case"decompose.split":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,function(t,e){const a={},r=(r,u)=>{a[r]={type:"float",value:Re(t,u,e)}};switch(t.type){case"vec2":return r("x","x"),r("y","y"),r("u","x"),r("v","y"),a;case"vec3":return r("x","x"),r("y","y"),r("z","z"),a;case"rgb":return r("r","r"),r("g","g"),r("b","b"),r("x","x"),r("y","y"),r("z","z"),a;case"vec4":return r("x","x"),r("y","y"),r("z","z"),r("w","w"),a;case"rgba":return r("r","r"),r("g","g"),r("b","b"),r("a","a"),r("x","x"),r("y","y"),r("z","z"),r("w","w"),a;case"float":return a.x={type:"float",value:t.value},a}}(e,t.id))}case"color.gradient":{const e=this.expectType(this.input(t,"t",{type:"float",value:R(.5)}),["float"],t.id,"t"),a=H(function(t){const e=ze(t,"stops",[]);if(!Array.isArray(e))return[];const a=e.map((t,a)=>{if(null==t||"object"!=typeof t||Array.isArray(t))return;const r=t,u="string"==typeof r.color?r.color:"#ffffff";return{position:_e(r.position,Ke(a,e.length)),color:u,alpha:_e(r.alpha,1)}}).filter(t=>null!=t);return a.length>0?a:[]}(t)).sample(e.value);return this.output(t,{value:{type:"rgba",value:a}})}case"utility.curve":{const e=this.expectType(this.input(t,"t",{type:"float",value:R(.5)}),["float"],t.id,"t"),a=ze(t,"curve","Linear"),r=K(a,e.value)??Y(Ie.decode(a)).sample(e.value);return this.output(t,{value:{type:"float",value:r}})}case"utility.namedRerouteDeclaration":return this.output(t,{value:this.input(t,"value")});case"utility.namedRerouteUsage":{const e=this.compileNode(this.namedRerouteDeclaration(t).id);return this.output(t,{value:e.outputs.value})}case"color.hueShift":{const e=this.expectType(this.input(t,"color"),["rgba","rgb","vec4","vec3"],t.id,"color"),a=e.value,r="rgba"===e.type||"vec4"===e.type?a.rgb??a.xyz:a,u=this.floatInput(t,"shift",0),i=Rt(r,u);return"rgba"===e.type||"vec4"===e.type?this.output(t,{value:{type:e.type,value:zt(i,a.a??a.w)}}):this.output(t,{value:{type:e.type,value:i}})}case"color.blend":{const e=this.expectType(this.input(t,"base"),["rgba","rgb","vec4","vec3"],t.id,"base"),a=this.expectType(this.input(t,"blend"),["rgba","rgb","vec4","vec3"],t.id,"blend"),r=String(ze(t,"mode","multiply")),u=e.value,i=a.value,o="rgba"===e.type||"vec4"===e.type?u.rgb??u.xyz:u,n="rgba"===a.type||"vec4"===a.type?i.rgb??i.xyz:i;let s=qt(o,n,r);if("rgba"===a.type||"vec4"===a.type){const t=i.a??i.w;s=ut(o,s,t)}if("rgba"===e.type||"vec4"===e.type){const a=u.a??u.w;return this.output(t,{value:{type:e.type,value:zt(s,a)}})}return this.output(t,{value:{type:e.type,value:s}})}case"color.desaturate":{const e=this.expectType(this.input(t,"color"),["rgba","rgb","vec4","vec3"],t.id,"color"),a=e.value,r="rgba"===e.type||"vec4"===e.type?a.rgb??a.xyz:a,u=this.floatInput(t,"fraction",1),i=Ft(r,u);return"rgba"===e.type||"vec4"===e.type?this.output(t,{value:{type:e.type,value:zt(i,a.a??a.w)}}):this.output(t,{value:{type:e.type,value:i}})}case"color.unpackNormal":{const e=this.expectType(this.input(t,"color"),["vec3","vec4","rgb","rgba"],t.id,"color"),a=this.floatInput(t,"scale",1),r=this.optionalInput(t,"normal");return this.output(t,{value:{type:"vec3",value:k(e.value,a,r?this.expectType(r,["vec3"],t.id,"normal").value:void 0)}})}case"texture.sampler2d":{const e=this.input(t,"texture");return this.output(t,{value:this.toSampler(e,t.id)})}case"texture.sample2d":{const e=this.toSampler(this.input(t,"sampler"),t.id),a=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv"),r=e.value.sample(a.value);return this.output(t,{rgba:{type:"rgba",value:r},rgb:{type:"rgb",value:r.rgb},r:{type:"float",value:r.r},g:{type:"float",value:r.g},b:{type:"float",value:r.b},a:{type:"float",value:r.a}})}case"texture.triplanarMapping":{const e=this.input(t,"sampler"),a=this.toSampler(e,t.id),r=this.expectType(this.input(t,"scale",{type:"float",value:R(1)}),["float"],t.id,"scale"),u=this.expectType(this.input(t,"normal",{type:"vec3",value:Bt.normal}),["vec3"],t.id,"normal"),i=this.expectType(this.input(t,"position",{type:"vec3",value:Bt.position}),["vec3"],t.id,"position"),o=Ct(a.value,r.value,u.value,i.value);return this.output(t,{rgba:{type:"rgba",value:o},rgb:{type:"rgb",value:o.rgb},r:{type:"float",value:o.r},g:{type:"float",value:o.g},b:{type:"float",value:o.b},a:{type:"float",value:o.a}})}case"scene.sampleColor":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:Zt}),["vec2"],t.id,"uv"),a=ae(e.value);return this.output(t,{rgba:{type:"rgba",value:a},rgb:{type:"rgb",value:a.rgb},r:{type:"float",value:a.r},g:{type:"float",value:a.g},b:{type:"float",value:a.b},a:{type:"float",value:a.a}})}case"scene.sampleDepth":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:Zt}),["vec2"],t.id,"uv");return this.output(t,{depth:{type:"float",value:Qt(e.value)},linearEyeDepth:{type:"float",value:Xt(e.value)}})}case"scene.fragmentDepth":return this.output(t,{linearEyeDepth:{type:"float",value:Kt}});case"transform.translate":{const e=this.expectType(this.input(t,"offset",{type:"vec3",value:kt(0,0,0)}),["vec3","rgb"],t.id,"offset");return this.output(t,{value:{type:"mat4",value:Mt(e.value)}})}case"transform.scale":{const e=this.expectType(this.input(t,"scale",{type:"vec3",value:kt(1,1,1)}),["vec3","rgb"],t.id,"scale").value;return this.output(t,{value:{type:"mat4",value:xt(e.x,e.y,e.z)}})}case"transform.rotateAxis":{const e=this.expectType(this.input(t,"axis",{type:"vec3",value:kt(0,1,0)}),["vec3","rgb"],t.id,"axis"),a=this.expectType(this.input(t,"angle",{type:"float",value:R(0)}),["float"],t.id,"angle");return this.output(t,{value:{type:"mat4",value:le(e.value,a.value)}})}case"uv.rotate":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.expectType(this.input(t,"angle",{type:"float",value:R(0)}),["float"],t.id,"angle").value,r=this.expectType(this.input(t,"center",{type:"vec2",value:$t(.5,.5)}),["vec2"],t.id,"center").value;return this.output(t,{value:{type:"vec2",value:Le(e,a,r)}})}case"uv.twirl":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.expectType(this.input(t,"strength",{type:"float",value:R(1)}),["float"],t.id,"strength").value,r=this.expectType(this.input(t,"center",{type:"vec2",value:$t(.5,.5)}),["vec2"],t.id,"center").value,u=this.expectType(this.input(t,"offset",{type:"vec2",value:$t(0,0)}),["vec2"],t.id,"offset").value;return this.output(t,{value:{type:"vec2",value:Et(e,a,r,u)}})}case"uv.radial":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=Dt(e.subtractScalar(.5));return this.output(t,{coords:{type:"vec2",value:a.coords},radius:{type:"float",value:a.radius},angle:{type:"float",value:a.angle}})}case"uv.bulge":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.expectType(this.input(t,"center",{type:"vec2",value:$t(.5,.5)}),["vec2"],t.id,"center").value,r=this.expectType(this.input(t,"power",{type:"float",value:R(1)}),["float"],t.id,"power").value;return this.output(t,{value:{type:"vec2",value:G(e,a,r)}})}case"uv.flipbook":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.floatInput(t,"columns",Ae(t,"columns",1)),r=this.floatInput(t,"rows",Ae(t,"rows",1)),u=this.floatInput(t,"fps",Ae(t,"fps",60)),i=this.expectType(this.input(t,"time",{type:"float",value:It.elapsed}),["float"],t.id,"time").value,o=String(ze(t,"mode","clamp"));return this.output(t,{value:{type:"vec2",value:pe(e,a,r,i,u,o)}})}case"uv.pom":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.input(t,"heightMap"),r=this.toSampler(a,t.id).value,u=this.floatInput(t,"heightScale",.05),i=Ae(t,"minLayers",8),o=Ae(t,"maxLayers",24);return this.output(t,{value:{type:"vec2",value:ce(e,r,u,i,o)}})}case"shape.rectangle":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value;return this.output(t,{value:{type:"float",value:_t(e,this.floatInput(t,"width",.5),this.floatInput(t,"height",.5))}})}case"shape.roundedRectangle":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value;return this.output(t,{value:{type:"float",value:Wt(e,this.floatInput(t,"width",.5),this.floatInput(t,"height",.5),this.floatInput(t,"radius",.1))}})}case"noise.simplex":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.floatInput(t,"scale",8);return this.output(t,{value:{type:"float",value:new ne(e.multiplyScalar(a))}})}case"noise.voronoi2d":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.floatInput(t,"scale",8);return this.output(t,{value:{type:"float",value:new se(e.multiplyScalar(a))}})}case"effect.fresnel":return this.output(t,{value:{type:"float",value:E(Yt(this.floatInput(t,"power",1)))}});case"effect.edgeDepth":{const e=this.floatInput(t,"power",1);return this.output(t,{value:{type:"float",value:Ht(e)}})}case"effect.depthFade":{const e=this.floatInput(t,"distance",1);return this.output(t,{value:{type:"float",value:Jt(e)}})}case"util.panner":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"coord"),a=this.expectType(this.input(t,"speed",{type:"vec2",value:$t(0,0)}),["vec2"],t.id,"speed"),r=this.expectType(this.input(t,"tile",{type:"vec2",value:$t(1,1)}),["vec2"],t.id,"tile"),u=this.expectType(this.input(t,"time",{type:"float",value:It.elapsed}),["float"],t.id,"time");return this.output(t,{value:{type:"vec2",value:e.value.multiply(r.value).add(a.value.multiplyScalar(u.value))}})}}}compileParameterNode(t){const e=String(ze(t,"parameter","")),a=this.graph.parameters?.find(t=>t.name===e||t.id===e);if(null==a)throw new ShaderGraphCompileError(`Parameter "${e}" does not exist`,t.id);const r=de(a.type),u={type:r,value:Ve(this.options.parameters?.[a.name]??a.defaultValue,r,a.name)};if("sampler2d"!==r)return{value:u};const i=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv"),o=u.value.sample(i.value);return{value:{type:"rgba",value:o},rgb:{type:"rgb",value:o.rgb},r:{type:"float",value:o.r},g:{type:"float",value:o.g},b:{type:"float",value:o.b},a:{type:"float",value:o.a},sampler:u}}compileBinaryMath(t){const e=this.expectBinaryMathValue(this.input(t,"a")),a=this.expectBinaryMathValue(this.input(t,"b")),r=t.kind.split(".")[1];if("mat4"===e.type||"mat4"===a.type)return function(t,e,a,r){if("mat4"===t.type&&"mat4"===e.type&&"divide"!==a)return{type:"mat4",value:je(t.value,e.value,a,r)};if("mat4"===t.type&&"float"===e.type&&("multiply"===a||"divide"===a))return{type:"mat4",value:je(t.value,e.value,a,r)};if("float"===t.type&&"mat4"===e.type&&"multiply"===a)return{type:"mat4",value:je(e.value,t.value,a,r)};if("mat4"===t.type&&"vec4"===e.type&&"multiply"===a)return{type:"vec4",value:t.value.multiplyVec(e.value)};throw new ShaderGraphCompileError(`Cannot ${a} ${t.type} and ${e.type}`,r)}(e,a,r,t.id);if(e.type===a.type)return{type:e.type,value:je(e.value,a.value,r,t.id)};if("float"===e.type&&"float"!==a.type&&"multiply"===r)return{type:a.type,value:je(a.value,e.value,r,t.id)};if("float"!==e.type&&"float"===a.type)return{type:e.type,value:je(e.value,a.value,r,t.id)};throw new ShaderGraphCompileError(`Cannot ${r} ${e.type} and ${a.type}`,t.id)}expectBinaryMathValue(t){if(!qe(t.type)&&"mat4"!==t.type)throw new ShaderGraphCompileError(`Expected a numeric value but got ${t.type}`);return t}compileUnaryMath(t,e){const a=this.expectNumeric(this.input(t,"value"));return{type:a.type,value:e(a.value)}}compileAtan2(t){const e=this.expectNumeric(this.input(t,"y")),a=this.expectNumeric(this.input(t,"x"));return{type:function(t,e,a){if(t===e)return t;if("rgb"===t&&"vec3"===e||"vec3"===t&&"rgb"===e)return"vec3";if("rgba"===t&&"vec4"===e||"vec4"===t&&"rgba"===e)return"vec4";throw new ShaderGraphCompileError(`Cannot mix ${t} and ${e}`,a)}(e.type,a.type,t.id),value:C(e.value,a.value)}}compileBinaryFunction(t,e,a=!1){const r=this.expectNumeric(this.input(t,"a")),u=this.expectNumeric(this.input(t,"b"));return{type:a&&"float"===u.type?r.type:De(r.type,u.type,t.id),value:e(r.value,u.value)}}compilePaintedLayerMix(t){const e=this.expectNumeric(this.input(t,"base")),a=[e.value],r=[At(0)];let u=e.type;for(let e=1;e<=8;e++){const i=this.optionalInput(t,`layer${e}`);if(null==i)continue;const o=this.expectNumeric(i);u=De(u,o.type,t.id),a.push(o.value),r.push(At(e))}return 1===a.length?e:{type:u,value:it({layerColors:a,layerWeights:r,enableNoise:Boolean(ze(t,"enableNoise",!0)),noiseScale:this.floatInput(t,"noiseScale",Ae(t,"noiseScale",.1)),noiseAmount:this.floatInput(t,"noiseAmount",Ae(t,"noiseAmount",.5)),decay:this.floatInput(t,"softness",Ae(t,"softness",.3)),mode:"hard"===String(ze(t,"mode","soft"))?X.hard:X.soft})}}defaultUV(){return"trail"===this.graph.target?oe:"decal"===this.graph.target?ue:E(M.uv)}uvAttribute(t){const e=Math.max(0,Math.floor(Ae(t,"channel",0)));return 0===e?Bt.uv:fe(me(`uv${e}`))}namedRerouteDeclaration(t){const e=String(t.params?.declarationId??"");if(0===e.length)throw new ShaderGraphCompileError("Named reroute usage is missing a declaration",t.id);const a=this.nodesById.get(e);if(null==a)throw new ShaderGraphCompileError(`Named reroute declaration "${e}" does not exist`,t.id);if("utility.namedRerouteDeclaration"!==a.kind)throw new ShaderGraphCompileError(`Node "${e}" is not a named reroute declaration`,t.id);return a}input(t,e,a){const r=t.inputs?.[e];if(null!=r)return this.resolveInput(r,t.id,e);const u=(this.graph.edges??[]).find(a=>a.to.nodeId===t.id&&a.to.port===e);if(null!=u)return this.resolveSocket(u.from,t.id,e);if(null!=a)return a;const i=this.inlineLiteralFallback(t,e);if(null!=i)return i;throw new ShaderGraphCompileError(`Missing input "${e}"`,t.id,e)}optionalInput(t,e){const a=t.inputs?.[e];if(null!=a)return this.resolveInput(a,t.id,e);const r=(this.graph.edges??[]).find(a=>a.to.nodeId===t.id&&a.to.port===e);return null!=r?this.resolveSocket(r.from,t.id,e):void 0}floatInput(t,e,a){return this.expectType(this.input(t,e,{type:"float",value:R(a)}),["float"],t.id,e).value}boolInput(t,e,a){return this.expectType(this.input(t,e,{type:"boolean",value:U(a)}),["boolean"],t.id,e).value}compileComparison(t){const e=this.expectType(this.input(t,"a"),["float"],t.id,"a").value,a=this.expectType(this.input(t,"b"),["float"],t.id,"b").value;switch(t.kind){case"compare.greaterThan":return e.gt(a);case"compare.greaterThanOrEqual":return e.gte(a);case"compare.lessThan":return e.lt(a);case"compare.lessThanOrEqual":return e.lte(a);case"compare.equal":return e.equals(a);case"compare.notEqual":return e.notEquals(a)}throw new ShaderGraphCompileError(`Unsupported comparison node "${t.kind}"`,t.id)}compileBooleanBinary(t,e){const a=this.boolInput(t,"a",!1),r=this.boolInput(t,"b",!1);return"and"===e?a.and(r):a.or(r)}resolveOutputBinding(t,e){if(null!=t.input)return this.resolveSocket(t.input,void 0,e);if(void 0!==t.value)return Pe(t.value);throw new ShaderGraphCompileError(`Output "${e}" is missing an input or value`)}floatOutput(t,e){return this.expectType(this.resolveOutputBinding(t,e),["float"],e).value}resolveInput(t,e,a){return function(t){return null!=t.nodeId}(t)?this.resolveSocket(t,e,a):Pe(t.value,t.valueType)}inlineLiteralFallback(t,e){const a=ye[t.kind]?.inputs.find(t=>t.name===e);if(null==a)return;const r=ve(t.kind,a),u=he(t.kind,a);return null!=r&&void 0!==u?Pe(u,r):void 0}resolveSocket(t,e,a){const r=this.compileNode(t.nodeId).outputs[t.port];if(null==r)throw new ShaderGraphCompileError(`Node "${t.nodeId}" does not have output "${t.port}"`,e??t.nodeId,a??t.port);return r}expectType(t,e,a,r){if(!e.includes(t.type))throw new ShaderGraphCompileError(`Expected ${e.join(" or ")} but got ${t.type}`,a,r);return t}expectNumeric(t){if(!qe(t.type))throw new ShaderGraphCompileError(`Expected a numeric value but got ${t.type}`);return t}toSampler(t,e){if("sampler2d"===t.type)return t;if("texture2d"===t.type){const a=t.value;if(null==a)throw new ShaderGraphCompileError("Texture input is empty",e);return{type:"sampler2d",value:Tt(a)}}throw new ShaderGraphCompileError(`Expected texture2d or sampler2d but got ${t.type}`,e)}toColorOutput(t){switch(t.type){case"float":case"vec2":case"vec3":case"vec4":case"rgb":case"rgba":return t.value;case"boolean":{const e=yt(t.value,R(1),R(0));return ct(kt(e,e,e),1)}case"mat4":throw new ShaderGraphCompileError("mat4 values cannot be used as color");case"texture2d":case"sampler2d":throw new ShaderGraphCompileError(`${t.type} must be sampled before it can be used as color`)}}toVec3Output(t,e){if("vec3"===t.type||"rgb"===t.type)return t.value;if("vec4"===t.type||"rgba"===t.type)return t.value.xyz;throw new ShaderGraphCompileError(`Output "${e}" expects vec3/rgb but got ${t.type}`)}toMat4Output(t,e){if("mat4"===t.type)return t.value;throw new ShaderGraphCompileError(`Output "${e}" expects mat4 but got ${t.type}`)}output(t,e){return{node:t,outputs:e}}}export function compileShaderGraph(t,e={}){return new ShaderGraphCompiler(t,e).compile()}export function compileShaderGraphPreview(t,e,a={}){if(null==e)return compileShaderGraph(t,a).output;const r=new ShaderGraphCompiler(t,a).compileNode(e),u=Object.values(r.outputs)[0];if(null==u)throw new ShaderGraphCompileError(`Node "${e}" has no previewable output`,e);return{color:Ue(u),transparent:"rgba"===u.type||"vec4"===u.type}}export function buildShaderGraphMaterial(t,a={}){if("postProcess"===t.target)return buildShaderGraphPostProcessMaterial(t,a);const r=function(t,e,a){const r=a.alphaTest??t.alphaTest??e.materialOptions?.alphaTest;return null!=r?{...t,alphaTest:r}:t}(null!=a.previewNodeId?compileShaderGraphPreview(t,a.previewNodeId,a):compileShaderGraph(t,a).output,t,a);if("sprite"===t.target)return new Pt({color:r.color,discard:r.discard,alphaTest:r.alphaTest,transparent:r.transparent??!0,position:Vt(new b("rotation",0),new b("screenSpaceSize",0)),uniforms:{color:{value:new e(16777215)}}});if("trail"===t.target){const{position:e}=ie.getTrailShaderNodes(a.trailBillboard??!1),u=new y({...r,position:e});return ie.applyTrailShaderParameters(u),Ge(u,t),u}if("decal"===t.target){const e=null!=r.discard?re.or(r.discard):re,a=new y({...r,transparent:!1,discard:e});return a.userData.isDecal=!0,Ge(a,t),a}const u=new y({transparent:!1,...r});return Ge(u,t),u}export function buildShaderGraphPostProcessMaterial(t,e={}){const a=null!=e.previewNodeId?Ne(compileShaderGraphPreview(t,e.previewNodeId,e).color):compileShaderGraph(t,e).output,r=new y({color:a.color,transparent:!1,fog:!1,lights:!1,outputEncoding:!1});return r.depthWrite=!1,r.depthTest=!1,r.toneMapped=!1,r.userData.isPostProcessShaderGraph=!0,r}export function buildShaderGraphInlinePreviewMaterial(t,e,a={}){const r=compileShaderGraphPreview({...t,target:"surface"},e,a),u=new y({color:r.color,transparent:r.transparent??!1,fog:!1,lights:!1});return u.depthWrite=!1,u.depthTest=!1,u.toneMapped=!1,u}function Ne(t,e){const a=ae(Zt),r=Gt("hology_post_process_weight",1),u=vt(null!=e?r.multiply(e):r);return{color:ut(a.rgb,Ce(t),u),transparent:!1,...null!=e?{opacity:e}:{}}}function Ce(t){return t instanceof h?kt(t,t,t):t instanceof x?kt(t.x,t.y,0):t instanceof S?t.xyz:t}export function shaderGraphMaterialSideToThree(e){switch(e){case"back":return t;case"double":return r;default:return u}}function Ee(t){return"decal"!==t.target&&(t.materialOptions?.transparent??"sprite"===t.target)}function Ge(t,e){"surface"===e.target&&(t.side=shaderGraphMaterialSideToThree(e.materialOptions?.side)),null!=e.materialOptions?.transparent&&(t.transparent=e.materialOptions.transparent),null!=e.materialOptions?.bloom&&(t.userData.hasBloom=e.materialOptions.bloom)}function Ue(t){switch(t.type){case"float":return Be(t.value);case"vec2":{const e=t.value;return ct(kt(e.x,e.y,0),1)}case"vec3":case"rgb":return ct(t.value,1);case"vec4":case"rgba":return t.value;case"boolean":return Be(yt(t.value,R(1),R(0)));case"mat4":throw new ShaderGraphCompileError("mat4 values cannot be previewed as color");case"texture2d":case"sampler2d":throw new ShaderGraphCompileError(`${t.type} nodes require a sampled output to preview`)}}function Be(t){return ct(kt(t,t,t),1)}function $e(t){return t instanceof h?kt(t,t,t).rgb:t instanceof x?kt(t.x,t.y,0).rgb:t}function ke(t){return t.rgb}function ze(t,e,a){const r=t.params?.[e];return void 0===r?a:r}function Ae(t,e,a){const r=ze(t,e,a);return"number"==typeof r?r:Number(r??a)}function Pe(t,e){if(null!=(a=t)&&"object"==typeof a&&!Array.isArray(a)&&"value"in a)return Pe(t.value,t.valueType??e);var a;const r=e??function(t){if("boolean"==typeof t)return"boolean";if("number"==typeof t)return"float";if(Array.isArray(t))return 2===t.length?"vec2":3===t.length?"vec3":16===t.length?"mat4":"vec4";return"string"==typeof t?"rgb":"float"}(t);return{type:r,value:Ve(t,r,"literal")}}function Ve(t,a,r){switch(a){case"boolean":return t instanceof c?t:U(Boolean(t));case"float":return t instanceof h?t:R(_e(t,0));case"vec2":return t instanceof x?t:He(t);case"vec3":return t instanceof w?t:Ye(t);case"vec4":return t instanceof S?t:function(t){const[e,a,r,u]=We(t,4,1);return zt(e,a,r,u)}(t);case"mat4":return t instanceof v?t:function(t){if(t instanceof i)return et(t);const e=new i;Array.isArray(t)&&16===t.length&&e.fromArray(t.map(t=>_e(t,0)));return et(e)}(t);case"rgb":return t instanceof d?t:function(t){if("string"==typeof t||"number"==typeof t||t instanceof e)return ht(t);const[a,r,u]=We(t,3);return kt(a,r,u).rgb}(t);case"rgba":return t instanceof m||t instanceof S?t:Je(t);case"texture2d":return t;case"sampler2d":return function(t){const e=t;return t instanceof f||t instanceof g||"function"==typeof e?.isSampler2D||!0===e?.isSampler2D}(t)?t:t instanceof n||!0===t?.isTexture?Tt(t):(Me.has(r)||(Me.add(r),console.warn(`Shader graph parameter "${r}" is missing a texture value; using a 1x1 white fallback texture.`)),Tt(Oe))}}function je(t,e,a,r){const u=`${a}Scalar`;if(e instanceof h&&"function"==typeof t[u])return t[u](e);if("function"==typeof t[a])return t[a](e);throw new ShaderGraphCompileError(`Node does not support ${a}`,r)}function De(t,e,a){if(t===e)return t;if("rgb"===t&&"vec3"===e||"vec3"===t&&"rgb"===e)return"vec3";if("rgba"===t&&"vec4"===e||"vec4"===t&&"rgba"===e)return"vec4";if("float"===t&&qe(e))return e;if("float"===e&&qe(t))return t;throw new ShaderGraphCompileError(`Cannot mix ${t} and ${e}`,a)}function Le(t,e,a){const r=t.subtract(a),u=mt(e),i=z(e);return $t(i.multiply(r.x).subtract(u.multiply(r.y)).add(a.x),u.multiply(r.x).add(i.multiply(r.y)).add(a.y))}function Re(t,e,a){const r=t.value["u"===e?"x":"v"===e?"y":e];if(r instanceof h)return r;throw new ShaderGraphCompileError(`Component "${e}" is not available on ${t.type}`,a)}function qe(t){return"float"===t||"vec2"===t||"vec3"===t||"vec4"===t||"rgb"===t||"rgba"===t}function Fe(t){return Number.isFinite(t)?Math.min(1,Math.max(0,t)):0}function _e(t,e){if("number"==typeof t)return t;if("string"==typeof t){const a=parseFloat(t);return Number.isFinite(a)?a:e}return"boolean"==typeof t?t?1:0:e}function We(t,a,r=0){if(Array.isArray(t))return Array.from({length:a},(e,a)=>_e(t[a],r));if(t instanceof s||t instanceof l||t instanceof p)return Array.from({length:a},(e,a)=>t.toArray()[a]??r);if(t instanceof e){const e=t.toArray();return Array.from({length:a},(t,a)=>e[a]??(3===a?1:r))}if(null!=t&&"object"==typeof t){const e=t,u=["x","y","z","w"];if(u.some(t=>null!=e[t]))return Array.from({length:a},(t,a)=>_e(e[u[a]],r));const i=["r","g","b","a"];if(i.some(t=>null!=e[t]))return Array.from({length:a},(t,a)=>_e(e[i[a]],3===a?1:r))}return Array.from({length:a},()=>_e(t,r))}function He(t){const[e,a]=We(t,2);return $t(e,a)}function Ye(t){const[e,a,r]=We(t,3);return kt(e,a,r)}function Je(t,a=1){if("string"==typeof t||"number"==typeof t||t instanceof e)return ct(t,a);if(t instanceof w)return ct(t,a);const[r,u,i,o]=We(t,4,a);return zt(r,u,i,o)}function Ke(t,e){return e<=1?0:t/(e-1)}/*
1
+ import{BackSide as t,Color as e,DataTexture as a,DoubleSide as r,FrontSide as u,Matrix4 as i,RGBAFormat as o,Texture as n,Vector2 as s,Vector3 as l,Vector4 as p}from"three";import{BooleanNode as c,FloatNode as h,Mat4Node as v,NodeShaderMaterial as y,RgbNode as d,RgbaNode as m,Sampler2DNode as f,Texture2dLookupNode as g,UniformFloatNode as b,Vec2Node as x,Vec3Node as w,Vec4Node as S,abs as T,acos as I,asin as O,attributes as M,atan as N,atan2 as C,autoVarying as E,bulge as G,bool as U,ceil as B,clamp as $,colorToNormal as k,cos as z,cross as A,degrees as V,distance as P,dot as j,exp as D,exp2 as L,float as R,floor as q,fract as F,inversesqrt as _,batchingMatrix as W,colorGradientSampler as H,curveSampler as Y,ifDefApply as J,sampleNamedEasingCurve as K,length as Q,LayerMixMode as X,log as Z,log2 as tt,mat4 as et,max as at,min as rt,mix as ut,mixColorsByLayer as it,particleUniforms as ot,mod as nt,normalize as st,pow as lt,radians as pt,rgba as ct,rgb as ht,saturate as vt,select as yt,sign as dt,sin as mt,smoothstep as ft,sqrt as gt,standardMaterial as bt,scaleTransform as xt,step as wt,tan as St,textureSampler2d as Tt,timeUniforms as It,toonMaterial as Ot,translate as Mt,transformed as Nt,triplanarMapping as Ct,twirl as Et,uniformFloat as Gt,uniforms as Ut,varyingAttributes as Bt,vec2 as $t,vec3 as kt,vec4 as zt,getPaintedMaterialLayerWeight as At}from"../../shader-nodes/index.js";import{SpriteNodeShaderMaterial as Vt,getSpritePosition as Pt}from"../sprite-shader.js";import{oneMinus as jt}from"../../shader-nodes/index.js";import{vectorToRadial as Dt,remap as Lt,hueShift as Rt,blendColor as qt,desaturateColor as Ft}from"../../shader-nodes/math.js";import{rectangleFloat as _t,roundedRectangleFloat as Wt}from"../../shader-nodes/shapes.js";import{edgeDepthEffect as Ht,fresnelEffect as Yt,depthFadeEffect as Jt}from"../../shader-nodes/effects.js";import{fragmentLinearEyeDepth as Kt,sampleSceneDepth as Qt,sampleSceneLinearEyeDepth as Xt,screenUV as Zt,nearUniformName as te,farUniformName as ee}from"../../shader-nodes/depth.js";import{sampleSceneColor as ae}from"../../shader-nodes/scene-sample.js";import{decalDiscard as re,decalUV as ue}from"../../shader-nodes/decal.js";import{Trail as ie,trailUV as oe}from"../../effects/vfx/trail-renderer.js";import{SimplexNoiseNode as ne,Voronoi2d as se,rotateAxis as le}from"../../shader-nodes/index.js";import{flipbookUv as pe}from"../../shader-nodes/texture-sequence.js";import{parallaxOcclusionMapping as ce}from"../../shader-nodes/pom.js";import{defaultInlineLiteralValueForPort as he,inlineLiteralTypeForPort as ve,SHADER_GRAPH_NODE_DEFINITIONS as ye}from"./registry.js";import{shaderGraphParameterTypeToValueType as de}from"./parameters.js";import{attributeVec2 as me,varying as fe,reflect as ge,refract as be,dFdx as xe,dFdy as we,fwidth as Se}from"three-shader-graph";import{decalNormal as Te}from"../../shader-nodes/decal.js";import{Curve2 as Ie}from"../../utils/curve.js";const Oe=(()=>{const t=new a(new Uint8Array([255,255,255,255]),1,1,o);return t.name="Missing shader graph texture parameter fallback",t.needsUpdate=!0,t})(),Me=new Set;export class ShaderGraphCompileError extends Error{constructor(t,e,a){super(t),this.nodeId=e,this.port=a,this.name="ShaderGraphCompileError"}}export const shaderGraphPostProcessWeightUniformName="hology_post_process_weight";export class ShaderGraphCompiler{constructor(t,e={}){this.graph=t,this.options=e,this.compiled=new Map,this.compiling=new Set,this.nodesById=new Map((t.nodes??[]).map(t=>[t.id,t]))}validate(){this.compile()}compile(){if(1!==this.graph.version)throw new ShaderGraphCompileError(`Unsupported shader graph version ${this.graph.version}`);return this.validateEdges(),this.validateNamedReroutes(),{output:this.compileOutput(),nodes:this.compiled}}validateEdges(){for(const t of this.graph.edges??[]){if(!this.nodesById.has(t.from.nodeId))throw new ShaderGraphCompileError(`Edge references missing source node "${t.from.nodeId}"`,t.from.nodeId,t.from.port);if(!this.nodesById.has(t.to.nodeId))throw new ShaderGraphCompileError(`Edge references missing target node "${t.to.nodeId}"`,t.to.nodeId,t.to.port)}}validateNamedReroutes(){for(const t of this.graph.nodes??[])"utility.namedRerouteUsage"===t.kind&&this.namedRerouteDeclaration(t)}compileOutput(){if("postProcess"===this.graph.target)return this.compilePostProcessOutput();const t=this.graph.outputs?.color,e={color:null!=t?this.toColorOutput(this.resolveOutputBinding(t,"color")):ct("#ffffff",1),transparent:Ee(this.graph)},a=this.graph.outputs?.opacity;null!=a&&(e.opacity=this.expectType(this.resolveOutputBinding(a,"opacity"),["float"],"opacity").value);const r=this.graph.outputs?.roughness;null!=r&&(e.roughness=this.expectType(this.resolveOutputBinding(r,"roughness"),["float"],"roughness").value);const u=this.graph.outputs?.metalness;null!=u&&(e.metalness=this.floatOutput(u,"metalness"));const i=this.graph.outputs?.normal;null!=i&&(e.normal=this.toVec3Output(this.resolveOutputBinding(i,"normal"),"normal"));const o=this.graph.outputs?.emissive;null!=o&&(e.emissive=this.toVec3Output(this.resolveOutputBinding(o,"emissive"),"emissive"));const n=this.graph.outputs?.ambientOcclusion;null!=n&&(e.ambientOcclusion=this.floatOutput(n,"ambientOcclusion"));const s=this.graph.outputs?.ambientOcclusionIntensity;null!=s&&(e.ambientOcclusionIntensity=this.floatOutput(s,"ambientOcclusionIntensity"));const l=this.graph.outputs?.sheenColor;null!=l&&(e.sheenColor=this.toVec3Output(this.resolveOutputBinding(l,"sheenColor"),"sheenColor"));const p=this.graph.outputs?.sheenRoughness;null!=p&&(e.sheenRoughness=this.floatOutput(p,"sheenRoughness"));const c=this.graph.outputs?.anisotropy;null!=c&&(e.anisotropy=this.floatOutput(c,"anisotropy"));const h=this.graph.outputs?.anisotropyDirection;null!=h&&(e.anisotropyDirection=this.expectType(this.resolveOutputBinding(h,"anisotropyDirection"),["vec2"],"anisotropyDirection").value);const v=this.graph.outputs?.bakedLight;null!=v&&(e.bakedLight=this.toVec3Output(this.resolveOutputBinding(v,"bakedLight"),"bakedLight"));const y=this.graph.outputs?.transform;null!=y&&"decal"!==this.graph.target&&(e.transform=this.toMat4Output(this.resolveOutputBinding(y,"transform"),"transform"));const d=this.graph.outputs?.discard;null!=d&&(e.discard=this.expectType(this.resolveOutputBinding(d,"discard"),["boolean"],"discard").value);const m=this.graph.outputs?.transparent;null!=m&&null!=m.value&&(e.transparent=Boolean(m.value));const f=this.graph.outputs?.alphaTest;return null!=f&&null!=f.value?e.alphaTest=Number(f.value):null!=this.graph.materialOptions?.alphaTest&&(e.alphaTest=this.graph.materialOptions.alphaTest),this.applyShadingModel(e)}compilePostProcessOutput(){const t=this.screenUv(),e=this.graph.outputs?.color,a=null!=e?this.toColorOutput(this.resolveOutputBinding(e,"color")):ae(t),r=this.graph.outputs?.opacity;return Ne(a,null!=r?this.expectType(this.resolveOutputBinding(r,"opacity"),["float"],"opacity").value:void 0,t)}screenUv(){return this.options.screenUV??Zt}applyShadingModel(t){const e=null!=t.opacity?function(t,e){if(t instanceof h)return ct(kt(t,t,t),e);if(t instanceof x)return ct(kt(t.x,t.y,0),e);if(t instanceof S)return ct(t.rgb,t.w.multiply(e));return ct(t,e)}(t.color,t.opacity):t.color;switch(this.graph.shadingModel??"standard"){case"standard":{const a={color:$e(e),roughness:t.roughness??R(.5),...null!=t.metalness?{metalness:t.metalness}:{},..."decal"===this.graph.target?{normal:st(fe(Ut.normalMatrix).multiplyVec(Te))}:{},...null!=t.normal?{normal:t.normal}:{},...null!=t.emissive?{emissive:ke(t.emissive)}:{},...null!=t.ambientOcclusion?{ambientOcclusion:t.ambientOcclusion}:{},...null!=t.ambientOcclusionIntensity?{ambientOcclusionIntensity:t.ambientOcclusionIntensity}:{},...null!=t.sheenColor?{sheenColor:t.sheenColor.rgb}:{},...null!=t.sheenRoughness?{sheenRoughness:t.sheenRoughness}:{},...null!=t.anisotropy?{anisotropy:t.anisotropy}:{},...null!=t.anisotropyDirection?{anisotropyDirection:t.anisotropyDirection}:{},...null!=t.bakedLight?{bakedLight:t.bakedLight}:{}};return{...t,color:bt(a)}}case"toon":{const a={color:$e(e),...null!=t.normal?{normal:t.normal}:{},...null!=t.emissive?{emissive:ke(t.emissive)}:{},...null!=t.ambientOcclusion?{ambientOcclusion:t.ambientOcclusion}:{},...null!=t.ambientOcclusionIntensity?{ambientOcclusionIntensity:t.ambientOcclusionIntensity}:{},...null!=t.bakedLight?{bakedLight:t.bakedLight}:{}};return{...t,color:Ot(a)}}case"unlit":return{...t,color:e}}}compileNode(t){const e=this.compiled.get(t);if(null!=e)return e;const a=this.nodesById.get(t);if(null==a)throw new ShaderGraphCompileError(`Missing shader graph node "${t}"`,t);if(null==ye[a.kind])throw new ShaderGraphCompileError(`Unsupported shader graph node "${a.kind}"`,a.id);if(this.compiling.has(t))throw new ShaderGraphCompileError(`Shader graph contains a cycle involving node "${t}"`,t);this.compiling.add(t);try{const e=this.compileNodeInternal(a);return this.compiled.set(t,e),e}finally{this.compiling.delete(t)}}compileNodeInternal(t){switch(t.kind){case"input.parameter":return this.output(t,this.compileParameterNode(t));case"input.slider":return this.output(t,{value:{type:"float",value:R(Fe(Ae(t,"value",.5)))}});case"constant.boolean":return this.output(t,{value:{type:"boolean",value:U(Boolean(ze(t,"value",!1)))}});case"constant.float":return this.output(t,{value:{type:"float",value:R(Ae(t,"value",0))}});case"constant.vec2":return this.output(t,{value:{type:"vec2",value:He(ze(t,"value",[0,0]))}});case"constant.vec3":return this.output(t,{value:{type:"vec3",value:Ye(ze(t,"value",[0,0,0]))}});case"constant.rgba":return this.output(t,{value:{type:"rgba",value:Je(ze(t,"value","#ffffff"),Ae(t,"alpha",1))}});case"builtin.uv":{let e;return e="trail"===this.graph.target?oe:"decal"===this.graph.target?ue:this.uvAttribute(t),this.output(t,{value:{type:"vec2",value:!0===ze(t,"flipY",!1)?$t(e.x,jt(e.y)):e},u:{type:"float",value:e.x},v:{type:"float",value:e.y}})}case"builtin.screenUv":return this.output(t,{value:{type:"vec2",value:this.screenUv()}});case"builtin.color":{const e=E(M.color);return this.output(t,{value:{type:"rgba",value:e},rgb:{type:"rgb",value:e.rgb},r:{type:"float",value:e.r},g:{type:"float",value:e.g},b:{type:"float",value:e.b},a:{type:"float",value:e.a}})}case"builtin.position":{const e=E(M.position);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.worldPosition":{const e=E(Nt.worldPosition);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.objectPosition":{let e=Ut.instanceMatrix.multiplyVec(zt(0,0,0,1));e=J("USE_BATCHING",e,t=>W.multiplyVec(t));const a=E(Ut.modelMatrix.multiplyVec(e).xyz);return this.output(t,{value:{type:"vec3",value:a},x:{type:"float",value:a.x},y:{type:"float",value:a.y},z:{type:"float",value:a.z}})}case"builtin.viewDir":{const e=E(Nt.viewDir);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.normal":{const e=E(M.normal);return this.output(t,{value:{type:"vec3",value:e},x:{type:"float",value:e.x},y:{type:"float",value:e.y},z:{type:"float",value:e.z}})}case"builtin.time":return this.output(t,{value:{type:"float",value:It.elapsed}});case"builtin.camera":{const e=Gt(te),a=Gt(ee),r=Ut.cameraPosition;return this.output(t,{position:{type:"vec3",value:r},x:{type:"float",value:r.x},y:{type:"float",value:r.y},z:{type:"float",value:r.z},near:{type:"float",value:e},far:{type:"float",value:a}})}case"builtin.viewMatrix":return this.output(t,{value:{type:"mat4",value:Ut.viewMatrix}});case"builtin.projectionMatrix":return this.output(t,{value:{type:"mat4",value:Ut.projectionMatrix}});case"builtin.modelViewMatrix":return this.output(t,{value:{type:"mat4",value:Ut.modelViewMatrix}});case"builtin.particle":return this.output(t,{energy:{type:"float",value:ot.energy},color:{type:"rgb",value:ot.color},opacity:{type:"float",value:ot.opacity},time:{type:"float",value:ot.time}});case"math.add":case"math.subtract":case"math.multiply":case"math.divide":return this.output(t,{value:this.compileBinaryMath(t)});case"math.oneMinus":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:e.type,value:jt(e.value)}})}case"math.abs":return this.output(t,{value:this.compileUnaryMath(t,T)});case"math.sign":return this.output(t,{value:this.compileUnaryMath(t,dt)});case"math.floor":return this.output(t,{value:this.compileUnaryMath(t,q)});case"math.ceil":return this.output(t,{value:this.compileUnaryMath(t,B)});case"math.fract":return this.output(t,{value:this.compileUnaryMath(t,F)});case"math.sin":return this.output(t,{value:this.compileUnaryMath(t,mt)});case"math.cos":return this.output(t,{value:this.compileUnaryMath(t,z)});case"math.tan":return this.output(t,{value:this.compileUnaryMath(t,St)});case"math.asin":return this.output(t,{value:this.compileUnaryMath(t,O)});case"math.acos":return this.output(t,{value:this.compileUnaryMath(t,I)});case"math.atan":return this.output(t,{value:this.compileUnaryMath(t,N)});case"math.atan2":return this.output(t,{value:this.compileAtan2(t)});case"math.radians":return this.output(t,{value:this.compileUnaryMath(t,pt)});case"math.degrees":return this.output(t,{value:this.compileUnaryMath(t,V)});case"math.sqrt":return this.output(t,{value:this.compileUnaryMath(t,gt)});case"math.inverseSqrt":return this.output(t,{value:this.compileUnaryMath(t,_)});case"math.exp":return this.output(t,{value:this.compileUnaryMath(t,D)});case"math.exp2":return this.output(t,{value:this.compileUnaryMath(t,L)});case"math.log":return this.output(t,{value:this.compileUnaryMath(t,Z)});case"math.log2":return this.output(t,{value:this.compileUnaryMath(t,tt)});case"math.saturate":return this.output(t,{value:this.compileUnaryMath(t,vt)});case"math.length":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:"float",value:Q(e.value)}})}case"math.normalize":return this.output(t,{value:this.compileUnaryMath(t,st)});case"math.clamp":{const e=this.expectNumeric(this.input(t,"value")),a=this.expectNumeric(this.input(t,"min",{type:"float",value:R(0)})),r=this.expectNumeric(this.input(t,"max",{type:"float",value:R(1)}));return this.output(t,{value:{type:e.type,value:$(e.value,a.value,r.value)}})}case"math.min":return this.output(t,{value:this.compileBinaryFunction(t,rt)});case"math.max":return this.output(t,{value:this.compileBinaryFunction(t,at)});case"math.pow":return this.output(t,{value:this.compileBinaryFunction(t,lt)});case"math.mod":return this.output(t,{value:this.compileBinaryFunction(t,nt)});case"math.step":return this.output(t,{value:this.compileBinaryFunction(t,wt,!0)});case"math.smoothstep":{const e=this.expectNumeric(this.input(t,"edge0",{type:"float",value:R(0)})),a=this.expectNumeric(this.input(t,"edge1",{type:"float",value:R(1)})),r=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:r.type,value:ft(e.value,a.value,r.value)}})}case"math.mix":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b")),r=this.expectNumeric(this.input(t,"t",{type:"float",value:R(.5)})),u=De(e.type,a.type,t.id);return this.output(t,{value:{type:u,value:ut(e.value,a.value,r.value)}})}case"math.remap":{const e=this.expectType(this.input(t,"value"),["float"],t.id,"value").value,a=this.floatInput(t,"inMin",-1),r=this.floatInput(t,"inMax",1),u=this.floatInput(t,"outMin",0),i=this.floatInput(t,"outMax",1);return this.output(t,{value:{type:"float",value:Lt(e,a,r,u,i)}})}case"math.select":{const e=this.boolInput(t,"condition",!1),a=this.expectNumeric(this.input(t,"a")),r=this.expectNumeric(this.input(t,"b")),u=De(a.type,r.type,t.id);return this.output(t,{value:{type:u,value:yt(e,a.value,r.value)}})}case"math.reflect":{const e=this.expectType(this.input(t,"incident"),["vec2","vec3","vec4","rgb","rgba"],t.id,"incident"),a=this.expectType(this.input(t,"normal"),["vec2","vec3","vec4","rgb","rgba"],t.id,"normal");return this.output(t,{value:{type:e.type,value:ge(e.value,a.value)}})}case"math.refract":{const e=this.expectType(this.input(t,"incident"),["vec2","vec3","vec4","rgb","rgba"],t.id,"incident"),a=this.expectType(this.input(t,"normal"),["vec2","vec3","vec4","rgb","rgba"],t.id,"normal"),r=this.floatInput(t,"ior",1.5);return this.output(t,{value:{type:e.type,value:be(e.value,a.value,r)}})}case"math.derivative":{const e=this.expectNumeric(this.input(t,"value")),a=String(ze(t,"mode","fwidth"));let r;return r="dFdx"===a?xe(e.value):"dFdy"===a?we(e.value):Se(e.value),this.output(t,{value:{type:e.type,value:r}})}case"layer.mixPainted":return this.output(t,{value:this.compilePaintedLayerMix(t)});case"math.dot":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b"));return De(e.type,a.type,t.id),this.output(t,{value:{type:"float",value:j(e.value,a.value)}})}case"math.distance":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b"));return De(e.type,a.type,t.id),this.output(t,{value:{type:"float",value:P(e.value,a.value)}})}case"math.cross":{const e=this.expectType(this.input(t,"a"),["vec3","rgb"],t.id,"a"),a=this.expectType(this.input(t,"b"),["vec3","rgb"],t.id,"b");return this.output(t,{value:{type:"vec3",value:A(e.value,a.value)}})}case"compare.greaterThan":case"compare.greaterThanOrEqual":case"compare.lessThan":case"compare.lessThanOrEqual":case"compare.equal":case"compare.notEqual":return this.output(t,{value:{type:"boolean",value:this.compileComparison(t)}});case"boolean.not":{const e=this.boolInput(t,"value",!1);return this.output(t,{value:{type:"boolean",value:yt(e,U(!1),U(!0))}})}case"boolean.and":return this.output(t,{value:{type:"boolean",value:this.compileBooleanBinary(t,"and")}});case"boolean.or":return this.output(t,{value:{type:"boolean",value:this.compileBooleanBinary(t,"or")}});case"compose.vec2":return this.output(t,{value:{type:"vec2",value:$t(this.floatInput(t,"x",0),this.floatInput(t,"y",0))}});case"compose.vec3":return this.output(t,{value:{type:"vec3",value:kt(this.floatInput(t,"x",0),this.floatInput(t,"y",0),this.floatInput(t,"z",0))}});case"compose.vec4":return this.output(t,{value:{type:"vec4",value:zt(this.floatInput(t,"x",0),this.floatInput(t,"y",0),this.floatInput(t,"z",0),this.floatInput(t,"w",0))}});case"compose.rgba":return this.output(t,{value:{type:"rgba",value:zt(this.floatInput(t,"r",1),this.floatInput(t,"g",1),this.floatInput(t,"b",1),this.floatInput(t,"a",1))}});case"decompose.component":{const e=this.expectNumeric(this.input(t,"value")),a=String(ze(t,"component","x"));return this.output(t,{value:{type:"float",value:Re(e,a,t.id)}})}case"decompose.split":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,function(t,e){const a={},r=(r,u)=>{a[r]={type:"float",value:Re(t,u,e)}};switch(t.type){case"vec2":return r("x","x"),r("y","y"),r("u","x"),r("v","y"),a;case"vec3":return r("x","x"),r("y","y"),r("z","z"),a;case"rgb":return r("r","r"),r("g","g"),r("b","b"),r("x","x"),r("y","y"),r("z","z"),a;case"vec4":return r("x","x"),r("y","y"),r("z","z"),r("w","w"),a;case"rgba":return r("r","r"),r("g","g"),r("b","b"),r("a","a"),r("x","x"),r("y","y"),r("z","z"),r("w","w"),a;case"float":return a.x={type:"float",value:t.value},a}}(e,t.id))}case"color.gradient":{const e=this.expectType(this.input(t,"t",{type:"float",value:R(.5)}),["float"],t.id,"t"),a=H(function(t){const e=ze(t,"stops",[]);if(!Array.isArray(e))return[];const a=e.map((t,a)=>{if(null==t||"object"!=typeof t||Array.isArray(t))return;const r=t,u="string"==typeof r.color?r.color:"#ffffff";return{position:_e(r.position,Ke(a,e.length)),color:u,alpha:_e(r.alpha,1)}}).filter(t=>null!=t);return a.length>0?a:[]}(t)).sample(e.value);return this.output(t,{value:{type:"rgba",value:a}})}case"utility.curve":{const e=this.expectType(this.input(t,"t",{type:"float",value:R(.5)}),["float"],t.id,"t"),a=ze(t,"curve","Linear"),r=K(a,e.value)??Y(Ie.decode(a)).sample(e.value);return this.output(t,{value:{type:"float",value:r}})}case"utility.namedRerouteDeclaration":return this.output(t,{value:this.input(t,"value")});case"utility.namedRerouteUsage":{const e=this.compileNode(this.namedRerouteDeclaration(t).id);return this.output(t,{value:e.outputs.value})}case"color.hueShift":{const e=this.expectType(this.input(t,"color"),["rgba","rgb","vec4","vec3"],t.id,"color"),a=e.value,r="rgba"===e.type||"vec4"===e.type?a.rgb??a.xyz:a,u=this.floatInput(t,"shift",0),i=Rt(r,u);return"rgba"===e.type||"vec4"===e.type?this.output(t,{value:{type:e.type,value:zt(i,a.a??a.w)}}):this.output(t,{value:{type:e.type,value:i}})}case"color.blend":{const e=this.expectType(this.input(t,"base"),["rgba","rgb","vec4","vec3"],t.id,"base"),a=this.expectType(this.input(t,"blend"),["rgba","rgb","vec4","vec3"],t.id,"blend"),r=String(ze(t,"mode","multiply")),u=e.value,i=a.value,o="rgba"===e.type||"vec4"===e.type?u.rgb??u.xyz:u,n="rgba"===a.type||"vec4"===a.type?i.rgb??i.xyz:i;let s=qt(o,n,r);if("rgba"===a.type||"vec4"===a.type){const t=i.a??i.w;s=ut(o,s,t)}if("rgba"===e.type||"vec4"===e.type){const a=u.a??u.w;return this.output(t,{value:{type:e.type,value:zt(s,a)}})}return this.output(t,{value:{type:e.type,value:s}})}case"color.desaturate":{const e=this.expectType(this.input(t,"color"),["rgba","rgb","vec4","vec3"],t.id,"color"),a=e.value,r="rgba"===e.type||"vec4"===e.type?a.rgb??a.xyz:a,u=this.floatInput(t,"fraction",1),i=Ft(r,u);return"rgba"===e.type||"vec4"===e.type?this.output(t,{value:{type:e.type,value:zt(i,a.a??a.w)}}):this.output(t,{value:{type:e.type,value:i}})}case"color.unpackNormal":{const e=this.expectType(this.input(t,"color"),["vec3","vec4","rgb","rgba"],t.id,"color"),a=this.floatInput(t,"scale",1),r=this.optionalInput(t,"normal");return this.output(t,{value:{type:"vec3",value:k(e.value,a,r?this.expectType(r,["vec3"],t.id,"normal").value:void 0)}})}case"texture.sampler2d":{const e=this.input(t,"texture");return this.output(t,{value:this.toSampler(e,t.id)})}case"texture.sample2d":{const e=this.toSampler(this.input(t,"sampler"),t.id),a=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv"),r=e.value.sample(a.value);return this.output(t,{rgba:{type:"rgba",value:r},rgb:{type:"rgb",value:r.rgb},r:{type:"float",value:r.r},g:{type:"float",value:r.g},b:{type:"float",value:r.b},a:{type:"float",value:r.a}})}case"texture.triplanarMapping":{const e=this.input(t,"sampler"),a=this.toSampler(e,t.id),r=this.expectType(this.input(t,"scale",{type:"float",value:R(1)}),["float"],t.id,"scale"),u=this.expectType(this.input(t,"normal",{type:"vec3",value:Bt.normal}),["vec3"],t.id,"normal"),i=this.expectType(this.input(t,"position",{type:"vec3",value:Bt.position}),["vec3"],t.id,"position"),o=Ct(a.value,r.value,u.value,i.value);return this.output(t,{rgba:{type:"rgba",value:o},rgb:{type:"rgb",value:o.rgb},r:{type:"float",value:o.r},g:{type:"float",value:o.g},b:{type:"float",value:o.b},a:{type:"float",value:o.a}})}case"scene.sampleColor":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.screenUv()}),["vec2"],t.id,"uv"),a=ae(e.value);return this.output(t,{rgba:{type:"rgba",value:a},rgb:{type:"rgb",value:a.rgb},r:{type:"float",value:a.r},g:{type:"float",value:a.g},b:{type:"float",value:a.b},a:{type:"float",value:a.a}})}case"scene.sampleDepth":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.screenUv()}),["vec2"],t.id,"uv");return this.output(t,{depth:{type:"float",value:Qt(e.value)},linearEyeDepth:{type:"float",value:Xt(e.value)}})}case"scene.fragmentDepth":return this.output(t,{linearEyeDepth:{type:"float",value:Kt}});case"transform.translate":{const e=this.expectType(this.input(t,"offset",{type:"vec3",value:kt(0,0,0)}),["vec3","rgb"],t.id,"offset");return this.output(t,{value:{type:"mat4",value:Mt(e.value)}})}case"transform.scale":{const e=this.expectType(this.input(t,"scale",{type:"vec3",value:kt(1,1,1)}),["vec3","rgb"],t.id,"scale").value;return this.output(t,{value:{type:"mat4",value:xt(e.x,e.y,e.z)}})}case"transform.rotateAxis":{const e=this.expectType(this.input(t,"axis",{type:"vec3",value:kt(0,1,0)}),["vec3","rgb"],t.id,"axis"),a=this.expectType(this.input(t,"angle",{type:"float",value:R(0)}),["float"],t.id,"angle");return this.output(t,{value:{type:"mat4",value:le(e.value,a.value)}})}case"uv.rotate":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.expectType(this.input(t,"angle",{type:"float",value:R(0)}),["float"],t.id,"angle").value,r=this.expectType(this.input(t,"center",{type:"vec2",value:$t(.5,.5)}),["vec2"],t.id,"center").value;return this.output(t,{value:{type:"vec2",value:Le(e,a,r)}})}case"uv.twirl":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.expectType(this.input(t,"strength",{type:"float",value:R(1)}),["float"],t.id,"strength").value,r=this.expectType(this.input(t,"center",{type:"vec2",value:$t(.5,.5)}),["vec2"],t.id,"center").value,u=this.expectType(this.input(t,"offset",{type:"vec2",value:$t(0,0)}),["vec2"],t.id,"offset").value;return this.output(t,{value:{type:"vec2",value:Et(e,a,r,u)}})}case"uv.radial":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=Dt(e.subtractScalar(.5));return this.output(t,{coords:{type:"vec2",value:a.coords},radius:{type:"float",value:a.radius},angle:{type:"float",value:a.angle}})}case"uv.bulge":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.expectType(this.input(t,"center",{type:"vec2",value:$t(.5,.5)}),["vec2"],t.id,"center").value,r=this.expectType(this.input(t,"power",{type:"float",value:R(1)}),["float"],t.id,"power").value;return this.output(t,{value:{type:"vec2",value:G(e,a,r)}})}case"uv.flipbook":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.floatInput(t,"columns",Ae(t,"columns",1)),r=this.floatInput(t,"rows",Ae(t,"rows",1)),u=this.floatInput(t,"fps",Ae(t,"fps",60)),i=this.expectType(this.input(t,"time",{type:"float",value:It.elapsed}),["float"],t.id,"time").value,o=String(ze(t,"mode","clamp"));return this.output(t,{value:{type:"vec2",value:pe(e,a,r,i,u,o)}})}case"uv.pom":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.input(t,"heightMap"),r=this.toSampler(a,t.id).value,u=this.floatInput(t,"heightScale",.05),i=Ae(t,"minLayers",8),o=Ae(t,"maxLayers",24);return this.output(t,{value:{type:"vec2",value:ce(e,r,u,i,o)}})}case"shape.rectangle":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value;return this.output(t,{value:{type:"float",value:_t(e,this.floatInput(t,"width",.5),this.floatInput(t,"height",.5))}})}case"shape.roundedRectangle":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value;return this.output(t,{value:{type:"float",value:Wt(e,this.floatInput(t,"width",.5),this.floatInput(t,"height",.5),this.floatInput(t,"radius",.1))}})}case"noise.simplex":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.floatInput(t,"scale",8);return this.output(t,{value:{type:"float",value:new ne(e.multiplyScalar(a))}})}case"noise.voronoi2d":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv").value,a=this.floatInput(t,"scale",8);return this.output(t,{value:{type:"float",value:new se(e.multiplyScalar(a))}})}case"effect.fresnel":return this.output(t,{value:{type:"float",value:E(Yt(this.floatInput(t,"power",1)))}});case"effect.edgeDepth":{const e=this.floatInput(t,"power",1);return this.output(t,{value:{type:"float",value:Ht(e)}})}case"effect.depthFade":{const e=this.floatInput(t,"distance",1);return this.output(t,{value:{type:"float",value:Jt(e)}})}case"util.panner":{const e=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"coord"),a=this.expectType(this.input(t,"speed",{type:"vec2",value:$t(0,0)}),["vec2"],t.id,"speed"),r=this.expectType(this.input(t,"tile",{type:"vec2",value:$t(1,1)}),["vec2"],t.id,"tile"),u=this.expectType(this.input(t,"time",{type:"float",value:It.elapsed}),["float"],t.id,"time");return this.output(t,{value:{type:"vec2",value:e.value.multiply(r.value).add(a.value.multiplyScalar(u.value))}})}}}compileParameterNode(t){const e=String(ze(t,"parameter","")),a=this.graph.parameters?.find(t=>t.name===e||t.id===e);if(null==a)throw new ShaderGraphCompileError(`Parameter "${e}" does not exist`,t.id);const r=de(a.type),u={type:r,value:Pe(this.options.parameters?.[a.name]??a.defaultValue,r,a.name)};if("sampler2d"!==r)return{value:u};const i=this.expectType(this.input(t,"uv",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"uv"),o=u.value.sample(i.value);return{value:{type:"rgba",value:o},rgb:{type:"rgb",value:o.rgb},r:{type:"float",value:o.r},g:{type:"float",value:o.g},b:{type:"float",value:o.b},a:{type:"float",value:o.a},sampler:u}}compileBinaryMath(t){const e=this.expectBinaryMathValue(this.input(t,"a")),a=this.expectBinaryMathValue(this.input(t,"b")),r=t.kind.split(".")[1];if("mat4"===e.type||"mat4"===a.type)return function(t,e,a,r){if("mat4"===t.type&&"mat4"===e.type&&"divide"!==a)return{type:"mat4",value:je(t.value,e.value,a,r)};if("mat4"===t.type&&"float"===e.type&&("multiply"===a||"divide"===a))return{type:"mat4",value:je(t.value,e.value,a,r)};if("float"===t.type&&"mat4"===e.type&&"multiply"===a)return{type:"mat4",value:je(e.value,t.value,a,r)};if("mat4"===t.type&&"vec4"===e.type&&"multiply"===a)return{type:"vec4",value:t.value.multiplyVec(e.value)};throw new ShaderGraphCompileError(`Cannot ${a} ${t.type} and ${e.type}`,r)}(e,a,r,t.id);if(e.type===a.type)return{type:e.type,value:je(e.value,a.value,r,t.id)};if("float"===e.type&&"float"!==a.type&&"multiply"===r)return{type:a.type,value:je(a.value,e.value,r,t.id)};if("float"!==e.type&&"float"===a.type)return{type:e.type,value:je(e.value,a.value,r,t.id)};throw new ShaderGraphCompileError(`Cannot ${r} ${e.type} and ${a.type}`,t.id)}expectBinaryMathValue(t){if(!qe(t.type)&&"mat4"!==t.type)throw new ShaderGraphCompileError(`Expected a numeric value but got ${t.type}`);return t}compileUnaryMath(t,e){const a=this.expectNumeric(this.input(t,"value"));return{type:a.type,value:e(a.value)}}compileAtan2(t){const e=this.expectNumeric(this.input(t,"y")),a=this.expectNumeric(this.input(t,"x"));return{type:function(t,e,a){if(t===e)return t;if("rgb"===t&&"vec3"===e||"vec3"===t&&"rgb"===e)return"vec3";if("rgba"===t&&"vec4"===e||"vec4"===t&&"rgba"===e)return"vec4";throw new ShaderGraphCompileError(`Cannot mix ${t} and ${e}`,a)}(e.type,a.type,t.id),value:C(e.value,a.value)}}compileBinaryFunction(t,e,a=!1){const r=this.expectNumeric(this.input(t,"a")),u=this.expectNumeric(this.input(t,"b"));return{type:a&&"float"===u.type?r.type:De(r.type,u.type,t.id),value:e(r.value,u.value)}}compilePaintedLayerMix(t){const e=this.expectNumeric(this.input(t,"base")),a=[e.value],r=[At(0)];let u=e.type;for(let e=1;e<=8;e++){const i=this.optionalInput(t,`layer${e}`);if(null==i)continue;const o=this.expectNumeric(i);u=De(u,o.type,t.id),a.push(o.value),r.push(At(e))}return 1===a.length?e:{type:u,value:it({layerColors:a,layerWeights:r,enableNoise:Boolean(ze(t,"enableNoise",!0)),noiseScale:this.floatInput(t,"noiseScale",Ae(t,"noiseScale",.1)),noiseAmount:this.floatInput(t,"noiseAmount",Ae(t,"noiseAmount",.5)),decay:this.floatInput(t,"softness",Ae(t,"softness",.3)),mode:"hard"===String(ze(t,"mode","soft"))?X.hard:X.soft})}}defaultUV(){return"trail"===this.graph.target?oe:"decal"===this.graph.target?ue:E(M.uv)}uvAttribute(t){const e=Math.max(0,Math.floor(Ae(t,"channel",0)));return 0===e?Bt.uv:fe(me(`uv${e}`))}namedRerouteDeclaration(t){const e=String(t.params?.declarationId??"");if(0===e.length)throw new ShaderGraphCompileError("Named reroute usage is missing a declaration",t.id);const a=this.nodesById.get(e);if(null==a)throw new ShaderGraphCompileError(`Named reroute declaration "${e}" does not exist`,t.id);if("utility.namedRerouteDeclaration"!==a.kind)throw new ShaderGraphCompileError(`Node "${e}" is not a named reroute declaration`,t.id);return a}input(t,e,a){const r=t.inputs?.[e];if(null!=r)return this.resolveInput(r,t.id,e);const u=(this.graph.edges??[]).find(a=>a.to.nodeId===t.id&&a.to.port===e);if(null!=u)return this.resolveSocket(u.from,t.id,e);if(null!=a)return a;const i=this.inlineLiteralFallback(t,e);if(null!=i)return i;throw new ShaderGraphCompileError(`Missing input "${e}"`,t.id,e)}optionalInput(t,e){const a=t.inputs?.[e];if(null!=a)return this.resolveInput(a,t.id,e);const r=(this.graph.edges??[]).find(a=>a.to.nodeId===t.id&&a.to.port===e);return null!=r?this.resolveSocket(r.from,t.id,e):void 0}floatInput(t,e,a){return this.expectType(this.input(t,e,{type:"float",value:R(a)}),["float"],t.id,e).value}boolInput(t,e,a){return this.expectType(this.input(t,e,{type:"boolean",value:U(a)}),["boolean"],t.id,e).value}compileComparison(t){const e=this.expectType(this.input(t,"a"),["float"],t.id,"a").value,a=this.expectType(this.input(t,"b"),["float"],t.id,"b").value;switch(t.kind){case"compare.greaterThan":return e.gt(a);case"compare.greaterThanOrEqual":return e.gte(a);case"compare.lessThan":return e.lt(a);case"compare.lessThanOrEqual":return e.lte(a);case"compare.equal":return e.equals(a);case"compare.notEqual":return e.notEquals(a)}throw new ShaderGraphCompileError(`Unsupported comparison node "${t.kind}"`,t.id)}compileBooleanBinary(t,e){const a=this.boolInput(t,"a",!1),r=this.boolInput(t,"b",!1);return"and"===e?a.and(r):a.or(r)}resolveOutputBinding(t,e){if(null!=t.input)return this.resolveSocket(t.input,void 0,e);if(void 0!==t.value)return Ve(t.value);throw new ShaderGraphCompileError(`Output "${e}" is missing an input or value`)}floatOutput(t,e){return this.expectType(this.resolveOutputBinding(t,e),["float"],e).value}resolveInput(t,e,a){return function(t){return null!=t.nodeId}(t)?this.resolveSocket(t,e,a):Ve(t.value,t.valueType)}inlineLiteralFallback(t,e){const a=ye[t.kind]?.inputs.find(t=>t.name===e);if(null==a)return;const r=ve(t.kind,a),u=he(t.kind,a);return null!=r&&void 0!==u?Ve(u,r):void 0}resolveSocket(t,e,a){const r=this.compileNode(t.nodeId).outputs[t.port];if(null==r)throw new ShaderGraphCompileError(`Node "${t.nodeId}" does not have output "${t.port}"`,e??t.nodeId,a??t.port);return r}expectType(t,e,a,r){if(!e.includes(t.type))throw new ShaderGraphCompileError(`Expected ${e.join(" or ")} but got ${t.type}`,a,r);return t}expectNumeric(t){if(!qe(t.type))throw new ShaderGraphCompileError(`Expected a numeric value but got ${t.type}`);return t}toSampler(t,e){if("sampler2d"===t.type)return t;if("texture2d"===t.type){const a=t.value;if(null==a)throw new ShaderGraphCompileError("Texture input is empty",e);return{type:"sampler2d",value:Tt(a)}}throw new ShaderGraphCompileError(`Expected texture2d or sampler2d but got ${t.type}`,e)}toColorOutput(t){switch(t.type){case"float":case"vec2":case"vec3":case"vec4":case"rgb":case"rgba":return t.value;case"boolean":{const e=yt(t.value,R(1),R(0));return ct(kt(e,e,e),1)}case"mat4":throw new ShaderGraphCompileError("mat4 values cannot be used as color");case"texture2d":case"sampler2d":throw new ShaderGraphCompileError(`${t.type} must be sampled before it can be used as color`)}}toVec3Output(t,e){if("vec3"===t.type||"rgb"===t.type)return t.value;if("vec4"===t.type||"rgba"===t.type)return t.value.xyz;throw new ShaderGraphCompileError(`Output "${e}" expects vec3/rgb but got ${t.type}`)}toMat4Output(t,e){if("mat4"===t.type)return t.value;throw new ShaderGraphCompileError(`Output "${e}" expects mat4 but got ${t.type}`)}output(t,e){return{node:t,outputs:e}}}export function compileShaderGraph(t,e={}){return new ShaderGraphCompiler(t,e).compile()}export function compileShaderGraphPreview(t,e,a={}){if(null==e)return compileShaderGraph(t,a).output;const r=new ShaderGraphCompiler(t,a).compileNode(e),u=Object.values(r.outputs)[0];if(null==u)throw new ShaderGraphCompileError(`Node "${e}" has no previewable output`,e);return{color:Ue(u),transparent:"rgba"===u.type||"vec4"===u.type}}export function buildShaderGraphMaterial(t,a={}){if("postProcess"===t.target)return buildShaderGraphPostProcessMaterial(t,a);const r=function(t,e,a){const r=a.alphaTest??t.alphaTest??e.materialOptions?.alphaTest;return null!=r?{...t,alphaTest:r}:t}(null!=a.previewNodeId?compileShaderGraphPreview(t,a.previewNodeId,a):compileShaderGraph(t,a).output,t,a);if("sprite"===t.target)return new Vt({color:r.color,discard:r.discard,alphaTest:r.alphaTest,transparent:r.transparent??!0,position:Pt(new b("rotation",0),new b("screenSpaceSize",0)),uniforms:{color:{value:new e(16777215)}}});if("trail"===t.target){const{position:e}=ie.getTrailShaderNodes(a.trailBillboard??!1),u=new y({...r,position:e});return ie.applyTrailShaderParameters(u),Ge(u,t),u}if("decal"===t.target){const e=null!=r.discard?re.or(r.discard):re,a=new y({...r,transparent:!1,discard:e});return a.userData.isDecal=!0,Ge(a,t),a}const u=new y({transparent:!1,...r});return Ge(u,t),u}export function buildShaderGraphPostProcessMaterial(t,e={}){const a=null!=e.previewNodeId?Ne(compileShaderGraphPreview(t,e.previewNodeId,e).color):compileShaderGraph(t,e).output,r=new y({color:a.color,transparent:!1,fog:!1,lights:!1,outputEncoding:!1});return r.depthWrite=!1,r.depthTest=!1,r.toneMapped=!1,r.userData.isPostProcessShaderGraph=!0,r}export function buildShaderGraphInlinePreviewMaterial(t,e,a={}){const r=compileShaderGraphPreview({...t,target:"surface"},e,a),u=new y({color:r.color,transparent:r.transparent??!1,fog:!1,lights:!1});return u.depthWrite=!1,u.depthTest=!1,u.toneMapped=!1,u}function Ne(t,e,a=Zt){const r=ae(a),u=Gt("hology_post_process_weight",1),i=vt(null!=e?u.multiply(e):u);return{color:ut(r.rgb,Ce(t),i),transparent:!1,...null!=e?{opacity:e}:{}}}function Ce(t){return t instanceof h?kt(t,t,t):t instanceof x?kt(t.x,t.y,0):t instanceof S?t.xyz:t}export function shaderGraphMaterialSideToThree(e){switch(e){case"back":return t;case"double":return r;default:return u}}function Ee(t){return"decal"!==t.target&&(t.materialOptions?.transparent??"sprite"===t.target)}function Ge(t,e){"surface"===e.target&&(t.side=shaderGraphMaterialSideToThree(e.materialOptions?.side)),null!=e.materialOptions?.transparent&&(t.transparent=e.materialOptions.transparent),null!=e.materialOptions?.bloom&&(t.userData.hasBloom=e.materialOptions.bloom)}function Ue(t){switch(t.type){case"float":return Be(t.value);case"vec2":{const e=t.value;return ct(kt(e.x,e.y,0),1)}case"vec3":case"rgb":return ct(t.value,1);case"vec4":case"rgba":return t.value;case"boolean":return Be(yt(t.value,R(1),R(0)));case"mat4":throw new ShaderGraphCompileError("mat4 values cannot be previewed as color");case"texture2d":case"sampler2d":throw new ShaderGraphCompileError(`${t.type} nodes require a sampled output to preview`)}}function Be(t){return ct(kt(t,t,t),1)}function $e(t){return t instanceof h?kt(t,t,t).rgb:t instanceof x?kt(t.x,t.y,0).rgb:t}function ke(t){return t.rgb}function ze(t,e,a){const r=t.params?.[e];return void 0===r?a:r}function Ae(t,e,a){const r=ze(t,e,a);return"number"==typeof r?r:Number(r??a)}function Ve(t,e){if(null!=(a=t)&&"object"==typeof a&&!Array.isArray(a)&&"value"in a)return Ve(t.value,t.valueType??e);var a;const r=e??function(t){if("boolean"==typeof t)return"boolean";if("number"==typeof t)return"float";if(Array.isArray(t))return 2===t.length?"vec2":3===t.length?"vec3":16===t.length?"mat4":"vec4";return"string"==typeof t?"rgb":"float"}(t);return{type:r,value:Pe(t,r,"literal")}}function Pe(t,a,r){switch(a){case"boolean":return t instanceof c?t:U(Boolean(t));case"float":return t instanceof h?t:R(_e(t,0));case"vec2":return t instanceof x?t:He(t);case"vec3":return t instanceof w?t:Ye(t);case"vec4":return t instanceof S?t:function(t){const[e,a,r,u]=We(t,4,1);return zt(e,a,r,u)}(t);case"mat4":return t instanceof v?t:function(t){if(t instanceof i)return et(t);const e=new i;Array.isArray(t)&&16===t.length&&e.fromArray(t.map(t=>_e(t,0)));return et(e)}(t);case"rgb":return t instanceof d?t:function(t){if("string"==typeof t||"number"==typeof t||t instanceof e)return ht(t);const[a,r,u]=We(t,3);return kt(a,r,u).rgb}(t);case"rgba":return t instanceof m||t instanceof S?t:Je(t);case"texture2d":return t;case"sampler2d":return function(t){const e=t;return t instanceof f||t instanceof g||"function"==typeof e?.isSampler2D||!0===e?.isSampler2D}(t)?t:t instanceof n||!0===t?.isTexture?Tt(t):(Me.has(r)||(Me.add(r),console.warn(`Shader graph parameter "${r}" is missing a texture value; using a 1x1 white fallback texture.`)),Tt(Oe))}}function je(t,e,a,r){const u=`${a}Scalar`;if(e instanceof h&&"function"==typeof t[u])return t[u](e);if("function"==typeof t[a])return t[a](e);throw new ShaderGraphCompileError(`Node does not support ${a}`,r)}function De(t,e,a){if(t===e)return t;if("rgb"===t&&"vec3"===e||"vec3"===t&&"rgb"===e)return"vec3";if("rgba"===t&&"vec4"===e||"vec4"===t&&"rgba"===e)return"vec4";if("float"===t&&qe(e))return e;if("float"===e&&qe(t))return t;throw new ShaderGraphCompileError(`Cannot mix ${t} and ${e}`,a)}function Le(t,e,a){const r=t.subtract(a),u=mt(e),i=z(e);return $t(i.multiply(r.x).subtract(u.multiply(r.y)).add(a.x),u.multiply(r.x).add(i.multiply(r.y)).add(a.y))}function Re(t,e,a){const r=t.value["u"===e?"x":"v"===e?"y":e];if(r instanceof h)return r;throw new ShaderGraphCompileError(`Component "${e}" is not available on ${t.type}`,a)}function qe(t){return"float"===t||"vec2"===t||"vec3"===t||"vec4"===t||"rgb"===t||"rgba"===t}function Fe(t){return Number.isFinite(t)?Math.min(1,Math.max(0,t)):0}function _e(t,e){if("number"==typeof t)return t;if("string"==typeof t){const a=parseFloat(t);return Number.isFinite(a)?a:e}return"boolean"==typeof t?t?1:0:e}function We(t,a,r=0){if(Array.isArray(t))return Array.from({length:a},(e,a)=>_e(t[a],r));if(t instanceof s||t instanceof l||t instanceof p)return Array.from({length:a},(e,a)=>t.toArray()[a]??r);if(t instanceof e){const e=t.toArray();return Array.from({length:a},(t,a)=>e[a]??(3===a?1:r))}if(null!=t&&"object"==typeof t){const e=t,u=["x","y","z","w"];if(u.some(t=>null!=e[t]))return Array.from({length:a},(t,a)=>_e(e[u[a]],r));const i=["r","g","b","a"];if(i.some(t=>null!=e[t]))return Array.from({length:a},(t,a)=>_e(e[i[a]],3===a?1:r))}return Array.from({length:a},()=>_e(t,r))}function He(t){const[e,a]=We(t,2);return $t(e,a)}function Ye(t){const[e,a,r]=We(t,3);return kt(e,a,r)}function Je(t,a=1){if("string"==typeof t||"number"==typeof t||t instanceof e)return ct(t,a);if(t instanceof w)return ct(t,a);const[r,u,i,o]=We(t,4,a);return zt(r,u,i,o)}function Ke(t,e){return e<=1?0:t/(e-1)}/*
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 * as THREE from 'three';
2
2
  import { Material } from "three";
3
- import { ConstantMat4Node, FloatNode, Vec4Node } from 'three-shader-graph';
3
+ import { ConstantMat4Node, FloatNode, UniformFloatNode, Vec4Node } from 'three-shader-graph';
4
4
  import { NodeShaderMaterial } from "../shader-nodes/index.js";
5
5
  import { NodeShaderOutput, Shader } from "./shader.js";
6
6
  export declare const identityTransform: ConstantMat4Node;
@@ -12,6 +12,7 @@ export declare class SpriteShader extends SpriteNodeShader {
12
12
  color: THREE.Color;
13
13
  opacity: number;
14
14
  intensity: number;
15
+ rotation: number;
15
16
  map?: THREE.Texture;
16
17
  alphaMap?: THREE.Texture;
17
18
  lockY: boolean;
@@ -21,8 +22,10 @@ export declare class SpriteShader extends SpriteNodeShader {
21
22
  output(): NodeShaderOutput;
22
23
  build(): Material;
23
24
  }
24
- export declare function getSpritePosition(rotation: FloatNode, screenSpaceSize?: FloatNode): Vec4Node;
25
+ export declare function getSpritePosition(rotation: FloatNode, screenSpaceSize?: FloatNode, lockYAxis?: FloatNode): Vec4Node;
25
26
  export declare class SpriteNodeShaderMaterial extends NodeShaderMaterial {
27
+ spriteRotationNode?: UniformFloatNode;
28
+ spriteScreenSpaceSizeNode?: UniformFloatNode;
26
29
  get color(): THREE.ColorRepresentation;
27
30
  set color(value: THREE.ColorRepresentation);
28
31
  get rotation(): number;
@@ -1,4 +1,4 @@
1
- import{__decorate as e,__metadata as t}from"tslib";import*as i from"three";import{batchingMatrix as r,ConstantMat4Node as o,float as a,glslFunction as n,ifDefApply as s,rgba as l,step as c,textureSampler2d as p,UniformFloatNode as d,uniforms as u,varying as h,varyingAttributes as S,vec3 as m,vec4 as x,Vec4Node as y}from"three-shader-graph";import{depthSampler as v,NodeShaderMaterial as f}from"../shader-nodes/index.js";import{Parameter as M,Shader as g}from"./shader.js";export const identityTransform=new o((new i.Matrix4).identity());const P=s("USE_BATCHING",identityTransform,e=>r);export class SpriteNodeShader extends g{build(){const e=this.output(),t=getSpritePosition(new d("rotation",0),new d("screenSpaceSize",0));return new SpriteNodeShaderMaterial({color:e.color,discard:e.discard,alphaTest:e.alphaTest,transparent:e.transparent??!0,position:t,uniforms:{color:{value:new i.Color(0)}}})}}export class SpriteShader extends SpriteNodeShader{constructor(){super(...arguments),this.color=new i.Color("#FFFFFF"),this.opacity=1,this.intensity=1,this.lockY=!1,this.screenSpaceSize=0,this.lenseFlare=!1,this.occlusionRadius=.2}output(){let e=a(this.opacity);this.alphaMap&&(e=e.multiply(p(this.alphaMap).sample(S.uv).r));let t=l(this.color,e);if(this.map&&(t=t.multiply(p(this.map).sample(S.uv))),null!=this.intensity&&1!==this.intensity&&(t=l(t.rgb.multiplyScalar(this.intensity),t.a)),this.lenseFlare){const e=a(this.occlusionRadius),i=b(w(m(0,0,0))),r=b(w(m(e.multiply(-1),0,0))),o=b(w(m(e,0,0))),n=b(w(m(0,e,0))),s=b(w(m(0,e.multiply(-1),0))),c=i.add(r).add(o).add(n).add(s).divide(5),p=h(c);return{color:l(t.rgb,t.a.multiply(p))}}return{color:t}}build(){const e=super.build();return this.lenseFlare&&(e.depthTest=!1,e.depthWrite=!1),this.lockY&&(e.defines.LOCK_Y_AXIS=""),null!=this.screenSpaceSize&&this.screenSpaceSize>0&&(e.defines.SCREEN_SPACE_SIZE=""),e.uniforms.screenSpaceSize.value=this.screenSpaceSize,e}}function w(e){let t=u.instanceMatrix.multiplyVec(x(e,1));return t=s("USE_BATCHING",t,e=>r.multiplyVec(e)),u.modelMatrix.multiplyVec(t)}function b(e){const t=u.projectionMatrix.multiplyVec(u.viewMatrix.multiplyVec(e)),i=t.xyz.divideScalar(t.w),r=i.xy.multiplyScalar(.5).addScalar(.5),o=v.sample(r).x,n=i.z.multiply(.5).add(.5),s=c(n,o.add(a(1e-4))),l=c(a(0),t.w);return s.multiply(l)}e([M(),t("design:type",i.Color)],SpriteShader.prototype,"color",void 0),e([M({range:[0,1]}),t("design:type",Number)],SpriteShader.prototype,"opacity",void 0),e([M({range:[0,10]}),t("design:type",Number)],SpriteShader.prototype,"intensity",void 0),e([M(),t("design:type",i.Texture)],SpriteShader.prototype,"map",void 0),e([M(),t("design:type",i.Texture)],SpriteShader.prototype,"alphaMap",void 0),e([M({help:"Sprite will rotate around Y axis to face camera"}),t("design:type",Boolean)],SpriteShader.prototype,"lockY",void 0),e([M({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([M({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([M({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=a(0)){return n(y,{cameraPosition:u.cameraPosition,viewMatrix:u.viewMatrix,modelViewMatrix:u.modelViewMatrix,rotation:e,screenSpaceSize:t,batchingMatrix:P,instanceMatrix:u.instanceMatrix},"\n mat4 finalModelMatrix = modelMatrix * batchingMatrix * instanceMatrix;\n\n // Scale from your model matrix\n vec2 scale;\n scale.x = length(vec3(finalModelMatrix[0].x, finalModelMatrix[0].y, finalModelMatrix[0].z));\n scale.y = length(vec3(finalModelMatrix[1].x, finalModelMatrix[1].y, finalModelMatrix[1].z));\n\n vec3 right, up;\n vec3 objectPos = (finalModelMatrix * vec4(0.0, 0.0, 0.0, 1.0)).xyz;\n\n #ifdef SCREEN_SPACE_SIZE\n float distanceToCamera = length(objectPos - cameraPosition);\n float screenScaleFactor = mix(1.0, distanceToCamera, screenSpaceSize);\n scale *= screenScaleFactor;\n #endif\n\n\n #ifdef LOCK_Y_AXIS\n vec3 cameraPos = cameraPosition;\n vec3 lookDir = normalize(vec3(cameraPos.x - objectPos.x, 0.0, cameraPos.z - objectPos.z));\n right = normalize(vec3(lookDir.z, 0.0, -lookDir.x));\n up = vec3(0.0, 1.0, 0.0);\n #else\n right = vec3(viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0]);\n up = vec3(viewMatrix[0][1], viewMatrix[1][1], viewMatrix[2][1]);\n #endif\n\n // then your shared code:\n vec2 center = vec2(0.5, 0.5);\n vec2 alignedPosition = (position.xy - (center - vec2(0.5))) * scale;\n\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n vec3 billboardPos = objectPos + right * rotatedPosition.x + up * rotatedPosition.y;\n\n // This can be used just to test outputting without sprite functionality\n // return projectionMatrix * viewMatrix * finalModelMatrix * vec4(position, 1.0);\n return projectionMatrix * viewMatrix * vec4(billboardPos, 1.0);\n ")}export class SpriteNodeShaderMaterial extends f{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.uniforms.rotation.value=e}get screenSpaceSize(){return this.uniforms.screenSpaceSize.value}set screenSpaceSize(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{attributes as r,batchingMatrix as o,ConstantMat4Node as a,cos as s,float as l,ifDefApply as n,length as p,mix as c,normalize as u,rgba as d,sin as h,step as S,textureSampler2d as m,UniformFloatNode as y,uniforms as x,varying as v,varyingAttributes as f,vec2 as g,vec3 as z,vec4 as w}from"three-shader-graph";import{depthSampler as M,NodeShaderMaterial as b,projectedSceneDepth as N,projectedSceneUV as F}from"../shader-nodes/index.js";import{Parameter as T,Shader as R}from"./shader.js";export const identityTransform=new a(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);const k=n("USE_BATCHING",identityTransform,e=>o);export class SpriteNodeShader extends R{build(){const e=this.output(),t=new y("rotation",0),r=new y("screenSpaceSize",0),o=getSpritePosition(t,r,new y("lockYAxis",0)),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(m(this.alphaMap).sample(f.uv).r));let t=d(this.color,e);if(this.map&&(t=t.multiply(m(this.map).sample(f.uv))),null!=this.intensity&&1!==this.intensity&&(t=d(t.rgb.multiplyScalar(this.intensity),t.a)),this.lenseFlare){const e=l(this.occlusionRadius),i=V(C(z(0,0,0))),r=V(C(z(e.multiply(-1),0,0))),o=V(C(z(e,0,0))),a=V(C(z(0,e,0))),s=V(C(z(0,e.multiply(-1),0))),n=i.add(r).add(o).add(a).add(s).divide(5),p=v(n);return{color:d(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 C(e){let t=x.instanceMatrix.multiplyVec(w(e,1));return t=n("USE_BATCHING",t,e=>o.multiplyVec(e)),x.modelMatrix.multiplyVec(t)}function V(e){const t=x.projectionMatrix.multiplyVec(x.viewMatrix.multiplyVec(e)),i=t.xyz.divideScalar(t.w),r=F(i.xy),o=M.sample(r).x,a=N(i.z),s=S(a,o.add(l(1e-4))),n=S(l(0),t.w);return s.multiply(n)}e([T(),t("design:type",i.Color)],SpriteShader.prototype,"color",void 0),e([T({range:[0,1]}),t("design:type",Number)],SpriteShader.prototype,"opacity",void 0),e([T({range:[0,10]}),t("design:type",Number)],SpriteShader.prototype,"intensity",void 0),e([T(),t("design:type",Number)],SpriteShader.prototype,"rotation",void 0),e([T(),t("design:type",i.Texture)],SpriteShader.prototype,"map",void 0),e([T(),t("design:type",i.Texture)],SpriteShader.prototype,"alphaMap",void 0),e([T({help:"Sprite will rotate around Y axis to face camera"}),t("design:type",Boolean)],SpriteShader.prototype,"lockY",void 0),e([T({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([T({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([T({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=l(0),i=l(0)){const o=x.modelMatrix.multiply(k).multiply(x.instanceMatrix),a=o.multiplyVec(w(0,0,0,1)).xyz,n=g(p(o.col(0).xyz),p(o.col(1).xyz)),d=p(a.subtract(x.cameraPosition)),m=n.multiplyScalar(c(l(1),d,t)),y=z(x.viewMatrix.col(0).x,x.viewMatrix.col(1).x,x.viewMatrix.col(2).x),v=z(x.viewMatrix.col(0).y,x.viewMatrix.col(1).y,x.viewMatrix.col(2).y),f=u(z(x.cameraPosition.x.subtract(a.x),0,x.cameraPosition.z.subtract(a.z))),M=u(z(f.z,0,f.x.multiply(-1))),b=S(l(.5),i),N=c(y,M,b),F=c(v,z(0,1,0),b),T=r.position.xy.multiply(m),R=g(s(e).multiply(T.x).subtract(h(e).multiply(T.y)),h(e).multiply(T.x).add(s(e).multiply(T.y))),C=a.add(N.multiplyScalar(R.x)).add(F.multiplyScalar(R.y));return x.projectionMatrix.multiplyVec(x.viewMatrix.multiplyVec(w(C,1)))}export class SpriteNodeShaderMaterial extends b{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,5 +1,6 @@
1
- import { WebGLRenderer } from 'three';
2
- import { FloatNode, Vec2Node } from 'three-shader-graph';
1
+ import { WebGLRenderer } from "three";
2
+ import { FloatNode, Vec2Node, Vec3Node } from "three-shader-graph";
3
+ import type { Compiler } from "three-shader-graph/build/main/lib/compiler.js";
3
4
  export declare function supportsDepthTextureExtension(renderer: WebGLRenderer): boolean;
4
5
  export declare const depthUniformName = "hology_depth_map";
5
6
  export declare const resolutionUniformName = "hology_resolution";
@@ -12,16 +13,26 @@ export declare function sampleSceneLinearEyeDepth(uv: Vec2Node): FloatNode;
12
13
  export declare const highPrecisionEyeDepth: FloatNode;
13
14
  export declare const fragmentLinearEyeDepth: FloatNode;
14
15
  export declare const resolution: import("three-shader-graph").UniformVec2Node;
15
- export declare const screenUV: Vec2Node;
16
+ declare class ScreenUvNode extends Vec2Node {
17
+ compile(c: Compiler): {
18
+ out: unknown;
19
+ };
20
+ }
21
+ export declare const screenUV: ScreenUvNode;
16
22
  export declare const linearEyeDepth: FloatNode;
23
+ /** Converts projected NDC XY to the UV convention used by scene textures. */
24
+ export declare function projectedSceneUV(ndc: Vec2Node): Vec2Node;
25
+ /** Converts projected NDC Z to the depth-buffer convention of the active backend. */
26
+ export declare function projectedSceneDepth(ndcDepth: FloatNode): FloatNode;
17
27
  /**
18
28
  * The position of the fragment closest behind the surface.
19
29
  */
20
- export declare const depthWorldPosition: import("three-shader-graph").Vec3Node;
30
+ export declare const depthWorldPosition: Vec3Node;
21
31
  /**
22
32
  * An approximated normal created by taking multiple samples using a depth texture
23
33
  */
24
- export declare const depthNormal: import("three-shader-graph").Vec3Node;
34
+ export declare const depthNormal: Vec3Node;
25
35
  export declare const sceneNormalSampler: import("three-shader-graph").UniformSampler2d;
26
- export declare const sceneNormal: import("three-shader-graph").Vec3Node;
36
+ export declare const sceneNormal: Vec3Node;
37
+ export {};
27
38
  //# sourceMappingURL=depth.d.ts.map
@@ -1,4 +1,4 @@
1
- import*as e from"three";import{Vector2 as t}from"three";import{cross as o,dot as r,float as n,FloatExpressionNode as s,FloatNode as c,inverse as a,normalize as i,texture2d as p,transformed as l,uniformFloat as m,uniforms as h,uniformSampler2d as u,uniformVec2 as d,unpackRGBToNormal as x,varying as f,vec2 as y,Vec2ExpressionNode as _,vec4 as U,Vec4Node as g}from"three-shader-graph";import{createPlaceholderTexture as k}from"../utils/three/placeholder-texture.js";export function supportsDepthTextureExtension(e){return!0}export const depthUniformName="hology_depth_map";export const resolutionUniformName="hology_resolution";export const nearUniformName="hology_camera_near";export const farUniformName="hology_camera_far";export const sceneNormalUniformName="hology_scene_normal_map";export const depthSampler=u(depthUniformName,new e.DepthTexture(1,1));const $=m(nearUniformName,.5),N=m(farUniformName,500);class v extends c{compile(e){const t=e.variable();var o=e.get($),r=e.get(N);return{chunk:`\n float depth_${t} = 2.0 * ${o} * ${r} / (${r} + ${o} - (2.0 * ${e.get(this.depth)} - 1.0) * (${r} - ${o}));\n `,out:`depth_${t}`}}constructor(e){super(),this.depth=e}}function w(e){return new v(e)}new class extends g{constructor(){super(...arguments),this.k="31u50"}compile(e){return{pars:`\n const float UnpackDownscale_${this.k} = 255. / 256.; // 0..1 -> fraction (excluding 1)\n const vec4 PackFactors_${this.k} = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\n const vec4 UnpackFactors_${this.k} = vec4( UnpackDownscale_${this.k} / PackFactors_${this.k}.rgb, 1.0 / PackFactors_${this.k}.a );\n `,out:`UnpackFactors_${this.k}`}}};function V(e){return p(depthSampler,e).r}export function sampleSceneDepth(e){return V(e)}export function sampleSceneLinearEyeDepth(e){return w(V(e))}const D=f(h.projectionMatrix.multiplyVec(l.mvPosition).zw);export const highPrecisionEyeDepth=D.x.multiply(.5).divide(D.y).add(.5);const S=new s("gl_FragCoord.z");export const fragmentLinearEyeDepth=w(S);export const resolution=d("hology_resolution",new t(250,1e3));export const screenUV=new _("gl_FragCoord.xy").divide(resolution);export const linearEyeDepth=w(V(screenUV));const P=f(a(h.projectionMatrix)),b=f(a(h.viewMatrix));function F(e=screenUV){const t=V(e).multiply(2).subtract(1),o=e.multiplyScalar(2).subtractScalar(1),r=U(o.x,o.y,t,1),n=P.multiplyVec(r),s=n.xyz.divideScalar(n.w);return b.multiplyVec(U(s,1)).xyz}export const depthWorldPosition=F(screenUV);const E=n(1).divide(resolution.x),z=n(1).divide(resolution.y),j=F(screenUV.add(y(E,n(0)))),M=F(screenUV.add(y(n(0),z)));export const depthNormal=i(o(j.subtract(depthWorldPosition),M.subtract(depthWorldPosition)));export const sceneNormalSampler=u(sceneNormalUniformName,k(128,128,255));export const sceneNormal=x(sceneNormalSampler.sample(screenUV).rgb);/*
1
+ import{Vector2 as e}from"three";import{cross as t,dot as o,float as r,FloatExpressionNode as n,FloatNode as c,inverse as s,inversesqrt as i,isWgslCompiler as p,isWgslFragmentCompiler as a,isWgslFullscreenFragmentCompiler as u,Mat4Node as l,max as m,select as h,texture2d as d,transformed as x,uniformFloat as f,uniforms as y,uniformSampler2d as g,uniformVec2 as v,unpackRGBToNormal as U,varying as _,vec2 as w,Vec2ExpressionNode as $,Vec2Node as k,vec4 as N,Vec4Node as D}from"three-shader-graph";import{createPlaceholderTexture as V}from"../utils/three/placeholder-texture.js";export function supportsDepthTextureExtension(e){return!0}export const depthUniformName="hology_depth_map";export const resolutionUniformName="hology_resolution";export const nearUniformName="hology_camera_near";export const farUniformName="hology_camera_far";export const sceneNormalUniformName="hology_scene_normal_map";export const depthSampler=g(depthUniformName,V());const S=f(nearUniformName,.5),P=f(farUniformName,500),b=r(1e-6);function F(e){return h(e.gte(r(0)),m(e,b),m(e.multiply(-1),b).multiply(-1))}function j(e){return r(2).multiply(S).multiply(P).divide(F(P.add(S).subtract(r(2).multiply(e).subtract(r(1)).multiply(P.subtract(S)))))}new class extends D{constructor(){super(...arguments),this.k="31u50"}compile(e){return{pars:`\n const float UnpackDownscale_${this.k} = 255. / 256.; // 0..1 -> fraction (excluding 1)\n const vec4 PackFactors_${this.k} = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\n const vec4 UnpackFactors_${this.k} = vec4( UnpackDownscale_${this.k} / PackFactors_${this.k}.rgb, 1.0 / PackFactors_${this.k}.a );\n `,out:`UnpackFactors_${this.k}`}}};function E(e){return d(depthSampler,e).r}export function sampleSceneDepth(e){return E(e)}export function sampleSceneLinearEyeDepth(e){return j(E(e))}const z=y.projectionMatrix.multiplyVec(x.mvPosition).zw,M=_(z);export const highPrecisionEyeDepth=M.x.multiply(.5).divide(F(M.y)).add(.5);const W=new n("gl_FragCoord.z");export const fragmentLinearEyeDepth=j(W);export const resolution=v("hology_resolution",new e(250,1e3));export const screenUV=new class extends k{compile(e){if(u(e))return{out:e.get(new $("uv"))};return{out:`(${e.get(new $("gl_FragCoord.xy"))} / max(${e.get(resolution)}, ${p(e)?e.construct("vec2",["1.0","1.0"]):"vec2(1.0)"}))`}}};export const linearEyeDepth=j(E(screenUV));function C(e){const t=_(e);return new class extends l{compile(o){return{out:o.get(a(o)?e:t)}}}}const L=C(s(y.projectionMatrix)),T=C(s(y.viewMatrix));function q(e=screenUV){const t=new B(E(e)),o=new A(e),r=N(o.x,o.y,t,1),n=L.multiplyVec(r),c=n.xyz.divideScalar(F(n.w));return T.multiplyVec(N(c,1)).xyz}class A extends k{constructor(e){super(),this.uv=e}compile(e){const t=e.get(this.uv);return{out:p(e)?`((${t}) * vec2<f32>(2.0, -2.0) + vec2<f32>(-1.0, 1.0))`:`((${t}) * 2.0 - 1.0)`}}}class B extends c{constructor(e){super(),this.depth=e}compile(e){const t=e.get(this.depth);return{out:p(e)?t:`((${t}) * 2.0 - 1.0)`}}}class G extends k{constructor(e){super(),this.ndc=e}compile(e){const t=e.get(this.ndc);return{out:p(e)?`((${t}) * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5, 0.5))`:`((${t}) * 0.5 + 0.5)`}}}class H extends c{constructor(e){super(),this.ndcDepth=e}compile(e){const t=e.get(this.ndcDepth);return{out:p(e)?t:`((${t}) * 0.5 + 0.5)`}}}export function projectedSceneUV(e){return new G(e)}export function projectedSceneDepth(e){return new H(e)}export const depthWorldPosition=q(screenUV);const I=r(1).divide(m(resolution.x,r(1))),J=r(1).divide(m(resolution.y,r(1))),K=q(screenUV.add(w(I,r(0)))),O=q(screenUV.add(w(r(0),new class extends c{constructor(e){super(),this.step=e}compile(e){const t=e.get(this.step);return{out:p(e)?`-(${t})`:t}}}(J))));export const depthNormal=(Q=t(K.subtract(depthWorldPosition),O.subtract(depthWorldPosition)),Q.multiplyScalar(i(m(o(Q,Q),b))));var Q;export const sceneNormalSampler=g(sceneNormalUniformName,V(128,128,255));export const sceneNormal=U(sceneNormalSampler.sample(screenUV).rgb);/*
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{glslFunction as t,RgbNode as i}from"three-shader-graph";export function applyDithering(n){return t(i,{color:n},"\n vec2 xy = gl_FragCoord.xy;\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( xy, vec2( a,b ) ), sn = mod( dt, 3.141592653589793 );\n\n float uvRand = fract( sin( sn ) * c );\n \n\t\t//Calculate grid position\n\t\tfloat grid_position = uvRand;\n\n\t\t//Shift the individual colors differently, thus making it even harder to see the dithering pattern\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\n\t\t//modify shift according to grid position.\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\n\t\t//shift the color by dither_shift\n\t\treturn color + dither_shift_RGB;\n ")}/*
1
+ import{dot as r,float as t,fract as l,mix as a,sin as i,Vec2ExpressionNode as p,vec2 as e,vec3 as o}from"three-shader-graph";export function applyDithering(d){const h=new p("gl_FragCoord.xy"),m=r(h,e(12.9898,78.233)),n=l(i(l(m.divide(t(Math.PI))).multiply(Math.PI)).multiply(43758.5453)),u=o(.25/255,-.25/255,.25/255),y=a(u.multiplyScalar(2),u.multiplyScalar(-2),n);return d.add(y)}/*
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 function glslFunction(t,e,n){const o=t.typeName;return new class extends t{compile(t){const c=`customFunction_${t.variable()}`,s=Object.entries(e).map(([t,e])=>`${e.constructor.typeName} ${t}`).join(", "),r=Object.values(e).map(e=>t.get(e)).join(", ");return{pars:`${o} ${c}(${s}) {\n ${n}\n }`,out:`${c}(${r})`}}}}/*
1
+ import{isWgslCompiler as e}from"three-shader-graph/build/main/lib/compiler.js";export function glslFunction(t,n,o){const r=t.typeName;return new class extends t{compile(t){if(e(t))throw new Error("WGSL cannot compile a glslFunction body. Replace it with shared nodes or provide a native WGSL node emitter.");const i=`customFunction_${t.variable()}`,a=Object.entries(n).map(([e,t])=>`${t.constructor.typeName} ${e}`).join(", "),c=Object.values(n).map(e=>t.get(e)).join(", ");return{pars:`${r} ${i}(${a}) {\n ${o}\n }`,out:`${i}(${c})`}}}}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,5 +1,5 @@
1
1
  export * from 'three-shader-graph';
2
- export { linearEyeDepth, fragmentLinearEyeDepth, depthNormal, depthSampler, depthWorldPosition, resolution, sceneNormal, screenUV } from './depth.js';
2
+ export { linearEyeDepth, fragmentLinearEyeDepth, depthNormal, depthSampler, depthWorldPosition, projectedSceneDepth, projectedSceneUV, resolution, sceneNormal, screenUV } from './depth.js';
3
3
  export { timeUniforms } from './time.js';
4
4
  export { particleUniforms } from './particle.js';
5
5
  export * from './layers.js';
@@ -15,4 +15,5 @@ export * from './scene-sample.js';
15
15
  export * from './curve-sample.js';
16
16
  export * from './dither.js';
17
17
  export * from './gradient-sample.js';
18
+ export * from './wgsl-node.js';
18
19
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- export*from"three-shader-graph";export{linearEyeDepth,fragmentLinearEyeDepth,depthNormal,depthSampler,depthWorldPosition,resolution,sceneNormal,screenUV}from"./depth.js";export{timeUniforms}from"./time.js";export{particleUniforms}from"./particle.js";export*from"./layers.js";export*from"./landscape.js";export*from"./shapes.js";export*from"./voronoi.js";export*from"./effects.js";export*from"./math.js";export*from"./bulge.js";export*from"./texture-sequence.js";export*from"./decal.js";export*from"./scene-sample.js";export*from"./curve-sample.js";export*from"./dither.js";export*from"./gradient-sample.js";/*
1
+ export*from"three-shader-graph";export{linearEyeDepth,fragmentLinearEyeDepth,depthNormal,depthSampler,depthWorldPosition,projectedSceneDepth,projectedSceneUV,resolution,sceneNormal,screenUV}from"./depth.js";export{timeUniforms}from"./time.js";export{particleUniforms}from"./particle.js";export*from"./layers.js";export*from"./landscape.js";export*from"./shapes.js";export*from"./voronoi.js";export*from"./effects.js";export*from"./math.js";export*from"./bulge.js";export*from"./texture-sequence.js";export*from"./decal.js";export*from"./scene-sample.js";export*from"./curve-sample.js";export*from"./dither.js";export*from"./gradient-sample.js";export*from"./wgsl-node.js";/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */