From fdc568c4bcb65cf260b49118f2eb8881084f7944 Mon Sep 17 00:00:00 2001 From: Daniel Bross Date: Sun, 6 Jul 2025 23:58:40 +0200 Subject: [PATCH] Removed old shadow map code --- module.jai | 2 -- renderer/engine_buffers.jai | 64 ------------------------------------- 2 files changed, 66 deletions(-) diff --git a/module.jai b/module.jai index 76c0ae7..f9950bd 100644 --- a/module.jai +++ b/module.jai @@ -41,8 +41,6 @@ Engine_Core :: struct { directional_light_buffer : Buffer_Handle; point_light_buffer : Buffer_Handle; - on_frustum_render: (Vector3, Vector3); - procs: struct { on_scene_loaded: (*Scene, Engine_Mode); on_pre_scene_loaded: (*Scene, Engine_Mode); diff --git a/renderer/engine_buffers.jai b/renderer/engine_buffers.jai index 85c88c2..fd45437 100644 --- a/renderer/engine_buffers.jai +++ b/renderer/engine_buffers.jai @@ -44,70 +44,6 @@ calc_tight_light_projection :: (camera: Camera, light_direction: Vector3) -> Mat return light_projection * light_view; } -calculate_sun_transform :: (camera: Camera, light_direction: Vector3) -> Matrix4 { - success, inv_viewproj := inverse(camera.projection_matrix * camera.view_matrix); - - view : Matrix4; - proj : Matrix4; - - ndc : [8] Vector4 = .[ - .{-1, -1, 0, 1}, .{1, -1, 0, 1}, .{-1, 1, 0, 1}, .{1, 1, 0, 1}, // near plane - .{-1, -1, 1, 1}, .{1, -1, 1, 1}, .{-1, 1, 1, 1}, .{1, 1, 1, 1} // far plane - ]; - - corners : [8] Vector3; - center : Vector3; - - for i: 0..7 { - world := inv_viewproj * ndc[i]; - corners[i] = world.xyz / world.w; - center += corners[i]; - } - - center /= 8.0; - - { - // Build light basis - forward := normalize(-light_direction); - up := ifx abs(forward.y) > 0.99 then Vector3.{0, 0, 1} else .{0, 1, 0}; - right := normalize(cross(up, forward)); - up = cross(forward, right); - - // Build view matrix manually (row-major layout) - view = Matrix4_Identity; - view.v[0] = Vector4.{right.x, right.y, right.z, 0.0}; - view.v[1] = Vector4.{up.x, up.y, up.z, 0.0}; - view.v[2] = Vector4.{forward.x, forward.y, forward.z, 0.0}; - view.v[3] = Vector4.{-dot(right, center), - -dot(up, center), - -dot(forward, center), - 1.0}; - } - - { - min_bounds : Vector3 = .{FLOAT32_MAX, FLOAT32_MAX, FLOAT32_MAX}; - max_bounds : Vector3 = .{-FLOAT32_MAX, -FLOAT32_MAX, -FLOAT32_MAX}; - - for i: 0..7 { - ls := transform_position(corners[i], view); - min_bounds = min(min_bounds, ls); - max_bounds = max(max_bounds, ls); - } - - // Step 5: Build orthographic projection (DX11 Z: 0..1) - left := min_bounds.x; - right := max_bounds.x; - bottom := min_bounds.y; - top := max_bounds.y; - near_z := min_bounds.z; - far_z := max_bounds.z; - - proj = orthographic_lh_projection_matrix(left, right, bottom, top, near_z, far_z); - } - - return proj * view; -} - update_light_buffer :: () { scene := engine.current_scene;