Skip to content

Conversation

@ecoskey
Copy link
Contributor

@ecoskey ecoskey commented Oct 24, 2025

Objective

current exponential falloff parametrization isn't intuitive, strays from previous "scale height" parametrization common in atmospheric scattering literature

Solution

  • Switch to a parametrization of the form
          -(1-p)/s    -1/s
         e         - e
f(p,s) = -----------------
                      -1/s
         1.0       - e

This is basically equivalent to the "scale height" parametrization e^-(1-p)/s for small values of scale, but also has the nice properties f(0, s) = 0, f(1, s) = 1 and has a broader domain for values of scale.

Testing

  • Ran the example, results looked good

@ecoskey ecoskey requested a review from mate-h October 24, 2025 01:24
@ecoskey ecoskey added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Oct 24, 2025
/// Returns a scattering medium representing an earthlike atmosphere.
///
/// Uses physically-based scale heights from Earth's atmosphere, assuming
/// a 60 km atmosphere height:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took this directly from your pr @mate-h, but isn't this meant to be 100km?

Falloff::Exponential { scale } => {
// fill discontinuity at scale == 0,
// arbitrarily choose linear falloff
if *scale == 0.0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This discontinuity is kind of unfortunate, since it's there because of the division by scale below. I'm fine with it though since it lets us stay close to the "scale height" parametrization.

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Very clear and a sensible parameterization. Does this need a migration guide if we get it in during 0.18?

@alice-i-cecile alice-i-cecile added this to the 0.18 milestone Oct 27, 2025
@ecoskey
Copy link
Contributor Author

ecoskey commented Oct 27, 2025

Very clear and a sensible parameterization. Does this need a migration guide if we get it in during 0.18?

Maybe? Up to you but I'd lean towards improving module docs instead, the main friction is going to be the whole new asset type anyways. This is also much closer to what's in 0.17 than what was merged in the general scattering PR.

@alice-i-cecile
Copy link
Member

Maybe? Up to you but I'd lean towards improving module docs instead, the main friction is going to be the whole new asset type anyways. This is also much closer to what's in 0.17 than what was merged in the general scattering PR.

Let's prioritize that then. Better docs are much more durable. I won't block on it in this PR.

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

Labels

A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants