@mesmotronic/three-retropass
Version:
RetroPass applies a retro aesthetic to your Three.js project, emulating the visual style of classic 8-bit and 16-bit games
93 lines (92 loc) • 3.63 kB
TypeScript
import * as THREE from 'three';
import { convertToTexture } from 'three/tsl';
import { TempNode } from 'three/webgpu';
import { RetroPassParameters } from '../../models/RetroPassParameters';
/**
* TSL node that applies a retro-style post-processing effect with
* pixelation, color quantization, and ordered (Bayer) dithering.
*
* Designed for use with Three.js WebGPURenderer and PostProcessing.
*
* @augments TempNode
* @example
* import { pass } from 'three/tsl';
* import { retroPass } from '@mesmotronic/three-retropass/webgpu';
*
* const scenePass = pass(scene, camera);
* const postProcessing = new PostProcessing(renderer);
* postProcessing.outputNode = retroPass(scenePass.getTextureNode(), { colorCount: 16 });
*/
export declare class RetroPassNode extends TempNode {
#private;
static get type(): string;
/** Input texture node (the scene render) */
textureNode: ReturnType<typeof convertToTexture>;
/** @private Uniform for retro resolution (e.g. 320×200) */
private _resolution;
/** @private Uniform for dithering on/off */
private _dithering;
/** @private Uniform for dithering strength */
private _ditheringOffset;
/** @private Uniform for number of colors */
private _colorCount;
/** @private Uniform for whether this is a quantized (cube) palette */
private _isQuantized;
/** @private TextureNode for the palette */
private _colorTextureNode;
/** @private Uniform for whether to invert the image */
private _inverted;
/**
* @param textureNode - The texture node that provides the input image
* @param parameters - Configuration parameters for the retro effect
*/
constructor(textureNode: ReturnType<typeof convertToTexture>, { colorCount, colorPalette, dithering, ditheringOffset, autoDitheringOffset, pixelRatio, resolution, autoResolution, }?: RetroPassParameters);
get resolution(): THREE.Vector2;
set resolution(value: THREE.Vector2);
get autoResolution(): boolean;
set autoResolution(value: boolean);
get pixelRatio(): number;
set pixelRatio(value: number);
get colorCount(): number;
set colorCount(value: number);
get colorPalette(): THREE.Color[];
set colorPalette(colors: THREE.Color[]);
get dithering(): boolean;
set dithering(value: boolean);
get ditheringOffset(): number;
set ditheringOffset(value: number);
get autoDitheringOffset(): boolean;
set autoDitheringOffset(value: boolean);
get inverted(): boolean;
set inverted(value: boolean);
/**
* Called by the renderer / PostProcessing pipeline when the output size
* changes. Mirrors the `setSize` API from the WebGL ShaderPass.
*/
setSize(width: number, height: number): void;
/**
* Builds the TSL node graph implementing the retro effect.
*/
setup(): import("three/webgpu").Node<"vec4">;
}
/**
* TSL convenience function for creating a RetroPassNode.
*
* @tsl
* @function
* @param node - Input node (scene render texture or any vec4 node)
* @param parameters - Retro effect configuration
* @returns A node-wrapped RetroPassNode ready for use in PostProcessing
*
* @example
* import { pass } from 'three/tsl';
* import { retroPass } from '@mesmotronic/three-retropass/webgpu';
*
* const scenePass = pass(scene, camera);
* postProcessing.outputNode = retroPass(scenePass.getTextureNode(), {
* colorCount: 4,
* dithering: true,
* });
*/
export declare const retroPass: (node: Parameters<typeof convertToTexture>[0], parameters?: RetroPassParameters) => RetroPassNode;
export default RetroPassNode;