Skip to content

Commit 63b8d6a

Browse files
authored
FrameGraph: add support for OIT (#17553)
Also in this PR: * Add new properties to the object renderer to render sublists of meshes (`renderDepthOnlyMeshes`, `renderOpaqueMeshes`, `renderAlphaTestMeshes` and `renderTransparentMeshes`) * Add new `initialize()` function to the `Pass` class
1 parent 1187298 commit 63b8d6a

26 files changed

+1078
-579
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class NodeRenderGraphBaseWithPropertiesPostProcessBlock extends NodeRende
9595
}
9696

9797
/** The viewport to use. */
98-
@editableInPropertyPage("Viewport", PropertyTypeForEdition.Viewport, "BASE PROPERTIES")
98+
@editableInPropertyPage("    Viewport", PropertyTypeForEdition.Viewport, "BASE PROPERTIES")
9999
public get viewport(): IViewportLike {
100100
return this._viewport;
101101
}

packages/dev/core/src/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.ts

Lines changed: 105 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
9494
state.disableShadows = this.disableShadows;
9595
state.renderInLinearSpace = this.renderInLinearSpace;
9696
state.renderMeshes = this.renderMeshes;
97+
state.renderDepthOnlyMeshes = this.renderDepthOnlyMeshes;
98+
state.renderOpaqueMeshes = this.renderOpaqueMeshes;
99+
state.renderAlphaTestMeshes = this.renderAlphaTestMeshes;
100+
state.renderTransparentMeshes = this.renderTransparentMeshes;
101+
state.useOITForTransparentMeshes = this.useOITForTransparentMeshes;
97102
state.renderParticles = this.renderParticles;
98103
state.renderSprites = this.renderSprites;
99104
state.forceLayerMaskCheck = this.forceLayerMaskCheck;
@@ -109,6 +114,11 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
109114
this.disableShadows = state.disableShadows;
110115
this.renderInLinearSpace = state.renderInLinearSpace;
111116
this.renderMeshes = state.renderMeshes;
117+
this.renderDepthOnlyMeshes = state.renderDepthOnlyMeshes;
118+
this.renderOpaqueMeshes = state.renderOpaqueMeshes;
119+
this.renderAlphaTestMeshes = state.renderAlphaTestMeshes;
120+
this.renderTransparentMeshes = state.renderTransparentMeshes;
121+
this.useOITForTransparentMeshes = state.useOITForTransparentMeshes;
112122
this.renderParticles = state.renderParticles;
113123
this.renderSprites = state.renderSprites;
114124
this.forceLayerMaskCheck = state.forceLayerMaskCheck;
@@ -129,7 +139,7 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
129139
}
130140

131141
/** Indicates that this object renderer is the main object renderer of the frame graph. */
132-
@editableInPropertyPage("Is main object renderer", PropertyTypeForEdition.Boolean, "RENDERING - OBJECTS")
142+
@editableInPropertyPage("Is main object renderer", PropertyTypeForEdition.Boolean, "GENERAL")
133143
public get isMainObjectRenderer() {
134144
return this._frameGraphTask.isMainObjectRenderer;
135145
}
@@ -139,7 +149,7 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
139149
}
140150

141151
/** Indicates if depth testing must be enabled or disabled */
142-
@editableInPropertyPage("Depth test", PropertyTypeForEdition.Boolean, "RENDERING - OBJECTS")
152+
@editableInPropertyPage("Depth test", PropertyTypeForEdition.Boolean, "GENERAL")
143153
public get depthTest() {
144154
return this._frameGraphTask.depthTest;
145155
}
@@ -149,7 +159,7 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
149159
}
150160

151161
/** Indicates if depth writing must be enabled or disabled */
152-
@editableInPropertyPage("Depth write", PropertyTypeForEdition.Boolean, "RENDERING - OBJECTS")
162+
@editableInPropertyPage("Depth write", PropertyTypeForEdition.Boolean, "GENERAL")
153163
public get depthWrite() {
154164
return this._frameGraphTask.depthWrite;
155165
}
@@ -159,7 +169,7 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
159169
}
160170

