@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.
246 lines • 12.4 kB
JavaScript
import { __decorate } from "../../../../tslib.es6.js";
import { RegisterClass } from "../../../../Misc/typeStore.js";
import { editableInPropertyPage } from "../../../../Decorators/nodeDecorator.js";
import { FrameGraphImageProcessingTask } from "../../../Tasks/PostProcesses/imageProcessingTask.js";
import { ThinImageProcessingPostProcess } from "../../../../PostProcesses/thinImageProcessingPostProcess.js";
import { NodeRenderGraphBasePostProcessBlock } from "./basePostProcessBlock.js";
import { ImageProcessingConfiguration } from "../../../../Materials/imageProcessingConfiguration.js";
import { Color4 } from "../../../../Maths/math.color.js";
/**
* Block that implements the image processing post process
*/
export class NodeRenderGraphImageProcessingPostProcessBlock extends NodeRenderGraphBasePostProcessBlock {
/**
* Gets the frame graph task associated with this block
*/
get task() {
return this._frameGraphTask;
}
/**
* Create a new image processing post process block
* @param name defines the block name
* @param frameGraph defines the hosting frame graph
* @param scene defines the hosting scene
*/
constructor(name, frameGraph, scene) {
super(name, frameGraph, scene);
this._finalizeInputOutputRegistering();
this._frameGraphTask = new FrameGraphImageProcessingTask(this.name, frameGraph, new ThinImageProcessingPostProcess(name, scene.getEngine(), {
scene,
imageProcessingConfiguration: new ImageProcessingConfiguration(),
}));
}
/** Contrast used in the effect */
get contrast() {
return this._frameGraphTask.postProcess.contrast;
}
set contrast(value) {
this._frameGraphTask.postProcess.contrast = value;
}
/** Exposure used in the effect */
get exposure() {
return this._frameGraphTask.postProcess.exposure;
}
set exposure(value) {
this._frameGraphTask.postProcess.exposure = value;
}
/** Whether the tone mapping effect is enabled. */
get toneMappingEnabled() {
return this._frameGraphTask.postProcess.toneMappingEnabled;
}
set toneMappingEnabled(value) {
this._frameGraphTask.postProcess.toneMappingEnabled = value;
}
/** Type of tone mapping effect. */
get toneMappingType() {
return this._frameGraphTask.postProcess.toneMappingType;
}
set toneMappingType(value) {
this._frameGraphTask.postProcess.toneMappingType = value;
}
/** Whether the vignette effect is enabled. */
get vignetteEnabled() {
return this._frameGraphTask.postProcess.vignetteEnabled;
}
set vignetteEnabled(value) {
this._frameGraphTask.postProcess.vignetteEnabled = value;
}
/** Vignette weight or intensity of the vignette effect. */
get vignetteWeight() {
return this._frameGraphTask.postProcess.vignetteWeight;
}
set vignetteWeight(value) {
this._frameGraphTask.postProcess.vignetteWeight = value;
}
/** Vignette stretch size. */
get vignetteStretch() {
return this._frameGraphTask.postProcess.vignetteStretch;
}
set vignetteStretch(value) {
this._frameGraphTask.postProcess.vignetteStretch = value;
}
/** Camera field of view used by the Vignette effect. */
get vignetteCameraFov() {
return this._frameGraphTask.postProcess.vignetteCameraFov;
}
set vignetteCameraFov(value) {
this._frameGraphTask.postProcess.vignetteCameraFov = value;
}
/** Vignette center X Offset. */
get vignetteCenterX() {
return this._frameGraphTask.postProcess.vignetteCenterX;
}
set vignetteCenterX(value) {
this._frameGraphTask.postProcess.vignetteCenterX = value;
}
/** Vignette center Y Offset. */
get vignetteCenterY() {
return this._frameGraphTask.postProcess.vignetteCenterY;
}
set vignetteCenterY(value) {
this._frameGraphTask.postProcess.vignetteCenterY = value;
}
/** Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode) */
get vignetteColor() {
return this._frameGraphTask.postProcess.vignetteColor;
}
set vignetteColor(value) {
this._frameGraphTask.postProcess.vignetteColor = value;
}
/** Vignette blend mode allowing different kind of effect. */
get vignetteBlendMode() {
return this._frameGraphTask.postProcess.vignetteBlendMode;
}
set vignetteBlendMode(value) {
this._frameGraphTask.postProcess.vignetteBlendMode = value;
}
/** Whether the dithering effect is enabled. */
get ditheringEnabled() {
return this._frameGraphTask.postProcess.ditheringEnabled;
}
set ditheringEnabled(value) {
this._frameGraphTask.postProcess.ditheringEnabled = value;
}
/** Sets whether the dithering effect is enabled. */
get ditheringIntensity() {
return this._frameGraphTask.postProcess.ditheringIntensity;
}
set ditheringIntensity(value) {
this._frameGraphTask.postProcess.ditheringIntensity = value;
}
/**
* Gets the current class name
* @returns the class name
*/
getClassName() {
return "NodeRenderGraphImageProcessingPostProcessBlock";
}
_dumpPropertiesCode() {
const codes = [];
codes.push(`${this._codeVariableName}.contrast = ${this.contrast};`);
codes.push(`${this._codeVariableName}.exposure = ${this.exposure};`);
codes.push(`${this._codeVariableName}.toneMappingEnabled = ${this.toneMappingEnabled};`);
codes.push(`${this._codeVariableName}.toneMappingType = ${this.toneMappingType};`);
codes.push(`${this._codeVariableName}.vignetteEnabled = ${this.vignetteEnabled};`);
codes.push(`${this._codeVariableName}.vignetteWeight = ${this.vignetteWeight};`);
codes.push(`${this._codeVariableName}.vignetteStretch = ${this.vignetteStretch};`);
codes.push(`${this._codeVariableName}.vignetteCameraFov = ${this.vignetteCameraFov};`);
codes.push(`${this._codeVariableName}.vignetteCenterX = ${this.vignetteCenterX};`);
codes.push(`${this._codeVariableName}.vignetteCenterY = ${this.vignetteCenterY};`);
codes.push(`${this._codeVariableName}.vignetteColor = new BABYLON.Color4(${this.vignetteColor.r}, ${this.vignetteColor.g}, ${this.vignetteColor.b}, 1);`);
codes.push(`${this._codeVariableName}.vignetteBlendMode = ${this.vignetteBlendMode};`);
codes.push(`${this._codeVariableName}.ditheringEnabled = ${this.ditheringEnabled};`);
codes.push(`${this._codeVariableName}.ditheringIntensity = ${this.ditheringIntensity};`);
return super._dumpPropertiesCode() + codes.join("\n");
}
serialize() {
const serializationObject = super.serialize();
serializationObject.contrast = this.contrast;
serializationObject.exposure = this.exposure;
serializationObject.toneMappingEnabled = this.toneMappingEnabled;
serializationObject.toneMappingType = this.toneMappingType;
serializationObject.vignetteEnabled = this.vignetteEnabled;
serializationObject.vignetteWeight = this.vignetteWeight;
serializationObject.vignetteStretch = this.vignetteStretch;
serializationObject.vignetteCameraFov = this.vignetteCameraFov;
serializationObject.vignetteCenterX = this.vignetteCenterX;
serializationObject.vignetteCenterY = this.vignetteCenterY;
serializationObject.vignetteColor = this.vignetteColor.asArray();
serializationObject.vignetteBlendMode = this.vignetteBlendMode;
serializationObject.ditheringEnabled = this.ditheringEnabled;
serializationObject.ditheringIntensity = this.ditheringIntensity;
return serializationObject;
}
_deserialize(serializationObject) {
super._deserialize(serializationObject);
this.contrast = serializationObject.contrast;
this.exposure = serializationObject.exposure;
this.toneMappingEnabled = serializationObject.toneMappingEnabled;
this.toneMappingType = serializationObject.toneMappingType;
this.vignetteEnabled = serializationObject.vignetteEnabled;
this.vignetteWeight = serializationObject.vignetteWeight;
this.vignetteStretch = serializationObject.vignetteStretch;
this.vignetteCameraFov = serializationObject.vignetteCameraFov;
this.vignetteCenterX = serializationObject.vignetteCenterX;
this.vignetteCenterY = serializationObject.vignetteCenterY;
this.vignetteColor = Color4.FromArray(serializationObject.vignetteColor);
this.vignetteBlendMode = serializationObject.vignetteBlendMode;
this.ditheringEnabled = serializationObject.ditheringEnabled;
this.ditheringIntensity = serializationObject.ditheringIntensity;
}
}
__decorate([
editableInPropertyPage("Contrast", 1 /* PropertyTypeForEdition.Float */, "PROPERTIES", { min: 0, max: 4 })
], NodeRenderGraphImageProcessingPostProcessBlock.prototype, "contrast", null);
__decorate([
editableInPropertyPage("Exposure", 1 /* PropertyTypeForEdition.Float */, "PROPERTIES", { min: 0, max: 4 })
], NodeRenderGraphImageProcessingPostProcessBlock.prototype, "exposure", null);
__decorate([
editableInPropertyPage("Enabled", 0 /* PropertyTypeForEdition.Boolean */, "TONE MAPPING")
], NodeRenderGraphImageProcessingPostProcessBlock.prototype, "toneMappingEnabled", null);
__decorate([
editableInPropertyPage("Type", 4 /* PropertyTypeForEdition.List */, "TONE MAPPING", {
options: [
{ value: ImageProcessingConfiguration.TONEMAPPING_STANDARD, label: "Standard" },
{ value: ImageProcessingConfiguration.TONEMAPPING_ACES, label: "ACES" },
{ value: ImageProcessingConfiguration.TONEMAPPING_KHR_PBR_NEUTRAL, label: "KHR PBR Neutral" },
],
})
], NodeRenderGraphImageProcessingPostProcessBlock.prototype, "toneMappingType", null);
__decorate([
editableInPropertyPage("Enabled", 0 /* PropertyTypeForEdition.Boolean */, "VIGNETTE")
], NodeRenderGraphImageProcessingPostProcessBlock.prototype, "vignetteEnabled", null);
__decorate([
editableInPropertyPage("Weight", 1 /* PropertyTypeForEdition.Float */, "VIGNETTE", { min: 0, max: 4 })
], NodeRenderGraphImageProcessingPostProcessBlock.prototype, "vignetteWeight", null);
__decorate([
editableInPropertyPage("Stretch", 1 /* PropertyTypeForEdition.Float */, "VIGNETTE", { min: 0, max: 1 })
], NodeRenderGraphImageProcessingPostProcessBlock.prototype, "vignetteStretch", null);
__decorate([
editableInPropertyPage("FOV", 1 /* PropertyTypeForEdition.Float */, "VIGNETTE", { min: 0, max: 3.14159 })
], NodeRenderGraphImageProcessingPostProcessBlock.prototype, "vignetteCameraFov", null);
__decorate([
editableInPropertyPage("Center X", 1 /* PropertyTypeForEdition.Float */, "VIGNETTE", { min: 0, max: 1 })
], NodeRenderGraphImageProcessingPostProcessBlock.prototype, "vignetteCenterX", null);
__decorate([
editableInPropertyPage("Center Y", 1 /* PropertyTypeForEdition.Float */, "VIGNETTE", { min: 0, max: 1 })
], NodeRenderGraphImageProcessingPostProcessBlock.prototype, "vignetteCenterY", null);
__decorate([
editableInPropertyPage("Color", 5 /* PropertyTypeForEdition.Color4 */, "VIGNETTE")
], NodeRenderGraphImageProcessingPostProcessBlock.prototype, "vignetteColor", null);
__decorate([
editableInPropertyPage("Blend mode", 4 /* PropertyTypeForEdition.List */, "VIGNETTE", {
options: [
{ value: ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY, label: "Multiply" },
{ value: ImageProcessingConfiguration.VIGNETTEMODE_OPAQUE, label: "Opaque" },
],
})
], NodeRenderGraphImageProcessingPostProcessBlock.prototype, "vignetteBlendMode", null);
__decorate([
editableInPropertyPage("Enabed", 0 /* PropertyTypeForEdition.Boolean */, "DITHERING")
], NodeRenderGraphImageProcessingPostProcessBlock.prototype, "ditheringEnabled", null);
__decorate([
editableInPropertyPage("Intensity", 1 /* PropertyTypeForEdition.Float */, "DITHERING", { min: 0, max: 1 })
], NodeRenderGraphImageProcessingPostProcessBlock.prototype, "ditheringIntensity", null);
RegisterClass("BABYLON.NodeRenderGraphImageProcessingPostProcessBlock", NodeRenderGraphImageProcessingPostProcessBlock);
//# sourceMappingURL=imageProcessingPostProcessBlock.js.map