Skip to content

Commit

Permalink
Small clean up to depth rendering (#6037)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
  • Loading branch information
mvaligursky and Martin Valigursky committed Feb 2, 2024
1 parent 21e3616 commit 204b64c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
16 changes: 15 additions & 1 deletion extras/render-passes/render-pass-camera-frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
PIXELFORMAT_RGBA8,
ADDRESS_CLAMP_TO_EDGE,
FILTER_LINEAR,
FILTER_NEAREST,
PIXELFORMAT_DEPTH,
RenderPass,
RenderPassColorGrab,
RenderPassForward,
Expand Down Expand Up @@ -132,9 +134,21 @@ class RenderPassCameraFrame extends RenderPass {
addressV: ADDRESS_CLAMP_TO_EDGE
});

const sceneDepth = new Texture(device, {
name: 'SceneDepth',
width: 4,
height: 4,
format: PIXELFORMAT_DEPTH, // TODO: handle stencil support
mipmaps: false,
minFilter: FILTER_NEAREST,
magFilter: FILTER_NEAREST,
addressU: ADDRESS_CLAMP_TO_EDGE,
addressV: ADDRESS_CLAMP_TO_EDGE
});

const rt = new RenderTarget({
colorBuffer: sceneTexture,
depth: true,
depthBuffer: sceneDepth,
samples: options.samples
});
this._rt = rt;
Expand Down
2 changes: 1 addition & 1 deletion src/scene/graphics/render-pass-depth.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class RenderPassDepth extends RenderPass {
const meshInstance = meshInstances[j];

// only collect meshes that update the depth
if (meshInstance.material?.depthWrite && !meshInstance._noDepthDrawGl1) {
if (meshInstance.material?.depthWrite) {
tempMeshInstances.push(meshInstance);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/scene/mesh-instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ class MeshInstance {
this._renderStyle = RENDERSTYLE_SOLID;
this._receiveShadow = true;
this._screenSpace = false;
this._noDepthDrawGl1 = false;

/**
* Controls whether the mesh instance can be culled by frustum culling
Expand Down
1 change: 0 additions & 1 deletion src/scene/particle-system/particle-emitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@ class ParticleEmitter {
this.meshInstance.pick = false;
this.meshInstance.updateKey(); // shouldn't be here?
this.meshInstance.cull = true;
this.meshInstance._noDepthDrawGl1 = true;
if (this.localSpace) {
this.meshInstance.aabb.setFromTransformedAabb(this.worldBounds, this.node.getWorldTransform());
} else {
Expand Down
1 change: 0 additions & 1 deletion src/scene/skybox/sky-mesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class SkyMesh {
this.meshInstance = meshInstance;

meshInstance.cull = false;
meshInstance._noDepthDrawGl1 = true;

// disable picker, the material has custom update shader and does not handle picker variant
meshInstance.pick = false;
Expand Down

0 comments on commit 204b64c

Please sign in to comment.