161171
/** Indicates if meshes should be rendered */
162-
@editableInPropertyPage("Render meshes", PropertyTypeForEdition.Boolean, "RENDERING - OBJECTS")
172+
@editableInPropertyPage("Render meshes", PropertyTypeForEdition.Boolean, "RENDERING")
163173
public get renderMeshes() {
164174
return this._frameGraphTask.renderMeshes;
165175
}
@@ -168,8 +178,70 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
168178
this._frameGraphTask.renderMeshes = value;
169179
}
170180

181+
/** Indicates if depth-only meshes should be rendered */
182+
@editableInPropertyPage("    Render depth-only meshes", PropertyTypeForEdition.Boolean, "RENDERING")
183+
public get renderDepthOnlyMeshes() {
184+
return this._frameGraphTask.renderDepthOnlyMeshes;
185+
}
186+
187+
public set renderDepthOnlyMeshes(value: boolean) {
188+
this._frameGraphTask.renderDepthOnlyMeshes = value;
189+
}
190+
191+
/** Indicates if opaque meshes should be rendered */
192+
@editableInPropertyPage("    Render opaque meshes", PropertyTypeForEdition.Boolean, "RENDERING")
193+
public get renderOpaqueMeshes() {
194+
return this._frameGraphTask.renderOpaqueMeshes;
195+
}
196+
197+
public set renderOpaqueMeshes(value: boolean) {
198+
this._frameGraphTask.renderOpaqueMeshes = value;
199+
}
200+
201+
/** Indicates if alpha tested meshes should be rendered */
202+
@editableInPropertyPage("    Render alpha test meshes", PropertyTypeForEdition.Boolean, "RENDERING")
203+
public get renderAlphaTestMeshes() {
204+
return this._frameGraphTask.renderAlphaTestMeshes;
205+
}
206+
207+
public set renderAlphaTestMeshes(value: boolean) {
208+
this._frameGraphTask.renderAlphaTestMeshes = value;
209+
}
210+
211+
/** Indicates if transparent meshes should be rendered */
212+
@editableInPropertyPage("    Render transparent meshes", PropertyTypeForEdition.Boolean, "RENDERING")
213+
public get renderTransparentMeshes() {
214+
return this._frameGraphTask.renderTransparentMeshes;
215+
}
216+
217+
public set renderTransparentMeshes(value: boolean) {
218+
this._frameGraphTask.renderTransparentMeshes = value;
219+
}
220+
221+
/** Indicates if use of Order Independent Transparency (OIT) for transparent meshes should be enabled */
222+
@editableInPropertyPage("        Use OIT for transparent meshes", PropertyTypeForEdition.Boolean, "RENDERING")
223+
// eslint-disable-next-line @typescript-eslint/naming-convention
224+
public get useOITForTransparentMeshes() {
225+
return this._frameGraphTask.useOITForTransparentMeshes;
226+
}
227+
228+
// eslint-disable-next-line @typescript-eslint/naming-convention
229+
public set useOITForTransparentMeshes(value: boolean) {
230+
this._frameGraphTask.useOITForTransparentMeshes = value;
231+
}
232+
233+
/** Defines the number of passes to use for Order Independent Transparency */
234+
@editableInPropertyPage("            Pass count", PropertyTypeForEdition.Int, "RENDERING", { min: 1, max: 20 })
235+
public get oitPassCount(): number {
236+
return this._frameGraphTask.oitPassCount;
237+
}
238+
239+
public set oitPassCount(value: number) {
240+
this._frameGraphTask.oitPassCount = value;
241+
}
242+
171243
/** Indicates if particles should be rendered */
172-
@editableInPropertyPage("Render particles", PropertyTypeForEdition.Boolean, "RENDERING - OBJECTS")
244+
@editableInPropertyPage("Render particles", PropertyTypeForEdition.Boolean, "RENDERING")
173245
public get renderParticles() {
174246
return this._frameGraphTask.renderParticles;
175247
}
@@ -179,7 +251,7 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
179251
}
180252

181253
/** Indicates if sprites should be rendered */
182-
@editableInPropertyPage("Render sprites", PropertyTypeForEdition.Boolean, "RENDERING - OBJECTS")
254+
@editableInPropertyPage("Render sprites", PropertyTypeForEdition.Boolean, "RENDERING")
183255
public get renderSprites() {
184256
return this._frameGraphTask.renderSprites;
185257
}
@@ -189,7 +261,7 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
189261
}
190262

