Skip to content

Commit e3853ed

Browse files
authored
Revert "TSL: Add MRT support for traaPass() (#31361)" (#31424)
This reverts commit 42048f8.
1 parent 8df553e commit e3853ed

File tree

2 files changed

+20
-78
lines changed

2 files changed

+20
-78
lines changed

examples/jsm/tsl/display/TRAAPassNode.js

Lines changed: 20 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Color, Vector2, NearestFilter, Matrix4, RendererUtils, PassNode, QuadMesh, NodeMaterial } from 'three/webgpu';
2-
import { add, float, If, Loop, int, Fn, min, max, clamp, nodeObject, texture, uniform, uv, vec2, vec4, luminance, output, mrt, textureLoad, screenCoordinate } from 'three/tsl';
2+
import { add, float, If, Loop, int, Fn, min, max, clamp, nodeObject, texture, uniform, uv, vec2, vec4, luminance } from 'three/tsl';
33

44
const _quadMesh = /*@__PURE__*/ new QuadMesh();
55
const _size = /*@__PURE__*/ new Vector2();
@@ -105,15 +105,6 @@ class TRAAPassNode extends PassNode {
105105
*/
106106
this._historyRenderTarget = null;
107107

108-
/**
109-
* The MRT for the transfer step.
110-
*
111-
* @private
112-
* @type {?MRTNode}
113-
* @default null
114-
*/
115-
this._transferMRT = null;
116-
117108
/**
118109
* Material used for the resolve step.
119110
*
@@ -213,21 +204,29 @@ class TRAAPassNode extends PassNode {
213204

214205
// configure velocity
215206

216-
const currentMRT = this.getMRT();
217-
const velocityOutput = currentMRT.get( 'velocity' );
207+
const mrt = this.getMRT();
208+
const velocityOutput = mrt.get( 'velocity' );
209+
210+
if ( velocityOutput !== undefined ) {
218211

219-
velocityOutput.setProjectionMatrix( this._originalProjectionMatrix );
212+
velocityOutput.setProjectionMatrix( this._originalProjectionMatrix );
213+
214+
} else {
215+
216+
throw new Error( 'THREE:TRAAPassNode: Missing velocity output in MRT configuration.' );
217+
218+
}
220219

221220
// render sample
222221

223-
renderer.setMRT( currentMRT );
222+
renderer.setMRT( mrt );
224223

225224
renderer.setClearColor( this.clearColor, this.clearAlpha );
226225
renderer.setRenderTarget( this._sampleRenderTarget );
227226
renderer.render( scene, camera );
228227

229228
renderer.setRenderTarget( null );
230-
renderer.setMRT( this._transferMRT );
229+
renderer.setMRT( null );
231230

232231
// every time when the dimensions change we need fresh history data. Copy the sample
233232
// into the history and final render target (no AA happens at that point).
@@ -313,49 +312,19 @@ class TRAAPassNode extends PassNode {
313312
this._sampleRenderTarget.texture.minFiler = NearestFilter;
314313
this._sampleRenderTarget.texture.magFilter = NearestFilter;
315314

316-
const currentMRT = this.getMRT();
317-
318-
if ( currentMRT === null ) {
319-
320-
throw new Error( 'THREE:TRAAPassNode: Missing MRT configuration.' );
315+
const velocityTarget = this._sampleRenderTarget.texture.clone();
316+
velocityTarget.isRenderTargetTexture = true;
317+
velocityTarget.name = 'velocity';
321318

322-
} else if ( currentMRT.has( 'velocity' ) === false ) {
323-
324-
throw new Error( 'THREE:TRAAPassNode: Missing velocity output in MRT configuration.' );
325-
326-
}
327-
328-
this._texturesIndex = currentMRT.getIndexes( this.renderTarget );
329-
330-
const transferNodes = {};
331-
332-
for ( const name in this._texturesIndex ) {
333-
334-
if ( name === 'output' ) {
335-
336-
transferNodes[ name ] = output;
337-
338-
} else {
339-
340-
const index = this._texturesIndex[ name ];
341-
342-
transferNodes[ name ] = textureLoad( this._sampleRenderTarget.textures[ index ], screenCoordinate );
343-
344-
}
345-
346-
}
347-
348-
this._transferMRT = mrt( transferNodes );
319+
this._sampleRenderTarget.textures.push( velocityTarget ); // for MRT
349320

350321
}
351322

352323
// textures
353324

354-
const velocityIndex = this._texturesIndex[ 'velocity' ];
355-
356325
const historyTexture = texture( this._historyRenderTarget.texture );
357326
const sampleTexture = texture( this._sampleRenderTarget.textures[ 0 ] );
358-
const velocityTexture = texture( this._sampleRenderTarget.textures[ velocityIndex ] );
327+
const velocityTexture = texture( this._sampleRenderTarget.textures[ 1 ] );
359328
const depthTexture = texture( this._sampleRenderTarget.depthTexture );
360329

361330
const resolve = Fn( () => {
@@ -426,7 +395,7 @@ class TRAAPassNode extends PassNode {
426395

427396
// materials
428397

429-
this._resolveMaterial.colorNode = resolve();
398+
this._resolveMaterial.fragmentNode = resolve();
430399

431400
return super.setup( builder );
432401

src/nodes/core/MRTNode.js

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -112,33 +112,6 @@ class MRTNode extends OutputStructNode {
112112

113113
}
114114

115-
/**
116-
* Returns the indexes of the MRT outputs in the current render target.
117-
*
118-
* @param {RenderTarget} renderTarget - The render target to get the indexes for.
119-
* @return {Array<number>} The indexes of the MRT outputs.
120-
*/
121-
getIndexes( renderTarget ) {
122-
123-
const textures = renderTarget.textures;
124-
const indexLib = {};
125-
126-
for ( const name in this.outputNodes ) {
127-
128-
const index = getTextureIndex( textures, name );
129-
130-
if ( index !== - 1 ) {
131-
132-
indexLib[ name ] = index;
133-
134-
}
135-
136-
}
137-
138-
return indexLib;
139-
140-
}
141-
142115
setup( builder ) {
143116

144117
const outputNodes = this.outputNodes;

0 commit comments

Comments
 (0)