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

Procedural atmospheric scattering #16314

Merged
merged 144 commits into from
Jan 23, 2025
Merged

Conversation

ecoskey
Copy link
Contributor

@ecoskey ecoskey commented Nov 9, 2024

Implement procedural atmospheric scattering from Sebastien Hillaire's 2020 paper. This approach should scale well even down to mobile hardware, and is physically accurate.

Co-author: @mate-h

He helped massively with getting this over the finish line, ensuring everything was physically correct, correcting several places where I had misunderstood or misapplied the paper, and improving the performance in several places as well. Thanks!

Credits

@aevyrie: helped find numerous bugs and improve the example to best show off this feature :)

Built off of @mtsr's original branch, which handled the transmittance lut (arguably the most important part)

Showcase:

sunset
twilight

For followup

  • Integrate with pcwalton's volumetrics code
  • refactor/reorganize for better integration with other effects
  • have atmosphere transmittance affect directional lights
  • add support for generating skybox/environment map

@jnhyatt
Copy link
Contributor

jnhyatt commented Jan 20, 2025

I think there may be an issue with units? I ran the atmosphere example and set the camera transform to Transform::from_xyz(0.0, 10.0, 0.0).looking_to(Dir3::X, Dir3::Y) and here's what I'm seeing:
image
I assume the altitude is derived from the camera's height? Leaving aside the issue that this won't work for games set in space, 10 meters elevation shouldn't look like this. I'm still reading through the paper and coming to grips with the code, but I'm wondering if for example y=1 is corresponding to "edge of the atmosphere" maybe?
I just found the scene_units_to_m parameter. That explains everything!

}
}

fn configure_camera_depth_usages(
Copy link
Contributor

Choose a reason for hiding this comment

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

I really dislike how we have that system in a bunch of different places. Don't need to do anything in this PR but I think there's something a bit weird with the fact that we need it in so many places.

Copy link
Contributor

@IceSentry IceSentry left a comment

Choose a reason for hiding this comment

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

I can't really comment on the math, but the results look good and the implementation itself is fine.

I added a few minor comments but none of them are blockers.

@IceSentry IceSentry added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 21, 2025
@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Jan 22, 2025
@ecoskey
Copy link
Contributor Author

ecoskey commented Jan 23, 2025

bevy_example_runner results: https://pixel-eagle.com/project/B25A040A-A980-4602-B90C-D480AB84076D?filter=PR-16314

Nothing seems super out of place

@pcwalton pcwalton removed their request for review January 23, 2025 08:39
@pcwalton
Copy link
Contributor

Unassigning myself as this has enough reviews already.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 23, 2025
@alice-i-cecile
Copy link
Member

Agreed, merging :) Thanks!

should fix NaN issue, scene seems unaffected
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 23, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 23, 2025
Merged via the queue into bevyengine:main with commit 81a25bb Jan 23, 2025
32 checks passed
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-Feature A new feature, making something new possible D-Complex Quite challenging from either a design or technical perspective. Ask for help! M-Needs-Release-Note Work that should be called out in the blog due to impact S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

10 participants