Skip to content

Commit

Permalink
Copy input buffer to output buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
vanruesc committed Dec 17, 2023
1 parent f57221f commit ced7197
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/passes/GeometryPass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { ObservableSet } from "../utils/ObservableSet.js";
import { GBuffer } from "../enums/GBuffer.js";
import { Resolution } from "../utils/Resolution.js";
import { ShaderWithDefines } from "../core/ShaderWithDefines.js";
import { CopyPass } from "./CopyPass.js";

/**
* Supported MSAA sample counts.
Expand Down Expand Up @@ -75,6 +76,12 @@ export class GeometryPass extends Pass implements Selective {

private readonly registeredMaterials: WeakSet<Material>;

/**
* A copy pass that is used to blit the default input buffer to the output color buffer.
*/

private readonly copyPass: CopyPass;

/**
* Controls which gBuffer components should be rendered by this pass.
*
Expand Down Expand Up @@ -145,6 +152,7 @@ export class GeometryPass extends Pass implements Selective {
this.selection = new Selection();
this.selection.enabled = false;
this.registeredMaterials = new WeakSet<Material>();
this.copyPass = new CopyPass();

const gBufferComponents = new ObservableSet<GBuffer>();
gBufferComponents.addEventListener(ObservableSet.EVENT_CHANGE, () => this.updateGBuffer());
Expand Down Expand Up @@ -174,6 +182,12 @@ export class GeometryPass extends Pass implements Selective {

}

protected override onInputChange(): void {

this.copyPass.input.defaultBuffer = this.input.defaultBuffer;

}

/**
* Sets the amount of MSAA samples.
*/
Expand Down Expand Up @@ -391,6 +405,7 @@ export class GeometryPass extends Pass implements Selective {

}

this.copyPass.output.defaultBuffer = renderTarget;
this.output.defaultBuffer = renderTarget;
this.updateOutputBufferColorSpace();

Expand Down Expand Up @@ -429,7 +444,7 @@ export class GeometryPass extends Pass implements Selective {

if(this.input.defaultBuffer !== null) {

//this.copyInputToColorBuffer();
this.copyPass.render();

}

Expand Down

0 comments on commit ced7197

Please sign in to comment.