Skip to content

Commit 3da81a9

Browse files
committed
Improve copy pass config
1 parent ade8597 commit 3da81a9

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/passes/GeometryPass.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ export class GeometryPass extends Pass implements Selective {
438438

439439
private updateGBuffer(): void {
440440

441-
if(this.output.defaultBuffer !== this.gBufferResource) {
441+
if(this.output.hasDefaultBuffer && this.output.defaultBuffer !== this.gBufferResource) {
442442

443443
// Don't modify foreign resources.
444444
return;
@@ -496,6 +496,20 @@ export class GeometryPass extends Pass implements Selective {
496496

497497
}
498498

499+
private updateCopyPass(): void {
500+
501+
const inputBuffer = this.input.defaultBuffer?.value ?? null;
502+
const outputBuffer = this.output.defaultBuffer?.value ?? null;
503+
const textureCount = outputBuffer?.textures.length ?? 0;
504+
505+
this.copyPass.enabled = (
506+
inputBuffer !== null &&
507+
inputBuffer !== outputBuffer?.texture &&
508+
textureCount < 2
509+
);
510+
511+
}
512+
499513
protected override onInputChange(): void {
500514

501515
this.copyPass.input.defaultBuffer = this.input.defaultBuffer;
@@ -510,14 +524,20 @@ export class GeometryPass extends Pass implements Selective {
510524

511525
}
512526

513-
const inputBuffer = this.input.defaultBuffer?.value ?? null;
514-
this.copyPass.enabled = inputBuffer !== null && this.gBuffer !== null;
527+
this.updateCopyPass();
515528

516529
}
517530

518531
protected override onOutputChange(): void {
519532

533+
if(!this.output.hasDefaultBuffer) {
534+
535+
this.updateGBuffer();
536+
537+
}
538+
520539
this.copyPass.output.defaultBuffer = this.output.defaultBuffer;
540+
this.updateCopyPass();
521541

522542
}
523543

0 commit comments

Comments
 (0)