[PR #3167] [MERGED] Build the sunset fan once a frame instead of in every sky pixel #4828

Closed
opened 2026-11-03 05:08:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3167
Author: @sleepe229
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix/3143-sunset-sky-cost


📝 Commits (2)

  • cd97b34 Build the sunset fan once a frame instead of in every sky pixel
  • 38712c4 Merge main into this branch after the render crate split (#3186)

📊 Changes

4 files changed (+155 additions, -29 deletions)

View changed files

📝 crates/horizon-client-render/src/entity.wgsl (+1 -0)
📝 crates/horizon-client-render/src/gfx.rs (+4 -0)
➕ crates/horizon-client-render/src/gfx/sunrise_fan.rs (+131 -0)
📝 crates/horizon-client-render/src/terrain.wgsl (+19 -29)

📄 Description

What and why

Fixes #3143.

While the sunrise/sunset glow is up (time around 11500-14500 and 22500-500), sunrise_weight in terrain.wgsl built the glow's 16 triangles again for every pixel of the fullscreen sky pass, with four sin/cos per triangle. /time set night is 13000, so the report landed right in that window.

The triangles only depend on the glow's alpha and which horizon the sun is on, so they're now built once per frame on the CPU (gfx/sunrise_fan.rs) and passed in Globals as normals. Per pixel the shader does dot products, and only triangles where the ray can hit get the full test. Shader packs that use the vanilla sky stage get the same change.

Sky pass only, 1920x1080, ms per frame:

GPU day dawn, before dawn, after
Intel UHD 730 0.56 -> 0.65 10.2 1.8
RTX 3060 0.04 0.47 0.27

The UHD 730 is the closest I have to the reporter's R7: the glow added about 9.7 ms per frame there, and their screenshots show about 8.6 ms (66 -> 42 fps). Day gets 0.09 ms slower on the UHD 730, probably from the bigger Globals.

The server tick doesn't change between day and night here (3.3 ms both, HORIZON_SPIKES), so nothing changed there.

Vanilla reference

Vanilla's sunrise/sunset fan in SkyRenderer, same geometry as before. The output doesn't change, so no harness covers it; the test in gfx/sunrise_fan.rs compares the new weights with the old per-pixel code over ~32k rays.

Self-check

pr_ready (tools/pr_ready.py --quick, against origin/main at b6c936f82, 3 min 49 s)

Check Result
Scope ✅ 4 files, +155 −29
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 398 passed (25 s)
rustfmt ✅ (5 s)
clippy ✅ (1 min 18 s)
tests: horizon-client ❌ failed (1 min 19 s)
doc tests ✅ 0 passed (42 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/3167 **Author:** [@sleepe229](https://github.com/sleepe229) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/3143-sunset-sky-cost` --- ### 📝 Commits (2) - [`cd97b34`](https://github.com/horizon-rust/horizon/commit/cd97b34460ce1e973a5ea6f21120450becd31c49) Build the sunset fan once a frame instead of in every sky pixel - [`38712c4`](https://github.com/horizon-rust/horizon/commit/38712c49ecf1c2ac4eb299d1f3206a42b2e51c93) Merge main into this branch after the render crate split (#3186) ### 📊 Changes **4 files changed** (+155 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/entity.wgsl` (+1 -0) 📝 `crates/horizon-client-render/src/gfx.rs` (+4 -0) ➕ `crates/horizon-client-render/src/gfx/sunrise_fan.rs` (+131 -0) 📝 `crates/horizon-client-render/src/terrain.wgsl` (+19 -29) </details> ### 📄 Description ## What and why Fixes #3143. While the sunrise/sunset glow is up (time around 11500-14500 and 22500-500), sunrise_weight in terrain.wgsl built the glow's 16 triangles again for every pixel of the fullscreen sky pass, with four sin/cos per triangle. /time set night is 13000, so the report landed right in that window. The triangles only depend on the glow's alpha and which horizon the sun is on, so they're now built once per frame on the CPU (gfx/sunrise_fan.rs) and passed in Globals as normals. Per pixel the shader does dot products, and only triangles where the ray can hit get the full test. Shader packs that use the vanilla sky stage get the same change. Sky pass only, 1920x1080, ms per frame: | GPU | day | dawn, before | dawn, after | |---|---|---|---| | Intel UHD 730 | 0.56 -> 0.65 | 10.2 | 1.8 | | RTX 3060 | 0.04 | 0.47 | 0.27 | The UHD 730 is the closest I have to the reporter's R7: the glow added about 9.7 ms per frame there, and their screenshots show about 8.6 ms (66 -> 42 fps). Day gets 0.09 ms slower on the UHD 730, probably from the bigger Globals. The server tick doesn't change between day and night here (3.3 ms both, HORIZON_SPIKES), so nothing changed there. ## Vanilla reference Vanilla's sunrise/sunset fan in SkyRenderer, same geometry as before. The output doesn't change, so no harness covers it; the test in gfx/sunrise_fan.rs compares the new weights with the old per-pixel code over ~32k rays. ## Self-check **pr_ready** (`tools/pr_ready.py --quick`, against origin/main at b6c936f82, 3 min 49 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +155 −29 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 398 passed (25 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (1 min 18 s) | | tests: horizon-client | ❌ failed (1 min 19 s) | | doc tests | ✅ 0 passed (42 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:08:14 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#4828
No description provided.