UNPKG

@babylonjs/core

Version:

Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.

234 lines (233 loc) 7.85 kB
import type { Camera } from "../../../Cameras/camera.js"; import { PostProcessRenderPipeline } from "../../../PostProcesses/RenderPipeline/postProcessRenderPipeline.js"; import type { Scene } from "../../../scene.js"; import "../../../PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.js"; import "../../../Shaders/chromaticAberration.fragment.js"; import "../../../Shaders/lensHighlights.fragment.js"; import "../../../Shaders/depthOfField.fragment.js"; /** * BABYLON.JS Chromatic Aberration GLSL Shader * Author: Olivier Guyot * Separates very slightly R, G and B colors on the edges of the screen * Inspired by Francois Tarlier & Martins Upitis */ export declare class LensRenderingPipeline extends PostProcessRenderPipeline { /** * @ignore * The chromatic aberration PostProcess id in the pipeline */ LensChromaticAberrationEffect: string; /** * @ignore * The highlights enhancing PostProcess id in the pipeline */ HighlightsEnhancingEffect: string; /** * @ignore * The depth-of-field PostProcess id in the pipeline */ LensDepthOfFieldEffect: string; private _scene; private _depthTexture; private _grainTexture; private _chromaticAberrationPostProcess; private _highlightsPostProcess; private _depthOfFieldPostProcess; private _edgeBlur; private _grainAmount; private _chromaticAberration; private _distortion; private _highlightsGain; private _highlightsThreshold; private _dofDistance; private _dofAperture; private _dofDarken; private _dofPentagon; private _blurNoise; /** * @constructor * * Effect parameters are as follow: * { * chromatic_aberration: number; // from 0 to x (1 for realism) * edge_blur: number; // from 0 to x (1 for realism) * distortion: number; // from 0 to x (1 for realism), note that this will effect the pointer position precision * grain_amount: number; // from 0 to 1 * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default) * dof_aperture: number; // depth-of-field: focus blur bias (default: 1) * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default) * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default) * dof_threshold: number; // depth-of-field: highlights threshold (default: 1) * blur_noise: boolean; // add a little bit of noise to the blur (default: true) * } * Note: if an effect parameter is unset, effect is disabled * * @param name The rendering pipeline name * @param parameters - An object containing all parameters (see above) * @param scene The scene linked to this pipeline * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5) * @param cameras The array of cameras that the rendering pipeline will be attached to */ constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]); /** * Get the class name * @returns "LensRenderingPipeline" */ getClassName(): string; /** * Gets associated scene */ get scene(): Scene; /** * Gets or sets the edge blur */ get edgeBlur(): number; set edgeBlur(value: number); /** * Gets or sets the grain amount */ get grainAmount(): number; set grainAmount(value: number); /** * Gets or sets the chromatic aberration amount */ get chromaticAberration(): number; set chromaticAberration(value: number); /** * Gets or sets the depth of field aperture */ get dofAperture(): number; set dofAperture(value: number); /** * Gets or sets the edge distortion */ get edgeDistortion(): number; set edgeDistortion(value: number); /** * Gets or sets the depth of field distortion */ get dofDistortion(): number; set dofDistortion(value: number); /** * Gets or sets the darken out of focus amount */ get darkenOutOfFocus(): number; set darkenOutOfFocus(value: number); /** * Gets or sets a boolean indicating if blur noise is enabled */ get blurNoise(): boolean; set blurNoise(value: boolean); /** * Gets or sets a boolean indicating if pentagon bokeh is enabled */ get pentagonBokeh(): boolean; set pentagonBokeh(value: boolean); /** * Gets or sets the highlight grain amount */ get highlightsGain(): number; set highlightsGain(value: number); /** * Gets or sets the highlight threshold */ get highlightsThreshold(): number; set highlightsThreshold(value: number); /** * Sets the amount of blur at the edges * @param amount blur amount */ setEdgeBlur(amount: number): void; /** * Sets edge blur to 0 */ disableEdgeBlur(): void; /** * Sets the amount of grain * @param amount Amount of grain */ setGrainAmount(amount: number): void; /** * Set grain amount to 0 */ disableGrain(): void; /** * Sets the chromatic aberration amount * @param amount amount of chromatic aberration */ setChromaticAberration(amount: number): void; /** * Sets chromatic aberration amount to 0 */ disableChromaticAberration(): void; /** * Sets the EdgeDistortion amount * @param amount amount of EdgeDistortion */ setEdgeDistortion(amount: number): void; /** * Sets edge distortion to 0 */ disableEdgeDistortion(): void; /** * Sets the FocusDistance amount * @param amount amount of FocusDistance */ setFocusDistance(amount: number): void; /** * Disables depth of field */ disableDepthOfField(): void; /** * Sets the Aperture amount * @param amount amount of Aperture */ setAperture(amount: number): void; /** * Sets the DarkenOutOfFocus amount * @param amount amount of DarkenOutOfFocus */ setDarkenOutOfFocus(amount: number): void; private _pentagonBokehIsEnabled; /** * Creates a pentagon bokeh effect */ enablePentagonBokeh(): void; /** * Disables the pentagon bokeh effect */ disablePentagonBokeh(): void; /** * Enables noise blur */ enableNoiseBlur(): void; /** * Disables noise blur */ disableNoiseBlur(): void; /** * Sets the HighlightsGain amount * @param amount amount of HighlightsGain */ setHighlightsGain(amount: number): void; /** * Sets the HighlightsThreshold amount * @param amount amount of HighlightsThreshold */ setHighlightsThreshold(amount: number): void; /** * Disables highlights */ disableHighlights(): void; /** * Removes the internal pipeline assets and detaches the pipeline from the scene cameras * @param disableDepthRender If the scene's depth rendering should be disabled (default: false) */ dispose(disableDepthRender?: boolean): void; private _createChromaticAberrationPostProcess; private _createHighlightsPostProcess; private _createDepthOfFieldPostProcess; private _createGrainTexture; }