@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,112 @@
|
|
|
1
|
+
import { InputNode } from '../../core/InputNode.js';
|
|
2
|
+
/**
|
|
3
|
+
* Light Path — Blender "Light Path" input node equivalent.
|
|
4
|
+
*
|
|
5
|
+
* Outputs the ray type currently being rendered, driven by externally-set
|
|
6
|
+
* uniforms. In rasterizer mode the uniforms default to camera-ray values
|
|
7
|
+
* (Is Camera Ray = 1, all others = 0).
|
|
8
|
+
*
|
|
9
|
+
* To drive a full multi-pass render where shadow/bounce contributions are
|
|
10
|
+
* separated, use LightPathController from @st-pathtracer-core, which sets
|
|
11
|
+
* these uniforms before each render pass.
|
|
12
|
+
*
|
|
13
|
+
* Uniform names are available on LightPath.U for external use.
|
|
14
|
+
*
|
|
15
|
+
* Outputs (all float):
|
|
16
|
+
* Is Camera Ray, Is Shadow Ray, Is Diffuse Ray, Is Glossy Ray,
|
|
17
|
+
* Is Singular Ray, Is Reflection Ray, Is Transmission Ray,
|
|
18
|
+
* Ray Length, Ray Depth, Diffuse Depth, Glossy Depth,
|
|
19
|
+
* Shadow Depth, Transparent Depth, Transmission Depth
|
|
20
|
+
*/
|
|
21
|
+
export class LightPath extends InputNode {
|
|
22
|
+
get nodeType() { return 'LightPath'; }
|
|
23
|
+
get metadata() {
|
|
24
|
+
return { label: 'Light Path', category: 'Input', color: '#5a3d7a', cost: 'low' };
|
|
25
|
+
}
|
|
26
|
+
constructor() {
|
|
27
|
+
super('LightPath');
|
|
28
|
+
this.parameters = {};
|
|
29
|
+
this._outputs = this.createOutputs({
|
|
30
|
+
'Is Camera Ray': 'float',
|
|
31
|
+
'Is Shadow Ray': 'float',
|
|
32
|
+
'Is Diffuse Ray': 'float',
|
|
33
|
+
'Is Glossy Ray': 'float',
|
|
34
|
+
'Is Singular Ray': 'float',
|
|
35
|
+
'Is Reflection Ray': 'float',
|
|
36
|
+
'Is Transmission Ray': 'float',
|
|
37
|
+
'Ray Length': 'float',
|
|
38
|
+
'Ray Depth': 'float',
|
|
39
|
+
'Diffuse Depth': 'float',
|
|
40
|
+
'Glossy Depth': 'float',
|
|
41
|
+
'Shadow Depth': 'float',
|
|
42
|
+
'Transparent Depth': 'float',
|
|
43
|
+
'Transmission Depth': 'float',
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
getOutputSockets() { return this._outputs; }
|
|
47
|
+
/**
|
|
48
|
+
* Register all LightPath uniforms with their rasterizer defaults.
|
|
49
|
+
* CompileContext picks these up and includes them in the compiled
|
|
50
|
+
* material's uniforms object so LightPathController can set them.
|
|
51
|
+
* Default: Is Camera Ray = 1.0, all others = 0.0.
|
|
52
|
+
*/
|
|
53
|
+
extraUniforms() {
|
|
54
|
+
const U = LightPath.U;
|
|
55
|
+
return {
|
|
56
|
+
[U.isCamera]: 1.0,
|
|
57
|
+
[U.isShadow]: 0.0,
|
|
58
|
+
[U.isDiffuse]: 0.0,
|
|
59
|
+
[U.isGlossy]: 0.0,
|
|
60
|
+
[U.isSingular]: 0.0,
|
|
61
|
+
[U.isReflection]: 0.0,
|
|
62
|
+
[U.isTransmission]: 0.0,
|
|
63
|
+
[U.rayLength]: 0.0,
|
|
64
|
+
[U.rayDepth]: 0.0,
|
|
65
|
+
[U.diffuseDepth]: 0.0,
|
|
66
|
+
[U.glossyDepth]: 0.0,
|
|
67
|
+
[U.shadowDepth]: 0.0,
|
|
68
|
+
[U.transparentDepth]: 0.0,
|
|
69
|
+
[U.transmissionDepth]: 0.0,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
compileDefs() { return ''; }
|
|
73
|
+
compileCall(ctx) {
|
|
74
|
+
const U = LightPath.U;
|
|
75
|
+
return [
|
|
76
|
+
`float ${ctx.outputVar(this, 'Is Camera Ray')} = ${U.isCamera};`,
|
|
77
|
+
`float ${ctx.outputVar(this, 'Is Shadow Ray')} = ${U.isShadow};`,
|
|
78
|
+
`float ${ctx.outputVar(this, 'Is Diffuse Ray')} = ${U.isDiffuse};`,
|
|
79
|
+
`float ${ctx.outputVar(this, 'Is Glossy Ray')} = ${U.isGlossy};`,
|
|
80
|
+
`float ${ctx.outputVar(this, 'Is Singular Ray')} = ${U.isSingular};`,
|
|
81
|
+
`float ${ctx.outputVar(this, 'Is Reflection Ray')} = ${U.isReflection};`,
|
|
82
|
+
`float ${ctx.outputVar(this, 'Is Transmission Ray')} = ${U.isTransmission};`,
|
|
83
|
+
`float ${ctx.outputVar(this, 'Ray Length')} = ${U.rayLength};`,
|
|
84
|
+
`float ${ctx.outputVar(this, 'Ray Depth')} = ${U.rayDepth};`,
|
|
85
|
+
`float ${ctx.outputVar(this, 'Diffuse Depth')} = ${U.diffuseDepth};`,
|
|
86
|
+
`float ${ctx.outputVar(this, 'Glossy Depth')} = ${U.glossyDepth};`,
|
|
87
|
+
`float ${ctx.outputVar(this, 'Shadow Depth')} = ${U.shadowDepth};`,
|
|
88
|
+
`float ${ctx.outputVar(this, 'Transparent Depth')} = ${U.transparentDepth};`,
|
|
89
|
+
`float ${ctx.outputVar(this, 'Transmission Depth')} = ${U.transmissionDepth};`,
|
|
90
|
+
].join('\n ');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Canonical uniform names used by LightPath.
|
|
95
|
+
* LightPathController sets these on the compiled ShaderMaterial.
|
|
96
|
+
*/
|
|
97
|
+
LightPath.U = {
|
|
98
|
+
isCamera: 'u_st_lp_isCamera',
|
|
99
|
+
isShadow: 'u_st_lp_isShadow',
|
|
100
|
+
isDiffuse: 'u_st_lp_isDiffuse',
|
|
101
|
+
isGlossy: 'u_st_lp_isGlossy',
|
|
102
|
+
isSingular: 'u_st_lp_isSingular',
|
|
103
|
+
isReflection: 'u_st_lp_isReflection',
|
|
104
|
+
isTransmission: 'u_st_lp_isTransmission',
|
|
105
|
+
rayLength: 'u_st_lp_rayLength',
|
|
106
|
+
rayDepth: 'u_st_lp_rayDepth',
|
|
107
|
+
diffuseDepth: 'u_st_lp_diffuseDepth',
|
|
108
|
+
glossyDepth: 'u_st_lp_glossyDepth',
|
|
109
|
+
shadowDepth: 'u_st_lp_shadowDepth',
|
|
110
|
+
transparentDepth: 'u_st_lp_transparentDepth',
|
|
111
|
+
transmissionDepth: 'u_st_lp_transmissionDepth',
|
|
112
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
* Object Info — Blender "Object Info" node equivalent.
|
|
6
|
+
* Provides per-object random and index values for procedural variation across instances.
|
|
7
|
+
*
|
|
8
|
+
* Outputs: Random (float), ObjectIndex (float), MaterialIndex (float)
|
|
9
|
+
*
|
|
10
|
+
* Random is seeded per-node-instance so two ObjectInfo nodes in the same graph
|
|
11
|
+
* produce independent random values — useful for layering variation.
|
|
12
|
+
*/
|
|
13
|
+
export declare class ObjectInfo extends InputNode {
|
|
14
|
+
get nodeType(): string;
|
|
15
|
+
get metadata(): NodeMetadata;
|
|
16
|
+
private readonly _outputs;
|
|
17
|
+
private readonly _seed;
|
|
18
|
+
constructor();
|
|
19
|
+
getOutputSockets(): Record<string, import("../../core/OutputSocket.js").OutputSocket>;
|
|
20
|
+
compileCall(ctx: CompileContext): string;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=ObjectInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectInfo.d.ts","sourceRoot":"","sources":["../../../src/nodes/input/ObjectInfo.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;;;;;;;;GAQG;AACH,qBAAa,UAAW,SAAQ,SAAS;IACvC,IAAI,QAAQ,WAA0B;IAEtC,IAAI,QAAQ,IAAI,YAAY,CAE3B;IAED,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmE;IAC5F,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;;IAcjC,gBAAgB;IAEhB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;CAazC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { InputNode } from '../../core/InputNode.js';
|
|
2
|
+
/**
|
|
3
|
+
* Object Info — Blender "Object Info" node equivalent.
|
|
4
|
+
* Provides per-object random and index values for procedural variation across instances.
|
|
5
|
+
*
|
|
6
|
+
* Outputs: Random (float), ObjectIndex (float), MaterialIndex (float)
|
|
7
|
+
*
|
|
8
|
+
* Random is seeded per-node-instance so two ObjectInfo nodes in the same graph
|
|
9
|
+
* produce independent random values — useful for layering variation.
|
|
10
|
+
*/
|
|
11
|
+
export class ObjectInfo extends InputNode {
|
|
12
|
+
get nodeType() { return 'ObjectInfo'; }
|
|
13
|
+
get metadata() {
|
|
14
|
+
return { label: 'Object Info', category: 'Input', color: '#3d6b96', cost: 'low' };
|
|
15
|
+
}
|
|
16
|
+
constructor() {
|
|
17
|
+
super('ObjectInfo');
|
|
18
|
+
// Each instance gets a unique seed so multiple ObjectInfo nodes in one graph
|
|
19
|
+
// produce independent random outputs
|
|
20
|
+
this._seed = Math.random();
|
|
21
|
+
this._outputs = this.createOutputs({
|
|
22
|
+
Random: 'float',
|
|
23
|
+
ObjectIndex: 'float',
|
|
24
|
+
MaterialIndex: 'float',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
getOutputSockets() { return this._outputs; }
|
|
28
|
+
compileCall(ctx) {
|
|
29
|
+
const rv = ctx.outputVar(this, 'Random');
|
|
30
|
+
const oiv = ctx.outputVar(this, 'ObjectIndex');
|
|
31
|
+
const miv = ctx.outputVar(this, 'MaterialIndex');
|
|
32
|
+
// Hash world position to produce a stable per-object random value.
|
|
33
|
+
// floor() snaps to object origin so all fragments of the same object get the same value.
|
|
34
|
+
return [
|
|
35
|
+
`vec3 _oi_origin_${this.id} = floor(vPosition * 0.01) * 100.0;`,
|
|
36
|
+
`float ${rv} = fract(sin(dot(_oi_origin_${this.id}, vec3(127.1, 311.7, 74.7)) + ${this._seed.toFixed(6)}) * 43758.5453);`,
|
|
37
|
+
`float ${oiv} = floor(${rv} * 255.0);`,
|
|
38
|
+
`float ${miv} = floor(fract(${rv} * 17.0) * 255.0);`,
|
|
39
|
+
].join('\n ');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
* Ocean Attribute — Blender "Attribute" node reading the "Ocean" foam data layer.
|
|
6
|
+
*
|
|
7
|
+
* Reads the `foam` Float32BufferAttribute written by OceanModifier and passes it
|
|
8
|
+
* from the vertex shader to the fragment shader via a varying.
|
|
9
|
+
*
|
|
10
|
+
* Outputs:
|
|
11
|
+
* Fac (float) — raw foam value [0, 1]. 0 = calm water, 1 = breaking wave.
|
|
12
|
+
* Color (color) — vec3(fac, fac, fac) for use in color/emission nodes.
|
|
13
|
+
*
|
|
14
|
+
* Usage matches Blender's Attribute node with Data Layer set to "Ocean":
|
|
15
|
+
* const ocean = new OceanAttribute()
|
|
16
|
+
* const ramp = new ColorRamp({ fac: ocean.output('Fac'), stops: ['#000000', '#ffffff'] })
|
|
17
|
+
* // white where foam, dark where calm
|
|
18
|
+
*/
|
|
19
|
+
export declare class OceanAttribute extends InputNode {
|
|
20
|
+
get nodeType(): string;
|
|
21
|
+
get metadata(): NodeMetadata;
|
|
22
|
+
private readonly _outputs;
|
|
23
|
+
constructor();
|
|
24
|
+
getOutputSockets(): Record<string, import("../../core/OutputSocket.js").OutputSocket>;
|
|
25
|
+
vertexInjections(): {
|
|
26
|
+
attrName: string;
|
|
27
|
+
attrType: "float";
|
|
28
|
+
varyingName: string;
|
|
29
|
+
}[];
|
|
30
|
+
compileCall(ctx: CompileContext): string;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=OceanAttribute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OceanAttribute.d.ts","sourceRoot":"","sources":["../../../src/nodes/input/OceanAttribute.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;;;;;;;;;;;;;;GAcG;AACH,qBAAa,cAAe,SAAQ,SAAS;IAC3C,IAAI,QAAQ,WAA8B;IAE1C,IAAI,QAAQ,IAAI,YAAY,CAE3B;IAED,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmE;;IAO5F,gBAAgB;IAEhB,gBAAgB;;;;;IAIhB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;CAQzC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { InputNode } from '../../core/InputNode.js';
|
|
2
|
+
/**
|
|
3
|
+
* Ocean Attribute — Blender "Attribute" node reading the "Ocean" foam data layer.
|
|
4
|
+
*
|
|
5
|
+
* Reads the `foam` Float32BufferAttribute written by OceanModifier and passes it
|
|
6
|
+
* from the vertex shader to the fragment shader via a varying.
|
|
7
|
+
*
|
|
8
|
+
* Outputs:
|
|
9
|
+
* Fac (float) — raw foam value [0, 1]. 0 = calm water, 1 = breaking wave.
|
|
10
|
+
* Color (color) — vec3(fac, fac, fac) for use in color/emission nodes.
|
|
11
|
+
*
|
|
12
|
+
* Usage matches Blender's Attribute node with Data Layer set to "Ocean":
|
|
13
|
+
* const ocean = new OceanAttribute()
|
|
14
|
+
* const ramp = new ColorRamp({ fac: ocean.output('Fac'), stops: ['#000000', '#ffffff'] })
|
|
15
|
+
* // white where foam, dark where calm
|
|
16
|
+
*/
|
|
17
|
+
export class OceanAttribute extends InputNode {
|
|
18
|
+
get nodeType() { return 'OceanAttribute'; }
|
|
19
|
+
get metadata() {
|
|
20
|
+
return { label: 'Ocean Attribute', category: 'Input', color: '#1a4a6b', cost: 'low' };
|
|
21
|
+
}
|
|
22
|
+
constructor() {
|
|
23
|
+
super('OceanAttribute');
|
|
24
|
+
this._outputs = this.createOutputs({ Fac: 'float', Color: 'color' });
|
|
25
|
+
}
|
|
26
|
+
getOutputSockets() { return this._outputs; }
|
|
27
|
+
vertexInjections() {
|
|
28
|
+
return [{ attrName: 'foam', attrType: 'float', varyingName: 'vFoam' }];
|
|
29
|
+
}
|
|
30
|
+
compileCall(ctx) {
|
|
31
|
+
const fv = ctx.outputVar(this, 'Fac');
|
|
32
|
+
const cv = ctx.outputVar(this, 'Color');
|
|
33
|
+
return [
|
|
34
|
+
`float ${fv} = clamp(vFoam, 0.0, 1.0);`,
|
|
35
|
+
`vec3 ${cv} = vec3(${fv});`,
|
|
36
|
+
].join('\n ');
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
* Particle Info — Blender "Particle Info" input node equivalent.
|
|
6
|
+
* Reads per-particle data written into vertex attributes by particle renderers.
|
|
7
|
+
*
|
|
8
|
+
* Geometry requirements (from st-particle-core BillboardRenderer / InstanceRenderer):
|
|
9
|
+
* attribute float particleIndex — particle index in pool [0, N)
|
|
10
|
+
* attribute float particleAge — normalised age [0, 1]
|
|
11
|
+
* attribute float particleRandom — per-particle stable random value [0, 1]
|
|
12
|
+
*
|
|
13
|
+
* Outputs:
|
|
14
|
+
* Index (float) — particle index (normalised to [0, 1] via index/count)
|
|
15
|
+
* Age (float) — normalised lifetime: 0 = just born, 1 = about to die
|
|
16
|
+
* Random (float) — per-particle stable random value in [0, 1]
|
|
17
|
+
*/
|
|
18
|
+
export declare class ParticleInfo extends InputNode {
|
|
19
|
+
get nodeType(): string;
|
|
20
|
+
get metadata(): NodeMetadata;
|
|
21
|
+
private readonly _outputs;
|
|
22
|
+
constructor();
|
|
23
|
+
getOutputSockets(): Record<string, import("../../core/OutputSocket.js").OutputSocket>;
|
|
24
|
+
vertexInjections(): {
|
|
25
|
+
attrName: string;
|
|
26
|
+
attrType: "float";
|
|
27
|
+
varyingName: string;
|
|
28
|
+
}[];
|
|
29
|
+
compileCall(ctx: CompileContext): string;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=ParticleInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParticleInfo.d.ts","sourceRoot":"","sources":["../../../src/nodes/input/ParticleInfo.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;;;;;;;;;;;;;GAaG;AACH,qBAAa,YAAa,SAAQ,SAAS;IACzC,IAAI,QAAQ,WAA4B;IAExC,IAAI,QAAQ,IAAI,YAAY,CAE3B;IAED,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmE;;IAW5F,gBAAgB;IAEhB,gBAAgB;;;;;IAQhB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;CAOzC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { InputNode } from '../../core/InputNode.js';
|
|
2
|
+
/**
|
|
3
|
+
* Particle Info — Blender "Particle Info" input node equivalent.
|
|
4
|
+
* Reads per-particle data written into vertex attributes by particle renderers.
|
|
5
|
+
*
|
|
6
|
+
* Geometry requirements (from st-particle-core BillboardRenderer / InstanceRenderer):
|
|
7
|
+
* attribute float particleIndex — particle index in pool [0, N)
|
|
8
|
+
* attribute float particleAge — normalised age [0, 1]
|
|
9
|
+
* attribute float particleRandom — per-particle stable random value [0, 1]
|
|
10
|
+
*
|
|
11
|
+
* Outputs:
|
|
12
|
+
* Index (float) — particle index (normalised to [0, 1] via index/count)
|
|
13
|
+
* Age (float) — normalised lifetime: 0 = just born, 1 = about to die
|
|
14
|
+
* Random (float) — per-particle stable random value in [0, 1]
|
|
15
|
+
*/
|
|
16
|
+
export class ParticleInfo extends InputNode {
|
|
17
|
+
get nodeType() { return 'ParticleInfo'; }
|
|
18
|
+
get metadata() {
|
|
19
|
+
return { label: 'Particle Info', category: 'Input', color: '#3b5c3b', cost: 'low' };
|
|
20
|
+
}
|
|
21
|
+
constructor() {
|
|
22
|
+
super('ParticleInfo');
|
|
23
|
+
this._outputs = this.createOutputs({
|
|
24
|
+
Index: 'float',
|
|
25
|
+
Age: 'float',
|
|
26
|
+
Random: 'float',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
getOutputSockets() { return this._outputs; }
|
|
30
|
+
vertexInjections() {
|
|
31
|
+
return [
|
|
32
|
+
{ attrName: 'particleIndex', attrType: 'float', varyingName: 'vParticleIndex' },
|
|
33
|
+
{ attrName: 'particleAge', attrType: 'float', varyingName: 'vParticleAge' },
|
|
34
|
+
{ attrName: 'particleRandom', attrType: 'float', varyingName: 'vParticleRandom' },
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
compileCall(ctx) {
|
|
38
|
+
return [
|
|
39
|
+
`float ${ctx.outputVar(this, 'Index')} = vParticleIndex;`,
|
|
40
|
+
`float ${ctx.outputVar(this, 'Age')} = vParticleAge;`,
|
|
41
|
+
`float ${ctx.outputVar(this, 'Random')} = vParticleRandom;`,
|
|
42
|
+
].join('\n ');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { InputNode } from '../../core/InputNode.js';
|
|
2
|
+
import { CompileContext } from '../../core/CompileContext.js';
|
|
3
|
+
import type { NodeMetadata } from '../../core/ShaderNode.js';
|
|
4
|
+
/**
|
|
5
|
+
* RGB — Blender "RGB" input node equivalent.
|
|
6
|
+
* Outputs a single constant colour.
|
|
7
|
+
*
|
|
8
|
+
* Outputs: Color (color)
|
|
9
|
+
*/
|
|
10
|
+
export declare class RGB extends InputNode {
|
|
11
|
+
get nodeType(): string;
|
|
12
|
+
get metadata(): NodeMetadata;
|
|
13
|
+
private readonly hex;
|
|
14
|
+
private readonly _outputs;
|
|
15
|
+
constructor(color?: string);
|
|
16
|
+
getOutputSockets(): Record<string, import("../../core/OutputSocket.js").OutputSocket>;
|
|
17
|
+
compileCall(ctx: CompileContext): string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=RGB.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RGB.d.ts","sourceRoot":"","sources":["../../../src/nodes/input/RGB.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE5D;;;;;GAKG;AACH,qBAAa,GAAI,SAAQ,SAAS;IAChC,IAAI,QAAQ,WAAmB;IAE/B,IAAI,QAAQ,IAAI,YAAY,CAE3B;IAED,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmE;gBAEhF,KAAK,GAAE,MAAkB;IAMrC,gBAAgB;IAEhB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;CAGzC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { InputNode } from '../../core/InputNode.js';
|
|
2
|
+
import { CompileContext } from '../../core/CompileContext.js';
|
|
3
|
+
/**
|
|
4
|
+
* RGB — Blender "RGB" input node equivalent.
|
|
5
|
+
* Outputs a single constant colour.
|
|
6
|
+
*
|
|
7
|
+
* Outputs: Color (color)
|
|
8
|
+
*/
|
|
9
|
+
export class RGB extends InputNode {
|
|
10
|
+
get nodeType() { return 'RGB'; }
|
|
11
|
+
get metadata() {
|
|
12
|
+
return { label: 'RGB', category: 'Input', color: '#3d6b96', cost: 'low' };
|
|
13
|
+
}
|
|
14
|
+
constructor(color = '#ffffff') {
|
|
15
|
+
super('RGB');
|
|
16
|
+
this.hex = color;
|
|
17
|
+
this._outputs = this.createOutputs({ Color: 'color' });
|
|
18
|
+
}
|
|
19
|
+
getOutputSockets() { return this._outputs; }
|
|
20
|
+
compileCall(ctx) {
|
|
21
|
+
return `vec3 ${ctx.outputVar(this, 'Color')} = ${CompileContext.hexToVec3(this.hex)};`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
* ScreenCamera — provides per-pixel ray direction and camera position
|
|
6
|
+
* for screen-space / ray-marching shaders.
|
|
7
|
+
*
|
|
8
|
+
* Used with ScreenOutput, which injects the camera uniforms automatically.
|
|
9
|
+
* Call `screenOut.updateCamera(camera, w, h)` once per frame.
|
|
10
|
+
*
|
|
11
|
+
* Outputs:
|
|
12
|
+
* RayPos (color/vec3) — camera world-space position
|
|
13
|
+
* RayDir (color/vec3) — normalised ray direction for this pixel
|
|
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 ScreenCamera extends InputNode {
|
|
24
|
+
get nodeType(): string;
|
|
25
|
+
get metadata(): NodeMetadata;
|
|
26
|
+
private readonly _outputs;
|
|
27
|
+
constructor();
|
|
28
|
+
getOutputSockets(): Record<string, import("../../core/OutputSocket.js").OutputSocket>;
|
|
29
|
+
/**
|
|
30
|
+
* Declare the camera uniforms that ScreenOutput will inject.
|
|
31
|
+
* They are vec2/vec3/float types that live outside the standard
|
|
32
|
+
* float/vec3 uniform registry — declared here so the GLSL is valid.
|
|
33
|
+
*/
|
|
34
|
+
compileDefs(): string;
|
|
35
|
+
compileCall(ctx: CompileContext): string;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=ScreenCamera.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScreenCamera.d.ts","sourceRoot":"","sources":["../../../src/nodes/input/ScreenCamera.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;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,YAAa,SAAQ,SAAS;IACzC,IAAI,QAAQ,WAA4B;IAExC,IAAI,QAAQ,IAAI,YAAY,CAE3B;IAED,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmE;;IAO5F,gBAAgB;IAEhB;;;;OAIG;IACH,WAAW,IAAI,MAAM;IAWrB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;CAazC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { InputNode } from '../../core/InputNode.js';
|
|
2
|
+
/**
|
|
3
|
+
* ScreenCamera — provides per-pixel ray direction and camera position
|
|
4
|
+
* for screen-space / ray-marching shaders.
|
|
5
|
+
*
|
|
6
|
+
* Used with ScreenOutput, which injects the camera uniforms automatically.
|
|
7
|
+
* Call `screenOut.updateCamera(camera, w, h)` once per frame.
|
|
8
|
+
*
|
|
9
|
+
* Outputs:
|
|
10
|
+
* RayPos (color/vec3) — camera world-space position
|
|
11
|
+
* RayDir (color/vec3) — normalised ray direction for this pixel
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const cam = new ScreenCamera()
|
|
15
|
+
* const march = new SchwarzschildMarch({ rayPos: cam.output('RayPos'), rayDir: cam.output('RayDir'), ... })
|
|
16
|
+
* const out = new ScreenOutput({ color: march.output('Color') })
|
|
17
|
+
* out.compile()
|
|
18
|
+
* scene.add(out.mesh)
|
|
19
|
+
* // in loop: out.updateCamera(camera, innerWidth, innerHeight)
|
|
20
|
+
*/
|
|
21
|
+
export class ScreenCamera extends InputNode {
|
|
22
|
+
get nodeType() { return 'ScreenCamera'; }
|
|
23
|
+
get metadata() {
|
|
24
|
+
return { label: 'Screen Camera', category: 'Input', color: '#3d6b96', cost: 'low' };
|
|
25
|
+
}
|
|
26
|
+
constructor() {
|
|
27
|
+
super('ScreenCamera');
|
|
28
|
+
this._outputs = this.createOutputs({ RayPos: 'color', RayDir: 'color' });
|
|
29
|
+
}
|
|
30
|
+
getOutputSockets() { return this._outputs; }
|
|
31
|
+
/**
|
|
32
|
+
* Declare the camera uniforms that ScreenOutput will inject.
|
|
33
|
+
* They are vec2/vec3/float types that live outside the standard
|
|
34
|
+
* float/vec3 uniform registry — declared here so the GLSL is valid.
|
|
35
|
+
*/
|
|
36
|
+
compileDefs() {
|
|
37
|
+
return [
|
|
38
|
+
`uniform vec2 uSCResolution;`,
|
|
39
|
+
`uniform vec3 uSCCamPos;`,
|
|
40
|
+
`uniform vec3 uSCCamRight;`,
|
|
41
|
+
`uniform vec3 uSCCamUp;`,
|
|
42
|
+
`uniform vec3 uSCCamFwd;`,
|
|
43
|
+
`uniform float uSCFov;`,
|
|
44
|
+
].join('\n');
|
|
45
|
+
}
|
|
46
|
+
compileCall(ctx) {
|
|
47
|
+
const id = this.id;
|
|
48
|
+
return [
|
|
49
|
+
`vec2 _scUV_${id} = (gl_FragCoord.xy / uSCResolution - 0.5);`,
|
|
50
|
+
`_scUV_${id}.x *= uSCResolution.x / uSCResolution.y;`,
|
|
51
|
+
`vec3 ${ctx.outputVar(this, 'RayPos')} = uSCCamPos;`,
|
|
52
|
+
`vec3 ${ctx.outputVar(this, 'RayDir')} = normalize(`,
|
|
53
|
+
` uSCCamRight * _scUV_${id}.x * uSCFov +`,
|
|
54
|
+
` uSCCamUp * _scUV_${id}.y * uSCFov +`,
|
|
55
|
+
` uSCCamFwd`,
|
|
56
|
+
`);`,
|
|
57
|
+
].join('\n ');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
* Tangent — Blender "Tangent" input node equivalent.
|
|
6
|
+
* Provides tangent and bitangent vectors for anisotropic shading.
|
|
7
|
+
* Derived from screen-space position derivatives in the absence of a tangent attribute.
|
|
8
|
+
*
|
|
9
|
+
* Outputs:
|
|
10
|
+
* Tangent (color/vec3) — surface tangent direction
|
|
11
|
+
* Bitangent (color/vec3) — surface bitangent direction
|
|
12
|
+
*/
|
|
13
|
+
export declare class Tangent extends InputNode {
|
|
14
|
+
get nodeType(): string;
|
|
15
|
+
get metadata(): NodeMetadata;
|
|
16
|
+
private readonly _outputs;
|
|
17
|
+
constructor();
|
|
18
|
+
getOutputSockets(): Record<string, import("../../core/OutputSocket.js").OutputSocket>;
|
|
19
|
+
compileCall(ctx: CompileContext): string;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=Tangent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tangent.d.ts","sourceRoot":"","sources":["../../../src/nodes/input/Tangent.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;;;;;;;;GAQG;AACH,qBAAa,OAAQ,SAAQ,SAAS;IACpC,IAAI,QAAQ,WAAuB;IAEnC,IAAI,QAAQ,IAAI,YAAY,CAE3B;IAED,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmE;;IAO5F,gBAAgB;IAEhB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;CASzC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { InputNode } from '../../core/InputNode.js';
|
|
2
|
+
/**
|
|
3
|
+
* Tangent — Blender "Tangent" input node equivalent.
|
|
4
|
+
* Provides tangent and bitangent vectors for anisotropic shading.
|
|
5
|
+
* Derived from screen-space position derivatives in the absence of a tangent attribute.
|
|
6
|
+
*
|
|
7
|
+
* Outputs:
|
|
8
|
+
* Tangent (color/vec3) — surface tangent direction
|
|
9
|
+
* Bitangent (color/vec3) — surface bitangent direction
|
|
10
|
+
*/
|
|
11
|
+
export class Tangent extends InputNode {
|
|
12
|
+
get nodeType() { return 'Tangent'; }
|
|
13
|
+
get metadata() {
|
|
14
|
+
return { label: 'Tangent', category: 'Input', color: '#3d6b96', cost: 'low' };
|
|
15
|
+
}
|
|
16
|
+
constructor() {
|
|
17
|
+
super('Tangent');
|
|
18
|
+
this._outputs = this.createOutputs({ Tangent: 'color', Bitangent: 'color' });
|
|
19
|
+
}
|
|
20
|
+
getOutputSockets() { return this._outputs; }
|
|
21
|
+
compileCall(ctx) {
|
|
22
|
+
return [
|
|
23
|
+
`vec3 _tg_N_${this.id} = normalize(vNormal);`,
|
|
24
|
+
`vec3 _tg_dp1_${this.id} = dFdx(vPosition);`,
|
|
25
|
+
`vec3 _tg_dp2_${this.id} = dFdy(vPosition);`,
|
|
26
|
+
`vec3 ${ctx.outputVar(this, 'Tangent')} = normalize(_tg_dp1_${this.id} - _tg_N_${this.id} * dot(_tg_dp1_${this.id}, _tg_N_${this.id}));`,
|
|
27
|
+
`vec3 ${ctx.outputVar(this, 'Bitangent')} = cross(_tg_N_${this.id}, ${ctx.outputVar(this, 'Tangent')});`,
|
|
28
|
+
].join('\n ');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
* Texture Coordinate — Blender "Texture Coordinate" node equivalent.
|
|
6
|
+
*
|
|
7
|
+
* Outputs: UV (vector/vec2), Generated (color/vec3 object-space position), Normal (color/vec3)
|
|
8
|
+
*/
|
|
9
|
+
export declare class TextureCoordinate extends InputNode {
|
|
10
|
+
get nodeType(): string;
|
|
11
|
+
get metadata(): NodeMetadata;
|
|
12
|
+
private readonly _outputs;
|
|
13
|
+
constructor();
|
|
14
|
+
getOutputSockets(): Record<string, import("../../core/OutputSocket.js").OutputSocket>;
|
|
15
|
+
compileCall(ctx: CompileContext): string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=TextureCoordinate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextureCoordinate.d.ts","sourceRoot":"","sources":["../../../src/nodes/input/TextureCoordinate.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;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;IAC9C,IAAI,QAAQ,WAAiC;IAE7C,IAAI,QAAQ,IAAI,YAAY,CAE3B;IAED,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmE;;IAO5F,gBAAgB;IAEhB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;CAOzC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { InputNode } from '../../core/InputNode.js';
|
|
2
|
+
/**
|
|
3
|
+
* Texture Coordinate — Blender "Texture Coordinate" node equivalent.
|
|
4
|
+
*
|
|
5
|
+
* Outputs: UV (vector/vec2), Generated (color/vec3 object-space position), Normal (color/vec3)
|
|
6
|
+
*/
|
|
7
|
+
export class TextureCoordinate extends InputNode {
|
|
8
|
+
get nodeType() { return 'TextureCoordinate'; }
|
|
9
|
+
get metadata() {
|
|
10
|
+
return { label: 'Texture Coordinate', category: 'Input', color: '#3d6b96', cost: 'low' };
|
|
11
|
+
}
|
|
12
|
+
constructor() {
|
|
13
|
+
super('TextureCoordinate');
|
|
14
|
+
this._outputs = this.createOutputs({ UV: 'vector', Generated: 'color', Normal: 'color' });
|
|
15
|
+
}
|
|
16
|
+
getOutputSockets() { return this._outputs; }
|
|
17
|
+
compileCall(ctx) {
|
|
18
|
+
return [
|
|
19
|
+
`vec2 ${ctx.outputVar(this, 'UV')} = vUv;`,
|
|
20
|
+
`vec3 ${ctx.outputVar(this, 'Generated')} = vPosition;`,
|
|
21
|
+
`vec3 ${ctx.outputVar(this, 'Normal')} = normalize(vNormal);`,
|
|
22
|
+
].join('\n ');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
* UV Map — Blender "UV Map" input node equivalent.
|
|
6
|
+
* Outputs the mesh UV coordinates.
|
|
7
|
+
* In Three.js all geometries use a single UV channel exposed as vUv.
|
|
8
|
+
*
|
|
9
|
+
* Outputs:
|
|
10
|
+
* UV (vector/vec2) — UV coordinates [0,1]
|
|
11
|
+
*/
|
|
12
|
+
export declare class UVMap extends InputNode {
|
|
13
|
+
get nodeType(): string;
|
|
14
|
+
get metadata(): NodeMetadata;
|
|
15
|
+
private readonly _outputs;
|
|
16
|
+
constructor();
|
|
17
|
+
getOutputSockets(): Record<string, import("../../core/OutputSocket.js").OutputSocket>;
|
|
18
|
+
compileCall(ctx: CompileContext): string;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=UVMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UVMap.d.ts","sourceRoot":"","sources":["../../../src/nodes/input/UVMap.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,KAAM,SAAQ,SAAS;IAClC,IAAI,QAAQ,WAAqB;IAEjC,IAAI,QAAQ,IAAI,YAAY,CAE3B;IAED,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmE;;IAO5F,gBAAgB;IAEhB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,MAAM;CAGzC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { InputNode } from '../../core/InputNode.js';
|
|
2
|
+
/**
|
|
3
|
+
* UV Map — Blender "UV Map" input node equivalent.
|
|
4
|
+
* Outputs the mesh UV coordinates.
|
|
5
|
+
* In Three.js all geometries use a single UV channel exposed as vUv.
|
|
6
|
+
*
|
|
7
|
+
* Outputs:
|
|
8
|
+
* UV (vector/vec2) — UV coordinates [0,1]
|
|
9
|
+
*/
|
|
10
|
+
export class UVMap extends InputNode {
|
|
11
|
+
get nodeType() { return 'UVMap'; }
|
|
12
|
+
get metadata() {
|
|
13
|
+
return { label: 'UV Map', category: 'Input', color: '#3d6b96', cost: 'low' };
|
|
14
|
+
}
|
|
15
|
+
constructor() {
|
|
16
|
+
super('UVMap');
|
|
17
|
+
this._outputs = this.createOutputs({ UV: 'vector' });
|
|
18
|
+
}
|
|
19
|
+
getOutputSockets() { return this._outputs; }
|
|
20
|
+
compileCall(ctx) {
|
|
21
|
+
return `vec2 ${ctx.outputVar(this, 'UV')} = vUv;`;
|
|
22
|
+
}
|
|
23
|
+
}
|