Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix point light assignment #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

FlexW
Copy link

@FlexW FlexW commented Aug 15, 2024

Thank you for writing the book. I enjoyed it a lot. I think I spotted two mistakes. There might be other places in the codebase that have the same issues:

The min and max light id calculation needs to include lights that have their projected z coordinates smaller and greater than then bin z bounds.

I think it may be also needed to include this condition before checking the point lights projected z min/max to skip lights that are behind the camera.

if (sortedLight->projected_z_min < 0.0f && sortedLight->projected_z_max < 0.0f)
{
    // The light is behind the camera, skip it
    continue;
}

The address calculation of tiles need the x value multiplied by the words count. Otherwise the address is not correct because one tile covers words count unsigned integers.

The min and max light id calculation needs to include lights that have
their projected z coordinates smaller and greater than then bin z
bounds.

The address calculation of tiles need the x value multiplied by the
words count. Otherwise the address is not correct because one tile
covers words count unsigned integers.
@theWatchmen
Copy link
Collaborator

Thanks for the PR and apologies for the late reply, I was away on holiday :) I'll review the changes in the next few days.

@@ -2143,7 +2143,7 @@ void RenderScene::upload_gpu_data( UploadGpuDataContext& context ) {
for ( u32 i = 0; i < k_num_lights; ++i ) {
const SortedLight& light = sorted_lights[ i ];

if ( ( light.projected_z >= bin_min && light.projected_z <= bin_max ) ||
if ( ( light.projected_z_min <= bin_min && light.projected_z_max >= bin_max ) ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is correct, as this would include lights that have their min/max depth bounds outside the bin bounds. It could well be that this line is not needed though and that we just need to check the min/max z against the bin bounds. I haven't run the code yet, I'll verify more thoroughly later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants