28 const bool is_persp = winmat[3][3] == 0.0f;
30 float near = winmat[3][2] / (winmat[2][2] - 1.0f);
31 r_left = near * ((winmat[2][0] - 1.0f) / winmat[0][0]);
32 r_right = near * ((winmat[2][0] + 1.0f) / winmat[0][0]);
33 r_bottom = near * ((winmat[2][1] - 1.0f) / winmat[1][1]);
34 r_top = near * ((winmat[2][1] + 1.0f) / winmat[1][1]);
36 r_far = winmat[3][2] / (winmat[2][2] + 1.0f);
39 r_left = (-winmat[3][0] - 1.0f) / winmat[0][0];
40 r_right = (-winmat[3][0] + 1.0f) / winmat[0][0];
41 r_bottom = (-winmat[3][1] - 1.0f) / winmat[1][1];
42 r_top = (-winmat[3][1] + 1.0f) / winmat[1][1];
43 r_near = (winmat[3][2] + 1.0f) / winmat[2][2];
44 r_far = (winmat[3][2] - 1.0f) / winmat[2][2];
50 float left = 0.0f, right = 0.0f, bottom = 0.0f, top = 0.0f, near = 0.0f, far = 0.0f;
51 bool is_persp = winmat[3][3] == 0.0f;
64 float sca_far = far / near;
79 for (
int i = 0; i < 8; i++) [[
unroll]] {
92 frustum_planes.
planes[0] = mat[3] + mat[0];
93 frustum_planes.
planes[1] = mat[3] - mat[0];
94 frustum_planes.
planes[2] = mat[3] + mat[1];
95 frustum_planes.
planes[3] = mat[3] - mat[1];
96 frustum_planes.
planes[4] = mat[3] + mat[2];
97 frustum_planes.
planes[5] = mat[3] - mat[2];
102 float4x4 persmat = winmat * viewmat;
106 for (
int p = 0; p < 6; p++) {
117 bsphere.xyz = (frustum_corners.
corners[0].xyz + frustum_corners.
corners[6].xyz) * 0.5f;
119 for (
int i = 0; i < 8; i++) {
135 uint view_id = local_id.x;
142 srt.view_culling_buf[view_id].bound_sphere =
float4(-1.0f);
147 FrustumCorners frustum_corners = srt.view_culling_buf[view_id].frustum_corners;
149 srt.view_culling_buf[view_id].frustum_corners = frustum_corners;
152 FrustumPlanes frustum_planes = srt.view_culling_buf[view_id].frustum_planes;
155 srt.view_culling_buf[view_id].frustum_planes = frustum_planes;
#define storage(slot, qualifiers)
#define local_invocation_id
float distance(float, float) RET
bool all(VecOp< bool, D >) RET
MatBase< R, C > transpose(MatBase< C, R >) RET
VecBase< bool, D > equal(VecOp< T, D >, VecOp< T, D >) RET
float length(VecOp< float, D >) RET
MatBase< float, 4, 4 > float4x4
void frustum_culling_planes_calc(float4x4 winmat, float4x4 viewmat, FrustumPlanes &frustum_planes)
void planes_from_projmat(float4x4 mat, FrustumPlanes &frustum_planes)
void view_finalize_main(ViewFinalize &srt, View &views, const uint3 local_id)
PipelineCompute view_finalize(view_finalize_main)
void projmat_dimensions(float4x4 winmat, float &r_left, float &r_right, float &r_bottom, float &r_top, float &r_near, float &r_far)
void frustum_boundbox_calc(float4x4 winmat, float4x4 viewinv, FrustumCorners &frustum)
float4 frustum_culling_sphere_calc(FrustumCorners frustum_corners)
ViewCullingData(& view_culling_buf)[DRW_VIEW_MAX]