Skip to content

Fix Gaussian Masking Logic & Eliminate Code Duplication #81

@Wang-Chbo

Description

@Wang-Chbo

#15 raised a very interesting question that remains unanswered. However, in reality, the function name is quite misleading. The final code significantly relaxes the positional requirements for Gaussians, which is necessary: Imagine a scenario where the center of a Gaussian is not within the current view frustum, but the Gaaussian's diameter is large enough to affect many pixels within the current view frustum. In this case, we should not cull this Gaussian from rendering.
Additionally, I noticed that the calculations in Lines 149-152 of in_frustum duplicate code found elsewhere, such as Lines 196-200 in forward.cu. Therefore, I recommend deleting Lines 149-151 in in_frustum.

__forceinline__ __device__ bool in_frustum(int idx,
const float* orig_points,
const float* viewmatrix,
const float* projmatrix,
bool prefiltered,
float3& p_view)
{
float3 p_orig = { orig_points[3 * idx], orig_points[3 * idx + 1], orig_points[3 * idx + 2] };
// Bring points to screen space
float4 p_hom = transformPoint4x4(p_orig, projmatrix);
float p_w = 1.0f / (p_hom.w + 0.0000001f);
float3 p_proj = { p_hom.x * p_w, p_hom.y * p_w, p_hom.z * p_w };
p_view = transformPoint4x3(p_orig, viewmatrix);
if (p_view.z <= 0.2f)// || ((p_proj.x < -1.3 || p_proj.x > 1.3 || p_proj.y < -1.3 || p_proj.y > 1.3)))
{
if (prefiltered)
{
printf("Point is filtered although prefiltered is set. This shouldn't happen!");
__trap();
}
return false;
}
return true;
}

// Transform point by projecting
float3 p_orig = { orig_points[3 * idx], orig_points[3 * idx + 1], orig_points[3 * idx + 2] };
float4 p_hom = transformPoint4x4(p_orig, projmatrix);
float p_w = 1.0f / (p_hom.w + 0.0000001f);
float3 p_proj = { p_hom.x * p_w, p_hom.y * p_w, p_hom.z * p_w };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions