Skip to content

Ensure that rim lighting uses an exponent base greater than zero#69985

Merged
akien-mga merged 1 commit into
godotengine:masterfrom
clayjohn:mobile-rim
Dec 13, 2022
Merged

Ensure that rim lighting uses an exponent base greater than zero#69985
akien-mga merged 1 commit into
godotengine:masterfrom
clayjohn:mobile-rim

Conversation

@clayjohn

Copy link
Copy Markdown
Member

Fixes: #69908

This avoids the undefined behavior that happens if the base is zero and the exponent is zero

See https://registry.khronos.org/OpenGL-Refpages/gl4/html/pow.xhtml

Alternatively we could ensure the exponent is always greater than 0, but that would essentially be a change to the roughness of the material and would change the rim to be the same as if the roughness was less than 1. This change ensures the smallest visual difference.

Before:
Screenshot from 2022-12-12 13-29-09

After:
Screenshot from 2022-12-12 13-24-26

@clayjohn clayjohn added this to the 4.0 milestone Dec 12, 2022
@clayjohn clayjohn requested a review from a team as a code owner December 12, 2022 21:34

@akien-mga akien-mga left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good. May warrant a short comment like // Epsilon min to prevent pow(0, 0) singularity. for future readers.

This avoids the undefined behavior that happens if the base is zero and the exponent is zero
@clayjohn

Copy link
Copy Markdown
Member Author

Looks good. May warrant a short comment like // Epsilon min to prevent pow(0, 0) singularity. for future readers.

Done! :)

@BastiaanOlij BastiaanOlij left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Makes sense to me,

@clayjohn clayjohn changed the title Ensure that rim lighting uses a exponent base greater than zero Ensure that rim lighting uses an exponent base greater than zero Dec 13, 2022
@akien-mga akien-mga merged commit 83281e7 into godotengine:master Dec 13, 2022
@akien-mga

Copy link
Copy Markdown
Member

Thanks!

@clayjohn clayjohn deleted the mobile-rim branch August 25, 2025 16:29
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.

Vulkan Mobile: BaseMaterial3D Rim effect creates a dark dot on the mesh while moving the camera

3 participants