[PR #78] [MERGED] Rain and snow: tile the weather texture like WeatherEffectRenderer (fixes #71) #2309

Closed
opened 2026-11-02 15:54:49 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/78
Author: @ludovic111
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @ludovic111

Base: main ← Head: fix/rain-length-71


📝 Commits (1)

  • b723ef9 Rain and snow: tile the weather texture like WeatherEffectRenderer (#71)

📊 Changes

6 files changed (+513 additions, -58 deletions)

View changed files

➕ crates/horizon-client/examples/weather_fixture.rs (+59 -0)
📝 crates/horizon-client/src/game.rs (+54 -58)
📝 crates/horizon-client/src/lib.rs (+1 -0)
➕ crates/horizon-client/src/weather.rs (+273 -0)
➕ mods/horizon/src/test/java/dev/horizonlab/parity/VanillaWeatherRenderOracle.java (+87 -0)
➕ tools/test_weather_render_parity.py (+39 -0)

📄 Description

What was wrong

Rain streaks were about five times too long. weather_geometry drew each column as one quad from the column bottom to its top (up to 20 blocks) but sampled only a fixed quarter of rain.png over the whole height, so the texture was stretched.

What vanilla does

WeatherEffectRenderer.prepareInstances sets v = y * 0.25 + vOffset at each end of the column and draws with a repeating sampler, so rain.png (64×256) repeats every 4 blocks. The rest of the port, also from WeatherEffectRenderer (26.3):

  • createRainColumnInstance: per-column speed 3 + nextFloat() from a random reseeded with the column seed, scroll from the level's game time (ticks & 131071) and tickOffset, wrapped % 32.
  • createSnowColumnInstance: sideways drift (nextDouble + nextGaussian), its own scroll, brightened light ((l * 3 + 15) / 4).
  • extractRenderState: square of side 2 * weatherRadius + 1 (the Weather Radius option, it was hard-coded to 10 and cut to a circle), precipitation looked up at the camera's y, light at max(cameraY, terrainHeight), all rain columns drawn before snow.
  • prepareInstances: alpha lerp(min(d² / r², 1), maxAlpha, 0.5) * intensity (snow max 0.8), half-widths from the constructor's 32×32 table relative to the camera block (the camera's own column is 0/0, degenerate as in vanilla).

Horizon samples the sprite from its atlas, so weather::tile splits each quad at every whole texture repeat (in u and v) and maps each piece onto the sprite. The new crates/horizon-client/src/weather.rs holds the column builder; game.rs only gathers columns and emits vertices.

How it's tested

  • New differential harness tools/test_weather_render_parity.py (oracle VanillaWeatherRenderOracle calls the shipped createRainColumnInstance, createSnowColumnInstance and prepareInstances; probe examples/weather_fixture.rs): 513/513 cases match bit for bit (column instances, the four vertices' positions, uv, ARGB and light), including large coordinates, tick wrap-around, every weather radius and the camera's own column.
  • Unit tests for the texture tiling (weather::tests).
  • Same saved world (plains, rain, standing on a stone platform, rd 8) on vscreen, Horizon before/after and vanilla 26.3 joined into the same save: before, streaks run the whole 20-block column; after, they are short, 4-block-period streaks like vanilla. (Screenshots kept locally; the vanilla one contains Mojang textures so it isn't uploaded.)
  • cargo fmt --all --check, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace, python tools/check_public_tree.py.

Not changed: the MOTION_BLOCKING height scan (rain_height) and the precipitation temperature approximation (no temperature noise above y 80) are as before.

Fixes #71

🤖 Generated with Claude Code


🔄 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/78 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/rain-length-71` --- ### 📝 Commits (1) - [`b723ef9`](https://github.com/horizon-rust/horizon/commit/b723ef98282004a2b88bba90c8abc7086e478080) Rain and snow: tile the weather texture like WeatherEffectRenderer (#71) ### 📊 Changes **6 files changed** (+513 additions, -58 deletions) <details> <summary>View changed files</summary> ➕ `crates/horizon-client/examples/weather_fixture.rs` (+59 -0) 📝 `crates/horizon-client/src/game.rs` (+54 -58) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) ➕ `crates/horizon-client/src/weather.rs` (+273 -0) ➕ `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaWeatherRenderOracle.java` (+87 -0) ➕ `tools/test_weather_render_parity.py` (+39 -0) </details> ### 📄 Description ## What was wrong Rain streaks were about five times too long. `weather_geometry` drew each column as one quad from the column bottom to its top (up to 20 blocks) but sampled only a fixed quarter of `rain.png` over the whole height, so the texture was stretched. ## What vanilla does `WeatherEffectRenderer.prepareInstances` sets `v = y * 0.25 + vOffset` at each end of the column and draws with a repeating sampler, so `rain.png` (64×256) repeats every 4 blocks. The rest of the port, also from `WeatherEffectRenderer` (26.3): - `createRainColumnInstance`: per-column speed `3 + nextFloat()` from a random reseeded with the column seed, scroll from the level's game time (`ticks & 131071`) and `tickOffset`, wrapped `% 32`. - `createSnowColumnInstance`: sideways drift (`nextDouble` + `nextGaussian`), its own scroll, brightened light (`(l * 3 + 15) / 4`). - `extractRenderState`: square of side `2 * weatherRadius + 1` (the Weather Radius option, it was hard-coded to 10 and cut to a circle), precipitation looked up at the camera's y, light at `max(cameraY, terrainHeight)`, all rain columns drawn before snow. - `prepareInstances`: alpha `lerp(min(d² / r², 1), maxAlpha, 0.5) * intensity` (snow max 0.8), half-widths from the constructor's 32×32 table relative to the camera block (the camera's own column is 0/0, degenerate as in vanilla). Horizon samples the sprite from its atlas, so `weather::tile` splits each quad at every whole texture repeat (in u and v) and maps each piece onto the sprite. The new `crates/horizon-client/src/weather.rs` holds the column builder; `game.rs` only gathers columns and emits vertices. ## How it's tested - New differential harness `tools/test_weather_render_parity.py` (oracle `VanillaWeatherRenderOracle` calls the shipped `createRainColumnInstance`, `createSnowColumnInstance` and `prepareInstances`; probe `examples/weather_fixture.rs`): **513/513 cases match** bit for bit (column instances, the four vertices' positions, uv, ARGB and light), including large coordinates, tick wrap-around, every weather radius and the camera's own column. - Unit tests for the texture tiling (`weather::tests`). - Same saved world (plains, rain, standing on a stone platform, rd 8) on vscreen, Horizon before/after and vanilla 26.3 joined into the same save: before, streaks run the whole 20-block column; after, they are short, 4-block-period streaks like vanilla. (Screenshots kept locally; the vanilla one contains Mojang textures so it isn't uploaded.) - `cargo fmt --all --check`, `cargo clippy --workspace --all-targets -D warnings`, `cargo test --workspace`, `python tools/check_public_tree.py`. Not changed: the MOTION_BLOCKING height scan (`rain_height`) and the precipitation temperature approximation (no temperature noise above y 80) are as before. Fixes #71 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:54:49 +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#2309
No description provided.