@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.
- package/README.md +90 -0
- package/dist/bundle.js +5578 -0
- package/dist/core/CompileContext.d.ts +60 -0
- package/dist/core/CompileContext.d.ts.map +1 -0
- package/dist/core/CompileContext.js +276 -0
- package/dist/core/InputNode.d.ts +11 -0
- package/dist/core/InputNode.d.ts.map +1 -0
- package/dist/core/InputNode.js +13 -0
- package/dist/core/InputSocket.d.ts +21 -0
- package/dist/core/InputSocket.d.ts.map +1 -0
- package/dist/core/InputSocket.js +23 -0
- package/dist/core/OutputNode.d.ts +30 -0
- package/dist/core/OutputNode.d.ts.map +1 -0
- package/dist/core/OutputNode.js +60 -0
- package/dist/core/OutputSocket.d.ts +18 -0
- package/dist/core/OutputSocket.d.ts.map +1 -0
- package/dist/core/OutputSocket.js +16 -0
- package/dist/core/ProcessNode.d.ts +8 -0
- package/dist/core/ProcessNode.d.ts.map +1 -0
- package/dist/core/ProcessNode.js +7 -0
- package/dist/core/ShaderConfig.d.ts +13 -0
- package/dist/core/ShaderConfig.d.ts.map +1 -0
- package/dist/core/ShaderConfig.js +11 -0
- package/dist/core/ShaderNode.d.ts +114 -0
- package/dist/core/ShaderNode.d.ts.map +1 -0
- package/dist/core/ShaderNode.js +156 -0
- package/dist/core/ShaderNodeError.d.ts +32 -0
- package/dist/core/ShaderNodeError.d.ts.map +1 -0
- package/dist/core/ShaderNodeError.js +61 -0
- package/dist/core/SocketType.d.ts +12 -0
- package/dist/core/SocketType.d.ts.map +1 -0
- package/dist/core/SocketType.js +7 -0
- package/dist/index.d.ts +164 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +108 -0
- package/dist/nodes/input/Attribute.d.ts +45 -0
- package/dist/nodes/input/Attribute.d.ts.map +1 -0
- package/dist/nodes/input/Attribute.js +58 -0
- package/dist/nodes/input/CameraData.d.ts +21 -0
- package/dist/nodes/input/CameraData.d.ts.map +1 -0
- package/dist/nodes/input/CameraData.js +33 -0
- package/dist/nodes/input/ColorAttribute.d.ts +28 -0
- package/dist/nodes/input/ColorAttribute.d.ts.map +1 -0
- package/dist/nodes/input/ColorAttribute.js +32 -0
- package/dist/nodes/input/Geometry.d.ts +23 -0
- package/dist/nodes/input/Geometry.d.ts.map +1 -0
- package/dist/nodes/input/Geometry.js +38 -0
- package/dist/nodes/input/HairInfo.d.ts +38 -0
- package/dist/nodes/input/HairInfo.d.ts.map +1 -0
- package/dist/nodes/input/HairInfo.js +50 -0
- package/dist/nodes/input/LayerWeight.d.ts +26 -0
- package/dist/nodes/input/LayerWeight.d.ts.map +1 -0
- package/dist/nodes/input/LayerWeight.js +35 -0
- package/dist/nodes/input/LightPath.d.ts +60 -0
- package/dist/nodes/input/LightPath.d.ts.map +1 -0
- package/dist/nodes/input/LightPath.js +112 -0
- package/dist/nodes/input/ObjectInfo.d.ts +22 -0
- package/dist/nodes/input/ObjectInfo.d.ts.map +1 -0
- package/dist/nodes/input/ObjectInfo.js +41 -0
- package/dist/nodes/input/OceanAttribute.d.ts +32 -0
- package/dist/nodes/input/OceanAttribute.d.ts.map +1 -0
- package/dist/nodes/input/OceanAttribute.js +38 -0
- package/dist/nodes/input/ParticleInfo.d.ts +31 -0
- package/dist/nodes/input/ParticleInfo.d.ts.map +1 -0
- package/dist/nodes/input/ParticleInfo.js +44 -0
- package/dist/nodes/input/RGB.d.ts +19 -0
- package/dist/nodes/input/RGB.d.ts.map +1 -0
- package/dist/nodes/input/RGB.js +23 -0
- package/dist/nodes/input/ScreenCamera.d.ts +37 -0
- package/dist/nodes/input/ScreenCamera.d.ts.map +1 -0
- package/dist/nodes/input/ScreenCamera.js +59 -0
- package/dist/nodes/input/Tangent.d.ts +21 -0
- package/dist/nodes/input/Tangent.d.ts.map +1 -0
- package/dist/nodes/input/Tangent.js +30 -0
- package/dist/nodes/input/TextureCoordinate.d.ts +17 -0
- package/dist/nodes/input/TextureCoordinate.d.ts.map +1 -0
- package/dist/nodes/input/TextureCoordinate.js +24 -0
- package/dist/nodes/input/UVMap.d.ts +20 -0
- package/dist/nodes/input/UVMap.d.ts.map +1 -0
- package/dist/nodes/input/UVMap.js +23 -0
- package/dist/nodes/input/Value.d.ts +19 -0
- package/dist/nodes/input/Value.d.ts.map +1 -0
- package/dist/nodes/input/Value.js +22 -0
- package/dist/nodes/input/Wireframe.d.ts +25 -0
- package/dist/nodes/input/Wireframe.d.ts.map +1 -0
- package/dist/nodes/input/Wireframe.js +30 -0
- package/dist/nodes/output/Displacement.d.ts +28 -0
- package/dist/nodes/output/Displacement.d.ts.map +1 -0
- package/dist/nodes/output/Displacement.js +34 -0
- package/dist/nodes/output/MaterialOutput.d.ts +43 -0
- package/dist/nodes/output/MaterialOutput.d.ts.map +1 -0
- package/dist/nodes/output/MaterialOutput.js +118 -0
- package/dist/nodes/output/ScreenOutput.d.ts +38 -0
- package/dist/nodes/output/ScreenOutput.d.ts.map +1 -0
- package/dist/nodes/output/ScreenOutput.js +88 -0
- package/dist/nodes/process/AddShader.d.ts +30 -0
- package/dist/nodes/process/AddShader.d.ts.map +1 -0
- package/dist/nodes/process/AddShader.js +36 -0
- package/dist/nodes/process/AnimatedNoiseTexture.d.ts +39 -0
- package/dist/nodes/process/AnimatedNoiseTexture.d.ts.map +1 -0
- package/dist/nodes/process/AnimatedNoiseTexture.js +93 -0
- package/dist/nodes/process/Blackbody.d.ts +29 -0
- package/dist/nodes/process/Blackbody.d.ts.map +1 -0
- package/dist/nodes/process/Blackbody.js +50 -0
- package/dist/nodes/process/BrickTexture.d.ts +36 -0
- package/dist/nodes/process/BrickTexture.d.ts.map +1 -0
- package/dist/nodes/process/BrickTexture.js +71 -0
- package/dist/nodes/process/BrightContrast.d.ts +30 -0
- package/dist/nodes/process/BrightContrast.d.ts.map +1 -0
- package/dist/nodes/process/BrightContrast.js +41 -0
- package/dist/nodes/process/Bump.d.ts +31 -0
- package/dist/nodes/process/Bump.d.ts.map +1 -0
- package/dist/nodes/process/Bump.js +65 -0
- package/dist/nodes/process/CheckerTexture.d.ts +30 -0
- package/dist/nodes/process/CheckerTexture.d.ts.map +1 -0
- package/dist/nodes/process/CheckerTexture.js +48 -0
- package/dist/nodes/process/Clamp.d.ts +32 -0
- package/dist/nodes/process/Clamp.d.ts.map +1 -0
- package/dist/nodes/process/Clamp.js +37 -0
- package/dist/nodes/process/ColorRamp.d.ts +28 -0
- package/dist/nodes/process/ColorRamp.d.ts.map +1 -0
- package/dist/nodes/process/ColorRamp.js +49 -0
- package/dist/nodes/process/CombineColor.d.ts +34 -0
- package/dist/nodes/process/CombineColor.d.ts.map +1 -0
- package/dist/nodes/process/CombineColor.js +69 -0
- package/dist/nodes/process/CombineRGB.d.ts +29 -0
- package/dist/nodes/process/CombineRGB.d.ts.map +1 -0
- package/dist/nodes/process/CombineRGB.js +33 -0
- package/dist/nodes/process/CombineXYZ.d.ts +29 -0
- package/dist/nodes/process/CombineXYZ.d.ts.map +1 -0
- package/dist/nodes/process/CombineXYZ.js +33 -0
- package/dist/nodes/process/DiffuseBSDF.d.ts +30 -0
- package/dist/nodes/process/DiffuseBSDF.d.ts.map +1 -0
- package/dist/nodes/process/DiffuseBSDF.js +43 -0
- package/dist/nodes/process/Emission.d.ts +30 -0
- package/dist/nodes/process/Emission.d.ts.map +1 -0
- package/dist/nodes/process/Emission.js +36 -0
- package/dist/nodes/process/EnvironmentTexture.d.ts +41 -0
- package/dist/nodes/process/EnvironmentTexture.d.ts.map +1 -0
- package/dist/nodes/process/EnvironmentTexture.js +65 -0
- package/dist/nodes/process/FloatCurve.d.ts +34 -0
- package/dist/nodes/process/FloatCurve.d.ts.map +1 -0
- package/dist/nodes/process/FloatCurve.js +46 -0
- package/dist/nodes/process/Fresnel.d.ts +36 -0
- package/dist/nodes/process/Fresnel.d.ts.map +1 -0
- package/dist/nodes/process/Fresnel.js +53 -0
- package/dist/nodes/process/Gamma.d.ts +29 -0
- package/dist/nodes/process/Gamma.d.ts.map +1 -0
- package/dist/nodes/process/Gamma.js +35 -0
- package/dist/nodes/process/GlassBSDF.d.ts +31 -0
- package/dist/nodes/process/GlassBSDF.d.ts.map +1 -0
- package/dist/nodes/process/GlassBSDF.js +51 -0
- package/dist/nodes/process/GlossyBSDF.d.ts +30 -0
- package/dist/nodes/process/GlossyBSDF.d.ts.map +1 -0
- package/dist/nodes/process/GlossyBSDF.js +50 -0
- package/dist/nodes/process/GradientTexture.d.ts +31 -0
- package/dist/nodes/process/GradientTexture.d.ts.map +1 -0
- package/dist/nodes/process/GradientTexture.js +49 -0
- package/dist/nodes/process/HashValue.d.ts +30 -0
- package/dist/nodes/process/HashValue.d.ts.map +1 -0
- package/dist/nodes/process/HashValue.js +34 -0
- package/dist/nodes/process/HueSaturationValue.d.ts +32 -0
- package/dist/nodes/process/HueSaturationValue.d.ts.map +1 -0
- package/dist/nodes/process/HueSaturationValue.js +58 -0
- package/dist/nodes/process/ImageTexture.d.ts +34 -0
- package/dist/nodes/process/ImageTexture.d.ts.map +1 -0
- package/dist/nodes/process/ImageTexture.js +53 -0
- package/dist/nodes/process/InvertColor.d.ts +29 -0
- package/dist/nodes/process/InvertColor.d.ts.map +1 -0
- package/dist/nodes/process/InvertColor.js +35 -0
- package/dist/nodes/process/MagicTexture.d.ts +30 -0
- package/dist/nodes/process/MagicTexture.d.ts.map +1 -0
- package/dist/nodes/process/MagicTexture.js +54 -0
- package/dist/nodes/process/MapRange.d.ts +38 -0
- package/dist/nodes/process/MapRange.d.ts.map +1 -0
- package/dist/nodes/process/MapRange.js +52 -0
- package/dist/nodes/process/Mapping.d.ts +37 -0
- package/dist/nodes/process/Mapping.d.ts.map +1 -0
- package/dist/nodes/process/Mapping.js +57 -0
- package/dist/nodes/process/Math.d.ts +40 -0
- package/dist/nodes/process/Math.d.ts.map +1 -0
- package/dist/nodes/process/Math.js +100 -0
- package/dist/nodes/process/MixRGB.d.ts +35 -0
- package/dist/nodes/process/MixRGB.d.ts.map +1 -0
- package/dist/nodes/process/MixRGB.js +63 -0
- package/dist/nodes/process/MixShader.d.ts +35 -0
- package/dist/nodes/process/MixShader.d.ts.map +1 -0
- package/dist/nodes/process/MixShader.js +47 -0
- package/dist/nodes/process/MusgraveTexture.d.ts +36 -0
- package/dist/nodes/process/MusgraveTexture.d.ts.map +1 -0
- package/dist/nodes/process/MusgraveTexture.js +70 -0
- package/dist/nodes/process/NoiseTexture.d.ts +31 -0
- package/dist/nodes/process/NoiseTexture.d.ts.map +1 -0
- package/dist/nodes/process/NoiseTexture.js +78 -0
- package/dist/nodes/process/Normal.d.ts +30 -0
- package/dist/nodes/process/Normal.d.ts.map +1 -0
- package/dist/nodes/process/Normal.js +38 -0
- package/dist/nodes/process/NormalMap.d.ts +34 -0
- package/dist/nodes/process/NormalMap.d.ts.map +1 -0
- package/dist/nodes/process/NormalMap.js +54 -0
- package/dist/nodes/process/PrincipledBSDF.d.ts +32 -0
- package/dist/nodes/process/PrincipledBSDF.d.ts.map +1 -0
- package/dist/nodes/process/PrincipledBSDF.js +75 -0
- package/dist/nodes/process/PrincipledHair.d.ts +63 -0
- package/dist/nodes/process/PrincipledHair.d.ts.map +1 -0
- package/dist/nodes/process/PrincipledHair.js +137 -0
- package/dist/nodes/process/PrincipledVolume.d.ts +37 -0
- package/dist/nodes/process/PrincipledVolume.d.ts.map +1 -0
- package/dist/nodes/process/PrincipledVolume.js +67 -0
- package/dist/nodes/process/RGBCurves.d.ts +45 -0
- package/dist/nodes/process/RGBCurves.d.ts.map +1 -0
- package/dist/nodes/process/RGBCurves.js +81 -0
- package/dist/nodes/process/RGBtoBW.d.ts +28 -0
- package/dist/nodes/process/RGBtoBW.d.ts.map +1 -0
- package/dist/nodes/process/RGBtoBW.js +31 -0
- package/dist/nodes/process/RefractionBSDF.d.ts +32 -0
- package/dist/nodes/process/RefractionBSDF.d.ts.map +1 -0
- package/dist/nodes/process/RefractionBSDF.js +46 -0
- package/dist/nodes/process/SchwarzschildMarch.d.ts +56 -0
- package/dist/nodes/process/SchwarzschildMarch.d.ts.map +1 -0
- package/dist/nodes/process/SchwarzschildMarch.js +306 -0
- package/dist/nodes/process/SeparateColor.d.ts +33 -0
- package/dist/nodes/process/SeparateColor.d.ts.map +1 -0
- package/dist/nodes/process/SeparateColor.js +79 -0
- package/dist/nodes/process/SeparateRGB.d.ts +27 -0
- package/dist/nodes/process/SeparateRGB.d.ts.map +1 -0
- package/dist/nodes/process/SeparateRGB.js +31 -0
- package/dist/nodes/process/SeparateXYZ.d.ts +27 -0
- package/dist/nodes/process/SeparateXYZ.d.ts.map +1 -0
- package/dist/nodes/process/SeparateXYZ.js +31 -0
- package/dist/nodes/process/ShaderScript.d.ts +95 -0
- package/dist/nodes/process/ShaderScript.d.ts.map +1 -0
- package/dist/nodes/process/ShaderScript.js +119 -0
- package/dist/nodes/process/ShaderToRGB.d.ts +28 -0
- package/dist/nodes/process/ShaderToRGB.d.ts.map +1 -0
- package/dist/nodes/process/ShaderToRGB.js +33 -0
- package/dist/nodes/process/SheenBSDF.d.ts +31 -0
- package/dist/nodes/process/SheenBSDF.d.ts.map +1 -0
- package/dist/nodes/process/SheenBSDF.js +49 -0
- package/dist/nodes/process/SpecularBSDF.d.ts +32 -0
- package/dist/nodes/process/SpecularBSDF.d.ts.map +1 -0
- package/dist/nodes/process/SpecularBSDF.js +54 -0
- package/dist/nodes/process/SubsurfaceScattering.d.ts +33 -0
- package/dist/nodes/process/SubsurfaceScattering.d.ts.map +1 -0
- package/dist/nodes/process/SubsurfaceScattering.js +46 -0
- package/dist/nodes/process/ToonBSDF.d.ts +31 -0
- package/dist/nodes/process/ToonBSDF.d.ts.map +1 -0
- package/dist/nodes/process/ToonBSDF.js +44 -0
- package/dist/nodes/process/TranslucentBSDF.d.ts +29 -0
- package/dist/nodes/process/TranslucentBSDF.d.ts.map +1 -0
- package/dist/nodes/process/TranslucentBSDF.js +39 -0
- package/dist/nodes/process/VectorCurves.d.ts +42 -0
- package/dist/nodes/process/VectorCurves.d.ts.map +1 -0
- package/dist/nodes/process/VectorCurves.js +71 -0
- package/dist/nodes/process/VectorMath.d.ts +38 -0
- package/dist/nodes/process/VectorMath.d.ts.map +1 -0
- package/dist/nodes/process/VectorMath.js +105 -0
- package/dist/nodes/process/VectorRotate.d.ts +34 -0
- package/dist/nodes/process/VectorRotate.d.ts.map +1 -0
- package/dist/nodes/process/VectorRotate.js +52 -0
- package/dist/nodes/process/VectorTransform.d.ts +36 -0
- package/dist/nodes/process/VectorTransform.d.ts.map +1 -0
- package/dist/nodes/process/VectorTransform.js +48 -0
- package/dist/nodes/process/VolumeAbsorption.d.ts +30 -0
- package/dist/nodes/process/VolumeAbsorption.d.ts.map +1 -0
- package/dist/nodes/process/VolumeAbsorption.js +36 -0
- package/dist/nodes/process/VolumeScatter.d.ts +31 -0
- package/dist/nodes/process/VolumeScatter.d.ts.map +1 -0
- package/dist/nodes/process/VolumeScatter.js +42 -0
- package/dist/nodes/process/VoronoiTexture.d.ts +38 -0
- package/dist/nodes/process/VoronoiTexture.d.ts.map +1 -0
- package/dist/nodes/process/VoronoiTexture.js +123 -0
- package/dist/nodes/process/WaveTexture.d.ts +39 -0
- package/dist/nodes/process/WaveTexture.d.ts.map +1 -0
- package/dist/nodes/process/WaveTexture.js +77 -0
- package/dist/nodes/process/Wavelength.d.ts +28 -0
- package/dist/nodes/process/Wavelength.d.ts.map +1 -0
- package/dist/nodes/process/Wavelength.js +43 -0
- package/dist/nodes/process/WhiteNoise.d.ts +27 -0
- package/dist/nodes/process/WhiteNoise.d.ts.map +1 -0
- package/dist/nodes/process/WhiteNoise.js +44 -0
- package/dist/nodes/shader/AmbientOcclusion.d.ts +47 -0
- package/dist/nodes/shader/AmbientOcclusion.d.ts.map +1 -0
- package/dist/nodes/shader/AmbientOcclusion.js +128 -0
- package/dist/nodes/shader/RayPortal.d.ts +57 -0
- package/dist/nodes/shader/RayPortal.d.ts.map +1 -0
- package/dist/nodes/shader/RayPortal.js +56 -0
- package/dist/shaders/color.d.ts +12 -0
- package/dist/shaders/color.d.ts.map +1 -0
- package/dist/shaders/color.js +42 -0
- package/dist/shaders/noise.d.ts +12 -0
- package/dist/shaders/noise.d.ts.map +1 -0
- package/dist/shaders/noise.js +70 -0
- package/dist/types/shader.d.ts +17 -0
- package/dist/types/shader.d.ts.map +1 -0
- package/dist/types/shader.js +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { InputNode } from '../../core/InputNode.js';
|
|
2
|
+
import type { NodeMetadata } from '../../core/ShaderNode.js';
|
|
3
|
+
import type { CompileContext } from '../../core/CompileContext.js';
|
|
4
|
+
/**
|
|
5
|
+
* Value — Blender "Value" input node equivalent.
|
|
6
|
+
* Outputs a single constant float.
|
|
7
|
+
*
|
|
8
|
+
* Outputs: Value (float)
|
|
9
|
+
*/
|
|
10
|
+
export declare class Value extends InputNode {
|
|
11
|
+
get nodeType(): string;
|
|
12
|
+
get metadata(): NodeMetadata;
|
|
13
|
+
private readonly val;
|
|
14
|
+
private readonly _outputs;
|
|
15
|
+
constructor(value?: number);
|
|
16
|
+
getOutputSockets(): Record<string, import("../../core/OutputSocket.js").OutputSocket>;
|
|
17
|
+
compileCall(ctx: CompileContext): string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=Value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Value.d.ts","sourceRoot":"","sources":["../../../src/nodes/input/Value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAElE;;;;;GAKG;AACH,qBAAa,KAAM,SAAQ,SAAS;IAClC,IAAI,QAAQ,WAAqB;IAEjC,IAAI,QAAQ,IAAI,YAAY,CAE3B;IAED,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmE;gBAEhF,KAAK,GAAE,MAAY;IAM/B,gBAAgB;IAEhB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;CAGzC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InputNode } from '../../core/InputNode.js';
|
|
2
|
+
/**
|
|
3
|
+
* Value — Blender "Value" input node equivalent.
|
|
4
|
+
* Outputs a single constant float.
|
|
5
|
+
*
|
|
6
|
+
* Outputs: Value (float)
|
|
7
|
+
*/
|
|
8
|
+
export class Value extends InputNode {
|
|
9
|
+
get nodeType() { return 'Value'; }
|
|
10
|
+
get metadata() {
|
|
11
|
+
return { label: 'Value', category: 'Input', color: '#3d6b96', cost: 'low' };
|
|
12
|
+
}
|
|
13
|
+
constructor(value = 0.5) {
|
|
14
|
+
super('Value');
|
|
15
|
+
this.val = value;
|
|
16
|
+
this._outputs = this.createOutputs({ Value: 'float' });
|
|
17
|
+
}
|
|
18
|
+
getOutputSockets() { return this._outputs; }
|
|
19
|
+
compileCall(ctx) {
|
|
20
|
+
return `float ${ctx.outputVar(this, 'Value')} = ${this.val.toFixed(4)};`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { InputNode } from '../../core/InputNode.js';
|
|
2
|
+
import type { NodeMetadata } from '../../core/ShaderNode.js';
|
|
3
|
+
import type { CompileContext } from '../../core/CompileContext.js';
|
|
4
|
+
/**
|
|
5
|
+
* Wireframe — Blender "Wireframe" input node equivalent.
|
|
6
|
+
* Produces a greyscale mask highlighting polygon edges.
|
|
7
|
+
* Uses screen-space derivatives for edge detection.
|
|
8
|
+
*
|
|
9
|
+
* Outputs:
|
|
10
|
+
* Fac (float) — 1.0 on edges, 0.0 on face interior
|
|
11
|
+
*/
|
|
12
|
+
export declare class Wireframe extends InputNode {
|
|
13
|
+
get nodeType(): string;
|
|
14
|
+
get metadata(): NodeMetadata;
|
|
15
|
+
parameters: {
|
|
16
|
+
thickness: number;
|
|
17
|
+
};
|
|
18
|
+
private readonly _outputs;
|
|
19
|
+
constructor(inputs?: {
|
|
20
|
+
thickness?: number;
|
|
21
|
+
} | number);
|
|
22
|
+
getOutputSockets(): Record<string, import("../../core/OutputSocket.js").OutputSocket>;
|
|
23
|
+
compileCall(ctx: CompileContext): string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=Wireframe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Wireframe.d.ts","sourceRoot":"","sources":["../../../src/nodes/input/Wireframe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAElE;;;;;;;GAOG;AACH,qBAAa,SAAU,SAAQ,SAAS;IACtC,IAAI,QAAQ,WAAyB;IAErC,IAAI,QAAQ,IAAI,YAAY,CAE3B;IAED,UAAU,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmE;gBAEhF,MAAM,GAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAW;IAOxD,gBAAgB;IAEhB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;CAQzC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { InputNode } from '../../core/InputNode.js';
|
|
2
|
+
/**
|
|
3
|
+
* Wireframe — Blender "Wireframe" input node equivalent.
|
|
4
|
+
* Produces a greyscale mask highlighting polygon edges.
|
|
5
|
+
* Uses screen-space derivatives for edge detection.
|
|
6
|
+
*
|
|
7
|
+
* Outputs:
|
|
8
|
+
* Fac (float) — 1.0 on edges, 0.0 on face interior
|
|
9
|
+
*/
|
|
10
|
+
export class Wireframe extends InputNode {
|
|
11
|
+
get nodeType() { return 'Wireframe'; }
|
|
12
|
+
get metadata() {
|
|
13
|
+
return { label: 'Wireframe', category: 'Input', color: '#3d6b96', cost: 'medium' };
|
|
14
|
+
}
|
|
15
|
+
constructor(inputs = {}) {
|
|
16
|
+
super('Wireframe');
|
|
17
|
+
const thickness = typeof inputs === 'number' ? inputs : (inputs.thickness ?? 0.01);
|
|
18
|
+
this.parameters = { thickness };
|
|
19
|
+
this._outputs = this.createOutputs({ Fac: 'float' });
|
|
20
|
+
}
|
|
21
|
+
getOutputSockets() { return this._outputs; }
|
|
22
|
+
compileCall(ctx) {
|
|
23
|
+
const t = this.parameters.thickness.toFixed(4);
|
|
24
|
+
return [
|
|
25
|
+
`vec3 _wf_bc_${this.id} = vec3(vUv, 1.0 - vUv.x - vUv.y);`,
|
|
26
|
+
`float _wf_min_${this.id} = min(_wf_bc_${this.id}.x, min(_wf_bc_${this.id}.y, _wf_bc_${this.id}.z));`,
|
|
27
|
+
`float ${ctx.outputVar(this, 'Fac')} = 1.0 - smoothstep(${t} - 0.002, ${t} + 0.002, _wf_min_${this.id});`,
|
|
28
|
+
].join('\n ');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { OutputNode } from '../../core/OutputNode.js';
|
|
2
|
+
import type { NodeMetadata } from '../../core/ShaderNode.js';
|
|
3
|
+
import type { CompileContext } from '../../core/CompileContext.js';
|
|
4
|
+
import type { OutputSocket } from '../../core/OutputSocket.js';
|
|
5
|
+
import { InputSocket } from '../../core/InputSocket.js';
|
|
6
|
+
export interface DisplacementInputs {
|
|
7
|
+
height?: OutputSocket;
|
|
8
|
+
midlevel?: OutputSocket | number;
|
|
9
|
+
scale?: OutputSocket | number;
|
|
10
|
+
normal?: OutputSocket;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Displacement — Blender "Displacement" vector output node.
|
|
14
|
+
* Feeds into MaterialOutput.displacement to control vertex offset.
|
|
15
|
+
* In real-time WebGL, displacement is baked into the vertex shader via normal perturbation.
|
|
16
|
+
*
|
|
17
|
+
* Inputs: height (float), midlevel, scale, normal
|
|
18
|
+
* Outputs: Displacement (color/vec3)
|
|
19
|
+
*/
|
|
20
|
+
export declare class Displacement extends OutputNode {
|
|
21
|
+
get nodeType(): string;
|
|
22
|
+
get metadata(): NodeMetadata;
|
|
23
|
+
private readonly _inputs;
|
|
24
|
+
constructor(inputs?: DisplacementInputs);
|
|
25
|
+
getInputSockets(): Record<string, InputSocket<unknown>>;
|
|
26
|
+
compileCall(ctx: CompileContext): string;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=Displacement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Displacement.d.ts","sourceRoot":"","sources":["../../../src/nodes/output/Displacement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAEvD,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAI,YAAY,CAAA;IACvB,QAAQ,CAAC,EAAE,YAAY,GAAG,MAAM,CAAA;IAChC,KAAK,CAAC,EAAK,YAAY,GAAG,MAAM,CAAA;IAChC,MAAM,CAAC,EAAI,YAAY,CAAA;CACxB;AAED;;;;;;;GAOG;AACH,qBAAa,YAAa,SAAQ,UAAU;IAC1C,IAAI,QAAQ,WAA4B;IAExC,IAAI,QAAQ,IAAI,YAAY,CAE3B;IAED,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;gBAEnD,MAAM,GAAE,kBAAuB;IAU3C,eAAe;IAEf,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;CASzC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { OutputNode } from '../../core/OutputNode.js';
|
|
2
|
+
/**
|
|
3
|
+
* Displacement — Blender "Displacement" vector output node.
|
|
4
|
+
* Feeds into MaterialOutput.displacement to control vertex offset.
|
|
5
|
+
* In real-time WebGL, displacement is baked into the vertex shader via normal perturbation.
|
|
6
|
+
*
|
|
7
|
+
* Inputs: height (float), midlevel, scale, normal
|
|
8
|
+
* Outputs: Displacement (color/vec3)
|
|
9
|
+
*/
|
|
10
|
+
export class Displacement extends OutputNode {
|
|
11
|
+
get nodeType() { return 'Displacement'; }
|
|
12
|
+
get metadata() {
|
|
13
|
+
return { label: 'Displacement', category: 'Vector', color: '#4a3a8a', cost: 'low' };
|
|
14
|
+
}
|
|
15
|
+
constructor(inputs = {}) {
|
|
16
|
+
super('Displacement');
|
|
17
|
+
this._inputs = this.createInputs(inputs, {
|
|
18
|
+
height: ['float', 0.0],
|
|
19
|
+
midlevel: ['float', inputs.midlevel ?? 0.5],
|
|
20
|
+
scale: ['float', inputs.scale ?? 1.0],
|
|
21
|
+
normal: ['color', null],
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
getInputSockets() { return this._inputs; }
|
|
25
|
+
compileCall(ctx) {
|
|
26
|
+
const height = ctx.resolveInput(this._inputs.height);
|
|
27
|
+
const midlevel = ctx.resolveInput(this._inputs.midlevel);
|
|
28
|
+
const scale = ctx.resolveInput(this._inputs.scale);
|
|
29
|
+
const normal = this._inputs.normal.isConnected()
|
|
30
|
+
? ctx.outputVar(this._inputs.normal.connection.node, this._inputs.normal.connection.name)
|
|
31
|
+
: 'normalize(vNormal)';
|
|
32
|
+
return `vec3 _disp_${this.id} = ${normal} * (${height} - ${midlevel}) * ${scale};`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { OutputNode } from '../../core/OutputNode.js';
|
|
2
|
+
import { MeshPhysicalMaterial, Texture } from 'three';
|
|
3
|
+
import type { NodeMetadata } from '../../core/ShaderNode.js';
|
|
4
|
+
import type { CompileContext } from '../../core/CompileContext.js';
|
|
5
|
+
import type { OutputSocket } from '../../core/OutputSocket.js';
|
|
6
|
+
export interface MaterialOutputInputs {
|
|
7
|
+
surface?: OutputSocket;
|
|
8
|
+
volume?: OutputSocket;
|
|
9
|
+
displacement?: OutputSocket;
|
|
10
|
+
thickness?: OutputSocket;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Material Output — Blender "Material Output" node equivalent.
|
|
14
|
+
* Terminal node. Call compile() to produce the final shader.
|
|
15
|
+
*
|
|
16
|
+
* Inputs: surface (required), volume, displacement, thickness
|
|
17
|
+
*/
|
|
18
|
+
export declare class MaterialOutput extends OutputNode {
|
|
19
|
+
get nodeType(): string;
|
|
20
|
+
get metadata(): NodeMetadata;
|
|
21
|
+
private readonly _inputs;
|
|
22
|
+
constructor(inputs?: MaterialOutputInputs);
|
|
23
|
+
getInputSockets(): Record<string, import("../../core/InputSocket.js").InputSocket<unknown>>;
|
|
24
|
+
/**
|
|
25
|
+
* Converts the node graph to a THREE.MeshPhysicalMaterial for use with
|
|
26
|
+
* path-tracer renderers (three-gpu-pathtracer).
|
|
27
|
+
*
|
|
28
|
+
* Walks upstream from MaterialOutput.surface looking for a PrincipledBSDF
|
|
29
|
+
* (or Emission) node and maps its live parameters to MeshPhysicalMaterial
|
|
30
|
+
* properties. ImageTexture nodes connected to baseColor are wired as .map.
|
|
31
|
+
*
|
|
32
|
+
* For custom GLSL-heavy materials with no compatible BSDF root, the method
|
|
33
|
+
* returns a neutral grey MeshPhysicalMaterial as a fallback.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const mat = new MaterialOutput({ surface: bsdf.output('BSDF') })
|
|
37
|
+
* mat.compile() // rasterizer ShaderMaterial
|
|
38
|
+
* const ptMat = mat.toPhysicalMaterial() // path-tracer MeshPhysicalMaterial
|
|
39
|
+
*/
|
|
40
|
+
toPhysicalMaterial(extraUniforms?: Record<string, Texture>): MeshPhysicalMaterial;
|
|
41
|
+
compileCall(ctx: CompileContext): string;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=MaterialOutput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MaterialOutput.d.ts","sourceRoot":"","sources":["../../../src/nodes/output/MaterialOutput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAGrD,OAAO,EAAE,oBAAoB,EAAS,OAAO,EAAE,MAAM,OAAO,CAAA;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAO,YAAY,CAAA;IAC3B,MAAM,CAAC,EAAQ,YAAY,CAAA;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,SAAS,CAAC,EAAK,YAAY,CAAA;CAC5B;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC5C,IAAI,QAAQ,WAA8B;IAE1C,IAAI,QAAQ,IAAI,YAAY,CAE3B;IAED,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0E;gBAEtF,MAAM,GAAE,oBAAyB;IAoB7C,eAAe;IAEf;;;;;;;;;;;;;;;OAeG;IACH,kBAAkB,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,oBAAoB;IAmEjF,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;CAMzC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { OutputNode } from '../../core/OutputNode.js';
|
|
2
|
+
import { ShaderNodeError } from '../../core/ShaderNodeError.js';
|
|
3
|
+
import { ShaderConfig } from '../../core/ShaderConfig.js';
|
|
4
|
+
import { MeshPhysicalMaterial, Color, Texture } from 'three';
|
|
5
|
+
/**
|
|
6
|
+
* Material Output — Blender "Material Output" node equivalent.
|
|
7
|
+
* Terminal node. Call compile() to produce the final shader.
|
|
8
|
+
*
|
|
9
|
+
* Inputs: surface (required), volume, displacement, thickness
|
|
10
|
+
*/
|
|
11
|
+
export class MaterialOutput extends OutputNode {
|
|
12
|
+
get nodeType() { return 'MaterialOutput'; }
|
|
13
|
+
get metadata() {
|
|
14
|
+
return { label: 'Material Output', category: 'Output', color: '#a06030', cost: 'low' };
|
|
15
|
+
}
|
|
16
|
+
constructor(inputs = {}) {
|
|
17
|
+
super('MaterialOutput');
|
|
18
|
+
this._inputs = this.createInputs(inputs, {
|
|
19
|
+
surface: ['shader', null, true],
|
|
20
|
+
volume: ['shader', null],
|
|
21
|
+
displacement: ['vector', null],
|
|
22
|
+
thickness: ['float', 0.0],
|
|
23
|
+
});
|
|
24
|
+
if (ShaderConfig.errorLevel !== 'off' && !this._inputs.surface.isConnected()) {
|
|
25
|
+
ShaderNodeError.throw({
|
|
26
|
+
nodeType: this.nodeType,
|
|
27
|
+
nodeId: this.id,
|
|
28
|
+
inputName: 'surface',
|
|
29
|
+
problem: 'Required input "surface" has no connection.',
|
|
30
|
+
fix: 'new MaterialOutput({ surface: bsdf.output("BSDF") })',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
getInputSockets() { return this._inputs; }
|
|
35
|
+
/**
|
|
36
|
+
* Converts the node graph to a THREE.MeshPhysicalMaterial for use with
|
|
37
|
+
* path-tracer renderers (three-gpu-pathtracer).
|
|
38
|
+
*
|
|
39
|
+
* Walks upstream from MaterialOutput.surface looking for a PrincipledBSDF
|
|
40
|
+
* (or Emission) node and maps its live parameters to MeshPhysicalMaterial
|
|
41
|
+
* properties. ImageTexture nodes connected to baseColor are wired as .map.
|
|
42
|
+
*
|
|
43
|
+
* For custom GLSL-heavy materials with no compatible BSDF root, the method
|
|
44
|
+
* returns a neutral grey MeshPhysicalMaterial as a fallback.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* const mat = new MaterialOutput({ surface: bsdf.output('BSDF') })
|
|
48
|
+
* mat.compile() // rasterizer ShaderMaterial
|
|
49
|
+
* const ptMat = mat.toPhysicalMaterial() // path-tracer MeshPhysicalMaterial
|
|
50
|
+
*/
|
|
51
|
+
toPhysicalMaterial(extraUniforms) {
|
|
52
|
+
const surfaceSocket = this._inputs.surface;
|
|
53
|
+
if (!surfaceSocket.isConnected()) {
|
|
54
|
+
return new MeshPhysicalMaterial({ color: 0x888888, roughness: 0.5 });
|
|
55
|
+
}
|
|
56
|
+
const bsdfNode = surfaceSocket.connection.node;
|
|
57
|
+
const nodeType = bsdfNode.nodeType;
|
|
58
|
+
const p = bsdfNode.parameters;
|
|
59
|
+
// Helper: extract a Color from a parameter (may be [r,g,b] or a hex number)
|
|
60
|
+
const toColor = (key, fallback = '#ffffff') => {
|
|
61
|
+
const v = p[key];
|
|
62
|
+
if (Array.isArray(v))
|
|
63
|
+
return new Color(v[0], v[1], v[2]);
|
|
64
|
+
if (typeof v === 'number')
|
|
65
|
+
return new Color(v, v, v);
|
|
66
|
+
return new Color(fallback);
|
|
67
|
+
};
|
|
68
|
+
const toFloat = (key, fallback) => {
|
|
69
|
+
const v = p[key];
|
|
70
|
+
return typeof v === 'number' ? v : fallback;
|
|
71
|
+
};
|
|
72
|
+
// Check if baseColor input is wired to an ImageTexture
|
|
73
|
+
const bsdfInputs = bsdfNode.getInputSockets();
|
|
74
|
+
let map = null;
|
|
75
|
+
if (bsdfInputs.baseColor?.isConnected()) {
|
|
76
|
+
const upstream = bsdfInputs.baseColor.connection.node;
|
|
77
|
+
if (upstream.nodeType === 'ImageTexture') {
|
|
78
|
+
const uniformName = upstream.uniformName;
|
|
79
|
+
if (extraUniforms?.[uniformName] instanceof Texture) {
|
|
80
|
+
map = extraUniforms[uniformName];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (nodeType === 'Emission') {
|
|
85
|
+
return new MeshPhysicalMaterial({
|
|
86
|
+
emissive: toColor('color'),
|
|
87
|
+
emissiveIntensity: toFloat('strength', 1.0),
|
|
88
|
+
roughness: 1.0,
|
|
89
|
+
metalness: 0.0,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
// PrincipledBSDF, GlossyBSDF, DiffuseBSDF, GlassBSDF, RefractionBSDF
|
|
93
|
+
const isGlass = nodeType === 'GlassBSDF' || nodeType === 'RefractionBSDF';
|
|
94
|
+
const alpha = toFloat('alpha', 1.0);
|
|
95
|
+
const matParams = {
|
|
96
|
+
color: map ? 0xffffff : toColor('baseColor'),
|
|
97
|
+
metalness: toFloat('metallic', 0.0),
|
|
98
|
+
roughness: toFloat('roughness', 0.5),
|
|
99
|
+
ior: toFloat('ior', 1.5),
|
|
100
|
+
opacity: alpha,
|
|
101
|
+
transparent: alpha < 1.0 || isGlass,
|
|
102
|
+
};
|
|
103
|
+
if (map)
|
|
104
|
+
matParams.map = map;
|
|
105
|
+
const mat = new MeshPhysicalMaterial(matParams);
|
|
106
|
+
if (nodeType === 'GlassBSDF' || nodeType === 'RefractionBSDF') {
|
|
107
|
+
mat.transmission = 1.0;
|
|
108
|
+
mat.thickness = 0.5;
|
|
109
|
+
}
|
|
110
|
+
return mat;
|
|
111
|
+
}
|
|
112
|
+
compileCall(ctx) {
|
|
113
|
+
const sv = this._inputs.surface.isConnected()
|
|
114
|
+
? ctx.outputVar(this._inputs.surface.connection.node, this._inputs.surface.connection.name)
|
|
115
|
+
: 'vec3(0.8)';
|
|
116
|
+
return `gl_FragColor = vec4(${sv}, 1.0);`;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { OutputNode } from '../../core/OutputNode.js';
|
|
2
|
+
import { CompileContext } from '../../core/CompileContext.js';
|
|
3
|
+
import { ShaderMaterial, Mesh } from 'three';
|
|
4
|
+
import type { PerspectiveCamera } from 'three';
|
|
5
|
+
import type { OutputSocket } from '../../core/OutputSocket.js';
|
|
6
|
+
import type { NodeMetadata } from '../../core/ShaderNode.js';
|
|
7
|
+
/**
|
|
8
|
+
* ScreenOutput — renders a node graph to a fullscreen quad.
|
|
9
|
+
*
|
|
10
|
+
* After compile():
|
|
11
|
+
* scene.add(out.mesh) — add to scene
|
|
12
|
+
* out.updateCamera(camera, w, h) — call each frame
|
|
13
|
+
* renderer.render(scene, camera) — renders the shader
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const cam = new ScreenCamera()
|
|
17
|
+
* const march = new SchwarzschildMarch({ rayPos: cam.output('RayPos'), rayDir: cam.output('RayDir') })
|
|
18
|
+
* const out = new ScreenOutput({ color: march.output('Color') })
|
|
19
|
+
* out.compile()
|
|
20
|
+
* scene.add(out.mesh)
|
|
21
|
+
* // in loop: out.updateCamera(camera, innerWidth, innerHeight)
|
|
22
|
+
*/
|
|
23
|
+
export declare class ScreenOutput extends OutputNode {
|
|
24
|
+
get nodeType(): string;
|
|
25
|
+
get metadata(): NodeMetadata;
|
|
26
|
+
mesh: Mesh | null;
|
|
27
|
+
private readonly _inputs;
|
|
28
|
+
constructor(inputs?: {
|
|
29
|
+
color?: OutputSocket;
|
|
30
|
+
});
|
|
31
|
+
getInputSockets(): Record<string, import("../../core/InputSocket.js").InputSocket<unknown>>;
|
|
32
|
+
compileDefs(): string;
|
|
33
|
+
compileCall(ctx: CompileContext): string;
|
|
34
|
+
compile(): ShaderMaterial;
|
|
35
|
+
/** Sync Three.js camera → shader uniforms. Call once per frame. */
|
|
36
|
+
updateCamera(camera: PerspectiveCamera, width: number, height: number): void;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=ScreenOutput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScreenOutput.d.ts","sourceRoot":"","sources":["../../../src/nodes/output/ScreenOutput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAS,0BAA0B,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,IAAI,EAAmC,MAAM,OAAO,CAAA;AAC7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAW,4BAA4B,CAAA;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAW,0BAA0B,CAAA;AAEjE;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAa,SAAQ,UAAU;IAC1C,IAAI,QAAQ,WAA4B;IAExC,IAAI,QAAQ,IAAI,YAAY,CAE3B;IAED,IAAI,EAAE,IAAI,GAAG,IAAI,CAAO;IAExB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0E;gBAEtF,MAAM,GAAE;QAAE,KAAK,CAAC,EAAE,YAAY,CAAA;KAAO;IAOjD,eAAe;IACf,WAAW,IAAO,MAAM;IAExB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;IAOxC,OAAO,IAAI,cAAc;IA4CzB,mEAAmE;IACnE,YAAY,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;CAW7E"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { OutputNode } from '../../core/OutputNode.js';
|
|
2
|
+
import { CompileContext } from '../../core/CompileContext.js';
|
|
3
|
+
import { ShaderMaterial, Mesh, PlaneGeometry, Vector2, Vector3 } from 'three';
|
|
4
|
+
/**
|
|
5
|
+
* ScreenOutput — renders a node graph to a fullscreen quad.
|
|
6
|
+
*
|
|
7
|
+
* After compile():
|
|
8
|
+
* scene.add(out.mesh) — add to scene
|
|
9
|
+
* out.updateCamera(camera, w, h) — call each frame
|
|
10
|
+
* renderer.render(scene, camera) — renders the shader
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const cam = new ScreenCamera()
|
|
14
|
+
* const march = new SchwarzschildMarch({ rayPos: cam.output('RayPos'), rayDir: cam.output('RayDir') })
|
|
15
|
+
* const out = new ScreenOutput({ color: march.output('Color') })
|
|
16
|
+
* out.compile()
|
|
17
|
+
* scene.add(out.mesh)
|
|
18
|
+
* // in loop: out.updateCamera(camera, innerWidth, innerHeight)
|
|
19
|
+
*/
|
|
20
|
+
export class ScreenOutput extends OutputNode {
|
|
21
|
+
get nodeType() { return 'ScreenOutput'; }
|
|
22
|
+
get metadata() {
|
|
23
|
+
return { label: 'Screen Output', category: 'Output', color: '#a06030', cost: 'low' };
|
|
24
|
+
}
|
|
25
|
+
constructor(inputs = {}) {
|
|
26
|
+
super('ScreenOutput');
|
|
27
|
+
this.mesh = null;
|
|
28
|
+
this._inputs = this.createInputs(inputs, {
|
|
29
|
+
color: ['color', null, true],
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
getInputSockets() { return this._inputs; }
|
|
33
|
+
compileDefs() { return ''; }
|
|
34
|
+
compileCall(ctx) {
|
|
35
|
+
const cv = this._inputs.color.isConnected()
|
|
36
|
+
? ctx.outputVar(this._inputs.color.connection.node, this._inputs.color.connection.name)
|
|
37
|
+
: 'vec3(0.5)';
|
|
38
|
+
return `gl_FragColor = vec4(${cv}, 1.0);`;
|
|
39
|
+
}
|
|
40
|
+
compile() {
|
|
41
|
+
const ctx = new CompileContext();
|
|
42
|
+
const compiled = ctx.compile(this);
|
|
43
|
+
const vertexShader = `
|
|
44
|
+
varying vec2 vUv;
|
|
45
|
+
varying vec3 vNormal;
|
|
46
|
+
varying vec3 vPosition;
|
|
47
|
+
void main() {
|
|
48
|
+
vUv = uv;
|
|
49
|
+
vNormal = normal;
|
|
50
|
+
vPosition = position;
|
|
51
|
+
gl_Position = vec4(position, 1.0);
|
|
52
|
+
}`.trim();
|
|
53
|
+
const camUniforms = {
|
|
54
|
+
uSCResolution: { value: new Vector2(typeof innerWidth !== 'undefined' ? innerWidth : 800, typeof innerHeight !== 'undefined' ? innerHeight : 600) },
|
|
55
|
+
uSCCamPos: { value: new Vector3() },
|
|
56
|
+
uSCCamRight: { value: new Vector3(1, 0, 0) },
|
|
57
|
+
uSCCamUp: { value: new Vector3(0, 1, 0) },
|
|
58
|
+
uSCCamFwd: { value: new Vector3(0, 0, -1) },
|
|
59
|
+
uSCFov: { value: 1.0 },
|
|
60
|
+
};
|
|
61
|
+
this.material = new ShaderMaterial({
|
|
62
|
+
vertexShader,
|
|
63
|
+
fragmentShader: compiled.fragmentShader,
|
|
64
|
+
uniforms: { ...compiled.uniforms, ...camUniforms },
|
|
65
|
+
depthTest: false,
|
|
66
|
+
depthWrite: false,
|
|
67
|
+
});
|
|
68
|
+
for (const node of compiled.nodes)
|
|
69
|
+
node._wireParameters(this.material.uniforms);
|
|
70
|
+
this.mesh = new Mesh(new PlaneGeometry(2, 2), this.material);
|
|
71
|
+
this.mesh.frustumCulled = false;
|
|
72
|
+
this.mesh.renderOrder = -1;
|
|
73
|
+
return this.material;
|
|
74
|
+
}
|
|
75
|
+
/** Sync Three.js camera → shader uniforms. Call once per frame. */
|
|
76
|
+
updateCamera(camera, width, height) {
|
|
77
|
+
if (!this.material)
|
|
78
|
+
return;
|
|
79
|
+
const m = camera.matrixWorld;
|
|
80
|
+
const u = this.material.uniforms;
|
|
81
|
+
u.uSCResolution.value.set(width, height);
|
|
82
|
+
u.uSCCamPos.value.setFromMatrixPosition(m);
|
|
83
|
+
u.uSCCamRight.value.setFromMatrixColumn(m, 0);
|
|
84
|
+
u.uSCCamUp.value.setFromMatrixColumn(m, 1);
|
|
85
|
+
u.uSCCamFwd.value.setFromMatrixColumn(m, 2).negate();
|
|
86
|
+
u.uSCFov.value = Math.tan((camera.fov * Math.PI / 180) / 2);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ProcessNode } from '../../core/ProcessNode.js';
|
|
2
|
+
import type { NodeMetadata } from '../../core/ShaderNode.js';
|
|
3
|
+
import type { CompileContext } from '../../core/CompileContext.js';
|
|
4
|
+
import type { OutputSocket } from '../../core/OutputSocket.js';
|
|
5
|
+
export interface AddShaderInputs {
|
|
6
|
+
shader1?: OutputSocket;
|
|
7
|
+
shader2?: OutputSocket;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Add Shader — Blender "Add Shader" node equivalent.
|
|
11
|
+
* Adds two shader outputs together (unlike MixShader which blends).
|
|
12
|
+
* Useful for combining emission on top of a surface shader.
|
|
13
|
+
*
|
|
14
|
+
* Inputs: shader1 (shader), shader2 (shader)
|
|
15
|
+
* Outputs: BSDF (shader)
|
|
16
|
+
*/
|
|
17
|
+
export declare class AddShader extends ProcessNode {
|
|
18
|
+
get nodeType(): string;
|
|
19
|
+
static instanceSpecificDef: boolean;
|
|
20
|
+
get metadata(): NodeMetadata;
|
|
21
|
+
static glslFunction: string;
|
|
22
|
+
private readonly _inputs;
|
|
23
|
+
private readonly _outputs;
|
|
24
|
+
constructor(inputs?: AddShaderInputs);
|
|
25
|
+
getInputSockets(): Record<string, import("../../core/InputSocket.js").InputSocket<unknown>>;
|
|
26
|
+
getOutputSockets(): Record<string, OutputSocket>;
|
|
27
|
+
compileDefs(): string;
|
|
28
|
+
compileCall(ctx: CompileContext): string;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=AddShader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddShader.d.ts","sourceRoot":"","sources":["../../../src/nodes/process/AddShader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,YAAY,CAAA;IACtB,OAAO,CAAC,EAAE,YAAY,CAAA;CACvB;AAED;;;;;;;GAOG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACxC,IAAI,QAAQ,WAAyB;IACrC,MAAM,CAAC,mBAAmB,UAAQ;IAElC,IAAI,QAAQ,IAAI,YAAY,CAE3B;IAED,MAAM,CAAC,YAAY,SAGnB;IAEA,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2E;IACnG,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmE;gBAEhF,MAAM,GAAE,eAAoB;IASxC,eAAe;IACf,gBAAgB;IAChB,WAAW;IAEX,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;CAKzC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ProcessNode } from '../../core/ProcessNode.js';
|
|
2
|
+
/**
|
|
3
|
+
* Add Shader — Blender "Add Shader" node equivalent.
|
|
4
|
+
* Adds two shader outputs together (unlike MixShader which blends).
|
|
5
|
+
* Useful for combining emission on top of a surface shader.
|
|
6
|
+
*
|
|
7
|
+
* Inputs: shader1 (shader), shader2 (shader)
|
|
8
|
+
* Outputs: BSDF (shader)
|
|
9
|
+
*/
|
|
10
|
+
export class AddShader extends ProcessNode {
|
|
11
|
+
get nodeType() { return 'AddShader'; }
|
|
12
|
+
get metadata() {
|
|
13
|
+
return { label: 'Add Shader', category: 'Shader', color: '#336699', cost: 'low' };
|
|
14
|
+
}
|
|
15
|
+
constructor(inputs = {}) {
|
|
16
|
+
super('AddShader');
|
|
17
|
+
this._inputs = this.createInputs(inputs, {
|
|
18
|
+
shader1: ['shader', null],
|
|
19
|
+
shader2: ['shader', null],
|
|
20
|
+
});
|
|
21
|
+
this._outputs = this.createOutputs({ BSDF: 'shader' });
|
|
22
|
+
}
|
|
23
|
+
getInputSockets() { return this._inputs; }
|
|
24
|
+
getOutputSockets() { return this._outputs; }
|
|
25
|
+
compileDefs() { return AddShader.glslFunction; }
|
|
26
|
+
compileCall(ctx) {
|
|
27
|
+
const s1 = ctx.resolveInput(this._inputs.shader1);
|
|
28
|
+
const s2 = ctx.resolveInput(this._inputs.shader2);
|
|
29
|
+
return `vec3 ${ctx.outputVar(this, 'BSDF')} = _st_addShader(${s1}, ${s2});`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
AddShader.instanceSpecificDef = false;
|
|
33
|
+
AddShader.glslFunction = `
|
|
34
|
+
vec3 _st_addShader(vec3 a, vec3 b) {
|
|
35
|
+
return a + b;
|
|
36
|
+
}`;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ProcessNode } from '../../core/ProcessNode.js';
|
|
2
|
+
import type { NodeMetadata } from '../../core/ShaderNode.js';
|
|
3
|
+
import type { CompileContext } from '../../core/CompileContext.js';
|
|
4
|
+
import type { OutputSocket } from '../../core/OutputSocket.js';
|
|
5
|
+
export interface AnimatedNoiseTextureInputs {
|
|
6
|
+
vector?: OutputSocket;
|
|
7
|
+
scale?: number | OutputSocket;
|
|
8
|
+
detail?: number | OutputSocket;
|
|
9
|
+
roughness?: number | OutputSocket;
|
|
10
|
+
distortion?: number | OutputSocket;
|
|
11
|
+
speed?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Animated Noise Texture — time-animated extension of NoiseTexture.
|
|
15
|
+
* Uses four scrolling noise layers for realistic wave-like movement.
|
|
16
|
+
* Injects a `time` uniform into the compiled ShaderMaterial automatically.
|
|
17
|
+
*
|
|
18
|
+
* Inputs: vector, scale, detail, roughness, distortion, speed
|
|
19
|
+
* Outputs: Fac (float), Color (color)
|
|
20
|
+
*
|
|
21
|
+
* Usage:
|
|
22
|
+
* const noise = new AnimatedNoiseTexture({ scale: 5.0, speed: 1.0 })
|
|
23
|
+
* // After mat.compile(), time updates via: mat.material.uniforms.time.value = t
|
|
24
|
+
*/
|
|
25
|
+
export declare class AnimatedNoiseTexture extends ProcessNode {
|
|
26
|
+
get nodeType(): string;
|
|
27
|
+
static instanceSpecificDef: boolean;
|
|
28
|
+
get metadata(): NodeMetadata;
|
|
29
|
+
static glslFunction: string;
|
|
30
|
+
private readonly _inputs;
|
|
31
|
+
private readonly _outputs;
|
|
32
|
+
private readonly speed;
|
|
33
|
+
constructor(inputs?: AnimatedNoiseTextureInputs);
|
|
34
|
+
getInputSockets(): Record<string, import("../../core/InputSocket.js").InputSocket<unknown>>;
|
|
35
|
+
getOutputSockets(): Record<string, OutputSocket>;
|
|
36
|
+
compileDefs(): string;
|
|
37
|
+
compileCall(ctx: CompileContext): string;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=AnimatedNoiseTexture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimatedNoiseTexture.d.ts","sourceRoot":"","sources":["../../../src/nodes/process/AnimatedNoiseTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE9D,MAAM,WAAW,0BAA0B;IACzC,MAAM,CAAC,EAAM,YAAY,CAAA;IACzB,KAAK,CAAC,EAAO,MAAM,GAAG,YAAY,CAAA;IAClC,MAAM,CAAC,EAAM,MAAM,GAAG,YAAY,CAAA;IAClC,SAAS,CAAC,EAAG,MAAM,GAAG,YAAY,CAAA;IAClC,UAAU,CAAC,EAAE,MAAM,GAAG,YAAY,CAAA;IAClC,KAAK,CAAC,EAAO,MAAM,CAAA;CACpB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,oBAAqB,SAAQ,WAAW;IACnD,IAAI,QAAQ,WAAoC;IAChD,MAAM,CAAC,mBAAmB,UAAQ;IAElC,IAAI,QAAQ,IAAI,YAAY,CAQ3B;IAED,MAAM,CAAC,YAAY,SAuCnB;IAEA,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2E;IACnG,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmE;IAC5F,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;gBAErB,MAAM,GAAE,0BAA+B;IAanD,eAAe;IACf,gBAAgB;IAChB,WAAW;IAEX,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;CAYzC"}
|