Skip to content

Conversation

@hayden9329
Copy link

Fixed #2566

The previous workaround set an infinite radius to Float.MAX_VALUE, which can still cause overflow in shader math.

This Pull request updates the following:

  • Clamps infinite, negative, and NaN radius values to Float.MAX_VALUE / 4f
  • Adds a clear comment explaining the fix
  • Keeps "infinite" lights effectively infinite without shader bugs

I tested this locally, no overflow issues.
First-time contributor for a class project.

Clamps infinite, negative, or Not a Number radius to Float.MAX_VALUE / 4f
to prevent type overflow in shaders, as discussed in jMonkeyEngine#2566.
radius = Float.MAX_VALUE;

// Fix #2566 - Prevent shader overflow with infinite or invalid radius
if (radius == Float.POSITIVE_INFINITY || radius < 0f || Float.isNaN(radius)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to throw an exception on negative or NaN radius, since both are meaningless as radii. Negative radius already throws an exception previously.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinite radius point lights might cause type overflow

2 participants