From c09499dd015ca38546b9652fcffbf00941f551c8 Mon Sep 17 00:00:00 2001 From: Alberto Torres Date: Tue, 18 Mar 2025 18:05:55 +0100 Subject: [PATCH] Render: Add depth-only pass (temporary until pass system is rewritten). --- src/graphics/render.nim | 7 +++++++ src/types.nim | 1 + 2 files changed, 8 insertions(+) diff --git a/src/graphics/render.nim b/src/graphics/render.nim index cf9dae1..b949d28 100644 --- a/src/graphics/render.nim +++ b/src/graphics/render.nim @@ -495,6 +495,13 @@ proc draw_viewport*(self: RenderManager, viewport: Viewport, rect: (int32,int32, # self.draw_mesh(ob, ob.world_matrix, cd, 0) # glClear(GL_DEPTH_BUFFER_BIT) + if scene.depth_pass.len != 0: + glColorMask(false, false, false, false) + for ob in scene.depth_pass: + if ob.visible == true: + self.draw_mesh(ob, ob.world_matrix, cd, 0) + glColorMask(true, true, true, true) + # PASS 0 (opaque) if passes.find(0) >= 0 and scene.mesh_passes[0].len != 0: # Sort by distence to camera diff --git a/src/types.nim b/src/types.nim index b805ba0..b8d0479 100644 --- a/src/types.nim +++ b/src/types.nim @@ -353,6 +353,7 @@ type children*: seq[GameObject] auto_updated_children*: seq[GameObject] mesh_passes*: seq[seq[Mesh]] + depth_pass*: seq[Mesh] bg_pass*: seq[Mesh] fg_pass*: seq[Mesh] lights*: seq[Light]