@triforge/shader-core 0.1.0

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 (297) hide show
  1. package/README.md +90 -0
  2. package/dist/bundle.js +5578 -0
  3. package/dist/core/CompileContext.d.ts +60 -0
  4. package/dist/core/CompileContext.d.ts.map +1 -0
  5. package/dist/core/CompileContext.js +276 -0
  6. package/dist/core/InputNode.d.ts +11 -0
  7. package/dist/core/InputNode.d.ts.map +1 -0
  8. package/dist/core/InputNode.js +13 -0
  9. package/dist/core/InputSocket.d.ts +21 -0
  10. package/dist/core/InputSocket.d.ts.map +1 -0
  11. package/dist/core/InputSocket.js +23 -0
  12. package/dist/core/OutputNode.d.ts +30 -0
  13. package/dist/core/OutputNode.d.ts.map +1 -0
  14. package/dist/core/OutputNode.js +60 -0
  15. package/dist/core/OutputSocket.d.ts +18 -0
  16. package/dist/core/OutputSocket.d.ts.map +1 -0
  17. package/dist/core/OutputSocket.js +16 -0
  18. package/dist/core/ProcessNode.d.ts +8 -0
  19. package/dist/core/ProcessNode.d.ts.map +1 -0
  20. package/dist/core/ProcessNode.js +7 -0
  21. package/dist/core/ShaderConfig.d.ts +13 -0
  22. package/dist/core/ShaderConfig.d.ts.map +1 -0
  23. package/dist/core/ShaderConfig.js +11 -0
  24. package/dist/core/ShaderNode.d.ts +114 -0
  25. package/dist/core/ShaderNode.d.ts.map +1 -0
  26. package/dist/core/ShaderNode.js +156 -0
  27. package/dist/core/ShaderNodeError.d.ts +32 -0
  28. package/dist/core/ShaderNodeError.d.ts.map +1 -0
  29. package/dist/core/ShaderNodeError.js +61 -0
  30. package/dist/core/SocketType.d.ts +12 -0
  31. package/dist/core/SocketType.d.ts.map +1 -0
  32. package/dist/core/SocketType.js +7 -0
  33. package/dist/index.d.ts +164 -0
  34. package/dist/index.d.ts.map +1 -0
  35. package/dist/index.js +108 -0
  36. package/dist/nodes/input/Attribute.d.ts +45 -0
  37. package/dist/nodes/input/Attribute.d.ts.map +1 -0
  38. package/dist/nodes/input/Attribute.js +58 -0
  39. package/dist/nodes/input/CameraData.d.ts +21 -0
  40. package/dist/nodes/input/CameraData.d.ts.map +1 -0
  41. package/dist/nodes/input/CameraData.js +33 -0
  42. package/dist/nodes/input/ColorAttribute.d.ts +28 -0
  43. package/dist/nodes/input/ColorAttribute.d.ts.map +1 -0
  44. package/dist/nodes/input/ColorAttribute.js +32 -0
  45. package/dist/nodes/input/Geometry.d.ts +23 -0
  46. package/dist/nodes/input/Geometry.d.ts.map +1 -0
  47. package/dist/nodes/input/Geometry.js +38 -0
  48. package/dist/nodes/input/HairInfo.d.ts +38 -0
  49. package/dist/nodes/input/HairInfo.d.ts.map +1 -0
  50. package/dist/nodes/input/HairInfo.js +50 -0
  51. package/dist/nodes/input/LayerWeight.d.ts +26 -0
  52. package/dist/nodes/input/LayerWeight.d.ts.map +1 -0
  53. package/dist/nodes/input/LayerWeight.js +35 -0
  54. package/dist/nodes/input/LightPath.d.ts +60 -0
  55. package/dist/nodes/input/LightPath.d.ts.map +1 -0
  56. package/dist/nodes/input/LightPath.js +112 -0
  57. package/dist/nodes/input/ObjectInfo.d.ts +22 -0
  58. package/dist/nodes/input/ObjectInfo.d.ts.map +1 -0
  59. package/dist/nodes/input/ObjectInfo.js +41 -0
  60. package/dist/nodes/input/OceanAttribute.d.ts +32 -0
  61. package/dist/nodes/input/OceanAttribute.d.ts.map +1 -0
  62. package/dist/nodes/input/OceanAttribute.js +38 -0
  63. package/dist/nodes/input/ParticleInfo.d.ts +31 -0
  64. package/dist/nodes/input/ParticleInfo.d.ts.map +1 -0
  65. package/dist/nodes/input/ParticleInfo.js +44 -0
  66. package/dist/nodes/input/RGB.d.ts +19 -0
  67. package/dist/nodes/input/RGB.d.ts.map +1 -0
  68. package/dist/nodes/input/RGB.js +23 -0
  69. package/dist/nodes/input/ScreenCamera.d.ts +37 -0
  70. package/dist/nodes/input/ScreenCamera.d.ts.map +1 -0
  71. package/dist/nodes/input/ScreenCamera.js +59 -0
  72. package/dist/nodes/input/Tangent.d.ts +21 -0
  73. package/dist/nodes/input/Tangent.d.ts.map +1 -0
  74. package/dist/nodes/input/Tangent.js +30 -0
  75. package/dist/nodes/input/TextureCoordinate.d.ts +17 -0
  76. package/dist/nodes/input/TextureCoordinate.d.ts.map +1 -0
  77. package/dist/nodes/input/TextureCoordinate.js +24 -0
  78. package/dist/nodes/input/UVMap.d.ts +20 -0
  79. package/dist/nodes/input/UVMap.d.ts.map +1 -0
  80. package/dist/nodes/input/UVMap.js +23 -0
  81. package/dist/nodes/input/Value.d.ts +19 -0
  82. package/dist/nodes/input/Value.d.ts.map +1 -0
  83. package/dist/nodes/input/Value.js +22 -0
  84. package/dist/nodes/input/Wireframe.d.ts +25 -0
  85. package/dist/nodes/input/Wireframe.d.ts.map +1 -0
  86. package/dist/nodes/input/Wireframe.js +30 -0
  87. package/dist/nodes/output/Displacement.d.ts +28 -0
  88. package/dist/nodes/output/Displacement.d.ts.map +1 -0
  89. package/dist/nodes/output/Displacement.js +34 -0
  90. package/dist/nodes/output/MaterialOutput.d.ts +43 -0
  91. package/dist/nodes/output/MaterialOutput.d.ts.map +1 -0
  92. package/dist/nodes/output/MaterialOutput.js +118 -0
  93. package/dist/nodes/output/ScreenOutput.d.ts +38 -0
  94. package/dist/nodes/output/ScreenOutput.d.ts.map +1 -0
  95. package/dist/nodes/output/ScreenOutput.js +88 -0
  96. package/dist/nodes/process/AddShader.d.ts +30 -0
  97. package/dist/nodes/process/AddShader.d.ts.map +1 -0
  98. package/dist/nodes/process/AddShader.js +36 -0
  99. package/dist/nodes/process/AnimatedNoiseTexture.d.ts +39 -0
  100. package/dist/nodes/process/AnimatedNoiseTexture.d.ts.map +1 -0
  101. package/dist/nodes/process/AnimatedNoiseTexture.js +93 -0
  102. package/dist/nodes/process/Blackbody.d.ts +29 -0
  103. package/dist/nodes/process/Blackbody.d.ts.map +1 -0
  104. package/dist/nodes/process/Blackbody.js +50 -0
  105. package/dist/nodes/process/BrickTexture.d.ts +36 -0
  106. package/dist/nodes/process/BrickTexture.d.ts.map +1 -0
  107. package/dist/nodes/process/BrickTexture.js +71 -0
  108. package/dist/nodes/process/BrightContrast.d.ts +30 -0
  109. package/dist/nodes/process/BrightContrast.d.ts.map +1 -0
  110. package/dist/nodes/process/BrightContrast.js +41 -0
  111. package/dist/nodes/process/Bump.d.ts +31 -0
  112. package/dist/nodes/process/Bump.d.ts.map +1 -0
  113. package/dist/nodes/process/Bump.js +65 -0
  114. package/dist/nodes/process/CheckerTexture.d.ts +30 -0
  115. package/dist/nodes/process/CheckerTexture.d.ts.map +1 -0
  116. package/dist/nodes/process/CheckerTexture.js +48 -0
  117. package/dist/nodes/process/Clamp.d.ts +32 -0
  118. package/dist/nodes/process/Clamp.d.ts.map +1 -0
  119. package/dist/nodes/process/Clamp.js +37 -0
  120. package/dist/nodes/process/ColorRamp.d.ts +28 -0
  121. package/dist/nodes/process/ColorRamp.d.ts.map +1 -0
  122. package/dist/nodes/process/ColorRamp.js +49 -0
  123. package/dist/nodes/process/CombineColor.d.ts +34 -0
  124. package/dist/nodes/process/CombineColor.d.ts.map +1 -0
  125. package/dist/nodes/process/CombineColor.js +69 -0
  126. package/dist/nodes/process/CombineRGB.d.ts +29 -0
  127. package/dist/nodes/process/CombineRGB.d.ts.map +1 -0
  128. package/dist/nodes/process/CombineRGB.js +33 -0
  129. package/dist/nodes/process/CombineXYZ.d.ts +29 -0
  130. package/dist/nodes/process/CombineXYZ.d.ts.map +1 -0
  131. package/dist/nodes/process/CombineXYZ.js +33 -0
  132. package/dist/nodes/process/DiffuseBSDF.d.ts +30 -0
  133. package/dist/nodes/process/DiffuseBSDF.d.ts.map +1 -0
  134. package/dist/nodes/process/DiffuseBSDF.js +43 -0
  135. package/dist/nodes/process/Emission.d.ts +30 -0
  136. package/dist/nodes/process/Emission.d.ts.map +1 -0
  137. package/dist/nodes/process/Emission.js +36 -0
  138. package/dist/nodes/process/EnvironmentTexture.d.ts +41 -0
  139. package/dist/nodes/process/EnvironmentTexture.d.ts.map +1 -0
  140. package/dist/nodes/process/EnvironmentTexture.js +65 -0
  141. package/dist/nodes/process/FloatCurve.d.ts +34 -0
  142. package/dist/nodes/process/FloatCurve.d.ts.map +1 -0
  143. package/dist/nodes/process/FloatCurve.js +46 -0
  144. package/dist/nodes/process/Fresnel.d.ts +36 -0
  145. package/dist/nodes/process/Fresnel.d.ts.map +1 -0
  146. package/dist/nodes/process/Fresnel.js +53 -0
  147. package/dist/nodes/process/Gamma.d.ts +29 -0
  148. package/dist/nodes/process/Gamma.d.ts.map +1 -0
  149. package/dist/nodes/process/Gamma.js +35 -0
  150. package/dist/nodes/process/GlassBSDF.d.ts +31 -0
  151. package/dist/nodes/process/GlassBSDF.d.ts.map +1 -0
  152. package/dist/nodes/process/GlassBSDF.js +51 -0
  153. package/dist/nodes/process/GlossyBSDF.d.ts +30 -0
  154. package/dist/nodes/process/GlossyBSDF.d.ts.map +1 -0
  155. package/dist/nodes/process/GlossyBSDF.js +50 -0
  156. package/dist/nodes/process/GradientTexture.d.ts +31 -0
  157. package/dist/nodes/process/GradientTexture.d.ts.map +1 -0
  158. package/dist/nodes/process/GradientTexture.js +49 -0
  159. package/dist/nodes/process/HashValue.d.ts +30 -0
  160. package/dist/nodes/process/HashValue.d.ts.map +1 -0
  161. package/dist/nodes/process/HashValue.js +34 -0
  162. package/dist/nodes/process/HueSaturationValue.d.ts +32 -0
  163. package/dist/nodes/process/HueSaturationValue.d.ts.map +1 -0
  164. package/dist/nodes/process/HueSaturationValue.js +58 -0
  165. package/dist/nodes/process/ImageTexture.d.ts +34 -0
  166. package/dist/nodes/process/ImageTexture.d.ts.map +1 -0
  167. package/dist/nodes/process/ImageTexture.js +53 -0
  168. package/dist/nodes/process/InvertColor.d.ts +29 -0
  169. package/dist/nodes/process/InvertColor.d.ts.map +1 -0
  170. package/dist/nodes/process/InvertColor.js +35 -0
  171. package/dist/nodes/process/MagicTexture.d.ts +30 -0
  172. package/dist/nodes/process/MagicTexture.d.ts.map +1 -0
  173. package/dist/nodes/process/MagicTexture.js +54 -0
  174. package/dist/nodes/process/MapRange.d.ts +38 -0
  175. package/dist/nodes/process/MapRange.d.ts.map +1 -0
  176. package/dist/nodes/process/MapRange.js +52 -0
  177. package/dist/nodes/process/Mapping.d.ts +37 -0
  178. package/dist/nodes/process/Mapping.d.ts.map +1 -0
  179. package/dist/nodes/process/Mapping.js +57 -0
  180. package/dist/nodes/process/Math.d.ts +40 -0
  181. package/dist/nodes/process/Math.d.ts.map +1 -0
  182. package/dist/nodes/process/Math.js +100 -0
  183. package/dist/nodes/process/MixRGB.d.ts +35 -0
  184. package/dist/nodes/process/MixRGB.d.ts.map +1 -0
  185. package/dist/nodes/process/MixRGB.js +63 -0
  186. package/dist/nodes/process/MixShader.d.ts +35 -0
  187. package/dist/nodes/process/MixShader.d.ts.map +1 -0
  188. package/dist/nodes/process/MixShader.js +47 -0
  189. package/dist/nodes/process/MusgraveTexture.d.ts +36 -0
  190. package/dist/nodes/process/MusgraveTexture.d.ts.map +1 -0
  191. package/dist/nodes/process/MusgraveTexture.js +70 -0
  192. package/dist/nodes/process/NoiseTexture.d.ts +31 -0
  193. package/dist/nodes/process/NoiseTexture.d.ts.map +1 -0
  194. package/dist/nodes/process/NoiseTexture.js +78 -0
  195. package/dist/nodes/process/Normal.d.ts +30 -0
  196. package/dist/nodes/process/Normal.d.ts.map +1 -0
  197. package/dist/nodes/process/Normal.js +38 -0
  198. package/dist/nodes/process/NormalMap.d.ts +34 -0
  199. package/dist/nodes/process/NormalMap.d.ts.map +1 -0
  200. package/dist/nodes/process/NormalMap.js +54 -0
  201. package/dist/nodes/process/PrincipledBSDF.d.ts +32 -0
  202. package/dist/nodes/process/PrincipledBSDF.d.ts.map +1 -0
  203. package/dist/nodes/process/PrincipledBSDF.js +75 -0
  204. package/dist/nodes/process/PrincipledHair.d.ts +63 -0
  205. package/dist/nodes/process/PrincipledHair.d.ts.map +1 -0
  206. package/dist/nodes/process/PrincipledHair.js +137 -0
  207. package/dist/nodes/process/PrincipledVolume.d.ts +37 -0
  208. package/dist/nodes/process/PrincipledVolume.d.ts.map +1 -0
  209. package/dist/nodes/process/PrincipledVolume.js +67 -0
  210. package/dist/nodes/process/RGBCurves.d.ts +45 -0
  211. package/dist/nodes/process/RGBCurves.d.ts.map +1 -0
  212. package/dist/nodes/process/RGBCurves.js +81 -0
  213. package/dist/nodes/process/RGBtoBW.d.ts +28 -0
  214. package/dist/nodes/process/RGBtoBW.d.ts.map +1 -0
  215. package/dist/nodes/process/RGBtoBW.js +31 -0
  216. package/dist/nodes/process/RefractionBSDF.d.ts +32 -0
  217. package/dist/nodes/process/RefractionBSDF.d.ts.map +1 -0
  218. package/dist/nodes/process/RefractionBSDF.js +46 -0
  219. package/dist/nodes/process/SchwarzschildMarch.d.ts +56 -0
  220. package/dist/nodes/process/SchwarzschildMarch.d.ts.map +1 -0
  221. package/dist/nodes/process/SchwarzschildMarch.js +306 -0
  222. package/dist/nodes/process/SeparateColor.d.ts +33 -0
  223. package/dist/nodes/process/SeparateColor.d.ts.map +1 -0
  224. package/dist/nodes/process/SeparateColor.js +79 -0
  225. package/dist/nodes/process/SeparateRGB.d.ts +27 -0
  226. package/dist/nodes/process/SeparateRGB.d.ts.map +1 -0
  227. package/dist/nodes/process/SeparateRGB.js +31 -0
  228. package/dist/nodes/process/SeparateXYZ.d.ts +27 -0
  229. package/dist/nodes/process/SeparateXYZ.d.ts.map +1 -0
  230. package/dist/nodes/process/SeparateXYZ.js +31 -0
  231. package/dist/nodes/process/ShaderScript.d.ts +95 -0
  232. package/dist/nodes/process/ShaderScript.d.ts.map +1 -0
  233. package/dist/nodes/process/ShaderScript.js +119 -0
  234. package/dist/nodes/process/ShaderToRGB.d.ts +28 -0
  235. package/dist/nodes/process/ShaderToRGB.d.ts.map +1 -0
  236. package/dist/nodes/process/ShaderToRGB.js +33 -0
  237. package/dist/nodes/process/SheenBSDF.d.ts +31 -0
  238. package/dist/nodes/process/SheenBSDF.d.ts.map +1 -0
  239. package/dist/nodes/process/SheenBSDF.js +49 -0
  240. package/dist/nodes/process/SpecularBSDF.d.ts +32 -0
  241. package/dist/nodes/process/SpecularBSDF.d.ts.map +1 -0
  242. package/dist/nodes/process/SpecularBSDF.js +54 -0
  243. package/dist/nodes/process/SubsurfaceScattering.d.ts +33 -0
  244. package/dist/nodes/process/SubsurfaceScattering.d.ts.map +1 -0
  245. package/dist/nodes/process/SubsurfaceScattering.js +46 -0
  246. package/dist/nodes/process/ToonBSDF.d.ts +31 -0
  247. package/dist/nodes/process/ToonBSDF.d.ts.map +1 -0
  248. package/dist/nodes/process/ToonBSDF.js +44 -0
  249. package/dist/nodes/process/TranslucentBSDF.d.ts +29 -0
  250. package/dist/nodes/process/TranslucentBSDF.d.ts.map +1 -0
  251. package/dist/nodes/process/TranslucentBSDF.js +39 -0
  252. package/dist/nodes/process/VectorCurves.d.ts +42 -0
  253. package/dist/nodes/process/VectorCurves.d.ts.map +1 -0
  254. package/dist/nodes/process/VectorCurves.js +71 -0
  255. package/dist/nodes/process/VectorMath.d.ts +38 -0
  256. package/dist/nodes/process/VectorMath.d.ts.map +1 -0
  257. package/dist/nodes/process/VectorMath.js +105 -0
  258. package/dist/nodes/process/VectorRotate.d.ts +34 -0
  259. package/dist/nodes/process/VectorRotate.d.ts.map +1 -0
  260. package/dist/nodes/process/VectorRotate.js +52 -0
  261. package/dist/nodes/process/VectorTransform.d.ts +36 -0
  262. package/dist/nodes/process/VectorTransform.d.ts.map +1 -0
  263. package/dist/nodes/process/VectorTransform.js +48 -0
  264. package/dist/nodes/process/VolumeAbsorption.d.ts +30 -0
  265. package/dist/nodes/process/VolumeAbsorption.d.ts.map +1 -0
  266. package/dist/nodes/process/VolumeAbsorption.js +36 -0
  267. package/dist/nodes/process/VolumeScatter.d.ts +31 -0
  268. package/dist/nodes/process/VolumeScatter.d.ts.map +1 -0
  269. package/dist/nodes/process/VolumeScatter.js +42 -0
  270. package/dist/nodes/process/VoronoiTexture.d.ts +38 -0
  271. package/dist/nodes/process/VoronoiTexture.d.ts.map +1 -0
  272. package/dist/nodes/process/VoronoiTexture.js +123 -0
  273. package/dist/nodes/process/WaveTexture.d.ts +39 -0
  274. package/dist/nodes/process/WaveTexture.d.ts.map +1 -0
  275. package/dist/nodes/process/WaveTexture.js +77 -0
  276. package/dist/nodes/process/Wavelength.d.ts +28 -0
  277. package/dist/nodes/process/Wavelength.d.ts.map +1 -0
  278. package/dist/nodes/process/Wavelength.js +43 -0
  279. package/dist/nodes/process/WhiteNoise.d.ts +27 -0
  280. package/dist/nodes/process/WhiteNoise.d.ts.map +1 -0
  281. package/dist/nodes/process/WhiteNoise.js +44 -0
  282. package/dist/nodes/shader/AmbientOcclusion.d.ts +47 -0
  283. package/dist/nodes/shader/AmbientOcclusion.d.ts.map +1 -0
  284. package/dist/nodes/shader/AmbientOcclusion.js +128 -0
  285. package/dist/nodes/shader/RayPortal.d.ts +57 -0
  286. package/dist/nodes/shader/RayPortal.d.ts.map +1 -0
  287. package/dist/nodes/shader/RayPortal.js +56 -0
  288. package/dist/shaders/color.d.ts +12 -0
  289. package/dist/shaders/color.d.ts.map +1 -0
  290. package/dist/shaders/color.js +42 -0
  291. package/dist/shaders/noise.d.ts +12 -0
  292. package/dist/shaders/noise.d.ts.map +1 -0
  293. package/dist/shaders/noise.js +70 -0
  294. package/dist/types/shader.d.ts +17 -0
  295. package/dist/types/shader.d.ts.map +1 -0
  296. package/dist/types/shader.js +1 -0
  297. package/package.json +44 -0
