Removed old shadow map code

This commit is contained in:
2025-07-06 23:58:40 +02:00
parent c3a1686325
commit fdc568c4bc
2 changed files with 0 additions and 66 deletions

View File

@@ -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);

View File

@@ -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;