191263
/** Indicates if layer mask check must be forced */
192-
@editableInPropertyPage("Force layer mask check", PropertyTypeForEdition.Boolean, "RENDERING - OBJECTS")
264+
@editableInPropertyPage("Force layer mask check", PropertyTypeForEdition.Boolean, "GENERAL")
193265
public get forceLayerMaskCheck() {
194266
return this._frameGraphTask.forceLayerMaskCheck;
195267
}
@@ -199,7 +271,7 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
199271
}
200272

201273
/** Indicates if bounding boxes should be rendered */
202-
@editableInPropertyPage("Enable bounding box rendering", PropertyTypeForEdition.Boolean, "RENDERING - OBJECTS")
274+
@editableInPropertyPage("Render bounding boxes", PropertyTypeForEdition.Boolean, "RENDERING")
203275
public get enableBoundingBoxRendering() {
204276
return this._frameGraphTask.enableBoundingBoxRendering;
205277
}
@@ -209,7 +281,7 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
209281
}
210282

211283
/** Indicates if outlines/overlays should be rendered */
212-
@editableInPropertyPage("Enable outline/overlay rendering", PropertyTypeForEdition.Boolean, "RENDERING - OBJECTS")
284+
@editableInPropertyPage("Render outlines/overlays", PropertyTypeForEdition.Boolean, "RENDERING")
213285
public get enableOutlineRendering() {
214286
return this._frameGraphTask.enableOutlineRendering;
215287
}
@@ -219,7 +291,7 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
219291
}
220292

221293
/** Indicates if shadows must be enabled or disabled */
222-
@editableInPropertyPage("Disable shadows", PropertyTypeForEdition.Boolean, "RENDERING - OBJECTS")
294+
@editableInPropertyPage("Disable shadows", PropertyTypeForEdition.Boolean, "GENERAL")
223295
public get disableShadows() {
224296
return this._frameGraphTask.disableShadows;
225297
}
@@ -229,7 +301,7 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
229301
}
230302

231303
/** If image processing should be disabled */
232-
@editableInPropertyPage("Disable image processing", PropertyTypeForEdition.Boolean, "RENDERING - OBJECTS")
304+
@editableInPropertyPage("Disable image processing", PropertyTypeForEdition.Boolean, "GENERAL")
233305
public get renderInLinearSpace() {
234306
return this._frameGraphTask.disableImageProcessing;
235307
}
@@ -239,7 +311,7 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
239311
}
240312

241313
/** True (default) to not change the aspect ratio of the scene in the RTT */
242-
@editableInPropertyPage("Do not change aspect ratio", PropertyTypeForEdition.Boolean, "RENDERING - OBJECTS")
314+
@editableInPropertyPage("Do not change aspect ratio", PropertyTypeForEdition.Boolean, "GENERAL")
243315
public get doNotChangeAspectRatio() {
244316
return this._frameGraphTask.objectRenderer.options.doNotChangeAspectRatio;
245317
}
@@ -249,7 +321,7 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
249321
}
250322

251323
/** True (default) to enable clustered lights */
252-
@editableInPropertyPage("Enable clustered lights", PropertyTypeForEdition.Boolean, "RENDERING - OBJECTS")
324+
@editableInPropertyPage("Enable clustered lights", PropertyTypeForEdition.Boolean, "GENERAL")
253325
public get enableClusteredLights() {
254326
return this._frameGraphTask.objectRenderer.options.enableClusteredLights;
255327
}
@@ -259,7 +331,7 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
259331
}
260332

261333
/** If true, MSAA color textures will be resolved at the end of the render pass (default: true) */
262-
@editableInPropertyPage("Resolve MSAA colors", PropertyTypeForEdition.Boolean, "RENDERING - OBJECTS")
334+
@editableInPropertyPage("Resolve MSAA colors", PropertyTypeForEdition.Boolean, "GENERAL")
263335
public get resolveMSAAColors() {
264336
return this._frameGraphTask.resolveMSAAColors;
265337
}
@@ -269,7 +341,7 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
269341
}
270342

