@triforge/compositor-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/dist/core/BasePass.d.ts +49 -0
- package/dist/core/BasePass.d.ts.map +1 -0
- package/dist/core/BasePass.js +36 -0
- package/dist/core/CompositorBackend.d.ts +12 -0
- package/dist/core/CompositorBackend.d.ts.map +1 -0
- package/dist/core/CompositorBackend.js +1 -0
- package/dist/core/CompositorOutput.d.ts +73 -0
- package/dist/core/CompositorOutput.d.ts.map +1 -0
- package/dist/core/CompositorOutput.js +201 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/passes/AlphaOver.d.ts +32 -0
- package/dist/passes/AlphaOver.d.ts.map +1 -0
- package/dist/passes/AlphaOver.js +59 -0
- package/dist/passes/Bloom.d.ts +25 -0
- package/dist/passes/Bloom.d.ts.map +1 -0
- package/dist/passes/Bloom.js +32 -0
- package/dist/passes/Blur.d.ts +23 -0
- package/dist/passes/Blur.d.ts.map +1 -0
- package/dist/passes/Blur.js +54 -0
- package/dist/passes/BrightnessContrast.d.ts +20 -0
- package/dist/passes/BrightnessContrast.d.ts.map +1 -0
- package/dist/passes/BrightnessContrast.js +42 -0
- package/dist/passes/ChromaticAberration.d.ts +22 -0
- package/dist/passes/ChromaticAberration.d.ts.map +1 -0
- package/dist/passes/ChromaticAberration.js +53 -0
- package/dist/passes/ColorBalance.d.ts +38 -0
- package/dist/passes/ColorBalance.d.ts.map +1 -0
- package/dist/passes/ColorBalance.js +50 -0
- package/dist/passes/CombineRGBA.d.ts +35 -0
- package/dist/passes/CombineRGBA.d.ts.map +1 -0
- package/dist/passes/CombineRGBA.js +49 -0
- package/dist/passes/DepthOfField.d.ts +27 -0
- package/dist/passes/DepthOfField.d.ts.map +1 -0
- package/dist/passes/DepthOfField.js +47 -0
- package/dist/passes/EdgeDetect.d.ts +31 -0
- package/dist/passes/EdgeDetect.d.ts.map +1 -0
- package/dist/passes/EdgeDetect.js +69 -0
- package/dist/passes/Exposure.d.ts +19 -0
- package/dist/passes/Exposure.d.ts.map +1 -0
- package/dist/passes/Exposure.js +42 -0
- package/dist/passes/FilmGrain.d.ts +26 -0
- package/dist/passes/FilmGrain.d.ts.map +1 -0
- package/dist/passes/FilmGrain.js +31 -0
- package/dist/passes/Gamma.d.ts +17 -0
- package/dist/passes/Gamma.d.ts.map +1 -0
- package/dist/passes/Gamma.js +36 -0
- package/dist/passes/GaussianBlur.d.ts +26 -0
- package/dist/passes/GaussianBlur.d.ts.map +1 -0
- package/dist/passes/GaussianBlur.js +81 -0
- package/dist/passes/GlareStreaks.d.ts +38 -0
- package/dist/passes/GlareStreaks.d.ts.map +1 -0
- package/dist/passes/GlareStreaks.js +82 -0
- package/dist/passes/HueSaturation.d.ts +26 -0
- package/dist/passes/HueSaturation.d.ts.map +1 -0
- package/dist/passes/HueSaturation.js +65 -0
- package/dist/passes/LUT.d.ts +64 -0
- package/dist/passes/LUT.d.ts.map +1 -0
- package/dist/passes/LUT.js +140 -0
- package/dist/passes/LensFlare.d.ts +34 -0
- package/dist/passes/LensFlare.d.ts.map +1 -0
- package/dist/passes/LensFlare.js +92 -0
- package/dist/passes/Mix.d.ts +23 -0
- package/dist/passes/Mix.d.ts.map +1 -0
- package/dist/passes/Mix.js +41 -0
- package/dist/passes/MotionBlur.d.ts +37 -0
- package/dist/passes/MotionBlur.d.ts.map +1 -0
- package/dist/passes/MotionBlur.js +65 -0
- package/dist/passes/Pixelate.d.ts +19 -0
- package/dist/passes/Pixelate.d.ts.map +1 -0
- package/dist/passes/Pixelate.js +45 -0
- package/dist/passes/RenderLayers.d.ts +31 -0
- package/dist/passes/RenderLayers.d.ts.map +1 -0
- package/dist/passes/RenderLayers.js +45 -0
- package/dist/passes/SSAO.d.ts +34 -0
- package/dist/passes/SSAO.d.ts.map +1 -0
- package/dist/passes/SSAO.js +42 -0
- package/dist/passes/SSR.d.ts +32 -0
- package/dist/passes/SSR.d.ts.map +1 -0
- package/dist/passes/SSR.js +44 -0
- package/dist/passes/SeparateRGBA.d.ts +29 -0
- package/dist/passes/SeparateRGBA.d.ts.map +1 -0
- package/dist/passes/SeparateRGBA.js +45 -0
- package/dist/passes/SetAlpha.d.ts +21 -0
- package/dist/passes/SetAlpha.d.ts.map +1 -0
- package/dist/passes/SetAlpha.js +36 -0
- package/dist/passes/Sharpen.d.ts +17 -0
- package/dist/passes/Sharpen.d.ts.map +1 -0
- package/dist/passes/Sharpen.js +42 -0
- package/dist/passes/Vignette.d.ts +22 -0
- package/dist/passes/Vignette.d.ts.map +1 -0
- package/dist/passes/Vignette.js +49 -0
- package/dist/passes/ZCombine.d.ts +34 -0
- package/dist/passes/ZCombine.d.ts.map +1 -0
- package/dist/passes/ZCombine.js +50 -0
- package/package.json +48 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Vector2 } from 'three';
|
|
2
|
+
import { BasePass } from '../core/BasePass.js';
|
|
3
|
+
/**
|
|
4
|
+
* SSAO — Screen Space Ambient Occlusion.
|
|
5
|
+
* Blender Compositor: Ambient Occlusion pass.
|
|
6
|
+
*
|
|
7
|
+
* Wraps Three.js SSAOPass from three/addons.
|
|
8
|
+
* Requires scene and camera — injected automatically by CompositorOutput.
|
|
9
|
+
*
|
|
10
|
+
* Post-compile injection needed:
|
|
11
|
+
* ```typescript
|
|
12
|
+
* comp.compile(renderer, scene, camera)
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export class SSAO extends BasePass {
|
|
16
|
+
constructor(opts = {}) {
|
|
17
|
+
super();
|
|
18
|
+
this.passType = 'SSAO';
|
|
19
|
+
this.parameters = {
|
|
20
|
+
radius: opts.radius ?? 0.5,
|
|
21
|
+
minDistance: opts.minDistance ?? 0.005,
|
|
22
|
+
maxDistance: opts.maxDistance ?? 0.1,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
_threePassDeps() { return ['SSAOPass']; }
|
|
26
|
+
_buildThree(width, height, reg) {
|
|
27
|
+
const Pass = reg['SSAOPass'];
|
|
28
|
+
const scene = reg['_scene'];
|
|
29
|
+
const camera = reg['_camera'];
|
|
30
|
+
if (!Pass)
|
|
31
|
+
throw new Error('SSAO: SSAOPass not found in three/addons.');
|
|
32
|
+
if (!scene)
|
|
33
|
+
throw new Error('SSAO: scene not provided. Pass scene to CompositorOutput.compile().');
|
|
34
|
+
if (!camera)
|
|
35
|
+
throw new Error('SSAO: camera not provided. Pass camera to CompositorOutput.compile().');
|
|
36
|
+
const pass = new Pass(scene, camera, new Vector2(width, height));
|
|
37
|
+
pass['kernelRadius'] = this.parameters.radius;
|
|
38
|
+
pass['minDistance'] = this.parameters.minDistance;
|
|
39
|
+
pass['maxDistance'] = this.parameters.maxDistance;
|
|
40
|
+
return pass;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BasePass } from '../core/BasePass.js';
|
|
2
|
+
import type { PassRegistry } from '../core/BasePass.js';
|
|
3
|
+
export interface SSROptions {
|
|
4
|
+
/** Maximum ray distance for reflections. Default 180. Blender: Screen Space Reflections → Max Roughness */
|
|
5
|
+
maxDistance?: number;
|
|
6
|
+
/** Opacity / blend strength of reflections [0–1]. Default 0.5. */
|
|
7
|
+
opacity?: number;
|
|
8
|
+
/** Roughness threshold above which SSR is skipped [0–1]. Default 0.8. */
|
|
9
|
+
maxRoughness?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* SSR — Screen Space Reflections.
|
|
13
|
+
* Blender Compositor / EEVEE: Screen Space Reflections.
|
|
14
|
+
*
|
|
15
|
+
* Wraps Three.js SSRPass from three/addons.
|
|
16
|
+
* Requires scene and camera — injected automatically by CompositorOutput.
|
|
17
|
+
*
|
|
18
|
+
* SSR works best with smooth, metallic or glossy surfaces.
|
|
19
|
+
* For very rough surfaces set a low `maxRoughness` to skip the effect.
|
|
20
|
+
*/
|
|
21
|
+
export declare class SSR extends BasePass {
|
|
22
|
+
readonly passType = "SSR";
|
|
23
|
+
parameters: {
|
|
24
|
+
maxDistance: number;
|
|
25
|
+
opacity: number;
|
|
26
|
+
maxRoughness: number;
|
|
27
|
+
};
|
|
28
|
+
constructor(opts?: SSROptions);
|
|
29
|
+
_threePassDeps(): string[];
|
|
30
|
+
_buildThree(width: number, height: number, reg: PassRegistry): unknown;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=SSR.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SSR.d.ts","sourceRoot":"","sources":["../../src/passes/SSR.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,MAAM,WAAW,UAAU;IACzB,2GAA2G;IAC3G,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kEAAkE;IAClE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;;;GASG;AACH,qBAAa,GAAI,SAAQ,QAAQ;IAC/B,QAAQ,CAAC,QAAQ,SAAQ;IACzB,UAAU,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAA;gBAE9D,IAAI,GAAE,UAAe;IASjC,cAAc;IAEd,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO;CAoBvE"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BasePass } from '../core/BasePass.js';
|
|
2
|
+
/**
|
|
3
|
+
* SSR — Screen Space Reflections.
|
|
4
|
+
* Blender Compositor / EEVEE: Screen Space Reflections.
|
|
5
|
+
*
|
|
6
|
+
* Wraps Three.js SSRPass from three/addons.
|
|
7
|
+
* Requires scene and camera — injected automatically by CompositorOutput.
|
|
8
|
+
*
|
|
9
|
+
* SSR works best with smooth, metallic or glossy surfaces.
|
|
10
|
+
* For very rough surfaces set a low `maxRoughness` to skip the effect.
|
|
11
|
+
*/
|
|
12
|
+
export class SSR extends BasePass {
|
|
13
|
+
constructor(opts = {}) {
|
|
14
|
+
super();
|
|
15
|
+
this.passType = 'SSR';
|
|
16
|
+
this.parameters = {
|
|
17
|
+
maxDistance: opts.maxDistance ?? 180,
|
|
18
|
+
opacity: opts.opacity ?? 0.5,
|
|
19
|
+
maxRoughness: opts.maxRoughness ?? 0.8,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
_threePassDeps() { return ['SSRPass']; }
|
|
23
|
+
_buildThree(width, height, reg) {
|
|
24
|
+
const Pass = reg['SSRPass'];
|
|
25
|
+
const scene = reg['_scene'];
|
|
26
|
+
const camera = reg['_camera'];
|
|
27
|
+
const renderer = reg['_renderer'];
|
|
28
|
+
if (!Pass)
|
|
29
|
+
throw new Error('SSR: SSRPass not found in three/addons.');
|
|
30
|
+
if (!scene)
|
|
31
|
+
throw new Error('SSR: scene not provided.');
|
|
32
|
+
if (!camera)
|
|
33
|
+
throw new Error('SSR: camera not provided.');
|
|
34
|
+
const pass = new Pass(renderer, scene, camera, {
|
|
35
|
+
width,
|
|
36
|
+
height,
|
|
37
|
+
isPerspectiveCamera: true,
|
|
38
|
+
});
|
|
39
|
+
pass['maxDistance'] = this.parameters.maxDistance;
|
|
40
|
+
pass['opacity'] = this.parameters.opacity;
|
|
41
|
+
pass['maxRoughness'] = this.parameters.maxRoughness;
|
|
42
|
+
return pass;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BasePass } from '../core/BasePass.js';
|
|
2
|
+
import type { PassRegistry } from '../core/BasePass.js';
|
|
3
|
+
export type RGBAChannel = 0 | 1 | 2 | 3;
|
|
4
|
+
export interface SeparateRGBAOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Which channel to extract and display as greyscale.
|
|
7
|
+
* 0 = R, 1 = G, 2 = B, 3 = A. Default 0. Blender: Separate RGBA → R/G/B/A socket.
|
|
8
|
+
*/
|
|
9
|
+
channel?: RGBAChannel;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* SeparateRGBA — Blender Compositor: Separate RGBA node.
|
|
13
|
+
*
|
|
14
|
+
* Extracts a single channel (R, G, B, or A) and displays it as
|
|
15
|
+
* a greyscale image. Use to inspect individual channels of the render.
|
|
16
|
+
*
|
|
17
|
+
* Changing `parameters.channel` at runtime swaps the extracted channel
|
|
18
|
+
* without recompiling — channel 0=R 1=G 2=B 3=A.
|
|
19
|
+
*/
|
|
20
|
+
export declare class SeparateRGBA extends BasePass {
|
|
21
|
+
readonly passType = "SeparateRGBA";
|
|
22
|
+
parameters: {
|
|
23
|
+
channel: number;
|
|
24
|
+
};
|
|
25
|
+
constructor(opts?: SeparateRGBAOptions);
|
|
26
|
+
_threePassDeps(): string[];
|
|
27
|
+
_buildThree(_w: number, _h: number, reg: PassRegistry): unknown;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=SeparateRGBA.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeparateRGBA.d.ts","sourceRoot":"","sources":["../../src/passes/SeparateRGBA.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAEvC,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAA;CACtB;AAED;;;;;;;;GAQG;AACH,qBAAa,YAAa,SAAQ,QAAQ;IACxC,QAAQ,CAAC,QAAQ,kBAAiB;IAClC,UAAU,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;gBAEnB,IAAI,GAAE,mBAAwB;IAK1C,cAAc;IAEd,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO;CA0BhE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BasePass } from '../core/BasePass.js';
|
|
2
|
+
/**
|
|
3
|
+
* SeparateRGBA — Blender Compositor: Separate RGBA node.
|
|
4
|
+
*
|
|
5
|
+
* Extracts a single channel (R, G, B, or A) and displays it as
|
|
6
|
+
* a greyscale image. Use to inspect individual channels of the render.
|
|
7
|
+
*
|
|
8
|
+
* Changing `parameters.channel` at runtime swaps the extracted channel
|
|
9
|
+
* without recompiling — channel 0=R 1=G 2=B 3=A.
|
|
10
|
+
*/
|
|
11
|
+
export class SeparateRGBA extends BasePass {
|
|
12
|
+
constructor(opts = {}) {
|
|
13
|
+
super();
|
|
14
|
+
this.passType = 'SeparateRGBA';
|
|
15
|
+
this.parameters = { channel: opts.channel ?? 0 };
|
|
16
|
+
}
|
|
17
|
+
_threePassDeps() { return ['ShaderPass']; }
|
|
18
|
+
_buildThree(_w, _h, reg) {
|
|
19
|
+
const ShaderPass = reg['ShaderPass'];
|
|
20
|
+
if (!ShaderPass)
|
|
21
|
+
throw new Error('SeparateRGBA: ShaderPass not found.');
|
|
22
|
+
const shader = {
|
|
23
|
+
uniforms: {
|
|
24
|
+
tDiffuse: { value: null },
|
|
25
|
+
channel: { value: this.parameters.channel },
|
|
26
|
+
},
|
|
27
|
+
vertexShader: `varying vec2 vUv; void main(){ vUv=uv; gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0); }`,
|
|
28
|
+
fragmentShader: `
|
|
29
|
+
uniform sampler2D tDiffuse;
|
|
30
|
+
uniform float channel;
|
|
31
|
+
varying vec2 vUv;
|
|
32
|
+
void main(){
|
|
33
|
+
vec4 col = texture2D(tDiffuse, vUv);
|
|
34
|
+
float v;
|
|
35
|
+
if (channel < 0.5) v = col.r;
|
|
36
|
+
else if (channel < 1.5) v = col.g;
|
|
37
|
+
else if (channel < 2.5) v = col.b;
|
|
38
|
+
else v = col.a;
|
|
39
|
+
gl_FragColor = vec4(v, v, v, 1.0);
|
|
40
|
+
}
|
|
41
|
+
`,
|
|
42
|
+
};
|
|
43
|
+
return new ShaderPass(shader);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BasePass } from '../core/BasePass.js';
|
|
2
|
+
import type { PassRegistry } from '../core/BasePass.js';
|
|
3
|
+
export interface SetAlphaOptions {
|
|
4
|
+
/** Alpha value to set [0–1]. Default 1.0. Blender: Set Alpha → Alpha */
|
|
5
|
+
alpha?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* SetAlpha — Blender Compositor: Set Alpha node.
|
|
9
|
+
* Sets the alpha channel of the render to a constant value.
|
|
10
|
+
* Useful for compositing transparent elements.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SetAlpha extends BasePass {
|
|
13
|
+
readonly passType = "SetAlpha";
|
|
14
|
+
parameters: {
|
|
15
|
+
alpha: number;
|
|
16
|
+
};
|
|
17
|
+
constructor(opts?: SetAlphaOptions);
|
|
18
|
+
_threePassDeps(): string[];
|
|
19
|
+
_buildThree(_w: number, _h: number, reg: PassRegistry): unknown;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=SetAlpha.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SetAlpha.d.ts","sourceRoot":"","sources":["../../src/passes/SetAlpha.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,MAAM,WAAW,eAAe;IAC9B,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,qBAAa,QAAS,SAAQ,QAAQ;IACpC,QAAQ,CAAC,QAAQ,cAAa;IAC9B,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;gBAEjB,IAAI,GAAE,eAAoB;IAKtC,cAAc;IAEd,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO;CAqBhE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BasePass } from '../core/BasePass.js';
|
|
2
|
+
/**
|
|
3
|
+
* SetAlpha — Blender Compositor: Set Alpha node.
|
|
4
|
+
* Sets the alpha channel of the render to a constant value.
|
|
5
|
+
* Useful for compositing transparent elements.
|
|
6
|
+
*/
|
|
7
|
+
export class SetAlpha extends BasePass {
|
|
8
|
+
constructor(opts = {}) {
|
|
9
|
+
super();
|
|
10
|
+
this.passType = 'SetAlpha';
|
|
11
|
+
this.parameters = { alpha: opts.alpha ?? 1.0 };
|
|
12
|
+
}
|
|
13
|
+
_threePassDeps() { return ['ShaderPass']; }
|
|
14
|
+
_buildThree(_w, _h, reg) {
|
|
15
|
+
const ShaderPass = reg['ShaderPass'];
|
|
16
|
+
if (!ShaderPass)
|
|
17
|
+
throw new Error('SetAlpha: ShaderPass not found.');
|
|
18
|
+
const shader = {
|
|
19
|
+
uniforms: {
|
|
20
|
+
tDiffuse: { value: null },
|
|
21
|
+
alpha: { value: this.parameters.alpha },
|
|
22
|
+
},
|
|
23
|
+
vertexShader: `varying vec2 vUv; void main(){ vUv=uv; gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0); }`,
|
|
24
|
+
fragmentShader: `
|
|
25
|
+
uniform sampler2D tDiffuse;
|
|
26
|
+
uniform float alpha;
|
|
27
|
+
varying vec2 vUv;
|
|
28
|
+
void main(){
|
|
29
|
+
vec4 col = texture2D(tDiffuse, vUv);
|
|
30
|
+
gl_FragColor = vec4(col.rgb, alpha);
|
|
31
|
+
}
|
|
32
|
+
`,
|
|
33
|
+
};
|
|
34
|
+
return new ShaderPass(shader);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BasePass } from '../core/BasePass.js';
|
|
2
|
+
import type { PassRegistry } from '../core/BasePass.js';
|
|
3
|
+
export interface SharpenOptions {
|
|
4
|
+
/** Sharpen intensity [0–1]. Default 0.5. Blender: Filter → Sharpen */
|
|
5
|
+
intensity?: number;
|
|
6
|
+
}
|
|
7
|
+
/** Sharpen — Blender Compositor: Filter node (Sharpen) */
|
|
8
|
+
export declare class Sharpen extends BasePass {
|
|
9
|
+
readonly passType = "Sharpen";
|
|
10
|
+
parameters: {
|
|
11
|
+
intensity: number;
|
|
12
|
+
};
|
|
13
|
+
constructor(opts?: SharpenOptions);
|
|
14
|
+
_threePassDeps(): string[];
|
|
15
|
+
_buildThree(_width: number, _height: number, reg: PassRegistry): unknown;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=Sharpen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sharpen.d.ts","sourceRoot":"","sources":["../../src/passes/Sharpen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,0DAA0D;AAC1D,qBAAa,OAAQ,SAAQ,QAAQ;IACnC,QAAQ,CAAC,QAAQ,aAAY;IAC7B,UAAU,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;gBAErB,IAAI,GAAE,cAAmB;IAKrC,cAAc;IAEd,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO;CAgCzE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { BasePass } from '../core/BasePass.js';
|
|
2
|
+
/** Sharpen — Blender Compositor: Filter node (Sharpen) */
|
|
3
|
+
export class Sharpen extends BasePass {
|
|
4
|
+
constructor(opts = {}) {
|
|
5
|
+
super();
|
|
6
|
+
this.passType = 'Sharpen';
|
|
7
|
+
this.parameters = { intensity: opts.intensity ?? 0.5 };
|
|
8
|
+
}
|
|
9
|
+
_threePassDeps() { return ['ShaderPass']; }
|
|
10
|
+
_buildThree(_width, _height, reg) {
|
|
11
|
+
const ShaderPass = reg['ShaderPass'];
|
|
12
|
+
if (!ShaderPass)
|
|
13
|
+
throw new Error('Sharpen: ShaderPass not found in three/addons.');
|
|
14
|
+
const shader = {
|
|
15
|
+
uniforms: {
|
|
16
|
+
tDiffuse: { value: null },
|
|
17
|
+
intensity: { value: this.parameters.intensity },
|
|
18
|
+
texSize: { value: [1 / _width, 1 / _height] },
|
|
19
|
+
},
|
|
20
|
+
vertexShader: `
|
|
21
|
+
varying vec2 vUv;
|
|
22
|
+
void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0); }
|
|
23
|
+
`,
|
|
24
|
+
fragmentShader: `
|
|
25
|
+
uniform sampler2D tDiffuse;
|
|
26
|
+
uniform float intensity;
|
|
27
|
+
uniform vec2 texSize;
|
|
28
|
+
varying vec2 vUv;
|
|
29
|
+
void main() {
|
|
30
|
+
vec4 center = texture2D(tDiffuse, vUv);
|
|
31
|
+
vec4 n = texture2D(tDiffuse, vUv + vec2( 0.0, texSize.y));
|
|
32
|
+
vec4 s = texture2D(tDiffuse, vUv + vec2( 0.0, -texSize.y));
|
|
33
|
+
vec4 e = texture2D(tDiffuse, vUv + vec2( texSize.x, 0.0));
|
|
34
|
+
vec4 w = texture2D(tDiffuse, vUv + vec2(-texSize.x, 0.0));
|
|
35
|
+
vec4 sharp = center * (1.0 + 4.0 * intensity) - (n + s + e + w) * intensity;
|
|
36
|
+
gl_FragColor = vec4(clamp(sharp.rgb, 0.0, 1.0), center.a);
|
|
37
|
+
}
|
|
38
|
+
`,
|
|
39
|
+
};
|
|
40
|
+
return new ShaderPass(shader);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BasePass } from '../core/BasePass.js';
|
|
2
|
+
import type { PassRegistry } from '../core/BasePass.js';
|
|
3
|
+
export interface VignetteOptions {
|
|
4
|
+
/** Vignette darkness [0–1]. Default 0.5. Blender: Lens Distortion → Vignette */
|
|
5
|
+
darkness?: number;
|
|
6
|
+
/** Vignette offset — how far from centre the effect starts [0–1]. Default 1.0. */
|
|
7
|
+
offset?: number;
|
|
8
|
+
}
|
|
9
|
+
/** Vignette — Blender Compositor: Lens Distortion node (Vignette) */
|
|
10
|
+
export declare class Vignette extends BasePass {
|
|
11
|
+
readonly passType = "Vignette";
|
|
12
|
+
parameters: {
|
|
13
|
+
darkness: number;
|
|
14
|
+
offset: number;
|
|
15
|
+
};
|
|
16
|
+
constructor(opts?: VignetteOptions);
|
|
17
|
+
_threePassDeps(): string[];
|
|
18
|
+
_buildThree(_width: number, _height: number, reg: PassRegistry): unknown;
|
|
19
|
+
_buildPmndrs(reg: PassRegistry): unknown;
|
|
20
|
+
get _isPmndrsEffect(): boolean;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=Vignette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Vignette.d.ts","sourceRoot":"","sources":["../../src/passes/Vignette.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,MAAM,WAAW,eAAe;IAC9B,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,qEAAqE;AACrE,qBAAa,QAAS,SAAQ,QAAQ;IACpC,QAAQ,CAAC,QAAQ,cAAa;IAC9B,UAAU,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;gBAEpC,IAAI,GAAE,eAAoB;IAQtC,cAAc;IAEd,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO;IA8B/D,YAAY,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO;IAMjD,IAAa,eAAe,IAAI,OAAO,CAAgB;CACxD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BasePass } from '../core/BasePass.js';
|
|
2
|
+
/** Vignette — Blender Compositor: Lens Distortion node (Vignette) */
|
|
3
|
+
export class Vignette extends BasePass {
|
|
4
|
+
constructor(opts = {}) {
|
|
5
|
+
super();
|
|
6
|
+
this.passType = 'Vignette';
|
|
7
|
+
this.parameters = {
|
|
8
|
+
darkness: opts.darkness ?? 0.5,
|
|
9
|
+
offset: opts.offset ?? 1.0,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
_threePassDeps() { return ['ShaderPass']; }
|
|
13
|
+
_buildThree(_width, _height, reg) {
|
|
14
|
+
const ShaderPass = reg['ShaderPass'];
|
|
15
|
+
if (!ShaderPass)
|
|
16
|
+
throw new Error('Vignette: ShaderPass not found in three/addons.');
|
|
17
|
+
const shader = {
|
|
18
|
+
uniforms: {
|
|
19
|
+
tDiffuse: { value: null },
|
|
20
|
+
darkness: { value: this.parameters.darkness },
|
|
21
|
+
offset: { value: this.parameters.offset },
|
|
22
|
+
},
|
|
23
|
+
vertexShader: `
|
|
24
|
+
varying vec2 vUv;
|
|
25
|
+
void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0); }
|
|
26
|
+
`,
|
|
27
|
+
fragmentShader: `
|
|
28
|
+
uniform sampler2D tDiffuse;
|
|
29
|
+
uniform float darkness;
|
|
30
|
+
uniform float offset;
|
|
31
|
+
varying vec2 vUv;
|
|
32
|
+
void main() {
|
|
33
|
+
vec4 color = texture2D(tDiffuse, vUv);
|
|
34
|
+
float dist = distance(vUv, vec2(0.5));
|
|
35
|
+
color.rgb *= smoothstep(0.8, offset * 0.799, dist * (darkness + offset));
|
|
36
|
+
gl_FragColor = color;
|
|
37
|
+
}
|
|
38
|
+
`,
|
|
39
|
+
};
|
|
40
|
+
return new ShaderPass(shader);
|
|
41
|
+
}
|
|
42
|
+
_buildPmndrs(reg) {
|
|
43
|
+
const Effect = reg['VignetteEffect'];
|
|
44
|
+
if (!Effect)
|
|
45
|
+
throw new Error('Vignette: VignetteEffect not found in postprocessing.');
|
|
46
|
+
return new Effect({ darkness: this.parameters.darkness, offset: this.parameters.offset });
|
|
47
|
+
}
|
|
48
|
+
get _isPmndrsEffect() { return true; }
|
|
49
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BasePass } from '../core/BasePass.js';
|
|
2
|
+
import type { PassRegistry } from '../core/BasePass.js';
|
|
3
|
+
export interface ZCombineOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Depth split point [0–1]. Pixels with luma below this are treated as far.
|
|
6
|
+
* Default 0.5. Blender: Z Combine → use luminance as depth proxy.
|
|
7
|
+
*/
|
|
8
|
+
split?: number;
|
|
9
|
+
/** Blend softness around the split [0–1]. Default 0.1. */
|
|
10
|
+
softness?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* ZCombine — Blender Compositor: Z Combine node.
|
|
14
|
+
*
|
|
15
|
+
* In a linear render pipeline, a true Z combine (selecting pixels by
|
|
16
|
+
* depth buffer comparison) requires two separate render targets.
|
|
17
|
+
* This pass implements a luminance-keyed depth blend as a single-pass
|
|
18
|
+
* approximation: pixels darker than `split` are treated as "far" and
|
|
19
|
+
* receive a darken/fade effect; bright pixels are treated as "near".
|
|
20
|
+
*
|
|
21
|
+
* For a true two-target Z combine, render to two WebGLRenderTargets
|
|
22
|
+
* and composite them yourself before passing to the pipeline.
|
|
23
|
+
*/
|
|
24
|
+
export declare class ZCombine extends BasePass {
|
|
25
|
+
readonly passType = "ZCombine";
|
|
26
|
+
parameters: {
|
|
27
|
+
split: number;
|
|
28
|
+
softness: number;
|
|
29
|
+
};
|
|
30
|
+
constructor(opts?: ZCombineOptions);
|
|
31
|
+
_threePassDeps(): string[];
|
|
32
|
+
_buildThree(_w: number, _h: number, reg: PassRegistry): unknown;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=ZCombine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZCombine.d.ts","sourceRoot":"","sources":["../../src/passes/ZCombine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,QAAS,SAAQ,QAAQ;IACpC,QAAQ,CAAC,QAAQ,cAAa;IAC9B,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAA;gBAEnC,IAAI,GAAE,eAAoB;IAQtC,cAAc;IAEd,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO;CAyBhE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { BasePass } from '../core/BasePass.js';
|
|
2
|
+
/**
|
|
3
|
+
* ZCombine — Blender Compositor: Z Combine node.
|
|
4
|
+
*
|
|
5
|
+
* In a linear render pipeline, a true Z combine (selecting pixels by
|
|
6
|
+
* depth buffer comparison) requires two separate render targets.
|
|
7
|
+
* This pass implements a luminance-keyed depth blend as a single-pass
|
|
8
|
+
* approximation: pixels darker than `split` are treated as "far" and
|
|
9
|
+
* receive a darken/fade effect; bright pixels are treated as "near".
|
|
10
|
+
*
|
|
11
|
+
* For a true two-target Z combine, render to two WebGLRenderTargets
|
|
12
|
+
* and composite them yourself before passing to the pipeline.
|
|
13
|
+
*/
|
|
14
|
+
export class ZCombine extends BasePass {
|
|
15
|
+
constructor(opts = {}) {
|
|
16
|
+
super();
|
|
17
|
+
this.passType = 'ZCombine';
|
|
18
|
+
this.parameters = {
|
|
19
|
+
split: opts.split ?? 0.5,
|
|
20
|
+
softness: opts.softness ?? 0.1,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
_threePassDeps() { return ['ShaderPass']; }
|
|
24
|
+
_buildThree(_w, _h, reg) {
|
|
25
|
+
const ShaderPass = reg['ShaderPass'];
|
|
26
|
+
if (!ShaderPass)
|
|
27
|
+
throw new Error('ZCombine: ShaderPass not found.');
|
|
28
|
+
const shader = {
|
|
29
|
+
uniforms: {
|
|
30
|
+
tDiffuse: { value: null },
|
|
31
|
+
split: { value: this.parameters.split },
|
|
32
|
+
softness: { value: this.parameters.softness },
|
|
33
|
+
},
|
|
34
|
+
vertexShader: `varying vec2 vUv; void main(){ vUv=uv; gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0); }`,
|
|
35
|
+
fragmentShader: `
|
|
36
|
+
uniform sampler2D tDiffuse;
|
|
37
|
+
uniform float split;
|
|
38
|
+
uniform float softness;
|
|
39
|
+
varying vec2 vUv;
|
|
40
|
+
void main(){
|
|
41
|
+
vec4 col = texture2D(tDiffuse, vUv);
|
|
42
|
+
float luma = dot(col.rgb, vec3(0.299, 0.587, 0.114));
|
|
43
|
+
float depth = 1.0 - smoothstep(split - softness, split + softness, luma);
|
|
44
|
+
gl_FragColor = vec4(col.rgb * (1.0 - depth * 0.5), col.a);
|
|
45
|
+
}
|
|
46
|
+
`,
|
|
47
|
+
};
|
|
48
|
+
return new ShaderPass(shader);
|
|
49
|
+
}
|
|
50
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@triforge/compositor-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Blender-matched compositor node graph for Three.js — backend-agnostic (three/addons or pmndrs/postprocessing)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"package.json"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"dev": "tsc --watch",
|
|
15
|
+
"test": "node test/run-tests.js"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"three.js",
|
|
19
|
+
"post-processing",
|
|
20
|
+
"compositor",
|
|
21
|
+
"blender",
|
|
22
|
+
"effects"
|
|
23
|
+
],
|
|
24
|
+
"author": "Aftab Ibrahim Kazi",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"three": ">=0.128.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependenciesMeta": {
|
|
30
|
+
"postprocessing": {
|
|
31
|
+
"optional": true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/three": "^0.156.0",
|
|
36
|
+
"three": "^0.156.0",
|
|
37
|
+
"typescript": "^5.3.0"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/AftabIbrahimKazi/triforge.git",
|
|
42
|
+
"directory": "st-compositor-core"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/AftabIbrahimKazi/triforge#readme",
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
}
|
|
48
|
+
}
|