/** * @import { CameraFrameEffectPasses, CameraFrameEffectResources, CameraFrameEffectScene } from '../../render-passes/camera-frame-effect.js' * @import { GraphicsDevice } from '../../../platform/graphics/graphics-device.js' * @import { Texture } from '../../../platform/graphics/texture.js' */ /** * The SMAA effect - Subpixel Morphological Anti-Aliasing (SMAA 1x), a technique smoothing the * jagged edges of the rendered geometry. It finds the edges in the image, recognizes the shape of * each aliased edge, and blends the pixels along it with their neighbors by the area the edge * before aliasing would cover. Unlike temporal anti-aliasing it works within a single frame: it * does not jitter the camera, needs no history and does not ghost, at the cost of not resolving * detail finer than a pixel. * * The effect resolves the scene before the other effects read it, so that the depth of field, the * bloom and the composition all work with the anti-aliased scene. It is not registered by default * - add it to a {@link CameraFrame}: * * ```javascript * const smaa = new SmaaEffect(app.graphicsDevice); * cameraFrame.addEffect(smaa); * cameraFrame.update(); * ``` * * The parameters default to the HIGH quality preset of the reference implementation. The * presets, as threshold / maxSearchSteps / maxSearchStepsDiag / cornerRounding, are LOW: 0.15 / * 4 / 0 / 100, MEDIUM: 0.1 / 8 / 0 / 100, HIGH: 0.1 / 16 / 8 / 25 and ULTRA: 0.05 / 32 / 16 / 25. * * It can be combined with multisampling, see `rendering.samples` of the camera frame, which smooths * the edges further at a higher cost. Combined with {@link TaaEffect}, it resolves the scene in the * order the effects are registered - after the built-in temporal anti-aliasing unless inserted * before it with {@link CameraFrame#insertEffectBefore}. * * Based on the reference implementation of SMAA by Jorge Jimenez, Jose I. Echevarria, Belen * Masia, Fernando Navarro and Diego Gutierrez, distributed under the MIT license. * * @category Graphics */ export class SmaaEffect extends CameraFrameEffect { /** * @param {GraphicsDevice} device - The graphics device. */ constructor(device: GraphicsDevice); /** * The brightness difference between neighboring pixels above which they are separated by an * edge, 0-0.5 range. Lower values smooth more edges, at a higher cost, and can smooth texture * detail along with the geometry. Defaults to 0.1. * * @type {number} */ threshold: number; /** * The maximum number of steps searching for the end of a horizontal or vertical edge, each * step covering two pixels, 1-112 range. The ends of longer edges are not found, which smooths * them less accurately. Defaults to 16. * * @type {number} */ maxSearchSteps: number; /** * The maximum number of steps searching for the end of a diagonal edge, 0-20 range. Zero * disables the detection of diagonal edges, which are then smoothed as horizontal and * vertical ones. Defaults to 8. * * @type {number} */ maxSearchStepsDiag: number; /** * How much the sharp corners of the geometry are rounded, 0-100 range. Zero keeps them the * sharpest, 100 smooths them like the rest of the edges. Defaults to 25. * * @type {number} */ cornerRounding: number; /** * The passes of the effect, while they exist. * * @type {FramePassSmaa|null} * @private */ private _pass; /** * The area lookup texture. * * @type {Texture|null} * @private */ private _areaTexture; /** * The search lookup texture. * * @type {Texture|null} * @private */ private _searchTexture; /** * Resolved once the lookup textures are filled. * * @type {Promise} * @ignore */ _lookupReady: Promise; } import { CameraFrameEffect } from '../../render-passes/camera-frame-effect.js'; import type { GraphicsDevice } from '../../../platform/graphics/graphics-device.js';