271343
/** If true, MSAA depth texture will be resolved at the end of the render pass (default: false) */
272-
@editableInPropertyPage("Resolve MSAA depth", PropertyTypeForEdition.Boolean, "RENDERING - OBJECTS")
344+
@editableInPropertyPage("Resolve MSAA depth", PropertyTypeForEdition.Boolean, "GENERAL")
273345
public get resolveMSAADepth() {
274346
return this._frameGraphTask.resolveMSAADepth;
275347
}
@@ -384,6 +456,12 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
384456
codes.push(`${this._codeVariableName}.depthTest = ${this.depthTest};`);
385457
codes.push(`${this._codeVariableName}.depthWrite = ${this.depthWrite};`);
386458
codes.push(`${this._codeVariableName}.renderMeshes = ${this.renderMeshes};`);
459+
codes.push(`${this._codeVariableName}.renderDepthOnlyMeshes = ${this.renderDepthOnlyMeshes};`);
460+
codes.push(`${this._codeVariableName}.renderOpaqueMeshes = ${this.renderOpaqueMeshes};`);
461+
codes.push(`${this._codeVariableName}.renderAlphaTestMeshes = ${this.renderAlphaTestMeshes};`);
462+
codes.push(`${this._codeVariableName}.renderTransparentMeshes = ${this.renderTransparentMeshes};`);
463+
codes.push(`${this._codeVariableName}.useOITForTransparentMeshes = ${this.useOITForTransparentMeshes};`);
464+
codes.push(`${this._codeVariableName}.oitPassCount = ${this.oitPassCount};`);
387465
codes.push(`${this._codeVariableName}.renderParticles = ${this.renderParticles};`);
388466
codes.push(`${this._codeVariableName}.renderSprites = ${this.renderSprites};`);
389467
codes.push(`${this._codeVariableName}.forceLayerMaskCheck = ${this.forceLayerMaskCheck};`);
@@ -402,6 +480,12 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
402480
serializationObject.depthTest = this.depthTest;
403481
serializationObject.depthWrite = this.depthWrite;
404482
serializationObject.renderMeshes = this.renderMeshes;
483+
serializationObject.renderDepthOnlyMeshes = this.renderDepthOnlyMeshes;
484+
serializationObject.renderOpaqueMeshes = this.renderOpaqueMeshes;
485+
serializationObject.renderAlphaTestMeshes = this.renderAlphaTestMeshes;
486+
serializationObject.renderTransparentMeshes = this.renderTransparentMeshes;
487+
serializationObject.useOITForTransparentMeshes = this.useOITForTransparentMeshes;
488+
serializationObject.oitPassCount = this.oitPassCount;
405489
serializationObject.renderParticles = this.renderParticles;
406490
serializationObject.renderSprites = this.renderSprites;
407491
serializationObject.forceLayerMaskCheck = this.forceLayerMaskCheck;
@@ -420,6 +504,12 @@ export class NodeRenderGraphBaseObjectRendererBlock extends NodeRenderGraphBlock
420504
this.depthTest = serializationObject.depthTest;
421505
this.depthWrite = serializationObject.depthWrite;
422506
this.renderMeshes = serializationObject.renderMeshes ?? true;
507+
this.renderDepthOnlyMeshes = serializationObject.renderDepthOnlyMeshes ?? true;
508+
this.renderOpaqueMeshes = serializationObject.renderOpaqueMeshes ?? true;
509+
this.renderAlphaTestMeshes = serializationObject.renderAlphaTestMeshes ?? true;
510+
this.renderTransparentMeshes = serializationObject.renderTransparentMeshes ?? true;
511+
this.useOITForTransparentMeshes = serializationObject.useOITForTransparentMeshes ?? false;
512+
this.oitPassCount = serializationObject.oitPassCount ?? 5;
423513
this.renderParticles = serializationObject.renderParticles ?? true;
424514
this.renderSprites = serializationObject.renderSprites ?? true;
425515
this.forceLayerMaskCheck = serializationObject.forceLayerMaskCheck ?? true;

packages/dev/core/src/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export class NodeRenderGraphGeometryRendererBlock extends NodeRenderGraphBaseObj
102102
}
103103

104104
/** Width of the geometry texture */
105-
@editableInPropertyPage("Texture width", PropertyTypeForEdition.Int, "RENDERING - GEOMETRY")
105+
@editableInPropertyPage("Texture width", PropertyTypeForEdition.Int, "GEOMETRY")
106106
public get width() {
107107
return this._frameGraphTask.size.width;
108108
}
@@ -112,7 +112,7 @@ export class NodeRenderGraphGeometryRendererBlock extends NodeRenderGraphBaseObj
112112
}
113113

