Render: Fix frustum culling.

This commit is contained in:
Alberto Torres 2025-03-18 20:24:56 +01:00
parent e169723b7b
commit bde930692d

View file

@ -84,17 +84,7 @@ func newRenderCameraData*(world_matrix, proj_matrix: Mat4, cull_planes: array[6,
result.viewport_size_inv = 1'f32/viewport_size
func updateCullPlanes*(self: var RenderCameraData, cull_planes: array[6, Vec4]) =
# TODO: check if this works just by multiplying the planes w matrix
var p4 = vec4()
var n4 = vec4()
for i, plane in cull_planes:
n4 = plane
n4.w = 0
p4 = n4 * -plane.w
p4.w = 1
p4 = self.cam2world * p4
n4 = self.cam2world * n4
self.cull_planes[i] = plane_from_norm_point(n4.xyz, p4.xyz)
self.cull_planes = (self.projection_matrix * self.world2cam).get_culling_planes()
proc newRenderManager*(engine: MyouEngine): RenderManager =
result = new RenderManager