Skip to content

Commit

Permalink
Merge pull request #290 from zhuxudong/fix/framebuffer-picker-ignore-…
Browse files Browse the repository at this point in the history
…postprocess

fix: ignore post-processing when framebuffer-picking
  • Loading branch information
JujieX authored Jul 23, 2024
2 parents 27f097f + f22310d commit f48e86a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/framebuffer-picker/src/FramebufferPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Camera,
dependentComponents,
DependentMode,
DepthTextureMode,
Logger,
Renderer,
RenderTarget,
Expand Down Expand Up @@ -130,6 +131,11 @@ export class FramebufferPicker extends Script {
this._checkFrameBufferSize();

const camera = this._camera;
const originalPostProcessEnabled = camera.enablePostProcess;
const originalHDR = camera.enableHDR;
const originalDepthMode = camera.depthTextureMode;
const originalOpaqueTextureEnabled = camera.opaqueTextureEnabled;

this._updateRenderersPickColor(camera.scene);
// Prepare render target and shader
const lastRenderTarget = camera.renderTarget;
Expand All @@ -138,12 +144,24 @@ export class FramebufferPicker extends Script {
camera.setReplacementShader(pickShader);
camera.aspectRatio = lastRatio;

// Reset internal RT and useless pass
camera.enablePostProcess = false;
camera.enableHDR = false;
camera.depthTextureMode = DepthTextureMode.None;
camera.opaqueTextureEnabled = false;

camera.render();

// Revert render target and shader
camera.resetReplacementShader();
camera.renderTarget = lastRenderTarget;
camera.resetAspectRatio();

// Revert internal RT and original pass
camera.enablePostProcess = originalPostProcessEnabled;
camera.enableHDR = originalHDR;
camera.depthTextureMode = originalDepthMode;
camera.opaqueTextureEnabled = originalOpaqueTextureEnabled;
}

private _readPixelFromRenderTarget(x: number, y: number, xEnd?: number, yEnd?: number): Uint8Array {
Expand Down

0 comments on commit f48e86a

Please sign in to comment.