[PR #3993] [MERGED] Reduce sunrise fan intersection work with projected sector selection #5341

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3993
Author: @Vasysik
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: perf/sunrise-sector-selection


📝 Commits (2)

  • 79360c5 Reduce sunrise fan intersection work with projected sector selection
  • 4af27b5 sunrise_fan: restore the comments' Möller and × characters

📊 Changes

3 files changed (+345 additions, -3 deletions)

View changed files

📝 crates/horizon-client-render/src/gfx/sunrise_fan.rs (+111 -2)
📝 crates/horizon-client-render/src/terrain.wgsl (+45 -1)
➕ crates/horizon-client-render/tests/sunrise_shader.rs (+189 -0)

📄 Description

🤖 Opened by Vasysik's AI agent (OpenAI Codex, GPT-6), not by Vasysik personally.

Fixes #3992

The shared sunrise/sunset shader still scans all 16 projected fan triangles for each sky pixel after the CPU-normal optimization for #3143. On an Adreno 710 tablet this remained a substantial GPU cost in a frozen, warmed dawn scene, independently of chunk generation.

Select the projected angular sector using magnitude comparisons with tan(PI/8), test it and the opposite sector, and reject rays on the wrong side of the fan. Adjacent sectors are retained near rounded boundaries and the full search remains for the degenerate projection. The barycentric calculation, fan vertices, colors and output resolution are unchanged.

The patch contains no Android-specific rendering code. Classic shader packs' sky geometry/GLSL path is unchanged. Native sky packs continue to use the automatically prefixed terrain sky helpers; tests cover name collisions and full terrain WGSL validation.

Validation

  • Eight focused checks passed in an isolated Rust harness using the exact files from this branch, without compiling or running the full game.
  • CPU comparisons cover a 360 x 179 direction grid at four alpha values on both horizons, plus randomized and exact rim directions.
  • The actual optimized and reference WGSL were compared on an NVIDIA RTX 4070 for 515,552 ray/alpha/horizon combinations, with absolute weight error below 1e-4. This is correctness testing, not an FPS benchmark.
  • Full terrain WGSL, native helper prefixing/name collisions, strict targeted Clippy and the public-tree check passed.
  • The upstream full-workspace pr_ready suite has not been run locally; CI still needs to validate the complete workspace. GPU correctness is an opt-in ignored integration test: cargo test -p horizon-client-render --test sunrise_shader -- --include-ignored --nocapture.

Full Windows game smoke checks

Built the actual PR branch with the optimized fast profile and launched four isolated, disposable profiles on an NVIDIA RTX 4070 (driver 610.88), with audio disabled and no player data. These were offscreen game runs in a generated test-terrain world, not FPS benchmarks.

  • Standard sky: Vulkan and DirectX 12; captured noon, sunrise and sunset, all normal exits, no shader validation errors or panics.
  • Native Golden Hour 1.0.0: sky, Glow and Colour grade stages loaded successfully on Vulkan.
  • Classic ZIP: the repository's terrain-test fixture loaded gbuffers_skybasic, celestial/terrain stages and composite successfully on Vulkan. The fixture intentionally changes output colors.
  • Other GPU vendors and operating systems have not been tested.

Existing Android measurements

POCO Pad 2405CPCFBG, Adreno 710, Android 16, 2560 x 1600, 16 chunks, Fancy graphics, fixed camera/time and warmed terrain. Each sample is 12 seconds, repeated twice. These are measurements from the Android integration of this algorithm, not a fresh benchmark of upstream main and not desktop or phone claims.

Renderer Before After
Vulkan batching 29.79–29.81 FPS; GPU 31.32–31.38 ms 57.48–59.71 FPS; GPU 14.50–15.17 ms
Vulkan compatibility 24.85–25.22 FPS; GPU 36.92–37.10 ms 43.99–44.61 FPS; GPU 20.73–20.76 ms

No general FPS improvement across GPUs or unrelated stalls is claimed.

🤖 Generated with OpenAI Codex.


🔄 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/3993 **Author:** [@Vasysik](https://github.com/Vasysik) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `perf/sunrise-sector-selection` --- ### 📝 Commits (2) - [`79360c5`](https://github.com/horizon-rust/horizon/commit/79360c58679c24c901eca75977851a3882e3c5f8) Reduce sunrise fan intersection work with projected sector selection - [`4af27b5`](https://github.com/horizon-rust/horizon/commit/4af27b50a804ca4ff394abe6e4ede150c6aab74d) sunrise_fan: restore the comments' Möller and × characters ### 📊 Changes **3 files changed** (+345 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/gfx/sunrise_fan.rs` (+111 -2) 📝 `crates/horizon-client-render/src/terrain.wgsl` (+45 -1) ➕ `crates/horizon-client-render/tests/sunrise_shader.rs` (+189 -0) </details> ### 📄 Description > 🤖 Opened by Vasysik's AI agent (OpenAI Codex, GPT-6), not by Vasysik personally. Fixes #3992 The shared sunrise/sunset shader still scans all 16 projected fan triangles for each sky pixel after the CPU-normal optimization for #3143. On an Adreno 710 tablet this remained a substantial GPU cost in a frozen, warmed dawn scene, independently of chunk generation. Select the projected angular sector using magnitude comparisons with tan(PI/8), test it and the opposite sector, and reject rays on the wrong side of the fan. Adjacent sectors are retained near rounded boundaries and the full search remains for the degenerate projection. The barycentric calculation, fan vertices, colors and output resolution are unchanged. The patch contains no Android-specific rendering code. Classic shader packs' sky geometry/GLSL path is unchanged. Native sky packs continue to use the automatically prefixed terrain sky helpers; tests cover name collisions and full terrain WGSL validation. ### Validation - Eight focused checks passed in an isolated Rust harness using the exact files from this branch, without compiling or running the full game. - CPU comparisons cover a 360 x 179 direction grid at four alpha values on both horizons, plus randomized and exact rim directions. - The actual optimized and reference WGSL were compared on an NVIDIA RTX 4070 for 515,552 ray/alpha/horizon combinations, with absolute weight error below 1e-4. This is correctness testing, not an FPS benchmark. - Full terrain WGSL, native helper prefixing/name collisions, strict targeted Clippy and the public-tree check passed. - The upstream full-workspace pr_ready suite has not been run locally; CI still needs to validate the complete workspace. GPU correctness is an opt-in ignored integration test: `cargo test -p horizon-client-render --test sunrise_shader -- --include-ignored --nocapture`. ### Full Windows game smoke checks Built the actual PR branch with the optimized `fast` profile and launched four isolated, disposable profiles on an NVIDIA RTX 4070 (driver 610.88), with audio disabled and no player data. These were offscreen game runs in a generated test-terrain world, not FPS benchmarks. - Standard sky: Vulkan and DirectX 12; captured noon, sunrise and sunset, all normal exits, no shader validation errors or panics. - Native Golden Hour 1.0.0: sky, Glow and Colour grade stages loaded successfully on Vulkan. - Classic ZIP: the repository's terrain-test fixture loaded `gbuffers_skybasic`, celestial/terrain stages and composite successfully on Vulkan. The fixture intentionally changes output colors. - Other GPU vendors and operating systems have not been tested. ### Existing Android measurements POCO Pad 2405CPCFBG, Adreno 710, Android 16, 2560 x 1600, 16 chunks, Fancy graphics, fixed camera/time and warmed terrain. Each sample is 12 seconds, repeated twice. These are measurements from the Android integration of this algorithm, not a fresh benchmark of upstream main and not desktop or phone claims. | Renderer | Before | After | | --- | --- | --- | | Vulkan batching | 29.79–29.81 FPS; GPU 31.32–31.38 ms | 57.48–59.71 FPS; GPU 14.50–15.17 ms | | Vulkan compatibility | 24.85–25.22 FPS; GPU 36.92–37.10 ms | 43.99–44.61 FPS; GPU 20.73–20.76 ms | No general FPS improvement across GPUs or unrelated stalls is claimed. 🤖 Generated with [OpenAI Codex](https://openai.com/codex/). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:11:55 +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#5341
No description provided.