@babylonjs/core 7.34.0 → 7.34.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animatable.core.d.ts +2 -1
- package/Animations/animatable.core.js +3 -2
- package/Animations/animatable.core.js.map +1 -1
- package/Animations/animationGroup.d.ts +2 -1
- package/Animations/animationGroup.js +4 -3
- package/Animations/animationGroup.js.map +1 -1
- package/Collisions/gpuPicker.d.ts +1 -1
- package/Collisions/gpuPicker.js +1 -1
- package/Collisions/gpuPicker.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.query.js +9 -9
- package/Engines/WebGPU/Extensions/engine.query.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/thinWebGPUEngine.d.ts +3 -0
- package/Engines/thinWebGPUEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +1 -3
- package/Engines/webgpuEngine.js +1 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +1 -2
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +9 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +20 -2
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.d.ts +5 -1
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js +18 -2
- package/FrameGraph/Node/Blocks/Rendering/objectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.d.ts +5 -1
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js +16 -2
- package/FrameGraph/Node/Blocks/Rendering/taaObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +9 -6
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +27 -25
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +9 -6
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +25 -23
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.d.ts +3 -2
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +8 -8
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +7 -3
- package/FrameGraph/frameGraphRenderContext.js +23 -4
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.d.ts +52 -10
- package/Gizmos/boundingBoxGizmo.js +17 -0
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/positionGizmo.js +1 -0
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.js +1 -0
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.js +1 -0
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +4 -0
- package/Materials/Textures/baseTexture.js +3 -0
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/multiRenderTarget.js +1 -1
- package/Materials/Textures/multiRenderTarget.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +46 -42
- package/Materials/Textures/renderTargetTexture.js +249 -435
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Meshes/abstractMesh.hotSpot.d.ts +4 -2
- package/Meshes/abstractMesh.hotSpot.js +34 -7
- package/Meshes/abstractMesh.hotSpot.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.d.ts +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +3 -10
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Rendering/index.d.ts +1 -0
- package/Rendering/index.js +1 -0
- package/Rendering/index.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +228 -0
- package/Rendering/objectRenderer.js +517 -0
- package/Rendering/objectRenderer.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js +2 -3
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.js +6 -0
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/XR/features/WebXRDepthSensing.js +1 -0
- package/XR/features/WebXRDepthSensing.js.map +1 -1
- package/XR/features/WebXRHandTracking.js +1 -0
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/XR/motionController/webXRAbstractMotionController.js +1 -0
- package/XR/motionController/webXRAbstractMotionController.js.map +1 -1
- package/XR/webXRCamera.js +1 -0
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRManagedOutputCanvas.js +1 -0
- package/XR/webXRManagedOutputCanvas.js.map +1 -1
- package/XR/webXRSessionManager.js +1 -0
- package/XR/webXRSessionManager.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { backbufferDepthStencilTextureHandle } from "../../frameGraphTypes.js";
|
|
2
|
-
import { RenderTargetTexture } from "../../../Materials/Textures/renderTargetTexture.js";
|
|
3
2
|
import { Color4 } from "../../../Maths/math.color.js";
|
|
4
3
|
import { MaterialHelperGeometryRendering } from "../../../Materials/materialHelper.geometryrendering.js";
|
|
5
4
|
|
|
6
5
|
import { FrameGraphTask } from "../../frameGraphTask.js";
|
|
6
|
+
import { ObjectRenderer } from "../../../Rendering/objectRenderer.js";
|
|
7
7
|
const clearColors = [new Color4(0, 0, 0, 0), new Color4(1, 1, 1, 1), new Color4(1e8, 1e8, 1e8, 1e8)];
|
|
8
8
|
/**
|
|
9
9
|
* Task used to render geometry to a set of textures.
|
|
@@ -17,13 +17,13 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
17
17
|
}
|
|
18
18
|
set camera(camera) {
|
|
19
19
|
this._camera = camera;
|
|
20
|
-
this.
|
|
20
|
+
this._renderer.activeCamera = this.camera;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* The
|
|
23
|
+
* The object renderer used by the geometry renderer task.
|
|
24
24
|
*/
|
|
25
|
-
get
|
|
26
|
-
return this.
|
|
25
|
+
get objectRenderer() {
|
|
26
|
+
return this._renderer;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Gets or sets the name of the task.
|
|
@@ -33,8 +33,8 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
33
33
|
}
|
|
34
34
|
set name(value) {
|
|
35
35
|
this._name = value;
|
|
36
|
-
if (this.
|
|
37
|
-
this.
|
|
36
|
+
if (this._renderer) {
|
|
37
|
+
this._renderer.name = value;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
@@ -42,8 +42,9 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
42
42
|
* @param name The name of the task.
|
|
43
43
|
* @param frameGraph The frame graph the task belongs to.
|
|
44
44
|
* @param scene The scene the frame graph is associated with.
|
|
45
|
+
* @param options The options of the object renderer.
|
|
45
46
|
*/
|
|
46
|
-
constructor(name, frameGraph, scene) {
|
|
47
|
+
constructor(name, frameGraph, scene, options) {
|
|
47
48
|
super(name, frameGraph);
|
|
48
49
|
/**
|
|
49
50
|
* Whether depth testing is enabled (default is true).
|
|
@@ -71,12 +72,14 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
71
72
|
this.textureDescriptions = [];
|
|
72
73
|
this._scene = scene;
|
|
73
74
|
this._engine = this._scene.getEngine();
|
|
74
|
-
this.
|
|
75
|
-
|
|
75
|
+
this._renderer = new ObjectRenderer(name, scene, options);
|
|
76
|
+
this._renderer.renderSprites = false;
|
|
77
|
+
this._renderer.renderParticles = false;
|
|
78
|
+
this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {
|
|
79
|
+
if (!this._renderer.options.doNotChangeAspectRatio) {
|
|
80
|
+
scene.updateTransformMatrix(true);
|
|
81
|
+
}
|
|
76
82
|
});
|
|
77
|
-
this._rtt.skipInitialClear = true;
|
|
78
|
-
this._rtt.renderSprites = false;
|
|
79
|
-
this._rtt.renderParticles = false;
|
|
80
83
|
this.name = name;
|
|
81
84
|
this._clearAttachmentsLayout = new Map();
|
|
82
85
|
this._allAttachmentsLayout = [];
|
|
@@ -96,10 +99,10 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
96
99
|
* Gets the list of excluded meshes from the velocity texture.
|
|
97
100
|
*/
|
|
98
101
|
get excludedSkinnedMeshFromVelocityTexture() {
|
|
99
|
-
return MaterialHelperGeometryRendering.GetConfiguration(this.
|
|
102
|
+
return MaterialHelperGeometryRendering.GetConfiguration(this._renderer.renderPassId).excludedSkinnedMesh;
|
|
100
103
|
}
|
|
101
104
|
isReady() {
|
|
102
|
-
return this.
|
|
105
|
+
return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);
|
|
103
106
|
}
|
|
104
107
|
record() {
|
|
105
108
|
if (this.textureDescriptions.length === 0 || this.objectList === undefined) {
|
|
@@ -108,11 +111,12 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
108
111
|
const outputTextureHandle = this._createMultiRenderTargetTexture();
|
|
109
112
|
const depthEnabled = this._checkDepthTextureCompatibility();
|
|
110
113
|
this._buildClearAttachmentsLayout();
|
|
111
|
-
this._registerForRenderPassId(this.
|
|
114
|
+
this._registerForRenderPassId(this._renderer.renderPassId);
|
|
112
115
|
const outputTextureDescription = this._frameGraph.getTextureDescription(outputTextureHandle);
|
|
113
|
-
this.
|
|
116
|
+
this._textureWidth = outputTextureDescription.size.width;
|
|
117
|
+
this._textureHeight = outputTextureDescription.size.height;
|
|
114
118
|
// Create pass
|
|
115
|
-
MaterialHelperGeometryRendering.MarkAsDirty(this.
|
|
119
|
+
MaterialHelperGeometryRendering.MarkAsDirty(this._renderer.renderPassId, this.objectList.meshes || this._scene.meshes);
|
|
116
120
|
const pass = this._frameGraph.addRenderPass(this.name);
|
|
117
121
|
pass.setRenderTarget(outputTextureHandle);
|
|
118
122
|
let handle = outputTextureHandle + 1;
|
|
@@ -157,21 +161,19 @@ export class FrameGraphGeometryRendererTask extends FrameGraphTask {
|
|
|
157
161
|
pass.setRenderTargetDepth(this.depthTexture);
|
|
158
162
|
}
|
|
159
163
|
pass.setExecuteFunc((context) => {
|
|
160
|
-
this.
|
|
161
|
-
this.
|
|
162
|
-
this._scene.incrementRenderId();
|
|
163
|
-
this._scene.resetCachedMaterial();
|
|
164
|
+
this._renderer.renderList = this.objectList.meshes;
|
|
165
|
+
this._renderer.particleSystemList = this.objectList.particleSystems;
|
|
164
166
|
context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);
|
|
165
167
|
this._clearAttachmentsLayout.forEach((layout, clearType) => {
|
|
166
168
|
context.clearColorAttachments(clearColors[clearType], layout);
|
|
167
169
|
});
|
|
168
170
|
context.bindAttachments(this._allAttachmentsLayout);
|
|
169
|
-
context.render(this.
|
|
171
|
+
context.render(this._renderer, this._textureWidth, this._textureHeight);
|
|
170
172
|
});
|
|
171
173
|
}
|
|
172
174
|
dispose() {
|
|
173
|
-
MaterialHelperGeometryRendering.DeleteConfiguration(this.
|
|
174
|
-
this.
|
|
175
|
+
MaterialHelperGeometryRendering.DeleteConfiguration(this._renderer.renderPassId);
|
|
176
|
+
this._renderer.dispose();
|
|
175
177
|
super.dispose();
|
|
176
178
|
}
|
|
177
179
|
_createMultiRenderTargetTexture() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometryRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/geometryRendererTask.ts"],"names":[],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C;YAE/F,aAAa,CAAC,OAAO,CAAC,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;SAC9D;IACL,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraphTextureHandle, Scene, Camera, AbstractEngine, FrameGraph, GeometryRenderingTextureClearType, FrameGraphObjectList, AbstractMesh } from \"core/index\";\r\nimport { backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { RenderTargetTexture } from \"../../../Materials/Textures/renderTargetTexture\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { MaterialHelperGeometryRendering } from \"core/Materials/materialHelper.geometryrendering\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Description of a texture used by the geometry renderer task.\r\n */\r\nexport interface IFrameGraphGeometryRendererTextureDescription {\r\n /**\r\n * The type of the texture.\r\n * The value should be one of the Constants.PREPASS_XXX_TEXTURE_TYPE values.\r\n */\r\n type: number;\r\n\r\n /**\r\n * The type of the texture.\r\n */\r\n textureType: number;\r\n\r\n /**\r\n * The format of the texture.\r\n */\r\n textureFormat: number;\r\n}\r\n\r\nconst clearColors: Color4[] = [new Color4(0, 0, 0, 0), new Color4(1, 1, 1, 1), new Color4(1e8, 1e8, 1e8, 1e8)];\r\n\r\n/**\r\n * Task used to render geometry to a set of textures.\r\n */\r\nexport class FrameGraphGeometryRendererTask extends FrameGraphTask {\r\n /**\r\n * The depth texture attachment to use for rendering (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used for rendering.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._rtt.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The object list used for rendering.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * Whether depth testing is enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * Whether depth writing is enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\r\n /**\r\n * The size of the output textures (default is 100% of the back buffer texture size).\r\n */\r\n public size: { width: number; height: number } = { width: 100, height: 100 };\r\n\r\n /**\r\n * Whether the size is a percentage of the back buffer size (default is true).\r\n */\r\n public sizeIsPercentage = true;\r\n\r\n /**\r\n * The number of samples to use for the output textures (default is 1).\r\n */\r\n public samples = 1;\r\n\r\n /**\r\n * The list of texture descriptions used by the geometry renderer task.\r\n */\r\n public textureDescriptions: IFrameGraphGeometryRendererTextureDescription[] = [];\r\n\r\n /**\r\n * The output depth texture attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth (in view space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryViewDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth (in screen space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryScreenDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The normal (in view space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryViewNormalTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The normal (in world space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryWorldNormalTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The position (in local space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryLocalPositionTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The position (in world space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryWorldPositionTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The albedo output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryAlbedoTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The reflectivity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryReflectivityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The velocity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryVelocityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The linear velocity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryLinearVelocityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The render target texture used by the geometry renderer task.\r\n */\r\n public get renderTargetTexture() {\r\n return this._rtt;\r\n }\r\n\r\n /**\r\n * Gets or sets the name of the task.\r\n */\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(value: string) {\r\n this._name = value;\r\n if (this._rtt) {\r\n this._rtt.name = value + \"_internal_rtt\";\r\n }\r\n }\r\n\r\n private _engine: AbstractEngine;\r\n private _scene: Scene;\r\n private _rtt: RenderTargetTexture;\r\n private _clearAttachmentsLayout: Map<GeometryRenderingTextureClearType, number[]>;\r\n private _allAttachmentsLayout: number[];\r\n\r\n /**\r\n * Constructs a new geometry renderer task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._engine = this._scene.getEngine();\r\n\r\n this._rtt = new RenderTargetTexture(name, 1, scene, {\r\n delayAllocation: true,\r\n });\r\n this._rtt.skipInitialClear = true;\r\n this._rtt.renderSprites = false;\r\n this._rtt.renderParticles = false;\r\n\r\n this.name = name;\r\n this._clearAttachmentsLayout = new Map();\r\n this._allAttachmentsLayout = [];\r\n\r\n this.outputDepthTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryViewDepthTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryScreenDepthTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryViewNormalTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryWorldNormalTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryLocalPositionTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryWorldPositionTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryAlbedoTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryReflectivityTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryVelocityTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryLinearVelocityTexture = this._frameGraph.createDanglingHandle();\r\n }\r\n\r\n /**\r\n * Gets the list of excluded meshes from the velocity texture.\r\n */\r\n public get excludedSkinnedMeshFromVelocityTexture(): AbstractMesh[] {\r\n return MaterialHelperGeometryRendering.GetConfiguration(this._rtt.renderPassId).excludedSkinnedMesh;\r\n }\r\n\r\n public override isReady() {\r\n return this._rtt.isReadyForRendering();\r\n }\r\n\r\n public record() {\r\n if (this.textureDescriptions.length === 0 || this.objectList === undefined) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: object list and at least one geometry texture description must be provided`);\r\n }\r\n\r\n const outputTextureHandle = this._createMultiRenderTargetTexture();\r\n\r\n const depthEnabled = this._checkDepthTextureCompatibility();\r\n\r\n this._buildClearAttachmentsLayout();\r\n\r\n this._registerForRenderPassId(this._rtt.renderPassId);\r\n\r\n const outputTextureDescription = this._frameGraph.getTextureDescription(outputTextureHandle);\r\n\r\n this._rtt._size = outputTextureDescription.size;\r\n\r\n // Create pass\r\n MaterialHelperGeometryRendering.MarkAsDirty(this._rtt.renderPassId, this.objectList.meshes || this._scene.meshes);\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(outputTextureHandle);\r\n\r\n let handle = outputTextureHandle + 1;\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n switch (geometryDescription.type) {\r\n case Constants.PREPASS_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryViewDepthTexture, handle++);\r\n break;\r\n case Constants.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryScreenDepthTexture, handle++);\r\n break;\r\n case Constants.PREPASS_NORMAL_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryViewNormalTexture, handle++);\r\n break;\r\n case Constants.PREPASS_WORLD_NORMAL_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryWorldNormalTexture, handle++);\r\n break;\r\n case Constants.PREPASS_LOCAL_POSITION_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryLocalPositionTexture, handle++);\r\n break;\r\n case Constants.PREPASS_POSITION_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryWorldPositionTexture, handle++);\r\n break;\r\n case Constants.PREPASS_ALBEDO_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryAlbedoTexture, handle++);\r\n break;\r\n case Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryReflectivityTexture, handle++);\r\n break;\r\n case Constants.PREPASS_VELOCITY_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryVelocityTexture, handle++);\r\n break;\r\n case Constants.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryLinearVelocityTexture, handle++);\r\n break;\r\n }\r\n }\r\n\r\n if (this.depthTexture !== undefined) {\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n }\r\n\r\n pass.setExecuteFunc((context) => {\r\n this._rtt.renderList = this.objectList.meshes;\r\n this._rtt.particleSystemList = this.objectList.particleSystems;\r\n\r\n this._scene.incrementRenderId();\r\n this._scene.resetCachedMaterial();\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\r\n this._clearAttachmentsLayout.forEach((layout, clearType) => {\r\n context.clearColorAttachments(clearColors[clearType], layout);\r\n });\r\n\r\n context.bindAttachments(this._allAttachmentsLayout);\r\n\r\n context.render(this._rtt);\r\n });\r\n }\r\n\r\n public override dispose(): void {\r\n MaterialHelperGeometryRendering.DeleteConfiguration(this._rtt.renderPassId);\r\n this._rtt.dispose();\r\n super.dispose();\r\n }\r\n\r\n private _createMultiRenderTargetTexture(): FrameGraphTextureHandle {\r\n const types: number[] = [];\r\n const formats: number[] = [];\r\n const labels: string[] = [];\r\n const useSRGBBuffers: boolean[] = [];\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n\r\n if (index === -1) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: unknown texture type ${description.type}`);\r\n }\r\n\r\n types[i] = description.textureType;\r\n formats[i] = description.textureFormat;\r\n labels[i] = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index].name;\r\n useSRGBBuffers[i] = false;\r\n }\r\n\r\n return this._frameGraph.createRenderTargetTexture(\r\n this.name,\r\n {\r\n size: this.size,\r\n sizeIsPercentage: this.sizeIsPercentage,\r\n options: {\r\n createMipMaps: false,\r\n generateDepthBuffer: false,\r\n textureCount: this.textureDescriptions.length,\r\n samples: this.samples,\r\n types,\r\n formats,\r\n useSRGBBuffers,\r\n labels,\r\n },\r\n },\r\n true\r\n );\r\n }\r\n\r\n private _checkDepthTextureCompatibility(): boolean {\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth/stencil back buffer is not allowed as a depth texture`);\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== this.samples) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n this._frameGraph.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n return depthEnabled;\r\n }\r\n\r\n private _buildClearAttachmentsLayout() {\r\n const clearAttachmentsLayout = new Map<GeometryRenderingTextureClearType, boolean[]>();\r\n const allAttachmentsLayout: boolean[] = [];\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n let layout = clearAttachmentsLayout.get(geometryDescription.clearType);\r\n if (layout === undefined) {\r\n layout = [];\r\n clearAttachmentsLayout.set(geometryDescription.clearType, layout);\r\n for (let j = 0; j < i; j++) {\r\n layout[j] = false;\r\n }\r\n }\r\n\r\n clearAttachmentsLayout.forEach((layout, clearType) => {\r\n layout.push(clearType === geometryDescription.clearType);\r\n });\r\n\r\n allAttachmentsLayout.push(true);\r\n }\r\n\r\n this._clearAttachmentsLayout = new Map();\r\n\r\n clearAttachmentsLayout.forEach((layout, clearType) => {\r\n this._clearAttachmentsLayout.set(clearType, this._engine.buildTextureLayout(layout));\r\n });\r\n\r\n this._allAttachmentsLayout = this._engine.buildTextureLayout(allAttachmentsLayout);\r\n }\r\n\r\n private _registerForRenderPassId(renderPassId: number) {\r\n const configuration = MaterialHelperGeometryRendering.CreateConfiguration(renderPassId);\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n configuration.defines[geometryDescription.defineIndex] = i;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"geometryRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/geometryRendererTask.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,qCAA8B;AAC/C,OAAO,EAAE,+BAA+B,EAAE,+DAAwD;AAClG,OAAO,EAAE,SAAS,EAAE,sCAA+B;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAuBnE,MAAM,WAAW,GAAa,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAE/G;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,cAAc;IAQ9D;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,MAAc;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9C,CAAC;IA8FD;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED;;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AAC;IACvF,CAAC;IAEO,wBAAwB,CAAC,YAAoB;QACjD,MAAM,aAAa,GAAG,+BAA+B,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;QAExF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtD,MAAM,WAAW,GAAG,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;YAChD,MAAM,KAAK,GAAG,+BAA+B,CAAC,2BAA2B,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC;YACxH,MAAM,mBAAmB,GAAG,+BAA+B,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC;YAE/F,aAAa,CAAC,OAAO,CAAC,mBAAmB,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;SAC9D;IACL,CAAC;CACJ","sourcesContent":["import type {\r\n FrameGraphTextureHandle,\r\n Scene,\r\n Camera,\r\n AbstractEngine,\r\n FrameGraph,\r\n GeometryRenderingTextureClearType,\r\n FrameGraphObjectList,\r\n AbstractMesh,\r\n ObjectRendererOptions,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"core/index\";\r\nimport { backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { MaterialHelperGeometryRendering } from \"core/Materials/materialHelper.geometryrendering\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer\";\r\n\r\n/**\r\n * Description of a texture used by the geometry renderer task.\r\n */\r\nexport interface IFrameGraphGeometryRendererTextureDescription {\r\n /**\r\n * The type of the texture.\r\n * The value should be one of the Constants.PREPASS_XXX_TEXTURE_TYPE values.\r\n */\r\n type: number;\r\n\r\n /**\r\n * The type of the texture.\r\n */\r\n textureType: number;\r\n\r\n /**\r\n * The format of the texture.\r\n */\r\n textureFormat: number;\r\n}\r\n\r\nconst clearColors: Color4[] = [new Color4(0, 0, 0, 0), new Color4(1, 1, 1, 1), new Color4(1e8, 1e8, 1e8, 1e8)];\r\n\r\n/**\r\n * Task used to render geometry to a set of textures.\r\n */\r\nexport class FrameGraphGeometryRendererTask extends FrameGraphTask {\r\n /**\r\n * The depth texture attachment to use for rendering (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used for rendering.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._renderer.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The object list used for rendering.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * Whether depth testing is enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * Whether depth writing is enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\r\n /**\r\n * The size of the output textures (default is 100% of the back buffer texture size).\r\n */\r\n public size: { width: number; height: number } = { width: 100, height: 100 };\r\n\r\n /**\r\n * Whether the size is a percentage of the back buffer size (default is true).\r\n */\r\n public sizeIsPercentage = true;\r\n\r\n /**\r\n * The number of samples to use for the output textures (default is 1).\r\n */\r\n public samples = 1;\r\n\r\n /**\r\n * The list of texture descriptions used by the geometry renderer task.\r\n */\r\n public textureDescriptions: IFrameGraphGeometryRendererTextureDescription[] = [];\r\n\r\n /**\r\n * The output depth texture attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth (in view space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryViewDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth (in screen space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryScreenDepthTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The normal (in view space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryViewNormalTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The normal (in world space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryWorldNormalTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The position (in local space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryLocalPositionTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The position (in world space) output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryWorldPositionTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The albedo output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryAlbedoTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The reflectivity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryReflectivityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The velocity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryVelocityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The linear velocity output texture. Will point to a valid texture only if that texture has been requested in textureDescriptions!\r\n */\r\n public readonly geometryLinearVelocityTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The object renderer used by the geometry renderer task.\r\n */\r\n public get objectRenderer() {\r\n return this._renderer;\r\n }\r\n\r\n /**\r\n * Gets or sets the name of the task.\r\n */\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(value: string) {\r\n this._name = value;\r\n if (this._renderer) {\r\n this._renderer.name = value;\r\n }\r\n }\r\n\r\n private _engine: AbstractEngine;\r\n private _scene: Scene;\r\n private _renderer: ObjectRenderer;\r\n private _textureWidth: number;\r\n private _textureHeight: number;\r\n private _clearAttachmentsLayout: Map<GeometryRenderingTextureClearType, number[]>;\r\n private _allAttachmentsLayout: number[];\r\n\r\n /**\r\n * Constructs a new geometry renderer task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._engine = this._scene.getEngine();\r\n\r\n this._renderer = new ObjectRenderer(name, scene, options);\r\n this._renderer.renderSprites = false;\r\n this._renderer.renderParticles = false;\r\n\r\n this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {\r\n if (!this._renderer.options.doNotChangeAspectRatio) {\r\n scene.updateTransformMatrix(true);\r\n }\r\n });\r\n\r\n this.name = name;\r\n this._clearAttachmentsLayout = new Map();\r\n this._allAttachmentsLayout = [];\r\n\r\n this.outputDepthTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryViewDepthTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryScreenDepthTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryViewNormalTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryWorldNormalTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryLocalPositionTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryWorldPositionTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryAlbedoTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryReflectivityTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryVelocityTexture = this._frameGraph.createDanglingHandle();\r\n this.geometryLinearVelocityTexture = this._frameGraph.createDanglingHandle();\r\n }\r\n\r\n /**\r\n * Gets the list of excluded meshes from the velocity texture.\r\n */\r\n public get excludedSkinnedMeshFromVelocityTexture(): AbstractMesh[] {\r\n return MaterialHelperGeometryRendering.GetConfiguration(this._renderer.renderPassId).excludedSkinnedMesh;\r\n }\r\n\r\n public override isReady() {\r\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\r\n }\r\n\r\n public record() {\r\n if (this.textureDescriptions.length === 0 || this.objectList === undefined) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: object list and at least one geometry texture description must be provided`);\r\n }\r\n\r\n const outputTextureHandle = this._createMultiRenderTargetTexture();\r\n\r\n const depthEnabled = this._checkDepthTextureCompatibility();\r\n\r\n this._buildClearAttachmentsLayout();\r\n\r\n this._registerForRenderPassId(this._renderer.renderPassId);\r\n\r\n const outputTextureDescription = this._frameGraph.getTextureDescription(outputTextureHandle);\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n // Create pass\r\n MaterialHelperGeometryRendering.MarkAsDirty(this._renderer.renderPassId, this.objectList.meshes || this._scene.meshes);\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(outputTextureHandle);\r\n\r\n let handle = outputTextureHandle + 1;\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n switch (geometryDescription.type) {\r\n case Constants.PREPASS_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryViewDepthTexture, handle++);\r\n break;\r\n case Constants.PREPASS_SCREENSPACE_DEPTH_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryScreenDepthTexture, handle++);\r\n break;\r\n case Constants.PREPASS_NORMAL_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryViewNormalTexture, handle++);\r\n break;\r\n case Constants.PREPASS_WORLD_NORMAL_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryWorldNormalTexture, handle++);\r\n break;\r\n case Constants.PREPASS_LOCAL_POSITION_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryLocalPositionTexture, handle++);\r\n break;\r\n case Constants.PREPASS_POSITION_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryWorldPositionTexture, handle++);\r\n break;\r\n case Constants.PREPASS_ALBEDO_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryAlbedoTexture, handle++);\r\n break;\r\n case Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryReflectivityTexture, handle++);\r\n break;\r\n case Constants.PREPASS_VELOCITY_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryVelocityTexture, handle++);\r\n break;\r\n case Constants.PREPASS_VELOCITY_LINEAR_TEXTURE_TYPE:\r\n this._frameGraph.resolveDanglingHandle(this.geometryLinearVelocityTexture, handle++);\r\n break;\r\n }\r\n }\r\n\r\n if (this.depthTexture !== undefined) {\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n }\r\n\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\r\n this._clearAttachmentsLayout.forEach((layout, clearType) => {\r\n context.clearColorAttachments(clearColors[clearType], layout);\r\n });\r\n\r\n context.bindAttachments(this._allAttachmentsLayout);\r\n\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n });\r\n }\r\n\r\n public override dispose(): void {\r\n MaterialHelperGeometryRendering.DeleteConfiguration(this._renderer.renderPassId);\r\n this._renderer.dispose();\r\n super.dispose();\r\n }\r\n\r\n private _createMultiRenderTargetTexture(): FrameGraphTextureHandle {\r\n const types: number[] = [];\r\n const formats: number[] = [];\r\n const labels: string[] = [];\r\n const useSRGBBuffers: boolean[] = [];\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n\r\n if (index === -1) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: unknown texture type ${description.type}`);\r\n }\r\n\r\n types[i] = description.textureType;\r\n formats[i] = description.textureFormat;\r\n labels[i] = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index].name;\r\n useSRGBBuffers[i] = false;\r\n }\r\n\r\n return this._frameGraph.createRenderTargetTexture(\r\n this.name,\r\n {\r\n size: this.size,\r\n sizeIsPercentage: this.sizeIsPercentage,\r\n options: {\r\n createMipMaps: false,\r\n generateDepthBuffer: false,\r\n textureCount: this.textureDescriptions.length,\r\n samples: this.samples,\r\n types,\r\n formats,\r\n useSRGBBuffers,\r\n labels,\r\n },\r\n },\r\n true\r\n );\r\n }\r\n\r\n private _checkDepthTextureCompatibility(): boolean {\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth/stencil back buffer is not allowed as a depth texture`);\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== this.samples) {\r\n throw new Error(`FrameGraphGeometryRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n this._frameGraph.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n return depthEnabled;\r\n }\r\n\r\n private _buildClearAttachmentsLayout() {\r\n const clearAttachmentsLayout = new Map<GeometryRenderingTextureClearType, boolean[]>();\r\n const allAttachmentsLayout: boolean[] = [];\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n let layout = clearAttachmentsLayout.get(geometryDescription.clearType);\r\n if (layout === undefined) {\r\n layout = [];\r\n clearAttachmentsLayout.set(geometryDescription.clearType, layout);\r\n for (let j = 0; j < i; j++) {\r\n layout[j] = false;\r\n }\r\n }\r\n\r\n clearAttachmentsLayout.forEach((layout, clearType) => {\r\n layout.push(clearType === geometryDescription.clearType);\r\n });\r\n\r\n allAttachmentsLayout.push(true);\r\n }\r\n\r\n this._clearAttachmentsLayout = new Map();\r\n\r\n clearAttachmentsLayout.forEach((layout, clearType) => {\r\n this._clearAttachmentsLayout.set(clearType, this._engine.buildTextureLayout(layout));\r\n });\r\n\r\n this._allAttachmentsLayout = this._engine.buildTextureLayout(allAttachmentsLayout);\r\n }\r\n\r\n private _registerForRenderPassId(renderPassId: number) {\r\n const configuration = MaterialHelperGeometryRendering.CreateConfiguration(renderPassId);\r\n\r\n for (let i = 0; i < this.textureDescriptions.length; i++) {\r\n const description = this.textureDescriptions[i];\r\n const index = MaterialHelperGeometryRendering.GeometryTextureDescriptions.findIndex((f) => f.type === description.type);\r\n const geometryDescription = MaterialHelperGeometryRendering.GeometryTextureDescriptions[index];\r\n\r\n configuration.defines[geometryDescription.defineIndex] = i;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { FrameGraph, FrameGraphTextureHandle, Scene, Camera, FrameGraphObjectList, FrameGraphRenderContext } from "../../../index.js";
|
|
2
|
-
import { RenderTargetTexture } from "../../../Materials/Textures/renderTargetTexture";
|
|
1
|
+
import type { FrameGraph, FrameGraphTextureHandle, Scene, Camera, FrameGraphObjectList, FrameGraphRenderContext, ObjectRendererOptions } from "../../../index.js";
|
|
3
2
|
import { FrameGraphTask } from "../../frameGraphTask";
|
|
3
|
+
import { ObjectRenderer } from "../../../Rendering/objectRenderer";
|
|
4
4
|
/**
|
|
5
5
|
* Task used to render objects to a texture.
|
|
6
6
|
*/
|
|
@@ -46,11 +46,13 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
46
46
|
*/
|
|
47
47
|
readonly outputDepthTexture: FrameGraphTextureHandle;
|
|
48
48
|
protected _scene: Scene;
|
|
49
|
-
protected
|
|
49
|
+
protected _renderer: ObjectRenderer;
|
|
50
|
+
protected _textureWidth: number;
|
|
51
|
+
protected _textureHeight: number;
|
|
50
52
|
/**
|
|
51
|
-
* The
|
|
53
|
+
* The object renderer used to render the objects.
|
|
52
54
|
*/
|
|
53
|
-
get
|
|
55
|
+
get objectRenderer(): ObjectRenderer;
|
|
54
56
|
get name(): string;
|
|
55
57
|
set name(value: string);
|
|
56
58
|
/**
|
|
@@ -58,8 +60,9 @@ export declare class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
58
60
|
* @param name The name of the task.
|
|
59
61
|
* @param frameGraph The frame graph the task belongs to.
|
|
60
62
|
* @param scene The scene the frame graph is associated with.
|
|
63
|
+
* @param options The options of the object renderer.
|
|
61
64
|
*/
|
|
62
|
-
constructor(name: string, frameGraph: FrameGraph, scene: Scene);
|
|
65
|
+
constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions);
|
|
63
66
|
isReady(): boolean;
|
|
64
67
|
record(skipCreationOfDisabledPasses?: boolean, additionalExecute?: (context: FrameGraphRenderContext) => void): void;
|
|
65
68
|
dispose(): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from "../../frameGraphTypes.js";
|
|
2
|
-
import { RenderTargetTexture } from "../../../Materials/Textures/renderTargetTexture.js";
|
|
3
2
|
import { FrameGraphTask } from "../../frameGraphTask.js";
|
|
3
|
+
import { ObjectRenderer } from "../../../Rendering/objectRenderer.js";
|
|
4
4
|
/**
|
|
5
5
|
* Task used to render objects to a texture.
|
|
6
6
|
*/
|
|
@@ -13,21 +13,21 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
13
13
|
}
|
|
14
14
|
set camera(camera) {
|
|
15
15
|
this._camera = camera;
|
|
16
|
-
this.
|
|
16
|
+
this._renderer.activeCamera = this.camera;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* The
|
|
19
|
+
* The object renderer used to render the objects.
|
|
20
20
|
*/
|
|
21
|
-
get
|
|
22
|
-
return this.
|
|
21
|
+
get objectRenderer() {
|
|
22
|
+
return this._renderer;
|
|
23
23
|
}
|
|
24
24
|
get name() {
|
|
25
25
|
return this._name;
|
|
26
26
|
}
|
|
27
27
|
set name(value) {
|
|
28
28
|
this._name = value;
|
|
29
|
-
if (this.
|
|
30
|
-
this.
|
|
29
|
+
if (this._renderer) {
|
|
30
|
+
this._renderer.name = value;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
@@ -35,8 +35,9 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
35
35
|
* @param name The name of the task.
|
|
36
36
|
* @param frameGraph The frame graph the task belongs to.
|
|
37
37
|
* @param scene The scene the frame graph is associated with.
|
|
38
|
+
* @param options The options of the object renderer.
|
|
38
39
|
*/
|
|
39
|
-
constructor(name, frameGraph, scene) {
|
|
40
|
+
constructor(name, frameGraph, scene, options) {
|
|
40
41
|
super(name, frameGraph);
|
|
41
42
|
/**
|
|
42
43
|
* The dependencies of the task (optional).
|
|
@@ -51,16 +52,18 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
51
52
|
*/
|
|
52
53
|
this.depthWrite = true;
|
|
53
54
|
this._scene = scene;
|
|
54
|
-
this.
|
|
55
|
-
delayAllocation: true,
|
|
56
|
-
});
|
|
57
|
-
this._rtt.skipInitialClear = true;
|
|
55
|
+
this._renderer = new ObjectRenderer(name, scene, options);
|
|
58
56
|
this.name = name;
|
|
57
|
+
this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {
|
|
58
|
+
if (!this._renderer.options.doNotChangeAspectRatio) {
|
|
59
|
+
scene.updateTransformMatrix(true);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
59
62
|
this.outputTexture = this._frameGraph.createDanglingHandle();
|
|
60
63
|
this.outputDepthTexture = this._frameGraph.createDanglingHandle();
|
|
61
64
|
}
|
|
62
65
|
isReady() {
|
|
63
|
-
return this.
|
|
66
|
+
return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);
|
|
64
67
|
}
|
|
65
68
|
record(skipCreationOfDisabledPasses = false, additionalExecute) {
|
|
66
69
|
if (this.destinationTexture === undefined || this.objectList === undefined) {
|
|
@@ -85,20 +88,19 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
85
88
|
if (this.depthTexture !== undefined) {
|
|
86
89
|
this._frameGraph.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);
|
|
87
90
|
}
|
|
88
|
-
this.
|
|
91
|
+
this._textureWidth = outputTextureDescription.size.width;
|
|
92
|
+
this._textureHeight = outputTextureDescription.size.height;
|
|
89
93
|
const pass = this._frameGraph.addRenderPass(this.name);
|
|
90
94
|
pass.setRenderTarget(this.destinationTexture);
|
|
91
95
|
if (this.depthTexture !== undefined) {
|
|
92
96
|
pass.setRenderTargetDepth(this.depthTexture);
|
|
93
97
|
}
|
|
94
|
-
pass.setExecuteFunc((
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
97
|
-
this.
|
|
98
|
-
this.
|
|
99
|
-
|
|
100
|
-
_context.render(this._rtt);
|
|
101
|
-
additionalExecute?.(_context);
|
|
98
|
+
pass.setExecuteFunc((context) => {
|
|
99
|
+
this._renderer.renderList = this.objectList.meshes;
|
|
100
|
+
this._renderer.particleSystemList = this.objectList.particleSystems;
|
|
101
|
+
context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);
|
|
102
|
+
context.render(this._renderer, this._textureWidth, this._textureHeight);
|
|
103
|
+
additionalExecute?.(context);
|
|
102
104
|
});
|
|
103
105
|
if (this.dependencies !== undefined) {
|
|
104
106
|
for (const handle of this.dependencies) {
|
|
@@ -120,7 +122,7 @@ export class FrameGraphObjectRendererTask extends FrameGraphTask {
|
|
|
120
122
|
}
|
|
121
123
|
}
|
|
122
124
|
dispose() {
|
|
123
|
-
this.
|
|
125
|
+
this._renderer.dispose();
|
|
124
126
|
super.dispose();
|
|
125
127
|
}
|
|
126
128
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,cAAc;IAkB5D;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,MAAc;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;IACzC,CAAC;IAgCD;;OAEG;IACH,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,IAAoB,IAAI;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAoB,IAAI,CAAC,KAAa;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,IAAI,CAAC,IAAI,EAAE;YACX,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,KAAK,GAAG,eAAe,CAAC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C,MAAM,CAAC,CAAC;iBACnC;aACJ;SACJ;IACL,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACpB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureHandle, Scene, Camera, FrameGraphObjectList, FrameGraphRenderContext } from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { RenderTargetTexture } from \"../../../Materials/Textures/renderTargetTexture\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\n\r\n/**\r\n * Task used to render objects to a texture.\r\n */\r\nexport class FrameGraphObjectRendererTask extends FrameGraphTask {\r\n /**\r\n * The destination texture where the objects will be rendered.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth attachment texture where the objects will be rendered (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The dependencies of the task (optional).\r\n */\r\n public dependencies?: FrameGraphTextureHandle[] = [];\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used to render the objects.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._rtt.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The list of objects to render.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * If depth testing should be enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * If depth writing should be enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\r\n /**\r\n * The output texture.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n protected _scene: Scene;\r\n protected _rtt: RenderTargetTexture;\r\n\r\n /**\r\n * The render target texture used to render the objects.\r\n */\r\n public get renderTargetTexture() {\r\n return this._rtt;\r\n }\r\n\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(value: string) {\r\n this._name = value;\r\n if (this._rtt) {\r\n this._rtt.name = value + \"_internal_rtt\";\r\n }\r\n }\r\n\r\n /**\r\n * Constructs a new object renderer task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._rtt = new RenderTargetTexture(name, 1, scene, {\r\n delayAllocation: true,\r\n });\r\n this._rtt.skipInitialClear = true;\r\n this.name = name;\r\n\r\n this.outputTexture = this._frameGraph.createDanglingHandle();\r\n this.outputDepthTexture = this._frameGraph.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this._rtt.isReadyForRendering();\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses = false, additionalExecute?: (context: FrameGraphRenderContext) => void) {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle && this.destinationTexture !== backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer color texture is the only color texture allowed when the depth is the back buffer depth/stencil`\r\n );\r\n }\r\n if (this.depthTexture !== backbufferDepthStencilTextureHandle && this.destinationTexture === backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the destination is the back buffer color`\r\n );\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this._frameGraph.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._rtt._size = outputTextureDescription.size;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n }\r\n pass.setExecuteFunc((_context) => {\r\n this._rtt.renderList = this.objectList.meshes;\r\n this._rtt.particleSystemList = this.objectList.particleSystems;\r\n this._scene.incrementRenderId();\r\n this._scene.resetCachedMaterial();\r\n _context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n _context.render(this._rtt);\r\n additionalExecute?.(_context);\r\n });\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n pass.useTexture(handle);\r\n }\r\n }\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n }\r\n passDisabled.setExecuteFunc((_context) => {});\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n passDisabled.useTexture(handle);\r\n }\r\n }\r\n }\r\n }\r\n\r\n public override dispose(): void {\r\n this._rtt.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"objectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/objectRendererTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,cAAc;IAkB5D;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,MAAc;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9C,CAAC;IAkCD;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAoB,IAAI;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAoB,IAAI,CAAC,KAAa;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,IAAI,CAAC,SAAS,EAAE;YAChB,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,KAAK,CAAC;SAC/B;IACL,CAAC;IAED;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,KAAY,EAAE,OAA+B;QAC3F,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QA7E5B;;WAEG;QACI,iBAAY,GAA+B,EAAE,CAAC;QAqBrD;;WAEG;QACI,cAAS,GAAG,IAAI,CAAC;QAExB;;WAEG;QACI,eAAU,GAAG,IAAI,CAAC;QA+CrB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,IAAI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eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, FrameGraphTextureHandle, Scene, Camera, FrameGraphObjectList, FrameGraphRenderContext, ObjectRendererOptions } from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { FrameGraphTask } from \"../../frameGraphTask\";\r\nimport { ObjectRenderer } from \"../../../Rendering/objectRenderer\";\r\n\r\n/**\r\n * Task used to render objects to a texture.\r\n */\r\nexport class FrameGraphObjectRendererTask extends FrameGraphTask {\r\n /**\r\n * The destination texture where the objects will be rendered.\r\n */\r\n public destinationTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The depth attachment texture where the objects will be rendered (optional).\r\n */\r\n public depthTexture?: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The dependencies of the task (optional).\r\n */\r\n public dependencies?: FrameGraphTextureHandle[] = [];\r\n\r\n private _camera: Camera;\r\n\r\n /**\r\n * Gets or sets the camera used to render the objects.\r\n */\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n public set camera(camera: Camera) {\r\n this._camera = camera;\r\n this._renderer.activeCamera = this.camera;\r\n }\r\n\r\n /**\r\n * The list of objects to render.\r\n */\r\n public objectList: FrameGraphObjectList;\r\n\r\n /**\r\n * If depth testing should be enabled (default is true).\r\n */\r\n public depthTest = true;\r\n\r\n /**\r\n * If depth writing should be enabled (default is true).\r\n */\r\n public depthWrite = true;\r\n\r\n /**\r\n * The output texture.\r\n */\r\n public readonly outputTexture: FrameGraphTextureHandle;\r\n\r\n /**\r\n * The output depth attachment texture.\r\n * This texture will point to the same texture than the depthTexture property if it is set.\r\n * Note, however, that the handle itself will be different!\r\n */\r\n public readonly outputDepthTexture: FrameGraphTextureHandle;\r\n\r\n protected _scene: Scene;\r\n protected _renderer: ObjectRenderer;\r\n protected _textureWidth: number;\r\n protected _textureHeight: number;\r\n\r\n /**\r\n * The object renderer used to render the objects.\r\n */\r\n public get objectRenderer() {\r\n return this._renderer;\r\n }\r\n\r\n public override get name() {\r\n return this._name;\r\n }\r\n\r\n public override set name(value: string) {\r\n this._name = value;\r\n if (this._renderer) {\r\n this._renderer.name = value;\r\n }\r\n }\r\n\r\n /**\r\n * Constructs a new object renderer task.\r\n * @param name The name of the task.\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph);\r\n\r\n this._scene = scene;\r\n this._renderer = new ObjectRenderer(name, scene, options);\r\n this.name = name;\r\n\r\n this._renderer.onBeforeRenderingManagerRenderObservable.add(() => {\r\n if (!this._renderer.options.doNotChangeAspectRatio) {\r\n scene.updateTransformMatrix(true);\r\n }\r\n });\r\n\r\n this.outputTexture = this._frameGraph.createDanglingHandle();\r\n this.outputDepthTexture = this._frameGraph.createDanglingHandle();\r\n }\r\n\r\n public override isReady() {\r\n return this._renderer.isReadyForRendering(this._textureWidth, this._textureHeight);\r\n }\r\n\r\n public record(skipCreationOfDisabledPasses = false, additionalExecute?: (context: FrameGraphRenderContext) => void) {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n if (this.depthTexture === backbufferDepthStencilTextureHandle && this.destinationTexture !== backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer color texture is the only color texture allowed when the depth is the back buffer depth/stencil`\r\n );\r\n }\r\n if (this.depthTexture !== backbufferDepthStencilTextureHandle && this.destinationTexture === backbufferColorTextureHandle) {\r\n throw new Error(\r\n `FrameGraphObjectRendererTask ${this.name}: the back buffer depth/stencil texture is the only depth texture allowed when the destination is the back buffer color`\r\n );\r\n }\r\n\r\n const depthTextureDescription = this._frameGraph.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this._frameGraph.resolveDanglingHandle(this.outputTexture, this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n }\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n additionalExecute?.(context);\r\n });\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n pass.useTexture(handle);\r\n }\r\n }\r\n\r\n if (!skipCreationOfDisabledPasses) {\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n }\r\n passDisabled.setExecuteFunc((_context) => {});\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n passDisabled.useTexture(handle);\r\n }\r\n }\r\n }\r\n }\r\n\r\n public override dispose(): void {\r\n this._renderer.dispose();\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FrameGraph, Scene, DrawWrapper } from "../../../index.js";
|
|
1
|
+
import type { FrameGraph, Scene, DrawWrapper, ObjectRendererOptions } from "../../../index.js";
|
|
2
2
|
import { FrameGraphObjectRendererTask } from "./objectRendererTask";
|
|
3
3
|
import { ThinTAAPostProcess } from "../../../PostProcesses/thinTAAPostProcess.js";
|
|
4
4
|
/**
|
|
@@ -15,7 +15,8 @@ export declare class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRen
|
|
|
15
15
|
* @param name The name of the task
|
|
16
16
|
* @param frameGraph The frame graph the task belongs to.
|
|
17
17
|
* @param scene The scene the frame graph is associated with.
|
|
18
|
+
* @param options The options of the object renderer.
|
|
18
19
|
*/
|
|
19
|
-
constructor(name: string, frameGraph: FrameGraph, scene: Scene);
|
|
20
|
+
constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions);
|
|
20
21
|
record(): void;
|
|
21
22
|
}
|
|
@@ -11,9 +11,10 @@ export class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTas
|
|
|
11
11
|
* @param name The name of the task
|
|
12
12
|
* @param frameGraph The frame graph the task belongs to.
|
|
13
13
|
* @param scene The scene the frame graph is associated with.
|
|
14
|
+
* @param options The options of the object renderer.
|
|
14
15
|
*/
|
|
15
|
-
constructor(name, frameGraph, scene) {
|
|
16
|
-
super(name, frameGraph, scene);
|
|
16
|
+
constructor(name, frameGraph, scene, options) {
|
|
17
|
+
super(name, frameGraph, scene, options);
|
|
17
18
|
this.postProcess = new ThinTAAPostProcess(`${name} post-process`, scene.getEngine());
|
|
18
19
|
this._postProcessDrawWrapper = this.postProcess.drawWrapper;
|
|
19
20
|
}
|
|
@@ -58,17 +59,16 @@ export class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTas
|
|
|
58
59
|
if (this.depthTexture !== undefined) {
|
|
59
60
|
this._frameGraph.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);
|
|
60
61
|
}
|
|
61
|
-
this.
|
|
62
|
+
this._textureWidth = outputTextureDescription.size.width;
|
|
63
|
+
this._textureHeight = outputTextureDescription.size.height;
|
|
62
64
|
const pass = this._frameGraph.addRenderPass(this.name);
|
|
63
65
|
pass.setRenderTarget(this.destinationTexture);
|
|
64
66
|
if (this.depthTexture !== undefined) {
|
|
65
67
|
pass.setRenderTargetDepth(this.depthTexture);
|
|
66
68
|
}
|
|
67
69
|
pass.setExecuteFunc((context) => {
|
|
68
|
-
this.
|
|
69
|
-
this.
|
|
70
|
-
this._scene.incrementRenderId();
|
|
71
|
-
this._scene.resetCachedMaterial();
|
|
70
|
+
this._renderer.renderList = this.objectList.meshes;
|
|
71
|
+
this._renderer.particleSystemList = this.objectList.particleSystems;
|
|
72
72
|
this.postProcess.updateProjectionMatrix();
|
|
73
73
|
context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);
|
|
74
74
|
// We define the active camera and transformation matrices ourselves, otherwise this will be done by calling context.render, in which case
|
|
@@ -77,7 +77,7 @@ export class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTas
|
|
|
77
77
|
this._scene.activeCamera = this.camera;
|
|
78
78
|
this._scene.setTransformMatrix(this.camera.getViewMatrix(), this.camera.getProjectionMatrix());
|
|
79
79
|
}
|
|
80
|
-
context.render(this.
|
|
80
|
+
context.render(this._renderer, this._textureWidth, this._textureHeight);
|
|
81
81
|
this._scene.activeCamera = null;
|
|
82
82
|
context.bindRenderTarget(pingPongHandle, "frame graph - TAA merge with history texture");
|
|
83
83
|
if (!this.postProcess.disabled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taaObjectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/taaObjectRendererTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACp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, Scene, DrawWrapper, FrameGraphTextureCreationOptions } from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { FrameGraphObjectRendererTask } from \"./objectRendererTask\";\r\nimport { ThinTAAPostProcess } from \"core/PostProcesses/thinTAAPostProcess\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Task used to render objects to a texture with Temporal Anti-Aliasing (TAA).\r\n */\r\nexport class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTask {\r\n /**\r\n * The TAA post process.\r\n */\r\n public readonly postProcess: ThinTAAPostProcess;\r\n\r\n protected readonly _postProcessDrawWrapper: DrawWrapper;\r\n\r\n /**\r\n * Constructs a new TAA object renderer task.\r\n * @param name The name of the task\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene) {\r\n super(name, frameGraph, scene);\r\n\r\n this.postProcess = new ThinTAAPostProcess(`${name} post-process`, scene.getEngine());\r\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\r\n }\r\n\r\n public override record() {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n if (this.destinationTexture === backbufferColorTextureHandle || this.depthTexture === backbufferDepthStencilTextureHandle) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the back buffer color/depth textures are not allowed. Use regular textures instead.`);\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n const depthTextureDescription = this._frameGraph.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this.postProcess.camera = this.camera;\r\n this.postProcess.textureWidth = outputTextureDescription.size.width;\r\n this.postProcess.textureHeight = outputTextureDescription.size.height;\r\n\r\n const textureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: outputTextureDescription.size,\r\n options: {\r\n createMipMaps: false,\r\n generateMipMaps: false,\r\n types: [Constants.TEXTURETYPE_HALF_FLOAT],\r\n samplingModes: [Constants.TEXTURE_NEAREST_NEAREST],\r\n formats: [Constants.TEXTUREFORMAT_RGBA],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n generateDepthBuffer: false,\r\n generateStencilBuffer: false,\r\n label: \"\",\r\n },\r\n sizeIsPercentage: false,\r\n isHistoryTexture: true,\r\n };\r\n\r\n const pingPongHandle = this._frameGraph.createRenderTargetTexture(`${this.name} history`, textureCreationOptions);\r\n\r\n this._frameGraph.resolveDanglingHandle(this.outputTexture, pingPongHandle);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._rtt._size = outputTextureDescription.size;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n }\r\n\r\n pass.setExecuteFunc((context) => {\r\n this._rtt.renderList = this.objectList.meshes;\r\n this._rtt.particleSystemList = this.objectList.particleSystems;\r\n\r\n this._scene.incrementRenderId();\r\n this._scene.resetCachedMaterial();\r\n\r\n this.postProcess.updateProjectionMatrix();\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\r\n // We define the active camera and transformation matrices ourselves, otherwise this will be done by calling context.render, in which case\r\n // getProjectionMatrix will be called with a \"true\" parameter, forcing recalculation of the projection matrix and losing our changes.\r\n if (!this.postProcess.disabled) {\r\n this._scene.activeCamera = this.camera;\r\n this._scene.setTransformMatrix(this.camera.getViewMatrix(), this.camera.getProjectionMatrix());\r\n }\r\n\r\n context.render(this._rtt);\r\n\r\n this._scene.activeCamera = null;\r\n\r\n context.bindRenderTarget(pingPongHandle, \"frame graph - TAA merge with history texture\");\r\n\r\n if (!this.postProcess.disabled) {\r\n context.applyFullScreenEffect(this._postProcessDrawWrapper, () => {\r\n this.postProcess.bind();\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.destinationTexture);\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"historySampler\", pingPongHandle);\r\n });\r\n } else {\r\n context.copyTexture(this.destinationTexture);\r\n }\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n if (this.depthTexture !== undefined) {\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n }\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.destinationTexture);\r\n });\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n pass.useTexture(handle);\r\n passDisabled.useTexture(handle);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"taaObjectRendererTask.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FrameGraph/Tasks/Rendering/taaObjectRendererTask.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,mCAAmC,EAAE,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,qDAA8C;AAC3E,OAAO,EAAE,SAAS,EAAE,sCAA+B;AAEnD;;GAEG;AACH,MAAM,OAAO,+BAAgC,SAAQ,4BAA4B;IAQ7E;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,UAAsB,EAAE,KAAY,EAAE,OAA+B;QAC3F,KAAK,CAA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BAAiB,CAAC,IAAI,CAAC,uBAAuB,CAAC,MAAO,EAAE,gBAAgB,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;oBAC3G,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,uBAAuB,CAAC,MAAO,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;gBACtG,CAAC,CAAC,CAAC;aACN;iBAAM;gBACH,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;aAChD;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,WAAW,EAAE,IAAI,CAAC,CAAC;QAEnF,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;YACjC,YAAY,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SACxD;QACD,YAAY,CAAC,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;YACpC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;YACjC,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE;gBACpC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBACxB,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;aACnC;SACJ;IACL,CAAC;CACJ","sourcesContent":["// eslint-disable-next-line import/no-internal-modules\r\nimport type { FrameGraph, Scene, DrawWrapper, FrameGraphTextureCreationOptions, ObjectRendererOptions } from \"core/index\";\r\nimport { backbufferColorTextureHandle, backbufferDepthStencilTextureHandle } from \"../../frameGraphTypes\";\r\nimport { FrameGraphObjectRendererTask } from \"./objectRendererTask\";\r\nimport { ThinTAAPostProcess } from \"core/PostProcesses/thinTAAPostProcess\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Task used to render objects to a texture with Temporal Anti-Aliasing (TAA).\r\n */\r\nexport class FrameGraphTAAObjectRendererTask extends FrameGraphObjectRendererTask {\r\n /**\r\n * The TAA post process.\r\n */\r\n public readonly postProcess: ThinTAAPostProcess;\r\n\r\n protected readonly _postProcessDrawWrapper: DrawWrapper;\r\n\r\n /**\r\n * Constructs a new TAA object renderer task.\r\n * @param name The name of the task\r\n * @param frameGraph The frame graph the task belongs to.\r\n * @param scene The scene the frame graph is associated with.\r\n * @param options The options of the object renderer.\r\n */\r\n constructor(name: string, frameGraph: FrameGraph, scene: Scene, options?: ObjectRendererOptions) {\r\n super(name, frameGraph, scene, options);\r\n\r\n this.postProcess = new ThinTAAPostProcess(`${name} post-process`, scene.getEngine());\r\n this._postProcessDrawWrapper = this.postProcess.drawWrapper;\r\n }\r\n\r\n public override record() {\r\n if (this.destinationTexture === undefined || this.objectList === undefined) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: destinationTexture and objectList are required`);\r\n }\r\n\r\n if (this.destinationTexture === backbufferColorTextureHandle || this.depthTexture === backbufferDepthStencilTextureHandle) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the back buffer color/depth textures are not allowed. Use regular textures instead.`);\r\n }\r\n\r\n const outputTextureDescription = this._frameGraph.getTextureDescription(this.destinationTexture);\r\n\r\n let depthEnabled = false;\r\n\r\n if (this.depthTexture !== undefined) {\r\n const depthTextureDescription = this._frameGraph.getTextureDescription(this.depthTexture);\r\n if (depthTextureDescription.options.samples !== outputTextureDescription.options.samples) {\r\n throw new Error(`FrameGraphTAAObjectRendererTask ${this.name}: the depth texture and the output texture must have the same number of samples`);\r\n }\r\n\r\n depthEnabled = true;\r\n }\r\n\r\n this.postProcess.camera = this.camera;\r\n this.postProcess.textureWidth = outputTextureDescription.size.width;\r\n this.postProcess.textureHeight = outputTextureDescription.size.height;\r\n\r\n const textureCreationOptions: FrameGraphTextureCreationOptions = {\r\n size: outputTextureDescription.size,\r\n options: {\r\n createMipMaps: false,\r\n generateMipMaps: false,\r\n types: [Constants.TEXTURETYPE_HALF_FLOAT],\r\n samplingModes: [Constants.TEXTURE_NEAREST_NEAREST],\r\n formats: [Constants.TEXTUREFORMAT_RGBA],\r\n samples: 1,\r\n useSRGBBuffers: [false],\r\n generateDepthBuffer: false,\r\n generateStencilBuffer: false,\r\n label: \"\",\r\n },\r\n sizeIsPercentage: false,\r\n isHistoryTexture: true,\r\n };\r\n\r\n const pingPongHandle = this._frameGraph.createRenderTargetTexture(`${this.name} history`, textureCreationOptions);\r\n\r\n this._frameGraph.resolveDanglingHandle(this.outputTexture, pingPongHandle);\r\n if (this.depthTexture !== undefined) {\r\n this._frameGraph.resolveDanglingHandle(this.outputDepthTexture, this.depthTexture);\r\n }\r\n\r\n this._textureWidth = outputTextureDescription.size.width;\r\n this._textureHeight = outputTextureDescription.size.height;\r\n\r\n const pass = this._frameGraph.addRenderPass(this.name);\r\n\r\n pass.setRenderTarget(this.destinationTexture);\r\n if (this.depthTexture !== undefined) {\r\n pass.setRenderTargetDepth(this.depthTexture);\r\n }\r\n\r\n pass.setExecuteFunc((context) => {\r\n this._renderer.renderList = this.objectList.meshes;\r\n this._renderer.particleSystemList = this.objectList.particleSystems;\r\n\r\n this.postProcess.updateProjectionMatrix();\r\n\r\n context.setDepthStates(this.depthTest && depthEnabled, this.depthWrite && depthEnabled);\r\n\r\n // We define the active camera and transformation matrices ourselves, otherwise this will be done by calling context.render, in which case\r\n // getProjectionMatrix will be called with a \"true\" parameter, forcing recalculation of the projection matrix and losing our changes.\r\n if (!this.postProcess.disabled) {\r\n this._scene.activeCamera = this.camera;\r\n this._scene.setTransformMatrix(this.camera.getViewMatrix(), this.camera.getProjectionMatrix());\r\n }\r\n\r\n context.render(this._renderer, this._textureWidth, this._textureHeight);\r\n\r\n this._scene.activeCamera = null;\r\n\r\n context.bindRenderTarget(pingPongHandle, \"frame graph - TAA merge with history texture\");\r\n\r\n if (!this.postProcess.disabled) {\r\n context.applyFullScreenEffect(this._postProcessDrawWrapper, () => {\r\n this.postProcess.bind();\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"textureSampler\", this.destinationTexture);\r\n context.bindTextureHandle(this._postProcessDrawWrapper.effect!, \"historySampler\", pingPongHandle);\r\n });\r\n } else {\r\n context.copyTexture(this.destinationTexture);\r\n }\r\n });\r\n\r\n const passDisabled = this._frameGraph.addRenderPass(this.name + \"_disabled\", true);\r\n\r\n passDisabled.setRenderTarget(this.outputTexture);\r\n if (this.depthTexture !== undefined) {\r\n passDisabled.setRenderTargetDepth(this.depthTexture);\r\n }\r\n passDisabled.setExecuteFunc((context) => {\r\n context.copyTexture(this.destinationTexture);\r\n });\r\n\r\n if (this.dependencies !== undefined) {\r\n for (const handle of this.dependencies) {\r\n pass.useTexture(handle);\r\n passDisabled.useTexture(handle);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Nullable, AbstractEngine, DrawWrapper, IColor4Like, Layer, FrameGraphTextureHandle, Effect, FrameGraphTextureManager,
|
|
1
|
+
import type { Nullable, AbstractEngine, DrawWrapper, IColor4Like, Layer, FrameGraphTextureHandle, Effect, FrameGraphTextureManager, ObjectRenderer, Scene } from "../index.js";
|
|
2
2
|
import { FrameGraphContext } from "./frameGraphContext";
|
|
3
3
|
/**
|
|
4
4
|
* Frame graph context used render passes.
|
|
@@ -7,14 +7,16 @@ import { FrameGraphContext } from "./frameGraphContext";
|
|
|
7
7
|
export declare class FrameGraphRenderContext extends FrameGraphContext {
|
|
8
8
|
private readonly _engine;
|
|
9
9
|
private readonly _textureManager;
|
|
10
|
+
private readonly _scene?;
|
|
10
11
|
private readonly _effectRenderer;
|
|
11
12
|
private _currentRenderTargetHandle;
|
|
12
13
|
private _debugMessageWhenTargetBound;
|
|
13
14
|
private _debugMessageHasBeenPushed;
|
|
14
15
|
private _renderTargetIsBound;
|
|
15
16
|
private readonly _copyTexture;
|
|
17
|
+
private static _IsObjectRenderer;
|
|
16
18
|
/** @internal */
|
|
17
|
-
constructor(_engine: AbstractEngine, _textureManager: FrameGraphTextureManager);
|
|
19
|
+
constructor(_engine: AbstractEngine, _textureManager: FrameGraphTextureManager, _scene?: Scene | undefined);
|
|
18
20
|
/**
|
|
19
21
|
* Checks whether a texture handle points to the backbuffer's color or depth texture
|
|
20
22
|
* @param handle The handle to check
|
|
@@ -91,8 +93,10 @@ export declare class FrameGraphRenderContext extends FrameGraphContext {
|
|
|
91
93
|
/**
|
|
92
94
|
* Renders a RenderTargetTexture or a layer
|
|
93
95
|
* @param object The RenderTargetTexture/Layer to render
|
|
96
|
+
* @param viewportWidth The width of the viewport (optional for Layer, but mandatory for ObjectRenderer)
|
|
97
|
+
* @param viewportHeight The height of the viewport (optional for Layer, but mandatory for ObjectRenderer)
|
|
94
98
|
*/
|
|
95
|
-
render(object: Layer |
|
|
99
|
+
render(object: Layer | ObjectRenderer, viewportWidth?: number, viewportHeight?: number): void;
|
|
96
100
|
/**
|
|
97
101
|
* Binds a render target texture so that upcoming draw calls will render to it
|
|
98
102
|
* Note: it is a lazy operation, so the render target will only be bound when needed. This way, it is possible to call
|