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.

107 lines 4.83 kB
import { __decorate } from "../../../../tslib.es6.js"; import { RegisterClass } from "../../../../Misc/typeStore.js"; import { NodeRenderGraphBlockConnectionPointTypes } from "../../Types/nodeRenderGraphTypes.js"; import { editableInPropertyPage } from "../../../../Decorators/nodeDecorator.js"; import { FrameGraphMotionBlurTask } from "../../../Tasks/PostProcesses/motionBlurTask.js"; import { ThinMotionBlurPostProcess } from "../../../../PostProcesses/thinMotionBlurPostProcess.js"; import { NodeRenderGraphBasePostProcessBlock } from "./basePostProcessBlock.js"; /** * Block that implements the motion blur post process */ export class NodeRenderGraphMotionBlurPostProcessBlock extends NodeRenderGraphBasePostProcessBlock { /** * Gets the frame graph task associated with this block */ get task() { return this._frameGraphTask; } /** * Create a new NodeRenderGraphMotionBlurPostProcessBlock * @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.registerInput("geomVelocity", NodeRenderGraphBlockConnectionPointTypes.TextureVelocity, true); this.registerInput("geomViewDepth", NodeRenderGraphBlockConnectionPointTypes.TextureViewDepth, true); this._finalizeInputOutputRegistering(); this._frameGraphTask = new FrameGraphMotionBlurTask(this.name, frameGraph, new ThinMotionBlurPostProcess(name, frameGraph.scene)); } /** Defines how much the image is blurred by the movement. */ get motionStrength() { return this._frameGraphTask.postProcess.motionStrength; } set motionStrength(value) { this._frameGraphTask.postProcess.motionStrength = value; } /** Gets the number of iterations that are used for motion blur quality. */ get motionBlurSamples() { return this._frameGraphTask.postProcess.motionBlurSamples; } set motionBlurSamples(value) { this._frameGraphTask.postProcess.motionBlurSamples = value; } /** Gets whether or not the motion blur post-process is in object based mode. */ get isObjectBased() { return this._frameGraphTask.postProcess.isObjectBased; } set isObjectBased(value) { this._frameGraphTask.postProcess.isObjectBased = value; } /** * Gets the current class name * @returns the class name */ getClassName() { return "NodeRenderGraphMotionBlurPostProcessBlock"; } /** * Gets the geometry velocity input component */ get geomVelocity() { return this._inputs[2]; } /** * Gets the geometry view depth input component */ get geomViewDepth() { return this._inputs[3]; } _buildBlock(state) { super._buildBlock(state); this._frameGraphTask.velocityTexture = this.geomVelocity.connectedPoint?.value; this._frameGraphTask.depthTexture = this.geomViewDepth.connectedPoint?.value; } _dumpPropertiesCode() { const codes = []; codes.push(`${this._codeVariableName}.motionStrength = ${this.motionStrength};`); codes.push(`${this._codeVariableName}.motionBlurSamples = ${this.motionBlurSamples};`); codes.push(`${this._codeVariableName}.isObjectBased = ${this.isObjectBased};`); return super._dumpPropertiesCode() + codes.join("\n"); } serialize() { const serializationObject = super.serialize(); serializationObject.motionStrength = this.motionStrength; serializationObject.motionBlurSamples = this.motionBlurSamples; serializationObject.isObjectBased = this.isObjectBased; return serializationObject; } _deserialize(serializationObject) { super._deserialize(serializationObject); this.motionStrength = serializationObject.motionStrength; this.motionBlurSamples = serializationObject.motionBlurSamples; this.isObjectBased = serializationObject.isObjectBased; } } __decorate([ editableInPropertyPage("Strength", 1 /* PropertyTypeForEdition.Float */, "PROPERTIES") ], NodeRenderGraphMotionBlurPostProcessBlock.prototype, "motionStrength", null); __decorate([ editableInPropertyPage("Samples", 1 /* PropertyTypeForEdition.Float */, "PROPERTIES") ], NodeRenderGraphMotionBlurPostProcessBlock.prototype, "motionBlurSamples", null); __decorate([ editableInPropertyPage("Object based", 0 /* PropertyTypeForEdition.Boolean */, "PROPERTIES") ], NodeRenderGraphMotionBlurPostProcessBlock.prototype, "isObjectBased", null); RegisterClass("BABYLON.NodeRenderGraphMotionBlurPostProcessBlock", NodeRenderGraphMotionBlurPostProcessBlock); //# sourceMappingURL=motionBlurPostProcessBlock.js.map