Skip to content

Commit 812e65a

Browse files
authored
FrameGraph: misc improvements (#17408)
In this PR: * Fix default values for some node render graph properties * Add missing properties to node render graph post processes * Add **viewport** property to post-process and copyToTexture tasks * Add onBefore and onAfter task execution observables
1 parent 637c77d commit 812e65a

31 files changed

+436
-58
lines changed

packages/dev/core/src/Decorators/nodeDecorator.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export const enum PropertyTypeForEdition {
2929
String,
3030
/** property is a matrix */
3131
Matrix,
32+
/** property is a viewport */
33+
Viewport,
3234
}
3335

3436
/**

packages/dev/core/src/FrameGraph/Node/Blocks/PostProcesses/anaglyphPostProcessBlock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { RegisterClass } from "../../../../Misc/typeStore";
33
import { NodeRenderGraphBlockConnectionPointTypes } from "../../Types/nodeRenderGraphTypes";
44
import { FrameGraphAnaglyphTask } from "core/FrameGraph/Tasks/PostProcesses/anaglyphTask";
55
import { ThinAnaglyphPostProcess } from "core/PostProcesses/thinAnaglyphPostProcess";
6-
import { NodeRenderGraphBasePostProcessBlock } from "./basePostProcessBlock";
6+
import { NodeRenderGraphBaseWithPropertiesPostProcessBlock } from "./baseWithPropertiesPostProcessBlock";
77

88
/**
99
* Block that implements the anaglyph post process
1010
*/
11-
export class NodeRenderGraphAnaglyphPostProcessBlock extends NodeRenderGraphBasePostProcessBlock {
11+
export class NodeRenderGraphAnaglyphPostProcessBlock extends NodeRenderGraphBaseWithPropertiesPostProcessBlock {
1212
protected override _frameGraphTask: FrameGraphAnaglyphTask;
1313

1414
/**

packages/dev/core/src/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class NodeRenderGraphBasePostProcessBlock extends NodeRenderGraphBlock {
4242
}
4343

4444
/** Sampling mode used to sample from the source texture */
45-
@editableInPropertyPage("Source sampling mode", PropertyTypeForEdition.SamplingMode, "PROPERTIES")
45+
@editableInPropertyPage("Source sampling mode", PropertyTypeForEdition.SamplingMode, "BASE PROPERTIES")
4646
public get sourceSamplingMode() {
4747
return this._frameGraphTask.sourceSamplingMode;
4848
}
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
import type { FrameGraphPostProcessTask, IViewportLike } from "core/index";
2+
import { editableInPropertyPage, PropertyTypeForEdition } from "../../../../Decorators/nodeDecorator";
3+
import { NodeRenderGraphBasePostProcessBlock } from "./basePostProcessBlock";
4+
5+
/**
6+
* @internal
7+
*/
8+
export class NodeRenderGraphBaseWithPropertiesPostProcessBlock extends NodeRenderGraphBasePostProcessBlock {
9+
protected override _frameGraphTask: FrameGraphPostProcessTask;
10+
11+
protected _useCurrentViewport = false;
12+
protected _useFullScreenViewport = true;
13+
protected _viewport: IViewportLike = { x: 0, y: 0, width: 1, height: 1 };
14+
15+
/** If true, the depth attachment will be read-only. */
16+
@editableInPropertyPage("Depth Read Only", PropertyTypeForEdition.Boolean, "BASE PROPERTIES")
17+
public get depthReadOnly(): boolean {
18+
return this._frameGraphTask.depthReadOnly;
19+
}
20+
21+
public set depthReadOnly(value: boolean) {
22+
this._frameGraphTask.depthReadOnly = value;
23+
}
24+
25+
/** If true, the stencil attachment will be read-only. */
26+
@editableInPropertyPage("Stencil Read Only", PropertyTypeForEdition.Boolean, "BASE PROPERTIES")
27+
public get stencilReadOnly(): boolean {
28+
return this._frameGraphTask.stencilReadOnly;
29+
}
30+
31+
public set stencilReadOnly(value: boolean) {
32+
this._frameGraphTask.stencilReadOnly = value;
33+
}
34+
35+
/** If true, color write will be disabled when applying the post process. */
36+
@editableInPropertyPage("Disable Color Write", PropertyTypeForEdition.Boolean, "BASE PROPERTIES")
37+
public get disableColorWrite(): boolean {
38+
return this._frameGraphTask.disableColorWrite;
39+
}
40+
41+
public set disableColorWrite(value: boolean) {
42+
this._frameGraphTask.disableColorWrite = value;
43+
}
44+
45+
/** If true, the post process will be generated by a back face full-screen quad (CW order). */
46+
@editableInPropertyPage("Draw Back Face", PropertyTypeForEdition.Boolean, "BASE PROPERTIES")
47+
public get drawBackFace(): boolean {
48+
return this._frameGraphTask.drawBackFace;
49+
}
50+
51+
public set drawBackFace(value: boolean) {
52+
this._frameGraphTask.drawBackFace = value;
53+
}
54+
55+
/** If depth testing should be enabled (default is true). */
56+
@editableInPropertyPage("Depth Test", PropertyTypeForEdition.Boolean, "BASE PROPERTIES")
57+
public get depthTest(): boolean {
58+
return this._frameGraphTask.depthTest;
59+
}
60+
61+
public set depthTest(value: boolean) {
62+
this._frameGraphTask.depthTest = value;
63+
}
64+
65+
private _setViewport() {
66+
if (this._useCurrentViewport) {
67+
this._frameGraphTask.viewport = null;
68+
} else if (this._useFullScreenViewport) {
69+
this._frameGraphTask.viewport = undefined;
70+
} else {
71+
this._frameGraphTask.viewport = this._viewport;
72+
}
73+
}
74+
75+
/** If true, the current viewport will be left unchanged. */
76+
@editableInPropertyPage("Use currently active viewport", PropertyTypeForEdition.Boolean, "BASE PROPERTIES")
77+
public get useCurrentViewport(): boolean {
78+
return this._useCurrentViewport;
79+
}
80+
81+
public set useCurrentViewport(value: boolean) {
82+
this._useCurrentViewport = value;
83+
this._setViewport();
84+
}
85+
86+
/** If true, a full screen viewport will be used. */
87+
@editableInPropertyPage("Use full screen viewport", PropertyTypeForEdition.Boolean, "BASE PROPERTIES")
88+
public get useFullScreenViewport(): boolean {
89+
return this._useFullScreenViewport;
90+
}
91+
92+
public set useFullScreenViewport(value: boolean) {
93+
this._useFullScreenViewport = value;
94+
this._setViewport();
95+
}
96+
97+
/** The viewport to use. */
98+
@editableInPropertyPage("Viewport", PropertyTypeForEdition.Viewport, "BASE PROPERTIES")
99+
public get viewport(): IViewportLike {
100+
return this._viewport;
101+
}
102+
103+
public set viewport(value: IViewportLike) {
104+
this._viewport = value;
105+
this._setViewport();
106+
}
107+
108+
/**
109+
* Gets the current class name
110+
* @returns the class name
111+
*/
112+
public override getClassName() {
113+
return "NodeRenderGraphBaseWithPropertiesPostProcessBlock";
114+
}
115+
116+
protected override _dumpPropertiesCode() {
117+
const codes: string[] = [];
118+
codes.push(`${this._codeVariableName}.depthReadOnly = ${this.depthReadOnly};`);
119+
codes.push(`${this._codeVariableName}.stencilReadOnly = ${this.stencilReadOnly};`);
120+
codes.push(`${this._codeVariableName}.disableColorWrite = ${this.disableColorWrite};`);
121+
codes.push(`${this._codeVariableName}.drawBackFace = ${this.drawBackFace};`);
122+
codes.push(`${this._codeVariableName}.depthTest = ${this.depthTest};`);
123+
codes.push(`${this._codeVariableName}.viewport = ${this._useCurrentViewport ? "null" : this._useFullScreenViewport ? "undefined" : JSON.stringify(this._viewport)};`);
124+
return super._dumpPropertiesCode() + codes.join("\n");
125+
}
126+
127+
public override serialize(): any {
128+
const serializationObject = super.serialize();
129+
serializationObject.depthReadOnly = this.depthReadOnly;
130+
serializationObject.stencilReadOnly = this.stencilReadOnly;
131+
serializationObject.disableColorWrite = this.disableColorWrite;
132+
serializationObject.drawBackFace = this.drawBackFace;
133+
serializationObject.depthTest = this.depthTest;
134+
serializationObject.useCurrentViewport = this._useCurrentViewport;
135+
serializationObject.useFullScreenViewport = this._useFullScreenViewport;
136+
serializationObject.viewport = this._viewport;
137+
return serializationObject;
138+
}
139+
140+
public override _deserialize(serializationObject: any) {
141+
super._deserialize(serializationObject);
142+
this.depthReadOnly = !!serializationObject.depthReadOnly;
143+
this.stencilReadOnly = !!serializationObject.stencilReadOnly;
144+
this.disableColorWrite = !!serializationObject.disableColorWrite;
145+
this.drawBackFace = !!serializationObject.drawBackFace;
146+
this.depthTest = serializationObject.depthTest ?? true;
147+
if (serializationObject.useCurrentViewport !== undefined) {
148+
this._useCurrentViewport = serializationObject.useCurrentViewport;
149+
this._useFullScreenViewport = serializationObject.useFullScreenViewport;
150+
this._viewport = serializationObject.viewport;
151+
}
152+
this._setViewport();
153+
}
154+
}

packages/dev/core/src/FrameGraph/Node/Blocks/PostProcesses/blackAndWhitePostProcessBlock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { RegisterClass } from "../../../../Misc/typeStore";
33
import { editableInPropertyPage, PropertyTypeForEdition } from "../../../../Decorators/nodeDecorator";
44
import { FrameGraphBlackAndWhiteTask } from "core/FrameGraph/Tasks/PostProcesses/blackAndWhiteTask";
55
import { ThinBlackAndWhitePostProcess } from "core/PostProcesses/thinBlackAndWhitePostProcess";
6-
import { NodeRenderGraphBasePostProcessBlock } from "./basePostProcessBlock";
6+
import { NodeRenderGraphBaseWithPropertiesPostProcessBlock } from "./baseWithPropertiesPostProcessBlock";
77

88
/**
99
* Block that implements the black and white post process
1010
*/
11-
export class NodeRenderGraphBlackAndWhitePostProcessBlock extends NodeRenderGraphBasePostProcessBlock {
11+
export class NodeRenderGraphBlackAndWhitePostProcessBlock extends NodeRenderGraphBaseWithPropertiesPostProcessBlock {
1212
protected override _frameGraphTask: FrameGraphBlackAndWhiteTask;
1313

1414
/**

packages/dev/core/src/FrameGraph/Node/Blocks/PostProcesses/blurPostProcessBlock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { editableInPropertyPage, PropertyTypeForEdition } from "../../../../Deco
44
import { FrameGraphBlurTask } from "core/FrameGraph/Tasks/PostProcesses/blurTask";
55
import { ThinBlurPostProcess } from "core/PostProcesses/thinBlurPostProcess";
66
import { Vector2 } from "core/Maths/math.vector";
7-
import { NodeRenderGraphBasePostProcessBlock } from "./basePostProcessBlock";
7+
import { NodeRenderGraphBaseWithPropertiesPostProcessBlock } from "./baseWithPropertiesPostProcessBlock";
88

99
/**
1010
* Block that implements the blur post process
1111
*/
12-
export class NodeRenderGraphBlurPostProcessBlock extends NodeRenderGraphBasePostProcessBlock {
12+
export class NodeRenderGraphBlurPostProcessBlock extends NodeRenderGraphBaseWithPropertiesPostProcessBlock {
1313
protected override _frameGraphTask: FrameGraphBlurTask;
1414

1515
/**

packages/dev/core/src/FrameGraph/Node/Blocks/PostProcesses/chromaticAberrationPostProcessBlock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { RegisterClass } from "../../../../Misc/typeStore";
44
import { editableInPropertyPage, PropertyTypeForEdition } from "../../../../Decorators/nodeDecorator";
55
import { FrameGraphChromaticAberrationTask } from "core/FrameGraph/Tasks/PostProcesses/chromaticAberrationTask";
66
import { ThinChromaticAberrationPostProcess } from "core/PostProcesses/thinChromaticAberrationPostProcess";
7-
import { NodeRenderGraphBasePostProcessBlock } from "./basePostProcessBlock";
7+
import { NodeRenderGraphBaseWithPropertiesPostProcessBlock } from "./baseWithPropertiesPostProcessBlock";
88

99
/**
1010
* Block that implements the chromatic aberration post process
1111
*/
12-
export class NodeRenderGraphChromaticAberrationPostProcessBlock extends NodeRenderGraphBasePostProcessBlock {
12+
export class NodeRenderGraphChromaticAberrationPostProcessBlock extends NodeRenderGraphBaseWithPropertiesPostProcessBlock {
1313
protected override _frameGraphTask: FrameGraphChromaticAberrationTask;
1414

1515
/**

packages/dev/core/src/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { NodeRenderGraphBlockConnectionPointTypes } from "../../Types/nodeRender
44
import { editableInPropertyPage, PropertyTypeForEdition } from "../../../../Decorators/nodeDecorator";
55
import { FrameGraphCircleOfConfusionTask } from "core/FrameGraph/Tasks/PostProcesses/circleOfConfusionTask";
66
import { ThinCircleOfConfusionPostProcess } from "core/PostProcesses/thinCircleOfConfusionPostProcess";
7-
import { NodeRenderGraphBasePostProcessBlock } from "./basePostProcessBlock";
7+
import { NodeRenderGraphBaseWithPropertiesPostProcessBlock } from "./baseWithPropertiesPostProcessBlock";
88

99
/**
1010
* Block that implements the circle of confusion post process
1111
*/
12-
export class NodeRenderGraphCircleOfConfusionPostProcessBlock extends NodeRenderGraphBasePostProcessBlock {
12+
export class NodeRenderGraphCircleOfConfusionPostProcessBlock extends NodeRenderGraphBaseWithPropertiesPostProcessBlock {
1313
protected override _frameGraphTask: FrameGraphCircleOfConfusionTask;
1414

1515
/**

packages/dev/core/src/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import type { Scene, FrameGraph } from "core/index";
22
import { RegisterClass } from "../../../../Misc/typeStore";
33
import { editableInPropertyPage, PropertyTypeForEdition } from "../../../../Decorators/nodeDecorator";
44
import { FrameGraphColorCorrectionTask } from "../../../Tasks/PostProcesses/colorCorrectionTask";
5-
import { NodeRenderGraphBasePostProcessBlock } from "./basePostProcessBlock";
65
import { ThinColorCorrectionPostProcess } from "../../../../PostProcesses/thinColorCorrectionPostProcess";
6+
import { NodeRenderGraphBaseWithPropertiesPostProcessBlock } from "./baseWithPropertiesPostProcessBlock";
77

88
/**
99
* Block that implements the color correction post process
1010
*/
11-
export class NodeRenderGraphColorCorrectionPostProcessBlock extends NodeRenderGraphBasePostProcessBlock {
11+
export class NodeRenderGraphColorCorrectionPostProcessBlock extends NodeRenderGraphBaseWithPropertiesPostProcessBlock {
1212
protected override _frameGraphTask: FrameGraphColorCorrectionTask;
1313

1414
/**

packages/dev/core/src/FrameGraph/Node/Blocks/PostProcesses/convolutionPostProcessBlock.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import type { Scene, FrameGraph } from "core/index";
22
import { RegisterClass } from "../../../../Misc/typeStore";
33
import { editableInPropertyPage, PropertyTypeForEdition } from "../../../../Decorators/nodeDecorator";
44
import { FrameGraphConvolutionTask } from "../../../Tasks/PostProcesses/convolutionTask";
5-
import { NodeRenderGraphBasePostProcessBlock } from "./basePostProcessBlock";
65
import { ThinConvolutionPostProcess } from "../../../../PostProcesses/thinConvolutionPostProcess";
6+
import { NodeRenderGraphBaseWithPropertiesPostProcessBlock } from "./baseWithPropertiesPostProcessBlock";
77

88
/**
99
* Block that implements the convolution post process
1010
*/
11-
export class NodeRenderGraphConvolutionPostProcessBlock extends NodeRenderGraphBasePostProcessBlock {
11+
export class NodeRenderGraphConvolutionPostProcessBlock extends NodeRenderGraphBaseWithPropertiesPostProcessBlock {
1212
protected override _frameGraphTask: FrameGraphConvolutionTask;
1313

1414
public override _additionalConstructionParameters: [number[]];

0 commit comments

Comments
 (0)