Skip to content

Commit

Permalink
Removed WebGL1 depth grab support (#6295)
Browse files Browse the repository at this point in the history
* Removed WebGL1 depth grab support

* updated grab pass scheduling

---------

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
  • Loading branch information
mvaligursky and Martin Valigursky committed Apr 26, 2024
1 parent 6ecaaad commit 279122c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 145 deletions.
5 changes: 1 addition & 4 deletions src/scene/camera.js
Expand Up @@ -12,7 +12,6 @@ import {
} from './constants.js';
import { RenderPassColorGrab } from './graphics/render-pass-color-grab.js';
import { RenderPassDepthGrab } from './graphics/render-pass-depth-grab.js';
import { RenderPassDepth } from './graphics/render-pass-depth.js';

// pre-allocated temp variables
const _deviceCoord = new Vec3();
Expand Down Expand Up @@ -497,9 +496,7 @@ class Camera {
_enableRenderPassDepthGrab(device, renderer, enable) {
if (enable) {
if (!this.renderPassDepthGrab) {
this.renderPassDepthGrab = device.isWebGL1 ?
new RenderPassDepth(device, renderer, this) :
new RenderPassDepthGrab(device, this);
this.renderPassDepthGrab = new RenderPassDepthGrab(device, this);
}
} else {
this.renderPassDepthGrab?.destroy();
Expand Down
125 changes: 0 additions & 125 deletions src/scene/graphics/render-pass-depth.js

This file was deleted.

18 changes: 2 additions & 16 deletions src/scene/renderer/forward-renderer.js
Expand Up @@ -819,7 +819,6 @@ class ForwardRenderer extends Renderer {
buildFrameGraph(frameGraph, layerComposition) {

const scene = this.scene;
const webgl1 = this.device.isWebGL1;
frameGraph.reset();

// update composition, cull everything, assign atlas slots for clustered lighting
Expand Down Expand Up @@ -858,20 +857,7 @@ class ForwardRenderer extends Renderer {

} else {

// on webgl1, depth pass renders ahead of the main camera instead of the middle of the frame
const depthPass = camera.camera.renderPassDepthGrab;
if (depthPass && webgl1 && renderAction.firstCameraUse) {
depthPass.options.resizeSource = camera.camera.renderTarget;
depthPass.update(this.scene);
frameGraph.addRenderPass(depthPass);
}

const isDepthLayer = layer.id === LAYERID_DEPTH;

// skip depth layer on webgl1 if color grab pass is not enabled, as depth pass renders ahead of the main camera
if (webgl1 && isDepthLayer && !camera.renderSceneColorMap)
continue;

const isGrabPass = isDepthLayer && (camera.renderSceneColorMap || camera.renderSceneDepthMap);

// start of block of render actions rendering to the same render target
Expand All @@ -884,7 +870,7 @@ class ForwardRenderer extends Renderer {
// info about the next render action
const nextRenderAction = renderActions[i + 1];
const isNextLayerDepth = nextRenderAction ? nextRenderAction.layer.id === LAYERID_DEPTH : false;
const isNextLayerGrabPass = isNextLayerDepth && (camera.renderSceneColorMap || camera.renderSceneDepthMap) && !webgl1;
const isNextLayerGrabPass = isNextLayerDepth && (camera.renderSceneColorMap || camera.renderSceneDepthMap);
const nextNeedDirShadows = nextRenderAction ? (nextRenderAction.firstCameraUse && this.cameraDirShadowLights.has(nextRenderAction.camera.camera)) : false;

// end of the block using the same render target if the next render action uses a different render target, or needs directional shadows
Expand All @@ -907,7 +893,7 @@ class ForwardRenderer extends Renderer {
frameGraph.addRenderPass(colorGrabPass);
}

if (camera.renderSceneDepthMap && !webgl1) {
if (camera.renderSceneDepthMap) {
frameGraph.addRenderPass(camera.camera.renderPassDepthGrab);
}
}
Expand Down

0 comments on commit 279122c

Please sign in to comment.