@@ -0,0 +1,60 @@
1
+ import type { ShaderNode } from './ShaderNode.js';
2
+ import type { InputSocket } from './InputSocket.js';
3
+ import type { OutputNode } from './OutputNode.js';
4
+ export interface CompiledMaterial {
5
+ vertexShader: string;
6
+ fragmentShader: string;
7
+ uniforms: Record<string, {
8
+ value: unknown;
9
+ }>;
10
+ nodes: ShaderNode[];
11
+ }
12
+ /**
13
+ * Walks the node graph from an OutputNode, validates all connections,
14
+ * deduplicates GLSL function definitions, scopes variable names to node IDs,
15
+ * and emits a complete vertex + fragment shader pair.
16
+ *
17
+ * Three responsibilities:
18
+ * 1. Topological sort — correct dependency order
19
+ * 2. Deduplication — one function def per node type
20
+ * 3. Variable authority — all GLSL variable names owned here
21
+ */
22
+ export declare class CompileContext {
23
+ private visited;
24
+ private visiting;
25
+ private order;
26
+ private emittedDefs;
27
+ private defs;
28
+ private calls;
29
+ private graphPath;
30
+ private _uniforms;
31
+ /** Collected vertex attribute→varying injections from all nodes. Keyed by varyingName. */
32
+ private _vertexInjections;
33
+ compile(outputNode: OutputNode): CompiledMaterial;
34
+ /**
35
+ * Returns the GLSL variable name for a node's output socket.
36
+ * Format: _st_{nodeId}_{socketName}
37
+ */
38
+ outputVar(node: ShaderNode, socketName: string): string;
39
+ /**
40
+ * Resolves an input socket to a GLSL expression.
41
+ * If connected → returns the upstream node's output variable name.
42
+ * If float with uniformName → registers a uniform and returns its name (live, GSAP-driveable).
43
+ * Otherwise → returns a GLSL literal from the socket's default value.
44
+ */
45
+ resolveInput(socket: InputSocket<unknown>): string;
46
+ private visit;
47
+ private emit;
48
+ private emitDefs;
49
+ private validate;
50
+ private validateNode;
51
+ private typesCompatible;
52
+ private buildVertexShader;
53
+ private buildUniformDeclarations;
54
+ private buildFragmentShader;
55
+ private toLiteral;
56
+ static hexToRgbArray(hex: string): [number, number, number];
57
+ static hexToVec3(hex: string): string;
58
+ private hexToVec3;
59
+ }
60
+ //# sourceMappingURL=CompileContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CompileContext.d.ts","sourceRoot":"","sources":["../../src/core/CompileContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAI,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAQ,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;IAClD,KAAK,EAAW,UAAU,EAAE,CAAA;CAC7B;AAED;;;;;;;;;GASG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,OAAO,CAAqD;IACpE,OAAO,CAAC,QAAQ,CAAoD;IACpE,OAAO,CAAC,KAAK,CAAgD;IAC7D,OAAO,CAAC,WAAW,CAAiD;IACpE,OAAO,CAAC,IAAI,CAAiD;IAC7D,OAAO,CAAC,KAAK,CAAgD;IAC7D,OAAO,CAAC,SAAS,CAA4C;IAC7D,OAAO,CAAC,SAAS,CAAuD;IACxE,0FAA0F;IAC1F,OAAO,CAAC,iBAAiB,CAAiE;IAI1F,OAAO,CAAC,UAAU,EAAE,UAAU,GAAG,gBAAgB;IAcjD;;;OAGG;IACH,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAKvD;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,MAAM;IAuBlD,OAAO,CAAC,KAAK;IA8Bb,OAAO,CAAC,IAAI;IAoBZ,OAAO,CAAC,QAAQ;IA0BhB,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,YAAY;IAsCpB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,iBAAiB;IAuBzB,OAAO,CAAC,wBAAwB;IAMhC,OAAO,CAAC,mBAAmB;IA2B3B,OAAO,CAAC,SAAS;IAqBjB,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;IAS3D,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAQrC,OAAO,CAAC,SAAS;CAGlB"}
@@ -0,0 +1,276 @@
1
+ import { ShaderNodeError } from './ShaderNodeError.js';
2
+ import { ShaderConfig } from './ShaderConfig.js';
3
+ /**
4
+ * Walks the node graph from an OutputNode, validates all connections,
5
+ * deduplicates GLSL function definitions, scopes variable names to node IDs,
6
+ * and emits a complete vertex + fragment shader pair.
7
+ *
8
+ * Three responsibilities:
9
+ * 1. Topological sort — correct dependency order
10
+ * 2. Deduplication — one function def per node type
11
+ * 3. Variable authority — all GLSL variable names owned here
12
+ */
13
+ export class CompileContext {
14
+ constructor() {
15
+ this.visited = new Set();
16
+ this.visiting = new Set();
17
+ this.order = [];
18
+ this.emittedDefs = new Set();
19
+ this.defs = [];
20
+ this.calls = [];
21
+ this.graphPath = [];
22
+ this._uniforms = {};
23
+ /** Collected vertex attribute→varying injections from all nodes. Keyed by varyingName. */
24
+ this._vertexInjections = new Map();
25
+ }
26
+ // ── Public API ────────────────────────────────────────────────────
27
+ compile(outputNode) {
28
+ this.graphPath = [outputNode.nodeType];
29
+ this.validate(outputNode);
30
+ this.visit(outputNode);
31
+ this.emit();
32
+ return {
33
+ vertexShader: this.buildVertexShader(),
34
+ fragmentShader: this.buildFragmentShader(),
35
+ uniforms: this._uniforms,
36
+ nodes: this.order,
37
+ };
38
+ }
39
+ /**
40
+ * Returns the GLSL variable name for a node's output socket.
41
+ * Format: _st_{nodeId}_{socketName}
42
+ */
43
+ outputVar(node, socketName) {
44
+ const safe = socketName.replace(/[^a-zA-Z0-9_]/g, '_');
45
+ return `_st_${node.id}_${safe}`;
46
+ }
47
+ /**
48
+ * Resolves an input socket to a GLSL expression.
49
+ * If connected → returns the upstream node's output variable name.
50
+ * If float with uniformName → registers a uniform and returns its name (live, GSAP-driveable).
51
+ * Otherwise → returns a GLSL literal from the socket's default value.
52
+ */
53
+ resolveInput(socket) {
54
+ if (socket.connection) {
55
+ return this.outputVar(socket.connection.node, socket.connection.name);
56
+ }
57
+ if (socket.uniformName !== null) {
58
+ if (!(socket.uniformName in this._uniforms)) {
59
+ if (socket.type === 'color') {
60
+ const raw = socket.defaultValue;
61
+ const rgb = typeof raw === 'string'
62
+ ? CompileContext.hexToRgbArray(raw)
63
+ : (Array.isArray(raw) ? raw : [1, 1, 1]);
64
+ this._uniforms[socket.uniformName] = { value: rgb };
65
+ }
66
+ else {
67
+ this._uniforms[socket.uniformName] = { value: socket.defaultValue };
68
+ }
69
+ }
70
+ return socket.uniformName;
71
+ }
72
+ return this.toLiteral(socket.defaultValue, socket.type);
73
+ }
74
+ // ── Graph walk ────────────────────────────────────────────────────
75
+ visit(node) {
76
+ if (this.visited.has(node.id))
77
+ return;
78
+ if (this.visiting.has(node.id)) {
79
+ ShaderNodeError.throw({
80
+ nodeType: node.nodeType,
81
+ nodeId: node.id,
82
+ problem: 'Circular dependency detected. A node cannot depend on itself through its own chain.',
83
+ fix: 'Node outputs can only flow forward toward MaterialOutput, never back upstream.',
84
+ graphPath: [...this.graphPath],
85
+ });
86
+ }
87
+ this.visiting.add(node.id);
88
+ this.graphPath.push(node.nodeType);
89
+ for (const socket of Object.values(node.getInputSockets())) {
90
+ if (socket.connection) {
91
+ this.visit(socket.connection.node);
92
+ }
93
+ }
94
+ this.graphPath.pop();
95
+ this.visiting.delete(node.id);
96
+ this.visited.add(node.id);
97
+ this.order.push(node);
98
+ }
99
+ // ── Emission ──────────────────────────────────────────────────────
100
+ emit() {
101
+ for (const node of this.order) {
102
+ this.emitDefs(node);
103
+ const call = node.compileCall(this).trim();
104
+ if (call)
105
+ this.calls.push(call);
106
+ // Collect vertex attribute injections from this node
107
+ for (const inj of node.vertexInjections()) {
108
+ if (!this._vertexInjections.has(inj.varyingName)) {
109
+ this._vertexInjections.set(inj.varyingName, { attrName: inj.attrName, attrType: inj.attrType });
110
+ }
111
+ }
112
+ // Collect extra uniforms (e.g. LightPath ray-type flags)
113
+ for (const [name, value] of Object.entries(node.extraUniforms())) {
114
+ if (!(name in this._uniforms)) {
115
+ this._uniforms[name] = { value };
116
+ }
117
+ }
118
+ }
119
+ }
120
+ emitDefs(node) {
121
+ const NodeClass = node.constructor;
122
+ const isInstanceSpecific = NodeClass.instanceSpecificDef;
123
+ // Per-instance override takes priority
124
+ const fn = node.glslFunction
125
+ ?? NodeClass.glslFunction;
126
+ const defsSource = node.compileDefs();
127
+ if (isInstanceSpecific) {
128
+ // Each instance emits its own uniquely named function — no dedup
129
+ if (defsSource.trim())
130
+ this.defs.push(defsSource);
131
+ }
132
+ else {
133
+ // Shared function — emit once per node type
134
+ const key = node.nodeType;
135
+ if (!this.emittedDefs.has(key)) {
136
+ this.emittedDefs.add(key);
137
+ const source = fn ?? defsSource;
138
+ if (source.trim())
139
+ this.defs.push(source);
140
+ }
141
+ }
142
+ }
143
+ // ── Validation ────────────────────────────────────────────────────
144
+ validate(root) {
145
+ if (ShaderConfig.errorLevel === 'off')
146
+ return;
147
+ this.validateNode(root, [root.nodeType]);
148
+ }
149
+ validateNode(node, path) {
150
+ for (const [, socket] of Object.entries(node.getInputSockets())) {
151
+ // Required input with no connection and no usable default
152
+ if (socket.required && !socket.isConnected()) {
153
+ ShaderNodeError.throw({
154
+ nodeType: node.nodeType,
155
+ nodeId: node.id,
156
+ inputName: socket.name,
157
+ problem: `Required input "${socket.name}" has no connection.`,
158
+ fix: `Connect a node output to ${node.nodeType}.input("${socket.name}").`,
159
+ graphPath: path,
160
+ });
161
+ }
162
+ if (socket.connection) {
163
+ const upstream = socket.connection;
164
+ // Type compatibility check
165
+ const compatible = this.typesCompatible(upstream.type, socket.type);
166
+ if (!compatible) {
167
+ ShaderNodeError.throw({
168
+ nodeType: node.nodeType,
169
+ nodeId: node.id,
170
+ inputName: socket.name,
171
+ problem: `Type mismatch. Input "${socket.name}" expects "${socket.type}" but received "${upstream.type}" from ${upstream.node.nodeType}.output("${upstream.name}").`,
172
+ fix: ShaderConfig.errorLevel === 'verbose'
173
+ ? `Use an output socket of type "${socket.type}", or insert a conversion node between them.`
174
+ : undefined,
175
+ graphPath: path,
176
+ });
177
+ }
178
+ // Recurse
179
+ this.validateNode(upstream.node, [upstream.node.nodeType, ...path]);
180
+ }
181
+ }
182
+ }
183
+ typesCompatible(from, to) {
184
+ if (from === to)
185
+ return true;
186
+ // shader and color are both vec3 — compatible
187
+ if ((from === 'shader' || from === 'color') && (to === 'shader' || to === 'color'))
188
+ return true;
189
+ return false;
190
+ }
191
+ // ── GLSL builders ─────────────────────────────────────────────────
192
+ buildVertexShader() {
193
+ const customAttrs = [...this._vertexInjections.entries()]
194
+ .map(([vName, { attrName, attrType }]) => `attribute ${attrType} ${attrName};\nvarying ${attrType} ${vName};`)
195
+ .join('\n');
196
+ const customAssigns = [...this._vertexInjections.entries()]
197
+ .map(([vName, { attrName }]) => ` ${vName} = ${attrName};`)
198
+ .join('\n');
199
+ return `
200
+ varying vec2 vUv;
201
+ varying vec3 vNormal;
202
+ varying vec3 vPosition;
203
+ ${customAttrs}
204
+
205
+ void main() {
206
+ vUv = uv;
207
+ vNormal = normalize(mat3(transpose(inverse(modelMatrix))) * normal);
208
+ vPosition = (modelMatrix * vec4(position, 1.0)).xyz;
209
+ ${customAssigns}
210
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
211
+ }`.trim();
212
+ }
213
+ buildUniformDeclarations() {
214
+ return Object.entries(this._uniforms)
215
+ .map(([name, { value }]) => Array.isArray(value) ? `uniform vec3 ${name};` : `uniform float ${name};`)
216
+ .join('\n');
217
+ }
218
+ buildFragmentShader() {
219
+ const uniformsBlock = this.buildUniformDeclarations();
220
+ const customVaryings = [...this._vertexInjections.entries()]
221
+ .map(([vName, { attrType }]) => `varying ${attrType} ${vName};`)
222
+ .join('\n');
223
+ const defsBlock = this.defs.join('\n\n');
224
+ const callsBlock = this.calls.map(c => ` ${c}`).join('\n');
225
+ return `
226
+ precision mediump float;
227
+
228
+ varying vec2 vUv;
229
+ varying vec3 vNormal;
230
+ varying vec3 vPosition;
231
+ ${customVaryings}
232
+
233
+ ${uniformsBlock}
234
+
235
+ ${defsBlock}
236
+
237
+ void main() {
238
+ ${callsBlock}
239
+ }`.trim();
240
+ }
241
+ // ── Literal conversion ────────────────────────────────────────────
242
+ toLiteral(value, type) {
243
+ switch (type) {
244
+ case 'float':
245
+ return (typeof value === 'number' ? value : 0).toFixed(4);
246
+ case 'color':
247
+ return typeof value === 'string'
248
+ ? this.hexToVec3(value)
249
+ : 'vec3(1.0, 1.0, 1.0)';
250
+ case 'vector':
251
+ return 'vec2(vUv)';
252
+ case 'shader':
253
+ return 'vec3(0.0)';
254
+ default:
255
+ return 'vec3(1.0)';
256
+ }
257
+ }
258
+ static hexToRgbArray(hex) {
259
+ const h = hex.replace('#', '');
260
+ return [
261
+ parseInt(h.substring(0, 2), 16) / 255,
262
+ parseInt(h.substring(2, 4), 16) / 255,
263
+ parseInt(h.substring(4, 6), 16) / 255,
264
+ ];
265
+ }
266
+ static hexToVec3(hex) {
267
+ const h = hex.replace('#', '');
268
+ const r = (parseInt(h.substring(0, 2), 16) / 255).toFixed(4);
269
+ const g = (parseInt(h.substring(2, 4), 16) / 255).toFixed(4);
270
+ const b = (parseInt(h.substring(4, 6), 16) / 255).toFixed(4);
271
+ return `vec3(${r}, ${g}, ${b})`;
272
+ }
273
+ hexToVec3(hex) {
274
+ return CompileContext.hexToVec3(hex);
275
+ }
276
+ }
@@ -0,0 +1,11 @@
1
+ import { ShaderNode } from './ShaderNode.js';
2
+ import type { InputSocket } from './InputSocket.js';
3
+ /**
4
+ * Source node — outputs only, no upstream connections.
5
+ * Examples: TextureCoordinate, Value, RGB constant.
6
+ */
7
+ export declare abstract class InputNode extends ShaderNode {
8
+ getInputSockets(): Record<string, InputSocket<unknown>>;
9
+ compileDefs(): string;
10
+ }
11
+ //# sourceMappingURL=InputNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputNode.d.ts","sourceRoot":"","sources":["../../src/core/InputNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD;;;GAGG;AACH,8BAAsB,SAAU,SAAQ,UAAU;IAChD,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAIvD,WAAW,IAAI,MAAM;CAGtB"}
@@ -0,0 +1,13 @@
1
+ import { ShaderNode } from './ShaderNode.js';
2
+ /**
3
+ * Source node — outputs only, no upstream connections.
4
+ * Examples: TextureCoordinate, Value, RGB constant.
5
+ */
6
+ export class InputNode extends ShaderNode {
7
+ getInputSockets() {
8
+ return {};
9
+ }
10
+ compileDefs() {
11
+ return '';
12
+ }
13
+ }
@@ -0,0 +1,21 @@
1
+ import type { SocketType } from './SocketType.js';
2
+ import type { OutputSocket } from './OutputSocket.js';
3
+ /**
4
+ * Represents an input connection point on a node.
5
+ * Accepts either a literal value or a connected OutputSocket.
6
+ */
7
+ export declare class InputSocket<T> {
8
+ readonly name: string;
9
+ readonly type: SocketType;
10
+ readonly defaultValue: T;
11
+ readonly required: boolean;
12
+ /** Connected upstream socket — overrides value when set. */
13
+ connection: OutputSocket | null;
14
+ /** GLSL uniform name for this socket. Set by createInputs for float inputs. */
15
+ uniformName: string | null;
16
+ constructor(name: string, type: SocketType, defaultValue: T, required?: boolean);
17
+ /** The literal value — used when no connection is present. */
18
+ get value(): T;
19
+ isConnected(): boolean;
20
+ }
21
+ //# sourceMappingURL=InputSocket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InputSocket.d.ts","sourceRoot":"","sources":["../../src/core/InputSocket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD;;;GAGG;AACH,qBAAa,WAAW,CAAC,CAAC;aAQN,IAAI,EAAU,MAAM;aACpB,IAAI,EAAU,UAAU;aACxB,YAAY,EAAE,CAAC;aACf,QAAQ,EAAM,OAAO;IAVvC,4DAA4D;IAC5D,UAAU,EAAE,YAAY,GAAG,IAAI,CAAO;IAEtC,+EAA+E;IAC/E,WAAW,EAAE,MAAM,GAAG,IAAI,CAAO;gBAGf,IAAI,EAAU,MAAM,EACpB,IAAI,EAAU,UAAU,EACxB,YAAY,EAAE,CAAC,EACf,QAAQ,GAAM,OAAe;IAG/C,8DAA8D;IAC9D,IAAI,KAAK,IAAI,CAAC,CAEb;IAED,WAAW,IAAI,OAAO;CAGvB"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Represents an input connection point on a node.
3
+ * Accepts either a literal value or a connected OutputSocket.
4
+ */
5
+ export class InputSocket {
6
+ constructor(name, type, defaultValue, required = false) {
7
+ this.name = name;
8
+ this.type = type;
9
+ this.defaultValue = defaultValue;
10
+ this.required = required;
11
+ /** Connected upstream socket — overrides value when set. */
12
+ this.connection = null;
13
+ /** GLSL uniform name for this socket. Set by createInputs for float inputs. */
14
+ this.uniformName = null;
15
+ }
16
+ /** The literal value — used when no connection is present. */
17
+ get value() {
18
+ return this.defaultValue;
19
+ }
20
+ isConnected() {
21
+ return this.connection !== null;
22
+ }
23
+ }
@@ -0,0 +1,30 @@
1
+ import { ShaderNode } from './ShaderNode.js';
2
+ import { ShaderMaterial } from 'three';
3
+ import type { OutputSocket } from './OutputSocket.js';
4
+ /**
5
+ * Terminal node — inputs only, no outputs.
6
+ * Owns compile() — the entry point for the entire graph.
7
+ * Example: MaterialOutput.
8
+ */
9
+ export declare abstract class OutputNode extends ShaderNode {
10
+ /** The compiled THREE.ShaderMaterial — available after compile() is called. */
11
+ material: ShaderMaterial | null;
12
+ getOutputSockets(): Record<string, OutputSocket>;
13
+ compileDefs(): string;
14
+ /**
15
+ * Walks the full node graph, validates all connections,
16
+ * compiles to GLSL, and returns a ready-to-use THREE.ShaderMaterial.
17
+ *
18
+ * The result is also stored on .material so it can be reused
19
+ * across any number of meshes without recompiling.
20
+ *
21
+ * @example
22
+ * const blueMetal = new MaterialOutput({ surface: bsdf.output('BSDF') })
23
+ * blueMetal.compile()
24
+ *
25
+ * const torus = new THREE.Mesh(torusGeo, blueMetal.material)
26
+ * const sphere = new THREE.Mesh(sphereGeo, blueMetal.material)
27
+ */
28
+ compile(): ShaderMaterial;
29
+ }
30
+ //# sourceMappingURL=OutputNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OutputNode.d.ts","sourceRoot":"","sources":["../../src/core/OutputNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,cAAc,EAAW,MAAM,OAAO,CAAA;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD;;;;GAIG;AACH,8BAAsB,UAAW,SAAQ,UAAU;IACjD,+EAA+E;IAC/E,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAO;IAEtC,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC;IAIhD,WAAW,IAAI,MAAM;IAIrB;;;;;;;;;;;;;OAaG;IACH,OAAO,IAAI,cAAc;CAyB1B"}
@@ -0,0 +1,60 @@
1
+ import { ShaderNode } from './ShaderNode.js';
2
+ import { CompileContext } from './CompileContext.js';
3
+ import { ShaderMaterial, Vector3 } from 'three';
4
+ /**
5
+ * Terminal node — inputs only, no outputs.
6
+ * Owns compile() — the entry point for the entire graph.
7
+ * Example: MaterialOutput.
8
+ */
9
+ export class OutputNode extends ShaderNode {
10
+ constructor() {
11
+ super(...arguments);
12
+ /** The compiled THREE.ShaderMaterial — available after compile() is called. */
13
+ this.material = null;
14
+ }
15
+ getOutputSockets() {
16
+ return {};
17
+ }
18
+ compileDefs() {
19
+ return '';
20
+ }
21
+ /**
22
+ * Walks the full node graph, validates all connections,
23
+ * compiles to GLSL, and returns a ready-to-use THREE.ShaderMaterial.
24
+ *
25
+ * The result is also stored on .material so it can be reused
26
+ * across any number of meshes without recompiling.
27
+ *
28
+ * @example
29
+ * const blueMetal = new MaterialOutput({ surface: bsdf.output('BSDF') })
30
+ * blueMetal.compile()
31
+ *
32
+ * const torus = new THREE.Mesh(torusGeo, blueMetal.material)
33
+ * const sphere = new THREE.Mesh(sphereGeo, blueMetal.material)
34
+ */
35
+ compile() {
36
+ const ctx = new CompileContext();
37
+ const compiled = ctx.compile(this);
38
+ this.material = new ShaderMaterial({
39
+ vertexShader: compiled.vertexShader,
40
+ fragmentShader: compiled.fragmentShader,
41
+ uniforms: compiled.uniforms,
42
+ });
43
+ // Inject default scene-lighting uniforms used by PrincipledBSDF.
44
+ // Users can override these after compile() to match their scene lights.
45
+ if (!this.material.uniforms.uSunDirection) {
46
+ this.material.uniforms.uSunDirection = { value: new Vector3(1, 2, 1).normalize() };
47
+ }
48
+ if (!this.material.uniforms.uSunColor) {
49
+ this.material.uniforms.uSunColor = { value: new Vector3(1.0, 0.97, 0.9) };
50
+ }
51
+ if (!this.material.uniforms.uAmbientColor) {
52
+ this.material.uniforms.uAmbientColor = { value: new Vector3(0.05, 0.08, 0.18) };
53
+ }
54
+ // Wire each node's parameters object to the live GPU uniforms
55
+ for (const node of compiled.nodes) {
56
+ node._wireParameters(this.material.uniforms);
57
+ }
58
+ return this.material;
59
+ }
60
+ }
@@ -0,0 +1,18 @@
1
+ import type { SocketType } from './SocketType.js';
2
+ import type { ShaderNode } from './ShaderNode.js';
3
+ /**
4
+ * Represents an output connection point on a node.
5
+ * Pass to a downstream node's input to wire the graph.
6
+ *
7
+ * Example:
8
+ * const noise = new NoiseTexture({ scale: 3.0 })
9
+ * noise.output('Fac') // returns an OutputSocket
10
+ * noise.output('Color') // returns an OutputSocket
11
+ */
12
+ export declare class OutputSocket {
13
+ readonly node: ShaderNode;
14
+ readonly name: string;
15
+ readonly type: SocketType;
16
+ constructor(node: ShaderNode, name: string, type: SocketType);
17
+ }
18
+ //# sourceMappingURL=OutputSocket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OutputSocket.d.ts","sourceRoot":"","sources":["../../src/core/OutputSocket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD;;;;;;;;GAQG;AACH,qBAAa,YAAY;aAEL,IAAI,EAAE,UAAU;aAChB,IAAI,EAAE,MAAM;aACZ,IAAI,EAAE,UAAU;gBAFhB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU;CAEnC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Represents an output connection point on a node.
3
+ * Pass to a downstream node's input to wire the graph.
4
+ *
5
+ * Example:
6
+ * const noise = new NoiseTexture({ scale: 3.0 })
7
+ * noise.output('Fac') // returns an OutputSocket
8
+ * noise.output('Color') // returns an OutputSocket
9
+ */
10
+ export class OutputSocket {
11
+ constructor(node, name, type) {
12
+ this.node = node;
13
+ this.name = name;
14
+ this.type = type;
15
+ }
16
+ }
@@ -0,0 +1,8 @@
1
+ import { ShaderNode } from './ShaderNode.js';
2
+ /**
3
+ * Transform node — has both inputs and outputs.
4
+ * Examples: NoiseTexture, ColorRamp, PrincipledBSDF.
5
+ */
6
+ export declare abstract class ProcessNode extends ShaderNode {
7
+ }
8
+ //# sourceMappingURL=ProcessNode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcessNode.d.ts","sourceRoot":"","sources":["../../src/core/ProcessNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C;;;GAGG;AACH,8BAAsB,WAAY,SAAQ,UAAU;CAAG"}
@@ -0,0 +1,7 @@
1
+ import { ShaderNode } from './ShaderNode.js';
2
+ /**
3
+ * Transform node — has both inputs and outputs.
4
+ * Examples: NoiseTexture, ColorRamp, PrincipledBSDF.
5
+ */
6
+ export class ProcessNode extends ShaderNode {
7
+ }
@@ -0,0 +1,13 @@
1
+ export type ErrorLevel = 'verbose' | 'standard' | 'off';
2
+ /**
3
+ * Global configuration for @st-shader-core.
4
+ *
5
+ * Set errorLevel before building any materials:
6
+ * ShaderConfig.errorLevel = 'verbose' // development
7
+ * ShaderConfig.errorLevel = 'standard' // production (default)
8
+ * ShaderConfig.errorLevel = 'off' // maximum performance
9
+ */
10
+ export declare const ShaderConfig: {
11
+ errorLevel: ErrorLevel;
12
+ };
13
+ //# sourceMappingURL=ShaderConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShaderConfig.d.ts","sourceRoot":"","sources":["../../src/core/ShaderConfig.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,KAAK,CAAA;AAEvD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY;gBACG,UAAU;CACrC,CAAA"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Global configuration for @st-shader-core.
3
+ *
4
+ * Set errorLevel before building any materials:
5
+ * ShaderConfig.errorLevel = 'verbose' // development
6
+ * ShaderConfig.errorLevel = 'standard' // production (default)
7
+ * ShaderConfig.errorLevel = 'off' // maximum performance
8
+ */
9
+ export const ShaderConfig = {
10
+ errorLevel: 'standard',
11
+ };