@hology/core 0.0.198 → 0.0.200
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/effects/vfx/vfx-asset.d.ts +17 -6
- package/dist/effects/vfx/vfx-materializer.js +1 -1
- package/dist/effects/vfx/vfx-renderers.js +1 -1
- package/dist/gameplay/services/physics/physics-system.js +1 -1
- package/dist/scene/custom-param-runtime-types.d.ts +35 -0
- package/dist/scene/custom-param-runtime-types.js +4 -0
- package/dist/scene/landscape/landscape.js +1 -1
- package/dist/scene/materializer.d.ts +19 -3
- package/dist/scene/materializer.js +1 -1
- package/dist/scene/model.d.ts +13 -5
- package/dist/scene/sky.js +1 -1
- package/dist/scene/storage/storage.js +1 -1
- package/dist/shader/graph/compiler.d.ts +80 -0
- package/dist/shader/graph/compiler.js +4 -0
- package/dist/shader/graph/index.d.ts +5 -0
- package/dist/shader/graph/index.js +4 -0
- package/dist/shader/graph/model.d.ts +79 -0
- package/dist/shader/graph/model.js +4 -0
- package/dist/shader/graph/parameters.d.ts +7 -0
- package/dist/shader/graph/parameters.js +4 -0
- package/dist/shader/graph/registry.d.ts +17 -0
- package/dist/shader/graph/registry.js +4 -0
- package/dist/shader/index.d.ts +1 -0
- package/dist/shader/index.js +1 -1
- package/dist/shader-nodes/bulge.js +1 -1
- package/dist/shader-nodes/depth.d.ts +2 -0
- package/dist/shader-nodes/depth.js +1 -1
- package/dist/shader-nodes/effects.d.ts +5 -0
- package/dist/shader-nodes/effects.js +1 -1
- package/dist/shader-nodes/gradient-sample.d.ts +16 -0
- package/dist/shader-nodes/gradient-sample.js +4 -0
- package/dist/shader-nodes/index.d.ts +1 -0
- package/dist/shader-nodes/index.js +1 -1
- package/dist/shader-nodes/layers.d.ts +6 -3
- package/dist/shader-nodes/layers.js +1 -1
- package/dist/shader-nodes/math.d.ts +4 -0
- package/dist/shader-nodes/math.js +1 -1
- package/dist/shader-nodes/particle.d.ts +10 -2
- package/dist/shader-nodes/particle.js +1 -1
- package/dist/shader-nodes/texture-sequence.d.ts +2 -1
- package/dist/shader-nodes/texture-sequence.js +1 -1
- package/dist/test/runtime-param-type-inference.test.d.ts +2 -0
- package/dist/test/runtime-param-type-inference.test.js +4 -0
- package/dist/test/shader-graph.test.d.ts +2 -0
- package/dist/test/shader-graph.test.js +4 -0
- package/dist/test/storage-case-collision.test.js +1 -1
- package/package.json +6 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{BackSide as t,Color as e,DoubleSide as a,FrontSide as r,Matrix4 as u,Texture as i,Vector2 as o,Vector3 as n,Vector4 as s}from"three";import{BooleanNode as l,FloatNode as p,Mat4Node as c,NodeShaderMaterial as h,RgbNode as v,RgbaNode as y,Sampler2DNode as d,Texture2dLookupNode as m,UniformFloatNode as f,Vec2Node as g,Vec3Node as b,Vec4Node as x,abs as w,acos as I,asin as S,attributes as T,atan as O,autoVarying as M,bulge as C,bool as N,ceil as E,clamp as U,cos as G,cross as B,degrees as $,distance as z,dot as A,exp as k,exp2 as V,float as j,floor as D,fract as q,inversesqrt as L,colorGradientSampler as P,length as F,LayerMixMode as R,log as W,log2 as Y,mat4 as H,max as J,min as K,mix as Q,mixColorsByLayer as X,particleUniforms as Z,mod as _,normalize as tt,pow as et,radians as at,rgba as rt,rgb as ut,saturate as it,select as ot,sign as nt,sin as st,smoothstep as lt,sqrt as pt,standardMaterial as ct,scaleTransform as ht,step as vt,tan as yt,textureSampler2d as dt,timeUniforms as mt,toonMaterial as ft,translate as gt,transformed as bt,triplanarMapping as xt,twirl as wt,uniformFloat as It,uniforms as St,varyingAttributes as Tt,vec2 as Ot,vec3 as Mt,vec4 as Ct,getPaintedMaterialLayerWeight as Nt}from"../../shader-nodes/index.js";import{SpriteNodeShaderMaterial as Et,getSpritePosition as Ut}from"../sprite-shader.js";import{oneMinus as Gt}from"../../shader-nodes/index.js";import{vectorToRadial as Bt,remap as $t,hueShift as zt,blendColor as At,desaturateColor as kt}from"../../shader-nodes/math.js";import{rectangleFloat as Vt,roundedRectangleFloat as jt}from"../../shader-nodes/shapes.js";import{edgeDepthEffect as Dt,fresnelEffect as qt,depthFadeEffect as Lt}from"../../shader-nodes/effects.js";import{fragmentLinearEyeDepth as Pt,sampleSceneDepth as Ft,sampleSceneLinearEyeDepth as Rt,screenUV as Wt,nearUniformName as Yt,farUniformName as Ht}from"../../shader-nodes/depth.js";import{sampleSceneColor as Jt}from"../../shader-nodes/scene-sample.js";import{decalDiscard as Kt,decalUV as Qt}from"../../shader-nodes/decal.js";import{Trail as Xt,trailUV as Zt}from"../../effects/vfx/trail-renderer.js";import{SimplexNoiseNode as _t,Voronoi2d as te,rotateAxis as ee}from"../../shader-nodes/index.js";import{flipbookUv as ae}from"../../shader-nodes/texture-sequence.js";import{parallaxOcclusionMapping as re}from"../../shader-nodes/pom.js";import{SHADER_GRAPH_NODE_DEFINITIONS as ue}from"./registry.js";import{shaderGraphParameterTypeToValueType as ie}from"./parameters.js";import{varying as oe,reflect as ne,refract as se,dFdx as le,dFdy as pe,fwidth as ce}from"three-shader-graph";import{decalNormal as he}from"../../shader-nodes/decal.js";export class ShaderGraphCompileError extends Error{constructor(t,e,a){super(t),this.nodeId=e,this.port=a,this.name="ShaderGraphCompileError"}}export class ShaderGraphCompiler{constructor(t,e={}){this.graph=t,this.options=e,this.compiled=new Map,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(),{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)}}compileOutput(){const t=this.graph.outputs?.color,e={color:null!=t?this.toColorOutput(this.resolveOutputBinding(t,"color")):rt("#ffffff",1),transparent:ve(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)),this.applyShadingModel(e)}applyShadingModel(t){const e=null!=t.opacity?function(t,e){if(t instanceof p)return rt(Mt(t,t,t),e);if(t instanceof g)return rt(Mt(t.x,t.y,0),e);if(t instanceof x)return rt(t.rgb,t.w.multiply(e));return rt(t,e)}(t.color,t.opacity):t.color;switch(this.graph.shadingModel??"standard"){case"standard":{const a={color:fe(e),roughness:t.roughness??j(.5),...null!=t.metalness?{metalness:t.metalness}:{},..."decal"===this.graph.target?{normal:tt(oe(St.normalMatrix).multiplyVec(he))}:{},...null!=t.normal?{normal:t.normal}:{},...null!=t.emissive?{emissive:ge(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:ct(a)}}case"toon":{const a={color:fe(e),...null!=t.normal?{normal:t.normal}:{},...null!=t.emissive?{emissive:ge(t.emissive)}:{},...null!=t.ambientOcclusion?{ambientOcclusion:t.ambientOcclusion}:{},...null!=t.ambientOcclusionIntensity?{ambientOcclusionIntensity:t.ambientOcclusionIntensity}:{},...null!=t.bakedLight?{bakedLight:t.bakedLight}:{}};return{...t,color:ft(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==ue[a.kind])throw new ShaderGraphCompileError(`Unsupported shader graph node "${a.kind}"`,a.id);const r=this.compileNodeInternal(a);return this.compiled.set(t,r),r}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:j(Ne(xe(t,"value",.5)))}});case"constant.boolean":return this.output(t,{value:{type:"boolean",value:N(Boolean(be(t,"value",!1)))}});case"constant.float":return this.output(t,{value:{type:"float",value:j(xe(t,"value",0))}});case"constant.vec2":return this.output(t,{value:{type:"vec2",value:Ge(be(t,"value",[0,0]))}});case"constant.vec3":return this.output(t,{value:{type:"vec3",value:Be(be(t,"value",[0,0,0]))}});case"constant.rgba":return this.output(t,{value:{type:"rgba",value:$e(be(t,"value","#ffffff"),xe(t,"alpha",1))}});case"builtin.uv":{const e=this.defaultUV();return this.output(t,{value:{type:"vec2",value:!0===be(t,"flipY",!1)?Ot(e.x,Gt(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:Wt}});case"builtin.color":{const e=M(T.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=M(T.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=M(bt.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.viewDir":{const e=M(bt.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=M(T.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:mt.elapsed}});case"builtin.camera":{const e=It(Yt),a=It(Ht),r=St.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.particle":return this.output(t,{energy:{type:"float",value:Z.energy},color:{type:"rgb",value:Z.color},opacity:{type:"float",value:Z.opacity},time:{type:"float",value:Z.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:Gt(e.value)}})}case"math.abs":return this.output(t,{value:this.compileUnaryMath(t,w)});case"math.sign":return this.output(t,{value:this.compileUnaryMath(t,nt)});case"math.floor":return this.output(t,{value:this.compileUnaryMath(t,D)});case"math.ceil":return this.output(t,{value:this.compileUnaryMath(t,E)});case"math.fract":return this.output(t,{value:this.compileUnaryMath(t,q)});case"math.sin":return this.output(t,{value:this.compileUnaryMath(t,st)});case"math.cos":return this.output(t,{value:this.compileUnaryMath(t,G)});case"math.tan":return this.output(t,{value:this.compileUnaryMath(t,yt)});case"math.asin":return this.output(t,{value:this.compileUnaryMath(t,S)});case"math.acos":return this.output(t,{value:this.compileUnaryMath(t,I)});case"math.atan":return this.output(t,{value:this.compileUnaryMath(t,O)});case"math.radians":return this.output(t,{value:this.compileUnaryMath(t,at)});case"math.degrees":return this.output(t,{value:this.compileUnaryMath(t,$)});case"math.sqrt":return this.output(t,{value:this.compileUnaryMath(t,pt)});case"math.inverseSqrt":return this.output(t,{value:this.compileUnaryMath(t,L)});case"math.exp":return this.output(t,{value:this.compileUnaryMath(t,k)});case"math.exp2":return this.output(t,{value:this.compileUnaryMath(t,V)});case"math.log":return this.output(t,{value:this.compileUnaryMath(t,W)});case"math.log2":return this.output(t,{value:this.compileUnaryMath(t,Y)});case"math.saturate":return this.output(t,{value:this.compileUnaryMath(t,it)});case"math.length":{const e=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:"float",value:F(e.value)}})}case"math.normalize":return this.output(t,{value:this.compileUnaryMath(t,tt)});case"math.clamp":{const e=this.expectNumeric(this.input(t,"value")),a=this.expectNumeric(this.input(t,"min",{type:"float",value:j(0)})),r=this.expectNumeric(this.input(t,"max",{type:"float",value:j(1)}));return this.output(t,{value:{type:e.type,value:U(e.value,a.value,r.value)}})}case"math.min":return this.output(t,{value:this.compileBinaryFunction(t,K)});case"math.max":return this.output(t,{value:this.compileBinaryFunction(t,J)});case"math.pow":return this.output(t,{value:this.compileBinaryFunction(t,et)});case"math.mod":return this.output(t,{value:this.compileBinaryFunction(t,_)});case"math.step":return this.output(t,{value:this.compileBinaryFunction(t,vt,!0)});case"math.smoothstep":{const e=this.expectNumeric(this.input(t,"edge0",{type:"float",value:j(0)})),a=this.expectNumeric(this.input(t,"edge1",{type:"float",value:j(1)})),r=this.expectNumeric(this.input(t,"value"));return this.output(t,{value:{type:r.type,value:lt(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:j(.5)})),u=Te(e.type,a.type,t.id);return this.output(t,{value:{type:u,value:Q(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:$t(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=Te(a.type,r.type,t.id);return this.output(t,{value:{type:u,value:ot(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:ne(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:se(e.value,a.value,r)}})}case"math.derivative":{const e=this.expectNumeric(this.input(t,"value")),a=String(be(t,"mode","fwidth"));let r;return r="dFdx"===a?le(e.value):"dFdy"===a?pe(e.value):ce(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 Te(e.type,a.type,t.id),this.output(t,{value:{type:"float",value:A(e.value,a.value)}})}case"math.distance":{const e=this.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b"));return Te(e.type,a.type,t.id),this.output(t,{value:{type:"float",value:z(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:B(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:ot(e,N(!1),N(!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:Ot(this.floatInput(t,"x",0),this.floatInput(t,"y",0))}});case"compose.vec3":return this.output(t,{value:{type:"vec3",value:Mt(this.floatInput(t,"x",0),this.floatInput(t,"y",0),this.floatInput(t,"z",0))}});case"compose.rgba":return this.output(t,{value:{type:"rgba",value:Ct(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(be(t,"component","x"));return this.output(t,{value:{type:"float",value:Me(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:Me(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:j(.5)}),["float"],t.id,"t"),a=P(function(t){const e=be(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:Ee(r.position,ze(a,e.length)),color:u,alpha:Ee(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"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=zt(r,u);return"rgba"===e.type||"vec4"===e.type?this.output(t,{value:{type:e.type,value:Ct(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(be(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=At(o,n,r);if("rgba"===a.type||"vec4"===a.type){const t=i.a??i.w;s=Q(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:Ct(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=kt(r,u);return"rgba"===e.type||"vec4"===e.type?this.output(t,{value:{type:e.type,value:Ct(i,a.a??a.w)}}):this.output(t,{value:{type:e.type,value:i}})}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:j(1)}),["float"],t.id,"scale"),u=this.expectType(this.input(t,"normal",{type:"vec3",value:Tt.normal}),["vec3"],t.id,"normal"),i=this.expectType(this.input(t,"position",{type:"vec3",value:Tt.position}),["vec3"],t.id,"position"),o=xt(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:Wt}),["vec2"],t.id,"uv"),a=Jt(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:Wt}),["vec2"],t.id,"uv");return this.output(t,{depth:{type:"float",value:Ft(e.value)},linearEyeDepth:{type:"float",value:Rt(e.value)}})}case"scene.fragmentDepth":return this.output(t,{linearEyeDepth:{type:"float",value:Pt}});case"transform.translate":{const e=this.expectType(this.input(t,"offset",{type:"vec3",value:Mt(0,0,0)}),["vec3","rgb"],t.id,"offset");return this.output(t,{value:{type:"mat4",value:gt(e.value)}})}case"transform.scale":{const e=this.expectType(this.input(t,"scale",{type:"vec3",value:Mt(1,1,1)}),["vec3","rgb"],t.id,"scale").value;return this.output(t,{value:{type:"mat4",value:ht(e.x,e.y,e.z)}})}case"transform.rotateAxis":{const e=this.expectType(this.input(t,"axis",{type:"vec3",value:Mt(0,1,0)}),["vec3","rgb"],t.id,"axis"),a=this.expectType(this.input(t,"angle",{type:"float",value:j(0)}),["float"],t.id,"angle");return this.output(t,{value:{type:"mat4",value:ee(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:j(0)}),["float"],t.id,"angle").value,r=this.expectType(this.input(t,"center",{type:"vec2",value:Ot(.5,.5)}),["vec2"],t.id,"center").value;return this.output(t,{value:{type:"vec2",value:Oe(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:j(1)}),["float"],t.id,"strength").value,r=this.expectType(this.input(t,"center",{type:"vec2",value:Ot(.5,.5)}),["vec2"],t.id,"center").value,u=this.expectType(this.input(t,"offset",{type:"vec2",value:Ot(0,0)}),["vec2"],t.id,"offset").value;return this.output(t,{value:{type:"vec2",value:wt(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=Bt(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:Ot(.5,.5)}),["vec2"],t.id,"center").value,r=this.expectType(this.input(t,"power",{type:"float",value:j(1)}),["float"],t.id,"power").value;return this.output(t,{value:{type:"vec2",value:C(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",xe(t,"columns",1)),r=this.floatInput(t,"rows",xe(t,"rows",1)),u=this.floatInput(t,"fps",xe(t,"fps",60)),i=this.expectType(this.input(t,"time",{type:"float",value:mt.elapsed}),["float"],t.id,"time").value,o=String(be(t,"mode","clamp"));return this.output(t,{value:{type:"vec2",value:ae(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=xe(t,"minLayers",8),o=xe(t,"maxLayers",24);return this.output(t,{value:{type:"vec2",value:re(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:Vt(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:jt(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 _t(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 te(e.multiplyScalar(a))}})}case"effect.fresnel":return this.output(t,{value:{type:"float",value:M(qt(this.floatInput(t,"power",1)))}});case"effect.edgeDepth":{const e=this.floatInput(t,"power",1);return this.output(t,{value:{type:"float",value:Dt(e)}})}case"effect.depthFade":{const e=this.floatInput(t,"distance",1);return this.output(t,{value:{type:"float",value:Lt(e)}})}case"util.panner":{const e=this.expectType(this.input(t,"coord",{type:"vec2",value:this.defaultUV()}),["vec2"],t.id,"coord"),a=this.expectType(this.input(t,"speed",{type:"vec2",value:Ot(0,0)}),["vec2"],t.id,"speed"),r=this.expectType(this.input(t,"tile",{type:"vec2",value:Ot(1,1)}),["vec2"],t.id,"tile"),u=this.expectType(this.input(t,"time",{type:"float",value:mt.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(be(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=ie(a.type),u={type:r,value:Ie(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.expectNumeric(this.input(t,"a")),a=this.expectNumeric(this.input(t,"b")),r=t.kind.split(".")[1];if(e.type===a.type)return{type:e.type,value:Se(e.value,a.value,r,t.id)};if("float"===e.type&&"float"!==a.type&&"multiply"===r)return{type:a.type,value:Se(a.value,e.value,r,t.id)};if("float"!==e.type&&"float"===a.type)return{type:e.type,value:Se(e.value,a.value,r,t.id)};throw new ShaderGraphCompileError(`Cannot ${r} ${e.type} and ${a.type}`,t.id)}compileUnaryMath(t,e){const a=this.expectNumeric(this.input(t,"value"));return{type:a.type,value:e(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:Te(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=[Nt(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=Te(u,o.type,t.id),a.push(o.value),r.push(Nt(e))}return 1===a.length?e:{type:u,value:X({layerColors:a,layerWeights:r,enableNoise:Boolean(be(t,"enableNoise",!0)),noiseScale:this.floatInput(t,"noiseScale",xe(t,"noiseScale",.1)),noiseAmount:this.floatInput(t,"noiseAmount",xe(t,"noiseAmount",.5)),decay:this.floatInput(t,"softness",xe(t,"softness",.3)),mode:"hard"===String(be(t,"mode","soft"))?R.hard:R.soft})}}defaultUV(){return"trail"===this.graph.target?Zt:"decal"===this.graph.target?Qt:M(T.uv)}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;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:j(a)}),["float"],t.id,e).value}boolInput(t,e,a){return this.expectType(this.input(t,e,{type:"boolean",value:N(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 we(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):we(t.value,t.valueType)}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(!Ce(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:dt(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=ot(t.value,j(1),j(0));return rt(Mt(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:de(u),transparent:"rgba"===u.type||"vec4"===u.type}}export function buildShaderGraphMaterial(t,a={}){const r=null!=a.previewNodeId?compileShaderGraphPreview(t,a.previewNodeId,a):compileShaderGraph(t,a).output;if("sprite"===t.target)return new Et({color:r.color,discard:r.discard,transparent:r.transparent??!0,position:Ut(new f("rotation",0),new f("screenSpaceSize",0)),uniforms:{color:{value:new e(16777215)}}});if("trail"===t.target){const{position:e}=Xt.getTrailShaderNodes(a.trailBillboard??!1),u=new h({...r,position:e});return Xt.applyTrailShaderParameters(u),ye(u,t),console.log(u),u}if("decal"===t.target){const e=null!=r.discard?Kt.or(r.discard):Kt,a=new h({...r,transparent:!1,discard:e});return a.userData.isDecal=!0,ye(a,t),a}const u=new h({transparent:!1,...r});return ye(u,t),u}export function shaderGraphMaterialSideToThree(e){switch(e){case"back":return t;case"double":return a;default:return r}}function ve(t){return"decal"!==t.target&&(t.materialOptions?.transparent??"sprite"===t.target)}function ye(t,e){"surface"===e.target&&(t.side=shaderGraphMaterialSideToThree(e.materialOptions?.side)),null!=e.materialOptions?.transparent&&(t.transparent=e.materialOptions.transparent)}function de(t){switch(t.type){case"float":return me(t.value);case"vec2":{const e=t.value;return rt(Mt(e.x,e.y,0),1)}case"vec3":case"rgb":return rt(t.value,1);case"vec4":case"rgba":return t.value;case"boolean":return me(ot(t.value,j(1),j(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 me(t){return rt(Mt(t,t,t),1)}function fe(t){return t instanceof p?Mt(t,t,t).rgb:t instanceof g?Mt(t.x,t.y,0).rgb:t}function ge(t){return t.rgb}function be(t,e,a){const r=t.params?.[e];return void 0===r?a:r}function xe(t,e,a){const r=be(t,e,a);return"number"==typeof r?r:Number(r??a)}function we(t,e){if(null!=(a=t)&&"object"==typeof a&&!Array.isArray(a)&&"value"in a)return we(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:Ie(t,r,"literal")}}function Ie(t,a,r){switch(a){case"boolean":return t instanceof l?t:N(Boolean(t));case"float":return t instanceof p?t:j(Ee(t,0));case"vec2":return t instanceof g?t:Ge(t);case"vec3":return t instanceof b?t:Be(t);case"vec4":return t instanceof x?t:function(t){const[e,a,r,u]=Ue(t,4,1);return Ct(e,a,r,u)}(t);case"mat4":return t instanceof c?t:function(t){if(t instanceof u)return H(t);const e=new u;Array.isArray(t)&&16===t.length&&e.fromArray(t.map(t=>Ee(t,0)));return H(e)}(t);case"rgb":return t instanceof v?t:function(t){if("string"==typeof t||"number"==typeof t||t instanceof e)return ut(t);const[a,r,u]=Ue(t,3);return Mt(a,r,u).rgb}(t);case"rgba":return t instanceof y||t instanceof x?t:$e(t);case"texture2d":return t;case"sampler2d":if(function(t){const e=t;return t instanceof d||t instanceof m||"function"==typeof e?.isSampler2D||!0===e?.isSampler2D}(t))return t;if(t instanceof i)return dt(t);throw new ShaderGraphCompileError(`Parameter "${r}" needs a texture value`)}}function Se(t,e,a,r){const u=`${a}Scalar`;if(e instanceof p&&"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 Te(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&&Ce(e))return e;if("float"===e&&Ce(t))return t;throw new ShaderGraphCompileError(`Cannot mix ${t} and ${e}`,a)}function Oe(t,e,a){const r=t.subtract(a),u=st(e),i=G(e);return Ot(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 Me(t,e,a){const r=t.value["u"===e?"x":"v"===e?"y":e];if(r instanceof p)return r;throw new ShaderGraphCompileError(`Component "${e}" is not available on ${t.type}`,a)}function Ce(t){return"float"===t||"vec2"===t||"vec3"===t||"vec4"===t||"rgb"===t||"rgba"===t}function Ne(t){return Number.isFinite(t)?Math.min(1,Math.max(0,t)):0}function Ee(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 Ue(t,a,r=0){if(Array.isArray(t))return Array.from({length:a},(e,a)=>Ee(t[a],r));if(t instanceof o||t instanceof n||t instanceof s)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)=>Ee(e[u[a]],r));const i=["r","g","b","a"];if(i.some(t=>null!=e[t]))return Array.from({length:a},(t,a)=>Ee(e[i[a]],3===a?1:r))}return Array.from({length:a},()=>Ee(t,r))}function Ge(t){const[e,a]=Ue(t,2);return Ot(e,a)}function Be(t){const[e,a,r]=Ue(t,3);return Mt(e,a,r)}function $e(t,a=1){if("string"==typeof t||"number"==typeof t||t instanceof e)return rt(t,a);if(t instanceof b)return rt(t,a);const[r,u,i,o]=Ue(t,4,a);return Ct(r,u,i,o)}function ze(t,e){return e<=1?0:t/(e-1)}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export type ShaderGraphTarget = 'surface' | 'sprite' | 'decal' | 'trail';
|
|
2
|
+
export type ShaderGraphShadingModel = 'standard' | 'toon' | 'unlit';
|
|
3
|
+
export type ShaderGraphMaterialSide = 'front' | 'back' | 'double';
|
|
4
|
+
export type ShaderGraphValueType = 'boolean' | 'float' | 'vec2' | 'vec3' | 'vec4' | 'mat4' | 'rgb' | 'rgba' | 'texture2d' | 'sampler2d';
|
|
5
|
+
export declare const ShaderGraphParameterTypes: readonly ["float", "boolean", "vec2", "vec3", "vec4", "color", "texture"];
|
|
6
|
+
export type ShaderGraphParameterType = (typeof ShaderGraphParameterTypes)[number];
|
|
7
|
+
export type ShaderGraphNodeKind = 'input.parameter' | 'input.slider' | 'constant.boolean' | 'constant.float' | 'constant.vec2' | 'constant.vec3' | 'constant.rgba' | 'builtin.uv' | 'builtin.screenUv' | 'builtin.color' | 'builtin.position' | 'builtin.worldPosition' | 'builtin.normal' | 'builtin.time' | 'builtin.camera' | 'builtin.particle' | 'math.add' | 'math.subtract' | 'math.multiply' | 'math.divide' | 'math.oneMinus' | 'math.abs' | 'math.sign' | 'math.floor' | 'math.ceil' | 'math.fract' | 'math.sin' | 'math.cos' | 'math.tan' | 'math.asin' | 'math.acos' | 'math.atan' | 'math.radians' | 'math.degrees' | 'math.sqrt' | 'math.inverseSqrt' | 'math.exp' | 'math.exp2' | 'math.log' | 'math.log2' | 'math.saturate' | 'math.length' | 'math.normalize' | 'math.clamp' | 'math.min' | 'math.max' | 'math.pow' | 'math.mod' | 'math.step' | 'math.smoothstep' | 'math.mix' | 'math.select' | 'layer.mixPainted' | 'math.dot' | 'math.distance' | 'math.cross' | 'compare.greaterThan' | 'compare.greaterThanOrEqual' | 'compare.lessThan' | 'compare.lessThanOrEqual' | 'compare.equal' | 'compare.notEqual' | 'boolean.not' | 'boolean.and' | 'boolean.or' | 'compose.vec2' | 'compose.vec3' | 'compose.rgba' | 'decompose.component' | 'decompose.split' | 'texture.sampler2d' | 'texture.sample2d' | 'texture.triplanarMapping' | 'scene.sampleColor' | 'scene.sampleDepth' | 'scene.fragmentDepth' | 'color.gradient' | 'transform.translate' | 'transform.scale' | 'transform.rotateAxis' | 'uv.rotate' | 'uv.twirl' | 'uv.radial' | 'uv.bulge' | 'shape.rectangle' | 'shape.roundedRectangle' | 'noise.simplex' | 'noise.voronoi2d' | 'effect.fresnel' | 'effect.edgeDepth' | 'effect.depthFade' | 'util.panner' | 'uv.flipbook' | 'math.remap' | 'color.hueShift' | 'color.blend' | 'color.blend' | 'color.desaturate' | 'builtin.viewDir' | 'uv.pom' | 'math.reflect' | 'math.refract' | 'math.derivative';
|
|
8
|
+
export type ShaderGraphSerializableValue = null | boolean | number | string | ShaderGraphSerializableValue[] | {
|
|
9
|
+
[key: string]: ShaderGraphSerializableValue;
|
|
10
|
+
};
|
|
11
|
+
export interface ShaderGraphParameter {
|
|
12
|
+
id?: string;
|
|
13
|
+
name: string;
|
|
14
|
+
type: ShaderGraphParameterType;
|
|
15
|
+
defaultValue?: ShaderGraphSerializableValue;
|
|
16
|
+
}
|
|
17
|
+
export interface ShaderGraphSocketRef {
|
|
18
|
+
nodeId: string;
|
|
19
|
+
port: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ShaderGraphInputLiteral {
|
|
22
|
+
value: ShaderGraphSerializableValue;
|
|
23
|
+
valueType?: ShaderGraphValueType;
|
|
24
|
+
}
|
|
25
|
+
export type ShaderGraphInput = ShaderGraphSocketRef | ShaderGraphInputLiteral;
|
|
26
|
+
export interface ShaderGraphEdge {
|
|
27
|
+
id?: string;
|
|
28
|
+
from: ShaderGraphSocketRef;
|
|
29
|
+
to: ShaderGraphSocketRef;
|
|
30
|
+
}
|
|
31
|
+
export interface ShaderGraphNode {
|
|
32
|
+
id: string;
|
|
33
|
+
kind: ShaderGraphNodeKind;
|
|
34
|
+
label?: string;
|
|
35
|
+
params?: Record<string, ShaderGraphSerializableValue>;
|
|
36
|
+
inputs?: Record<string, ShaderGraphInput>;
|
|
37
|
+
}
|
|
38
|
+
export type ShaderGraphOutputSlot = 'color' | 'opacity' | 'roughness' | 'metalness' | 'normal' | 'emissive' | 'ambientOcclusion' | 'ambientOcclusionIntensity' | 'sheenColor' | 'sheenRoughness' | 'anisotropy' | 'anisotropyDirection' | 'bakedLight' | 'transform' | 'discard' | 'transparent' | 'alphaTest';
|
|
39
|
+
export interface ShaderGraphOutputBinding {
|
|
40
|
+
input?: ShaderGraphSocketRef;
|
|
41
|
+
value?: ShaderGraphSerializableValue;
|
|
42
|
+
}
|
|
43
|
+
export interface ShaderGraphGroup {
|
|
44
|
+
id: string;
|
|
45
|
+
title: string;
|
|
46
|
+
nodeIds: string[];
|
|
47
|
+
}
|
|
48
|
+
export interface ShaderGraphLayout {
|
|
49
|
+
nodes?: Record<string, {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
}>;
|
|
53
|
+
groups?: ShaderGraphGroup[];
|
|
54
|
+
}
|
|
55
|
+
export interface ShaderGraphMaterialOptions {
|
|
56
|
+
side?: ShaderGraphMaterialSide;
|
|
57
|
+
transparent?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface ShaderGraphDocument {
|
|
60
|
+
version: 1;
|
|
61
|
+
target: ShaderGraphTarget;
|
|
62
|
+
shadingModel?: ShaderGraphShadingModel;
|
|
63
|
+
materialOptions?: ShaderGraphMaterialOptions;
|
|
64
|
+
parameters: ShaderGraphParameter[];
|
|
65
|
+
nodes: ShaderGraphNode[];
|
|
66
|
+
edges: ShaderGraphEdge[];
|
|
67
|
+
outputs: Partial<Record<ShaderGraphOutputSlot, ShaderGraphOutputBinding>>;
|
|
68
|
+
layout?: ShaderGraphLayout;
|
|
69
|
+
}
|
|
70
|
+
export type ShaderGraphMaterialReference = {
|
|
71
|
+
source: 'asset';
|
|
72
|
+
assetId: string;
|
|
73
|
+
} | {
|
|
74
|
+
source: 'local';
|
|
75
|
+
graph: ShaderGraphDocument;
|
|
76
|
+
};
|
|
77
|
+
export declare function createDefaultShaderGraphDocument(target?: ShaderGraphTarget): ShaderGraphDocument;
|
|
78
|
+
export declare function createDefaultVfxShaderGraphDocument(target?: ShaderGraphTarget): ShaderGraphDocument;
|
|
79
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const ShaderGraphParameterTypes=["float","boolean","vec2","vec3","vec4","color","texture"];export function createDefaultShaderGraphDocument(e="surface"){return{version:1,target:e,shadingModel:"standard",parameters:[{id:"base-color",name:"baseColor",type:"color",defaultValue:"#ffffff"}],nodes:[{id:"base-color",kind:"input.parameter",label:"Parameter",params:{parameter:"baseColor"}}],edges:[],outputs:{color:{input:{nodeId:"base-color",port:"value"}}},layout:{nodes:{"base-color":{x:80,y:80}}}}}export function createDefaultVfxShaderGraphDocument(e="sprite"){return{version:1,target:e,shadingModel:"unlit",parameters:[{id:"base-color",name:"baseColor",type:"color",defaultValue:"#ffffff"}],nodes:[{id:"base-color",kind:"input.parameter",label:"Parameter",params:{parameter:"baseColor"}},{id:"particle",kind:"builtin.particle",label:"Particle"},{id:"particle-color",kind:"math.multiply",label:"Multiply"}],edges:[{id:"base-color-to-particle-color",from:{nodeId:"base-color",port:"value"},to:{nodeId:"particle-color",port:"a"}},{id:"particle-color-to-particle-color",from:{nodeId:"particle",port:"color"},to:{nodeId:"particle-color",port:"b"}}],outputs:{color:{input:{nodeId:"particle-color",port:"value"}},opacity:{input:{nodeId:"particle",port:"opacity"}}},layout:{nodes:{"base-color":{x:80,y:80},particle:{x:80,y:260},"particle-color":{x:340,y:160}},groups:[]}}}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PropertyParameter } from '../parameter.js';
|
|
2
|
+
import type { ShaderGraphDocument, ShaderGraphParameterType, ShaderGraphValueType } from './model.js';
|
|
3
|
+
export declare function shaderGraphParameterTypeToValueType(type: ShaderGraphParameterType): ShaderGraphValueType;
|
|
4
|
+
export declare function shaderGraphParameterTypeToRuntimeType(type: ShaderGraphParameterType): PropertyParameter['type'];
|
|
5
|
+
export declare function shaderGraphParametersToPropertyParameters(graph: Pick<ShaderGraphDocument, 'parameters'>): PropertyParameter[];
|
|
6
|
+
export declare function getShaderGraphParameterDefaults(graph: Pick<ShaderGraphDocument, 'parameters'>): Record<string, unknown>;
|
|
7
|
+
//# sourceMappingURL=parameters.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{BooleanNode as e,FloatNode as r,RgbNode as a,Sampler2DNode as t,Vec2Node as n,Vec3Node as o,Vec4Node as u}from"../../shader-nodes/index.js";export function shaderGraphParameterTypeToValueType(e){switch(e){case"boolean":return"boolean";case"float":return"float";case"texture":return"sampler2d";case"vec2":return"vec2";case"vec3":return"vec3";case"vec4":return"vec4";case"color":return"rgb"}}export function shaderGraphParameterTypeToRuntimeType(c){switch(c){case"float":return r;case"boolean":return e;case"texture":return t;case"vec2":return n;case"vec3":return o;case"vec4":return u;case"color":return a}}export function shaderGraphParametersToPropertyParameters(e){return(e.parameters??[]).map(c)}export function getShaderGraphParameterDefaults(e){return Object.fromEntries((e.parameters??[]).filter(e=>void 0!==e.defaultValue).map(e=>[e.name,e.defaultValue]))}function c(e){return{name:e.name,type:shaderGraphParameterTypeToRuntimeType(e.type),options:{defaultValue:e.defaultValue,optional:!0}}}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ShaderGraphNodeKind, ShaderGraphValueType } from './model.js';
|
|
2
|
+
export interface ShaderGraphPortDefinition {
|
|
3
|
+
name: string;
|
|
4
|
+
type: ShaderGraphValueType | 'dynamic';
|
|
5
|
+
label?: string;
|
|
6
|
+
optional?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ShaderGraphNodeDefinition {
|
|
9
|
+
kind: ShaderGraphNodeKind;
|
|
10
|
+
label: string;
|
|
11
|
+
category: string;
|
|
12
|
+
inputs: ShaderGraphPortDefinition[];
|
|
13
|
+
outputs: ShaderGraphPortDefinition[];
|
|
14
|
+
}
|
|
15
|
+
export declare const SHADER_GRAPH_NODE_DEFINITIONS: Record<ShaderGraphNodeKind, ShaderGraphNodeDefinition>;
|
|
16
|
+
export declare const SHADER_GRAPH_NODE_KINDS: ShaderGraphNodeKind[];
|
|
17
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const SHADER_GRAPH_NODE_DEFINITIONS={"input.parameter":{kind:"input.parameter",label:"Parameter",category:"Inputs",inputs:[],outputs:[{name:"value",type:"dynamic"}]},"input.slider":{kind:"input.slider",label:"Slider",category:"Inputs",inputs:[],outputs:[{name:"value",type:"float"}]},"constant.boolean":{kind:"constant.boolean",label:"Boolean",category:"Inputs",inputs:[],outputs:[{name:"value",type:"boolean"}]},"constant.float":{kind:"constant.float",label:"Float",category:"Inputs",inputs:[],outputs:[{name:"value",type:"float"}]},"constant.vec2":{kind:"constant.vec2",label:"Vec2",category:"Inputs",inputs:[],outputs:[{name:"value",type:"vec2"}]},"constant.vec3":{kind:"constant.vec3",label:"Vec3",category:"Inputs",inputs:[],outputs:[{name:"value",type:"vec3"}]},"constant.rgba":{kind:"constant.rgba",label:"Color",category:"Inputs",inputs:[],outputs:[{name:"value",type:"rgba"}]},"builtin.uv":{kind:"builtin.uv",label:"UV",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec2"},{name:"u",type:"float"},{name:"v",type:"float"}]},"builtin.screenUv":{kind:"builtin.screenUv",label:"Screen UV",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec2"}]},"builtin.color":{kind:"builtin.color",label:"Color Attribute",category:"Attributes",inputs:[],outputs:[{name:"value",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"builtin.position":{kind:"builtin.position",label:"Position Attribute",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.worldPosition":{kind:"builtin.worldPosition",label:"World Position",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.normal":{kind:"builtin.normal",label:"Normal Attribute",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.particle":{kind:"builtin.particle",label:"Particle",category:"Attributes",inputs:[],outputs:[{name:"energy",type:"float"},{name:"color",type:"rgb"},{name:"opacity",type:"float"},{name:"time",type:"float"}]},"builtin.time":{kind:"builtin.time",label:"Time",category:"Inputs",inputs:[],outputs:[{name:"value",type:"float"}]},"builtin.viewDir":{kind:"builtin.viewDir",label:"View Direction",category:"Attributes",inputs:[],outputs:[{name:"value",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]},"builtin.camera":{kind:"builtin.camera",label:"Camera",category:"Inputs",inputs:[],outputs:[{name:"position",type:"vec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"},{name:"near",type:"float"},{name:"far",type:"float"}]},"math.add":{kind:"math.add",label:"Add",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.subtract":{kind:"math.subtract",label:"Subtract",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.multiply":{kind:"math.multiply",label:"Multiply",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.divide":{kind:"math.divide",label:"Divide",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.oneMinus":{kind:"math.oneMinus",label:"One Minus",category:"Math",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.abs":e("math.abs","Abs","Math"),"math.sign":e("math.sign","Sign","Math"),"math.floor":e("math.floor","Floor","Math"),"math.ceil":e("math.ceil","Ceil","Math"),"math.fract":e("math.fract","Fract","Math"),"math.sin":e("math.sin","Sine","Trigonometry"),"math.cos":e("math.cos","Cosine","Trigonometry"),"math.tan":e("math.tan","Tangent","Trigonometry"),"math.asin":e("math.asin","Arc Sine","Trigonometry"),"math.acos":e("math.acos","Arc Cosine","Trigonometry"),"math.atan":e("math.atan","Arc Tangent","Trigonometry"),"math.radians":e("math.radians","Radians","Trigonometry"),"math.degrees":e("math.degrees","Degrees","Trigonometry"),"math.sqrt":e("math.sqrt","Square Root","Math"),"math.inverseSqrt":e("math.inverseSqrt","Inverse Square Root","Math"),"math.exp":e("math.exp","Exp","Math"),"math.exp2":e("math.exp2","Exp2","Math"),"math.log":e("math.log","Log","Math"),"math.log2":e("math.log2","Log2","Math"),"math.saturate":e("math.saturate","Saturate","Math"),"math.length":{kind:"math.length",label:"Length",category:"Vectors",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"math.normalize":e("math.normalize","Normalize","Vectors"),"math.clamp":{kind:"math.clamp",label:"Clamp",category:"Math",inputs:[{name:"value",type:"dynamic"},{name:"min",type:"dynamic"},{name:"max",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.min":t("math.min","Min"),"math.max":t("math.max","Max"),"math.pow":t("math.pow","Power"),"math.mod":t("math.mod","Modulo"),"math.step":t("math.step","Step"),"math.smoothstep":{kind:"math.smoothstep",label:"Smoothstep",category:"Math",inputs:[{name:"edge0",type:"dynamic"},{name:"edge1",type:"dynamic"},{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.mix":{kind:"math.mix",label:"Mix",category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"},{name:"t",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.remap":{kind:"math.remap",label:"Remap",category:"Math",inputs:[{name:"value",type:"float"},{name:"inMin",type:"float"},{name:"inMax",type:"float"},{name:"outMin",type:"float"},{name:"outMax",type:"float"}],outputs:[{name:"value",type:"float"}]},"math.reflect":{kind:"math.reflect",label:"Reflect",category:"Math",inputs:[{name:"incident",type:"dynamic"},{name:"normal",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.refract":{kind:"math.refract",label:"Refract",category:"Math",inputs:[{name:"incident",type:"dynamic"},{name:"normal",type:"dynamic"},{name:"ior",type:"float"}],outputs:[{name:"value",type:"dynamic"}]},"math.derivative":{kind:"math.derivative",label:"Derivative",category:"Math",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"math.select":{kind:"math.select",label:"Select",category:"Math",inputs:[{name:"condition",type:"boolean"},{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"layer.mixPainted":{kind:"layer.mixPainted",label:"Mix Painted Layers",category:"Layers",inputs:[{name:"base",type:"dynamic"},...Array.from({length:8},(e,t)=>({name:`layer${t+1}`,label:`Layer ${t+1}`,type:"dynamic",optional:!0})),{name:"softness",type:"float",optional:!0},{name:"noiseScale",label:"Noise Scale",type:"float",optional:!0},{name:"noiseAmount",label:"Noise Amount",type:"float",optional:!0}],outputs:[{name:"value",type:"dynamic"}]},"math.dot":{kind:"math.dot",label:"Dot Product",category:"Vectors",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"math.distance":{kind:"math.distance",label:"Distance",category:"Vectors",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"math.cross":{kind:"math.cross",label:"Cross Product",category:"Vectors",inputs:[{name:"a",type:"vec3"},{name:"b",type:"vec3"}],outputs:[{name:"value",type:"vec3"}]},"compare.greaterThan":a("compare.greaterThan","Greater Than"),"compare.greaterThanOrEqual":a("compare.greaterThanOrEqual","Greater Than Or Equal"),"compare.lessThan":a("compare.lessThan","Less Than"),"compare.lessThanOrEqual":a("compare.lessThanOrEqual","Less Than Or Equal"),"compare.equal":a("compare.equal","Equal"),"compare.notEqual":a("compare.notEqual","Not Equal"),"boolean.not":{kind:"boolean.not",label:"Not",category:"Boolean",inputs:[{name:"value",type:"boolean"}],outputs:[{name:"value",type:"boolean"}]},"boolean.and":n("boolean.and","And"),"boolean.or":n("boolean.or","Or"),"compose.vec2":{kind:"compose.vec2",label:"Compose Vec2",category:"Vectors",inputs:[{name:"x",type:"float"},{name:"y",type:"float"}],outputs:[{name:"value",type:"vec2"}]},"compose.vec3":{kind:"compose.vec3",label:"Compose Vec3",category:"Vectors",inputs:[{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}],outputs:[{name:"value",type:"vec3"}]},"compose.rgba":{kind:"compose.rgba",label:"Compose RGBA",category:"Color",inputs:[{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}],outputs:[{name:"value",type:"rgba"}]},"decompose.component":{kind:"decompose.component",label:"Component",category:"Vectors",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"float"}]},"decompose.split":{kind:"decompose.split",label:"Split Components",category:"Vectors",inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"},{name:"w",type:"float"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"},{name:"u",type:"float"},{name:"v",type:"float"}]},"color.gradient":{kind:"color.gradient",label:"Gradient",category:"Color",inputs:[{name:"t",type:"float"}],outputs:[{name:"value",type:"rgba"}]},"color.hueShift":{kind:"color.hueShift",label:"Hue Shift",category:"Color",inputs:[{name:"color",type:"dynamic"},{name:"shift",type:"float"}],outputs:[{name:"value",type:"dynamic"}]},"color.blend":{kind:"color.blend",label:"Blend Colors",category:"Color",inputs:[{name:"base",type:"dynamic"},{name:"blend",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]},"color.desaturate":{kind:"color.desaturate",label:"Desaturate",category:"Color",inputs:[{name:"color",type:"dynamic"},{name:"fraction",type:"float"}],outputs:[{name:"value",type:"dynamic"}]},"texture.sampler2d":{kind:"texture.sampler2d",label:"Sampler 2D",category:"Texture",inputs:[{name:"texture",type:"texture2d"}],outputs:[{name:"value",type:"sampler2d"}]},"texture.sample2d":{kind:"texture.sample2d",label:"Sample Texture 2D",category:"Textures",inputs:[{name:"sampler",type:"sampler2d"},{name:"uv",type:"vec2"}],outputs:[{name:"rgba",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"texture.triplanarMapping":{kind:"texture.triplanarMapping",label:"Triplanar Mapping",category:"Textures",inputs:[{name:"sampler",type:"sampler2d"},{name:"scale",type:"float"},{name:"normal",type:"vec3"},{name:"position",type:"vec3"}],outputs:[{name:"rgba",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"scene.sampleColor":{kind:"scene.sampleColor",label:"Sample Scene Color",category:"Texture",inputs:[{name:"uv",type:"vec2"}],outputs:[{name:"rgba",type:"rgba"},{name:"rgb",type:"rgb"},{name:"r",type:"float"},{name:"g",type:"float"},{name:"b",type:"float"},{name:"a",type:"float"}]},"scene.sampleDepth":{kind:"scene.sampleDepth",label:"Sample Scene Depth",category:"Texture",inputs:[{name:"uv",type:"vec2"}],outputs:[{name:"depth",type:"float"},{name:"linearEyeDepth",type:"float"}]},"scene.fragmentDepth":{kind:"scene.fragmentDepth",label:"Fragment Depth",category:"Texture",inputs:[],outputs:[{name:"linearEyeDepth",type:"float"}]},"transform.translate":{kind:"transform.translate",label:"Translate",category:"Transform",inputs:[{name:"offset",type:"vec3"}],outputs:[{name:"value",type:"mat4"}]},"transform.scale":{kind:"transform.scale",label:"Scale",category:"Transform",inputs:[{name:"scale",type:"vec3"}],outputs:[{name:"value",type:"mat4"}]},"transform.rotateAxis":{kind:"transform.rotateAxis",label:"Rotate Axis",category:"Transform",inputs:[{name:"axis",type:"vec3"},{name:"angle",type:"float"}],outputs:[{name:"value",type:"mat4"}]},"uv.rotate":{kind:"uv.rotate",label:"Rotate UV",category:"UV",inputs:[{name:"uv",type:"vec2"},{name:"angle",type:"float"},{name:"center",type:"vec2",optional:!0}],outputs:[{name:"value",type:"vec2"}]},"uv.twirl":{kind:"uv.twirl",label:"Twirl UV",category:"UV",inputs:[{name:"uv",type:"vec2"},{name:"strength",type:"float"},{name:"center",type:"vec2",optional:!0},{name:"offset",type:"vec2",optional:!0}],outputs:[{name:"value",type:"vec2"}]},"uv.radial":{kind:"uv.radial",label:"Radial UV",category:"UV",inputs:[{name:"uv",type:"vec2"}],outputs:[{name:"coords",type:"vec2"},{name:"radius",type:"float"},{name:"angle",type:"float"}]},"uv.bulge":{kind:"uv.bulge",label:"Bulge UV",category:"UV",inputs:[{name:"uv",type:"vec2"},{name:"center",type:"vec2",optional:!0},{name:"power",type:"float",optional:!0}],outputs:[{name:"value",type:"vec2"}]},"uv.flipbook":{kind:"uv.flipbook",label:"Flipbook UV",category:"UV",inputs:[{name:"uv",type:"vec2",optional:!0},{name:"columns",type:"float",optional:!0},{name:"rows",type:"float",optional:!0},{name:"fps",type:"float",optional:!0},{name:"time",type:"float",optional:!0}],outputs:[{name:"value",type:"vec2"}]},"uv.pom":{kind:"uv.pom",label:"Parallax Occlusion",category:"UV",inputs:[{name:"uv",type:"vec2",optional:!0},{name:"heightMap",type:"sampler2d"},{name:"heightScale",type:"float",optional:!0}],outputs:[{name:"value",type:"vec2"}]},"shape.rectangle":{kind:"shape.rectangle",label:"Rectangle",category:"Shapes",inputs:[{name:"uv",type:"vec2"},{name:"width",type:"float"},{name:"height",type:"float"}],outputs:[{name:"value",type:"float"}]},"shape.roundedRectangle":{kind:"shape.roundedRectangle",label:"Rounded Rectangle",category:"Shapes",inputs:[{name:"uv",type:"vec2"},{name:"width",type:"float"},{name:"height",type:"float"},{name:"radius",type:"float"}],outputs:[{name:"value",type:"float"}]},"noise.simplex":{kind:"noise.simplex",label:"Simplex Noise",category:"Noise",inputs:[{name:"uv",type:"vec2"},{name:"scale",type:"float",optional:!0}],outputs:[{name:"value",type:"float"}]},"noise.voronoi2d":{kind:"noise.voronoi2d",label:"Voronoi",category:"Noise",inputs:[{name:"uv",type:"vec2"},{name:"scale",type:"float",optional:!0}],outputs:[{name:"value",type:"float"}]},"effect.fresnel":{kind:"effect.fresnel",label:"Fresnel",category:"Effects",inputs:[{name:"power",type:"float",optional:!0}],outputs:[{name:"value",type:"float"}]},"effect.edgeDepth":{kind:"effect.edgeDepth",label:"Edge Depth",category:"Effects",inputs:[{name:"power",type:"float",optional:!0}],outputs:[{name:"value",type:"float"}]},"effect.depthFade":{kind:"effect.depthFade",label:"Depth Fade",category:"Effects",inputs:[{name:"distance",type:"float",optional:!0}],outputs:[{name:"value",type:"float"}]},"util.panner":{kind:"util.panner",label:"Panner",category:"Utilities",inputs:[{name:"coord",type:"vec2"},{name:"speed",type:"vec2"},{name:"tile",type:"vec2"},{name:"time",type:"float",optional:!0}],outputs:[{name:"value",type:"vec2"}]}};export const SHADER_GRAPH_NODE_KINDS=Object.keys(SHADER_GRAPH_NODE_DEFINITIONS);function e(e,t,a){return{kind:e,label:t,category:a,inputs:[{name:"value",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]}}function t(e,t){return{kind:e,label:t,category:"Math",inputs:[{name:"a",type:"dynamic"},{name:"b",type:"dynamic"}],outputs:[{name:"value",type:"dynamic"}]}}function a(e,t){return{kind:e,label:t,category:"Comparison",inputs:[{name:"a",type:"float"},{name:"b",type:"float"}],outputs:[{name:"value",type:"boolean"}]}}function n(e,t){return{kind:e,label:t,category:"Boolean",inputs:[{name:"a",type:"boolean"},{name:"b",type:"boolean"}],outputs:[{name:"value",type:"boolean"}]}}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
package/dist/shader/index.d.ts
CHANGED
package/dist/shader/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export*from"./parameter.js";export*from"./builtin/index.js";export*from"./shader.js";export*from"./decal-shader.js";export*from"./post-process-shader.js";export*from"./sprite-shader.js";export*from"./trail-shader.js";/*
|
|
1
|
+
export*from"./parameter.js";export*from"./builtin/index.js";export*from"./shader.js";export*from"./decal-shader.js";export*from"./post-process-shader.js";export*from"./sprite-shader.js";export*from"./trail-shader.js";export*from"./graph/index.js";/*
|
|
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{length as r,pow as t}from"three-shader-graph";export function bulge(e,a,l=1){let o=e;o=e.subtract(a);const u=r(o),c=1===l?u:t(u,l);return o=o.multiplyScalar(c),o=
|
|
1
|
+
import{length as r,pow as t}from"three-shader-graph";export function bulge(e,a,l=1){let o=e;o=e.subtract(a);const u=r(o),c=1===l?u:t(u,l);return o=o.multiplyScalar(c),o=o.add(a),o}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -7,6 +7,8 @@ export declare const nearUniformName = "hology_camera_near";
|
|
|
7
7
|
export declare const farUniformName = "hology_camera_far";
|
|
8
8
|
export declare const sceneNormalUniformName = "hology_scene_normal_map";
|
|
9
9
|
export declare const depthSampler: import("three-shader-graph").UniformSampler2d;
|
|
10
|
+
export declare function sampleSceneDepth(uv: Vec2Node): FloatNode;
|
|
11
|
+
export declare function sampleSceneLinearEyeDepth(uv: Vec2Node): FloatNode;
|
|
10
12
|
export declare const highPrecisionEyeDepth: import("three-shader-graph").FloatAddNode;
|
|
11
13
|
export declare const fragmentLinearEyeDepth: FloatNode;
|
|
12
14
|
export declare const resolution: import("three-shader-graph").UniformVec2Node;
|
|
@@ -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
|
|
1
|
+
import*as e from"three";import{Vector2 as t}from"three";import{cross as o,dot as r,float as n,FloatExpressionNode as c,FloatNode as s,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";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 k=m(nearUniformName,.5),$=m(farUniformName,500);class N extends s{compile(e){const t=e.variable();var o=e.get(k),r=e.get($);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 v(e){return new N(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 w(e){return p(depthSampler,e).r}export function sampleSceneDepth(e){return w(e)}export function sampleSceneLinearEyeDepth(e){return v(w(e))}const V=f(h.projectionMatrix.multiplyVec(l.mvPosition).zw);export const highPrecisionEyeDepth=V.x.multiply(.5).divide(V.y).add(.5);const D=new c("gl_FragCoord.z");export const fragmentLinearEyeDepth=v(D);export const resolution=d("hology_resolution",new t(250,1e3));export const screenUV=new _("gl_FragCoord.xy").divide(resolution);export const linearEyeDepth=v(w(screenUV));const S=f(a(h.projectionMatrix)),P=f(a(h.viewMatrix));function b(e=screenUV){const t=w(e).multiply(2).subtract(1),o=e.multiplyScalar(2).subtractScalar(1),r=U(o.x,o.y,t,1),n=S.multiplyVec(r),c=n.xyz.divideScalar(n.w);return P.multiplyVec(U(c,1)).xyz}export const depthWorldPosition=b(screenUV);const F=n(1).divide(resolution.x),E=n(1).divide(resolution.y),z=b(screenUV.add(y(F,n(0)))),M=b(screenUV.add(y(n(0),E)));export const depthNormal=i(o(z.subtract(depthWorldPosition),M.subtract(depthWorldPosition)));export const sceneNormalSampler=u(sceneNormalUniformName,new e.Texture);export const sceneNormal=x(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
|
*/
|
|
@@ -6,4 +6,9 @@ export declare function fresnelEffect(power?: number | FloatNode): FloatNode;
|
|
|
6
6
|
* with another or to increase the transparency of water where it meets a shore.
|
|
7
7
|
*/
|
|
8
8
|
export declare function edgeDepthEffect(power?: number | FloatNode): FloatNode;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a fade effect based on the distance between the scene geometry and the current fragment.
|
|
11
|
+
* This is useful for softening the intersections of meshes with the environment (e.g., water shorelines or force fields).
|
|
12
|
+
*/
|
|
13
|
+
export declare function depthFadeEffect(distance: FloatNode): import("three-shader-graph").FloatDivNode;
|
|
9
14
|
//# sourceMappingURL=effects.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{attributes as t,clamp as r,dot as e,float as o,ifDefApply as i,normalize as
|
|
1
|
+
import{attributes as t,clamp as r,dot as e,float as o,ifDefApply as i,normalize as n,pow as c,saturate as f,transformed as p,uniforms as a,varying as m,varyingAttributes as s,vec4 as u}from"three-shader-graph";import{fragmentLinearEyeDepth as d,linearEyeDepth as l}from"./depth.js";import{oneMinus as h}from"./math.js";a.modelMatrix.multiplyVec(u(t.position,1));export function fresnelEffect(t=1){const r=i("FLIP_SIDED",p.normal,()=>p.normal.multiplyScalar(-1));return c(h(f(e(p.viewDir,r))),o(t))}const x=o(1).subtract(r(l.subtract(d).divide(l),0,1));export function edgeDepthEffect(t=1){return c(x,o(t))}export function depthFadeEffect(t){const r=l.subtract(d);return f(r.divide(t))}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Color } from 'three';
|
|
2
|
+
import { FloatNode, RgbaNode, Sampler2DNode } from 'three-shader-graph';
|
|
3
|
+
export interface ColorGradientStop {
|
|
4
|
+
position: number;
|
|
5
|
+
color: string | number | Color | number[];
|
|
6
|
+
alpha?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const defaultColorGradientStops: ColorGradientStop[];
|
|
9
|
+
export declare function sampleColorGradient(stops: readonly ColorGradientStop[], t: FloatNode, resolution?: number): RgbaNode;
|
|
10
|
+
export declare function colorGradientSampler(stops: readonly ColorGradientStop[], resolution?: number): ColorGradientSampler;
|
|
11
|
+
export declare class ColorGradientSampler {
|
|
12
|
+
private sampler;
|
|
13
|
+
constructor(sampler: Sampler2DNode);
|
|
14
|
+
sample(t: FloatNode): RgbaNode;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=gradient-sample.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{ClampToEdgeWrapping as r,Color as t,DataTexture as o,LinearFilter as n,RGBAFormat as e,UnsignedByteType as i}from"three";import{textureSampler2d as a,vec2 as s}from"three-shader-graph";export const defaultColorGradientStops=[{position:0,color:"#000000",alpha:1},{position:1,color:"#ffffff",alpha:1}];export function sampleColorGradient(r,t,o=256){return colorGradientSampler(r,o).sample(t)}export function colorGradientSampler(t,s=256){const c=Math.max(2,Math.floor(s)),f=p(t),m=new Uint8Array(4*c);for(let r=0;r<c;r++){const t=l(f,r/(c-1)),o=4*r;m[o]=u(t.r),m[o+1]=u(t.g),m[o+2]=u(t.b),m[o+3]=u(t.a)}const h=new o(m,c,1);return h.format=e,h.type=i,h.minFilter=h.magFilter=n,h.wrapS=r,h.wrapT=r,h.generateMipmaps=!1,h.needsUpdate=!0,new ColorGradientSampler(a(h))}export class ColorGradientSampler{constructor(r){this.sampler=r}sample(r){return this.sampler.sample(s(r,0))}}function p(r){const o=(r.length>0?r:defaultColorGradientStops).map(r=>{const o=function(r){if(Array.isArray(r))return{r:m(f(r[0],0)),g:m(f(r[1],0)),b:m(f(r[2],0)),a:m(f(r[3],1))};const o=r instanceof t?r:new t(r);return{r:o.r,g:o.g,b:o.b,a:1}}(r.color);return{position:m(f(r.position,0)),r:o.r,g:o.g,b:o.b,a:m(f(r.alpha,o.a))}}).sort((r,t)=>r.position-t.position);return o.length>0?o:p(defaultColorGradientStops)}function l(r,t){const o=m(t);if(o<=r[0].position)return r[0];const n=r[r.length-1];if(o>=n.position)return n;for(let t=1;t<r.length;t++){const n=r[t];if(o>n.position)continue;const e=r[t-1],i=n.position-e.position,a=i>0?(o-e.position)/i:1;return{position:o,r:c(e.r,n.r,a),g:c(e.g,n.g,a),b:c(e.b,n.b,a),a:c(e.a,n.a,a)}}return n}function u(r){return Math.round(255*m(r))}function c(r,t,o){return r+(t-r)*m(o)}function f(r,t){return"number"==typeof r&&Number.isFinite(r)?r:t}function m(r){return Math.min(1,Math.max(0,Number.isFinite(r)?r:0))}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -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";/*
|
|
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";/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { RgbNode, RgbaNode, FloatNode, Vec4Node, Vec3Node } from "three-shader-graph";
|
|
1
|
+
import { RgbNode, RgbaNode, FloatNode, Vec4Node, Vec3Node, Vec2Node } from "three-shader-graph";
|
|
2
2
|
export declare enum LayerMixMode {
|
|
3
3
|
hard = 0,
|
|
4
4
|
soft = 1
|
|
5
5
|
}
|
|
6
|
-
export
|
|
6
|
+
export type LayerMixValue = RgbNode | RgbaNode | Vec2Node | Vec3Node | Vec4Node | FloatNode;
|
|
7
|
+
export interface MixColorsOptions<T extends LayerMixValue> {
|
|
7
8
|
layerColors: T[];
|
|
9
|
+
layerWeights?: FloatNode[];
|
|
8
10
|
enableNoise?: boolean;
|
|
9
11
|
noiseScale?: number | FloatNode;
|
|
10
12
|
noiseAmount?: number | FloatNode;
|
|
11
13
|
decay?: number | FloatNode;
|
|
12
14
|
mode?: LayerMixMode;
|
|
13
15
|
}
|
|
14
|
-
export declare function
|
|
16
|
+
export declare function getPaintedMaterialLayerWeight(layerIndex: number): FloatNode;
|
|
17
|
+
export declare function mixColorsByLayer<T extends LayerMixValue>(options: MixColorsOptions<T>): T;
|
|
15
18
|
//# sourceMappingURL=layers.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{float as e,uniforms as
|
|
1
|
+
import{float as e,uniforms as a,vec4 as t,attributes as i,SimplexNoiseNode as r,select as o,mix as l,smoothstep as n,AttributeVec4Node as d,varying as s}from"three-shader-graph";export var LayerMixMode;!function(e){e[e.hard=0]="hard",e[e.soft=1]="soft"}(LayerMixMode||(LayerMixMode={}));const u={enableNoise:!0,noiseScale:e(.1),noiseAmount:e(.5),decay:.3,mode:LayerMixMode.soft},y=s(a.modelMatrix.multiplyVec(t(i.position,1)).xz),c=new d("material"),m=new d("material2"),p=s(c),x=s(m),h=[e(0),p.x,p.y,p.z,p.w,x.x,x.y,x.z,x.w];export function getPaintedMaterialLayerWeight(a){return h[a]??e(0)}export function mixColorsByLayer(a){const t={...u,...a},i=t.layerColors.slice(0,h.length).map((e,a)=>({value:e,weight:t.layerWeights?.[a]??h[a]})),d=e(t.noiseAmount).multiply(e(.1)),s=e(t.noiseScale),c=new r(y.multiplyScalar(s)).multiply(e(2)).subtract(e(1)).multiply(d),m=t.enableNoise?c:e(0),p=e(.5),x=t.enableNoise?p.add(c.multiply(e(.1))):p,M=i[0]?.value??t.layerColors[0],g=i.slice(1);if(t.mode==LayerMixMode.hard)return g.reduce((e,a)=>o(a.weight.gt(x),a.value,e),M);{const a=e(t.decay),i=e(.5),r=a.divide(e(2)),o=i.subtract(r),d=i.add(r);return g.reduce((e,a)=>l(e,a.value,n(o,d,a.weight.add(m))),M)}}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -19,4 +19,8 @@ export declare function vectorToRadial(vec: Vec2Node): {
|
|
|
19
19
|
radius: import("three-shader-graph").FloatAddNode;
|
|
20
20
|
angle: import("three-shader-graph").FloatDivNode;
|
|
21
21
|
};
|
|
22
|
+
export declare function remap(value: FloatNode, inMin: FloatNode, inMax: FloatNode, outMin: FloatNode, outMax: FloatNode): FloatNode;
|
|
23
|
+
export declare function hueShift(color: Vec3Node, shift: FloatNode): Vec3Node;
|
|
24
|
+
export declare function blendColor(base: Vec3Node, blend: Vec3Node, mode: string): Vec3Node;
|
|
25
|
+
export declare function desaturateColor(color: Vec3Node, fraction: FloatNode): Vec3Node;
|
|
22
26
|
//# sourceMappingURL=math.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{FloatNode as t,IntNode as r,Vec2Node as
|
|
1
|
+
import{FloatNode as t,IntNode as r,Vec2Node as u,Vec3Node as a,Vec4Node as c,atan2 as e,float as s,fract as l,int as n,sqrt as i,vec2 as o,vec3 as p,vec4 as d,cos as m,sin as y,cross as b,dot as f,step as h,mix as x}from"three-shader-graph";export function oneMinus(e){switch(!0){case e instanceof t:return s(1).subtract(e);case e instanceof r:return n(1).subtract(e);case e instanceof u:return o(1,1).subtract(e);case e instanceof a:return p(1,1,1).subtract(e);case e instanceof c:return d(1,1,1,1).subtract(e)}throw"Unsupported type "+e}export function vectorToRadial(t){const{x:r,y:u}=t,a=i(r.multiply(r).add(u.multiply(u))),c=l(e(u,r).divide(2*Math.PI));return{coords:o(c,a),radius:a,angle:c}}export function remap(t,r,u,a,c){return t.subtract(r).divide(u.subtract(r)).multiply(c.subtract(a)).add(a)}export function hueShift(t,r){const u=p(.577350269,.577350269,.577350269),a=m(r),c=y(r),e=p(a,a,a),l=p(c,c,c),n=f(u,t).multiply(s(1).subtract(a)),i=p(n,n,n),o=t.multiply(e),d=b(u,t).multiply(l),h=u.multiply(i);return o.add(d).add(h)}export function blendColor(t,r,u){switch(u){case"add":return t.add(r);case"screen":{const u=p(1,1,1);return u.subtract(u.subtract(t).multiply(u.subtract(r)))}case"overlay":{const u=p(1,1,1),a=p(2,2,2),c=h(p(.5,.5,.5),t),e=u.subtract(c),s=t.multiply(r).multiply(a),l=u.subtract(u.subtract(t).multiply(u.subtract(r)).multiply(a));return s.multiply(e).add(l.multiply(c))}case"softLight":{const u=p(1,1,1),a=p(2,2,2),c=h(p(.5,.5,.5),r),e=u.subtract(c),s=r.multiply(a).subtract(u),l=t.subtract(u.subtract(r.multiply(a)).multiply(t).multiply(u.subtract(t))),n=t.add(s.multiply(i(t).subtract(t)));return l.multiply(e).add(n.multiply(c))}default:return t.multiply(r)}}export function desaturateColor(t,r){const u=p(.2126,.7152,.0722),a=f(t,u),c=p(a,a,a);return x(t,c,r)}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import { FloatNode,
|
|
1
|
+
import { FloatNode, Vec3Node } from 'three-shader-graph';
|
|
2
|
+
import { Compiler } from 'three-shader-graph/build/main/lib/compiler';
|
|
2
3
|
export declare const particleEnergyUniformName = "hology_particle_energy";
|
|
3
4
|
export declare const particleTimeUniformName = "hology_particle_time";
|
|
4
5
|
export declare const particleVelcoityUniformName = "hology_particle_velocity";
|
|
6
|
+
declare class InstancedColorNode extends Vec3Node {
|
|
7
|
+
compile(c: Compiler): {
|
|
8
|
+
chunk: string;
|
|
9
|
+
out: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
5
12
|
export declare const particleUniforms: {
|
|
6
13
|
energy: FloatNode;
|
|
7
|
-
color:
|
|
14
|
+
color: InstancedColorNode;
|
|
8
15
|
opacity: FloatNode;
|
|
9
16
|
time: import("three-shader-graph").UniformFloatNode;
|
|
10
17
|
};
|
|
11
18
|
export declare const particleAttributes: {};
|
|
19
|
+
export {};
|
|
12
20
|
//# sourceMappingURL=particle.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Vector3 as e}from"three";import{attributeVec3 as
|
|
1
|
+
import{Vector3 as e}from"three";import{attributeVec3 as o,ifDefApply as t,uniformFloat as r,Vec3Node as n,UniformVec3Node as i,autoVarying as c}from"three-shader-graph";export const particleEnergyUniformName="hology_particle_energy";export const particleTimeUniformName="hology_particle_time";export const particleVelcoityUniformName="hology_particle_velocity";const a=new i("color",new e(1,1,1),void 0,!1);const l=c(new class extends n{compile(e){return{chunk:`\n #ifdef USE_INSTANCING_COLOR\n vec3 instanceColor = instanceColor;\n #else\n vec3 instanceColor = ${e.get(a)};\n #endif\n `,out:"instanceColor"}}});export const particleUniforms={energy:t("USE_INSTANCING",r("hology_particle_energy",1),()=>o("particleData").y),color:l,opacity:t("USE_INSTANCING",r("opacity",1),()=>o("particleData").x),time:r("hology_particle_time")};export const particleAttributes={};/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { FloatNode, Sampler2DNode, Vec2Node } from "three-shader-graph";
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function flipbookUv(uv: Vec2Node, columns: number | FloatNode, rows: number | FloatNode, time: FloatNode, fps?: number | FloatNode, mode?: 'clamp' | 'loop'): Vec2Node;
|
|
3
|
+
export declare function sampleFlipbook(sampler: Sampler2DNode, uv: Vec2Node, columns: number | FloatNode, rows: number | FloatNode, time: FloatNode, fps?: number | FloatNode, mode?: 'clamp' | 'loop'): import("three-shader-graph").RgbaNode;
|
|
3
4
|
//# sourceMappingURL=texture-sequence.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{float as
|
|
1
|
+
import{float as t,floor as i,min as l,mod as p,varying as e,vec2 as o}from"three-shader-graph";export function flipbookUv(a,r,c,d,m=60,s="clamp"){const u=t(r),n=t(c),b=t(m),v=u.multiply(n);let f;switch(s){case"clamp":f=i(l(d.multiply(b),v.subtract(1)));break;case"loop":f=i(p(d.multiply(b),v))}const y=t(1).divide(u),h=t(1).divide(n),k=p(f,u).multiply(y),x=i(f.divide(n).add(1)).multiply(h),U=o(k,t(1).subtract(x));return e(U.add(a.divide(o(u,n))))}export function sampleFlipbook(t,i,l,p,e,o=60,a="clamp"){const r=flipbookUv(i,l,p,e,o,a);return t.sample(r)}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{expect as e,test as t,vi as r}from"vitest";import{Vector3 as a}from"three";import{rgb as o}from"three-shader-graph";r.mock("three/examples/jsm/Addons.js",()=>({BufferGeometryUtils:{},ConvexHull:class{},SkeletonUtils:{clone:e=>e}}));import{convertConfiguredParamsToRuntimeTypes as n,convertConfiguredParamValueToRuntimeType as i,inferRuntimeSerializedParamTypeHint as c}from"../scene/custom-param-runtime-types.js";import{SerializedParamType as p}from"../scene/model.js";class s{constructor(){this.tint=o("white"),this.direction=new a(1,1,1)}}t("runtime parameter type inference uses class instance default values",()=>{e(c((new s).tint)?.type).toBe(p.RgbNode),e(c((new s).direction)?.type).toBe(p.Vector3)}),t("configured params can be retargeted to inferred runtime types",()=>{const t=new s,{params:r,skipped:a}=n({tint:{type:p.Color,value:"#336699"},direction:{type:p.Number,value:.5}},{parameterTarget:t});e(a).toEqual([]),e(r.tint).toMatchObject({type:p.RgbNode,value:"#336699"}),e(r.direction).toMatchObject({type:p.Vector3,value:[.5,.5,.5]})}),t("configured params are normalized when stored type changed but value shape did not",()=>{const t=i({type:p.Vector3,value:.5},{type:p.Vector3});e(t).toMatchObject({type:p.Vector3,value:[.5,.5,.5]})}),t("configured params that cannot be safely coerced are skipped",()=>{const t=new s,r=i({type:p.Texture,value:"texture-asset-id"},c(t.direction));e(r).toBeNull()}),t("runtime type conversion caches extracted parameter metadata",()=>{const t=r.fn(()=>[{name:"direction",type:a,options:{}}]),o=r.fn(()=>p.Vector3),i={direction:{type:p.Number,value:.5}};n(i,{parameterType:s,extractPropertyParameters:t,toSerializedParamType:o}),n(i,{parameterType:s,extractPropertyParameters:t,toSerializedParamType:o}),e(t).toHaveBeenCalledTimes(1),e(o).toHaveBeenCalledTimes(1)}),t("runtime type conversion can be disabled",()=>{const t={direction:{type:p.Number,value:.5}},{params:r,skipped:a}=n(t,{parameterTarget:new s,applyRuntimeParamTypeInference:!1});e(r).toBe(t),e(r.direction).toMatchObject({type:p.Number,value:.5}),e(a).toEqual([])});/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|