114114
/** Height of the geometry texture */
115-
@editableInPropertyPage("Texture height", PropertyTypeForEdition.Int, "RENDERING - GEOMETRY")
115+
@editableInPropertyPage("Texture height", PropertyTypeForEdition.Int, "GEOMETRY")
116116
public get height() {
117117
return this._frameGraphTask.size.height;
118118
}
@@ -122,7 +122,7 @@ export class NodeRenderGraphGeometryRendererBlock extends NodeRenderGraphBaseObj
122122
}
123123

124124
/** Indicates if the geometry texture width and height are percentages or absolute values */
125-
@editableInPropertyPage("Size is in percentage", PropertyTypeForEdition.Boolean, "RENDERING - GEOMETRY")
125+
@editableInPropertyPage("Size is in percentage", PropertyTypeForEdition.Boolean, "GEOMETRY")
126126
public get sizeInPercentage() {
127127
return this._frameGraphTask.sizeIsPercentage;
128128
}
@@ -132,7 +132,7 @@ export class NodeRenderGraphGeometryRendererBlock extends NodeRenderGraphBaseObj
132132
}
133133

134134
/** Number of samples of the geometry texture */
135-
@editableInPropertyPage("Samples", PropertyTypeForEdition.Int, "RENDERING - GEOMETRY", { min: 1, max: 8 })
135+
@editableInPropertyPage("Samples", PropertyTypeForEdition.Int, "GEOMETRY", { min: 1, max: 8 })
136136
public get samples() {
137137
return this._frameGraphTask.samples;
138138
}
@@ -142,7 +142,7 @@ export class NodeRenderGraphGeometryRendererBlock extends NodeRenderGraphBaseObj
142142
}
143143

144144
/** Indicates if culling must be reversed */
145-
@editableInPropertyPage("Reverse culling", PropertyTypeForEdition.Boolean, "RENDERING - GEOMETRY")
145+
@editableInPropertyPage("Reverse culling", PropertyTypeForEdition.Boolean, "GEOMETRY")
146146
public get reverseCulling() {
147147
return this._frameGraphTask.reverseCulling;
148148
}
@@ -152,7 +152,7 @@ export class NodeRenderGraphGeometryRendererBlock extends NodeRenderGraphBaseObj
152152
}
153153

154154
/** Indicates if a mesh shouldn't be rendered when its material has depth write disabled */
155-
@editableInPropertyPage("Don't render if material depth write is disabled", PropertyTypeForEdition.Boolean, "RENDERING - GEOMETRY")
155+
@editableInPropertyPage("Don't render if material depth write is disabled", PropertyTypeForEdition.Boolean, "GEOMETRY")
156156
public get dontRenderWhenMaterialDepthWriteIsDisabled() {
157157
return this._frameGraphTask.dontRenderWhenMaterialDepthWriteIsDisabled;
158158
}
@@ -162,7 +162,7 @@ export class NodeRenderGraphGeometryRendererBlock extends NodeRenderGraphBaseObj
162162
}
163163

164164
/** Indicates if depth pre-pass must be disabled */
165-
@editableInPropertyPage("Disable depth pre-pass", PropertyTypeForEdition.Boolean, "RENDERING - GEOMETRY")
165+
@editableInPropertyPage("Disable depth pre-pass", PropertyTypeForEdition.Boolean, "GEOMETRY")
166166
public get disableDepthPrePass() {
167167
return this._frameGraphTask.disableDepthPrePass;
168168
}

packages/dev/core/src/FrameGraph/Node/Blocks/Textures/copyTextureBlock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class NodeRenderGraphCopyTextureBlock extends NodeRenderGraphBlock {
7676
}
7777

7878
/** The viewport to use. */
79-
@editableInPropertyPage("Viewport", PropertyTypeForEdition.Viewport, "PROPERTIES")
79+
@editableInPropertyPage("    Viewport", PropertyTypeForEdition.Viewport, "PROPERTIES")
8080
public get viewport(): IViewportLike {
8181
return this._viewport;
8282
}

0 commit comments

Comments
 (0)