From 04ad0bb88d946c3461eb19f8184f19c8076f2df3 Mon Sep 17 00:00:00 2001 From: Jim Eckerlein Date: Fri, 16 Dec 2022 13:04:09 +0100 Subject: [PATCH] Filter drawables behind camera each frame --- source/Renderer/renderer.js | 4 ++-- source/gltf/camera.js | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/source/Renderer/renderer.js b/source/Renderer/renderer.js index 00e02ddc..7445c209 100644 --- a/source/Renderer/renderer.js +++ b/source/Renderer/renderer.js @@ -331,14 +331,14 @@ class gltfRenderer // filter materials with transmission extension this.transmissionDrawables = currentCamera.sortPrimitivesByDepth(state.gltf, this.transmissionDrawables); - for (const drawable of this.transmissionDrawables) + for (const drawable of this.transmissionDrawables.filter((a) => a.depth <= 0)) { let renderpassConfiguration = {}; renderpassConfiguration.linearOutput = false; this.drawPrimitive(state, renderpassConfiguration, drawable.primitive, drawable.node, this.viewProjectionMatrix, this.opaqueRenderTexture); } - for (const drawable of this.transparentDrawables) + for (const drawable of this.transparentDrawables.filter((a) => a.depth <= 0)) { let renderpassConfiguration = {}; renderpassConfiguration.linearOutput = false; diff --git a/source/gltf/camera.js b/source/gltf/camera.js index 1e3ed124..3a138209 100644 --- a/source/gltf/camera.js +++ b/source/gltf/camera.js @@ -88,7 +88,6 @@ class gltfCamera extends GltfObject // 2. Sort primitives so that the furthest nodes are rendered first. // This is required for correct transparency rendering. return drawables - .filter((a) => a.depth <= 0) .sort((a, b) => a.depth - b.depth); }