Skip to content

Conversation

@peterbraden
Copy link
Owner

@peterbraden peterbraden commented Mar 21, 2025

Experimenting with Claude Code to refactor the sky-sphere implementation.

Details: https://peterbraden.co.uk/article/vibe-coding/

peterbraden and others added 8 commits March 18, 2025 19:55
…lors

This commit addresses a bug in the sky rendering implementation that significantly affected the appearance of sunset colors.

Key changes:
1. Fixed how optical depth was accumulated and used in the tau calculation, ensuring the atmospheric extinction properly accounts for the full path light travels through the atmosphere
2. Removed the redundant `calculate_sample_scattering()` function and integrated its functionality directly into the main scatter loop for better clarity
3. Added detailed documentation explaining the two approaches to optical depth calculation (accumulated vs per-sample) and their physical implications
4. Ensured the implementation uses the physically accurate accumulated optical depth approach which produces the characteristic red hues at sunset

Technical details:
- The bug occurred because we were using per-sample optical depth in the tau calculation rather than the cumulative value
- Optical depth needs to accumulate along the entire light path to correctly model wavelength-dependent atmospheric scattering (Rayleigh scattering)
- The tau calculation now properly uses optical_depth_r + optical_depth_light_r for Rayleigh and optical_depth_m + optical_depth_light_m for Mie
- This ensures light traveling through more atmosphere (as at sunrise/sunset) correctly exhibits more pronounced reddening

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit updates the documentation to clarify that accumulated optical
depth is the only physically correct approach based on the Beer-Lambert law.
Removes misleading references to an alternative approach which would be
physically incorrect.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@peterbraden peterbraden merged commit 009e94d into master Mar 24, 2025
1 check passed
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.

2 participants