Raymarched rendering for atmosphere and spherical coordinates#20766
Conversation
|
It looks like your PR has been selected for a highlight in the next release blog post, but you didn't provide a release note. Please review the instructions for writing release notes, then expand or revise the content in the release notes directory to showcase your changes. |
|
It looks like your PR has been selected for a highlight in the next release blog post, but you didn't provide a release note. Please review the instructions for writing release notes, then expand or revise the content in the release notes directory to showcase your changes. |
Which part fixes that? Also this is #19131 |
Co-authored-by: atlv <email@atlasdostal.com>
|
Thanks for the comments! I think everything has been addressed, including what to do for when the camera is inside of the earth. I update the atmosphere example here for testing but decided not to include it in this PR to avoid more scope. I would say at this stage it's ready for a final review. I updated the PR description with a new demo video. |
atlv24
left a comment
There was a problem hiding this comment.
Fully happy with these changes now. Thanks for being patient :)
One last thing i'd consider is if view_pos never gets used directly (always immediately fed to length+normalize to get r and up) then maybe having get_view_position return a struct that has an up and radius field would make sense. Happy with it as is though, thanks for all the work!
|
@alice-i-cecile this one is ready for a final review and merge! |
alice-i-cecile
left a comment
There was a problem hiding this comment.
I'm happy with this too :) Quite clear, and a feature that a lot of our devs will love.
# Objective Since introducing spherical coordinate systems and space views for Bevy's atmosphere in PR #20766, the LUT-based rendering had a remaining bug: when tilting the camera and viewing Earth from space, the lit/dark terminator rotated with the view instead of staying fixed. Raymarched rendering was correct, only the LUT path was affected. This PR fixes that by using an atmosphere frame that keeps the terminator stable while still concentrating texel density toward the horizon as in the Hillaire paper. This is what the bug reproduction looks like on main: https://github.com/user-attachments/assets/e3488e41-d663-4b19-90c5-65b1fdb77b4c With this change, the atmosphere rendering from space is officially supported using the LUT based method. That can be taken advantage of in lower end devices, or on a tight performance budget. ## Solution - Compute the atmosphere frame with local up for zenith and a world-fixed azimuth - Use the atmosphere transform for both LUT generation and sampling via `direction_world_to_atmosphere`, effectively reverting this code block to the previous state before PR #20766 - Raymarch the sky view LUT from the actual camera position. ## Testing - Ran the atmosphere example by increasing the scene's scale ```rs AtmosphereSettings { scene_units_to_m: 10e4, aerial_view_lut_max_distance: 3.2e4 * 128.0, ..default() }, ``` --- ## Showcase new LUT based rendering: <img width="1278" height="754" alt="lutbased" src="https://github.com/user-attachments/assets/d4792c8e-43a2-4b03-a21d-330ce26c3474" /> raymarched rendering for reference "ground truth": <img width="1280" height="753" alt="raymarched" src="https://github.com/user-attachments/assets/909bfaf8-6abd-4338-bcfd-f94f7b3a6de2" />
Objective
Solution
Testing
Showcase
Screen.Recording.2025-09-02.at.12.28.35.AM.mov