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

GPULightmapper exclude back-face triangles while calculating bounces #52618

Merged

Conversation

williamd67
Copy link
Contributor

@williamd67 williamd67 commented Sep 12, 2021

Edges that are at the edge of a plane, may get behind the scene and will hit
back-face triangles which where included in the lighting calculations. This
caused leaking of light at the edge of planes.

In case a ray hits back-face triangle, it is skipped in the bounce calculations.

Now it should fix #51638.

@williamd67 williamd67 requested a review from a team as a code owner September 12, 2021 22:12
@Calinou Calinou added this to the 4.0 milestone Sep 12, 2021
@Calinou
Copy link
Member

Calinou commented Sep 12, 2021

Does this close #51638?

@williamd67
Copy link
Contributor Author

Does this close ##51638?

It did not remove it completely although together with increasing the setting for Lightmap Scale of the Global Illumination from 1x to 2x. It did solve it. I plan to investigate it a little further.

@williamd67
Copy link
Contributor Author

williamd67 commented Sep 13, 2021

I found an issue in the implementation of the exclusion. I will commit an improved version of this fix.

@jcostello
Copy link
Contributor

I imagine that this PR fix this, right @williamd67? The house is empty inside with the boards with only one side

image

@@ -118,13 +118,17 @@ bool ray_hits_triangle(vec3 from, vec3 dir, float max_dist, vec3 p0, vec3 p1, ve
bool trace_ray(vec3 p_from, vec3 p_to
#if defined(MODE_BOUNCE_LIGHT) || defined(MODE_LIGHT_PROBES)
,
out uint r_triangle, out vec3 r_barycentric
out uint r_triangle, out vec3 r_barycentric, out bool backface
Copy link
Member

Choose a reason for hiding this comment

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

By convention, parameters which are modified by the function to return values use the r_ prefix (like the two other out parameters here).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback, I updated the PR and removed the extra parameter.

Edges that are at the edge of a plane, may get behind the scene and will hit
back-face triangles which where included in the lighting calculations. This
caused leaking of light at the edge of planes.

In case a ray hits back-face triangle, it is skipped in the bounce calculations.
@williamd67 williamd67 force-pushed the GPULightmapper-bounce-improvement branch from 1e3ec4c to 7c19684 Compare September 14, 2021 20:30
@williamd67
Copy link
Contributor Author

I fixed the issue 'distance checking for back-faces was skipped' I mentioned before.

Now it should fix #51638.

Copy link
Contributor

@JFonS JFonS left a comment

Choose a reason for hiding this comment

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

Changes look great, awesome work :)

@akien-mga akien-mga merged commit b1dafd9 into godotengine:master Sep 20, 2021
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

GPULightmapper leaks light in situations where the CPU lightmapper wouldn't
5 participants