Shader packs: keep what Iris does, drop what doesn't work, apply settings on Done
Review fixes for #1414 (contribution gate): - Java packs no longer get Horizon's shadow map: it was mirrored in y and reversed in depth against the GL conventions the packs sample with, had no distortion and only the camera's sections, so BSL drew no shadows while the pass cost 0.65 ms (MakeUp, M4 Pro). shadowtex* stays a far depth, as on main; the packs' own shadow programs are #1326. - Invented uniforms removed (centerDepthSmooth fixed at 0.5, ambientOcclusionLevel and shadowMapResolution as uniforms, constant temp/rainfall/biome/held items); an unknown uniform stays zero as before. wetness keeps its Iris smoothing. Unused directives removed. - texture.<stage>.<sampler> is scoped to Iris's stages (final reads the composite ones) instead of overriding the sampler in every pass; texture.noise replaces noisetex. One noise generator and one RGBA upload for both pack kinds. - The G-buffer pass, the opaque-depth copy and the shadow pass run only for a pack that reads them (naga's per-entry-point binding use, not a text search): every pack paid all three before. - Api 2's prelude additions go in their own file after api 1's, so api 1 packs keep the names they declare (aces_tonemap, material_at...). - Stage kinds shadow, gbuffer, deferred and final ran as composite: only composite is accepted; api 2 adds formats (validated), profiles, option descriptions and a noise texture. - Shader Pack Settings applies once when the page closes, as Iris's Done (each click or slider step rebuilt the pack: 2.7 s per click, 12.7 s for one drag with BSL). Labels follow Iris (.lang, else the name). A pack whose options can't be read isn't read again every frame. - Saved option values an option doesn't list are ignored, as OptiFine's ShaderOption.setValue (a stale file broke BSL's compile). - Import: the blocking file dialog (osascript/zenity/kdialog/PowerShell on the event loop) is gone; a pack dropped on the Shader Packs page is copied and picked, as Iris's onFilesDrop. Drops elsewhere do nothing, an existing pack isn't overwritten, links aren't followed. - Docs and the example say what the code does (SSAO, not GTAO). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+62
-12
@@ -13,16 +13,18 @@ Both are off by default. With no pack selected the renderer draws exactly what i
|
||||
| Part | State |
|
||||
| --- | --- |
|
||||
| Renderer layout (below) | today's code |
|
||||
| Horizon shader packs: `composite`, `deferred`, `gbuffer`, `shadow`, `final` stages (API 2), uniforms, custom textures, hot reload | done (`examples/shaderpacks/horizon-ultra` + `horizon-sample`) |
|
||||
| Shader Packs UI: import (`.zip`/folder dialog + drag-and-drop), profiles, sub-screens, sliders, toggles, reset to defaults | done (Horizon & Classic Video/Graphics settings) |
|
||||
| Real-time shadow map pass (`"Horizon shadow"`, `shadowtex0/1`, `shadowModelView`, `shadowProjection`) & pre-translucent depth (`depthtex1/2`) | done |
|
||||
| G-buffer normal & material pass (`"Horizon gbuffer"`, `scene_normal`, `scene_material`, `colortex1..3` initialization) | done |
|
||||
| Java shader packs: preprocessor (`crates/horizon-shaderpack`: includes, options, Iris's macros, JCPP's `#if` and `#define` rules, `.lang` files) | done: ten packs tested (Compatibility, below) |
|
||||
| Java shader packs: GLSL → WGSL (`horizon_shaderpack::translate`: syntax-tree legaliser, naga, 2D array & struct varyings, vertex `textureLod`, `mat2(vec4)`, `1 << 31` shifts) | done |
|
||||
| Java shader packs: `shaders.properties` (`horizon_shaderpack::properties`: screens, sliders, profiles, `program.*.enabled`, image formats, blend modes, custom textures) | done, wired to UI and GPU passes |
|
||||
| Java shader packs: full-screen pass plan (`horizon_shaderpack::pipeline`: `DRAWBUFFERS`/`RENDERTARGETS`, `colortexN` formats and clearing, buffer flips, blend state) | done |
|
||||
| Java shader packs: full-screen passes drawn (`java_pack.rs`, `gfx/java_stages.rs`: `begin`, `prepare`, `deferred*`, `composite*`, `final` over Horizon's world) | done: with shadow maps, `depthtex1/2`, custom PNG textures, GL blend modes, `wetness`, `centerDepthSmooth` |
|
||||
| Java shader packs: custom uniforms (`horizon_shaderpack::uniforms`), `sunPathRotation`, `clouds`/`sun`/`moon`, eye light | done |
|
||||
| Horizon shader packs: `composite` stage, uniforms, hot reload, Shader Packs page | done (the page: list, pick, open the folder, drop a pack on it) |
|
||||
| Horizon shader packs, api 2: stage `format`s, `[profiles]`, option descriptions, a `noise` texture, the opaque depth, a G-buffer reconstructed from depth, a sun/moon shadow map (Stages, below) | first slice: `examples/shaderpacks/horizon-ultra` |
|
||||
| Horizon shader packs: `deferred`, `gbuffer`, `shadow` stages (the pack's own code in the world pass) | planned |
|
||||
| Shader Pack Settings page: a pack's options, sub-screens, sliders, profiles and Reset, Horizon and Java packs alike; applied once on Done, as Iris does | done |
|
||||
| Java shader packs: preprocessing + GLSL parse coverage | spike done: 450 of 470 programs reach valid WGSL (below) |
|
||||
| Java shader packs: preprocessor (`crates/horizon-shaderpack`: includes, options, Iris's macros, JCPP's `#if` and `#define` rules, `.lang` files) | done: every program of the three test packs preprocesses; ten packs tested (Compatibility, below) |
|
||||
| Java shader packs: GLSL → WGSL (`horizon_shaderpack::translate`: syntax-tree legaliser, naga; struct and nested-array varyings, vertex `texture`, `mat2(vec4)`, `1 << 31`) | done: the 464 programs the three test packs enable by default translate (below) |
|
||||
| Java shader packs: `shaders.properties` (`horizon_shaderpack::properties`: screens, sliders, profiles, `program.*.enabled`, image formats, blend modes, `texture.*`) | done: read like Iris for the three test packs |
|
||||
| Java shader packs: full-screen pass plan (`horizon_shaderpack::pipeline`: `DRAWBUFFERS`/`RENDERTARGETS`, `colortexN` formats and clearing, buffer flips, `blend.*`) | done: planned for the three test packs |
|
||||
| Java shader packs: full-screen passes drawn (`java_pack.rs`, `gfx/java_stages.rs`: `begin`, `prepare`, `deferred*`, `composite*`, `final` over Horizon's world) | first slice: BSL and Complementary run (below); `depthtex1`/`depthtex2` before translucent geometry, `blend.*`, PNG `texture.<stage>.*` and `texture.noise` |
|
||||
| Java shader packs: custom uniforms (`horizon_shaderpack::uniforms`), `sunPathRotation`, `clouds`/`sun`/`moon`, eye light, `wetness` | done for the full-screen passes (below) |
|
||||
| Java shader packs: `gbuffers_*`, `shadow`, `.dat` and resource-location textures, images, compute | planned |
|
||||
|
||||
## How the renderer draws a frame today
|
||||
|
||||
@@ -63,7 +65,14 @@ The lightmap, fog and sky colours are computed on the CPU (`environment.rs`, `fo
|
||||
Horizon Settings... → Shader Packs...**, and the Shader Pack row of the graphics settings lead to it. It shows the folder's full path
|
||||
and an *Open Folder* button (the folder is made if it is missing), then one switch per pack: turning one on picks
|
||||
it, turning it off is the vanilla picture. With no pack, it says so under the path. The list is read again every
|
||||
second while the page is open, so a pack dropped into the folder shows up.
|
||||
second while the page is open, so a pack dropped into the folder shows up. A `.zip` or pack folder dropped on the
|
||||
window while the page shows is copied into the folder and picked (Iris's `ShaderPackScreen.onFilesDrop`); one of
|
||||
that name already there is left alone.
|
||||
- With a pack on that has options, **Shader Pack Settings...** opens them: Horizon packs' `[options]` and
|
||||
`[profiles]`, Java packs' `#define`/`const` options laid out by `shaders.properties` (`screen`, `screen.<name>`,
|
||||
`sliders`, `profile.*`) and named by `lang/en_us.lang` (`option.*`, `value.*`, `screen.*`, `profile.*`, as Iris;
|
||||
without one, the option's own name). The values are saved and the pack built again once, when the page closes
|
||||
(Iris applies on Done), not on every click or slider step. A saved value an option doesn't list is ignored.
|
||||
- The choice is kept in `horizon-graphics.txt` (`shaderPack:<folder or zip name>`, empty = off). A pack's option
|
||||
values are kept in `shaderpacks/<pack>.txt`, as Iris does.
|
||||
- A pack that fails to load or compile leaves the vanilla picture (or the last pack that worked) on and says why on
|
||||
@@ -79,7 +88,7 @@ my-pack/
|
||||
composite.wgsl
|
||||
bloom.wgsl
|
||||
textures/
|
||||
noise.png # planned
|
||||
noise.png # api 2: [textures] noise
|
||||
LICENSE
|
||||
```
|
||||
|
||||
@@ -112,6 +121,24 @@ step = 0.05
|
||||
[options.vignette]
|
||||
label = "Vignette"
|
||||
default = true
|
||||
description = "Darkens the corners." # optional: the button's tooltip
|
||||
```
|
||||
|
||||
Api 2 (`api = 2`) adds:
|
||||
|
||||
```toml
|
||||
[[stage]]
|
||||
kind = "composite"
|
||||
shader = "shaders/lighting.wgsl"
|
||||
format = "rgba16float" # this stage's target: rgba8unorm, rgba16float or rgb10a2unorm; the last stage
|
||||
# always writes the screen's format, so earlier ones can keep HDR colour
|
||||
|
||||
[profiles.low] # the Profile button cycles these; "Custom" when the values match none
|
||||
vignette = false
|
||||
saturation = 1.0
|
||||
|
||||
[textures]
|
||||
noise = "textures/noise.png" # replaces the prelude's noise_texture (256x256 random RGB without it)
|
||||
```
|
||||
|
||||
Options become WGSL [pipeline-overridable constants](https://www.w3.org/TR/WGSL/#override-decls): the shader
|
||||
@@ -176,6 +203,29 @@ Prelude helpers: `linear_depth(depth) -> f32` (blocks from the eye), `view_posit
|
||||
The uniform layout only grows: a new field goes at the end and the `api` number goes up; a pack that declares an
|
||||
older `api` still loads.
|
||||
|
||||
An `api = 2` pack's stages get a second prelude after the first (`shader_pack_prelude_api2.wgsl`; api 1 packs don't,
|
||||
so names they declare themselves can't clash):
|
||||
|
||||
| Binding | WGSL | What |
|
||||
| --- | --- | --- |
|
||||
| 6 | `frame_ext: FrameExt` (uniform) | last frame's view and projection and camera, the shadow map's matrices, resolution and distance, eye light, smoothed rain |
|
||||
| 7, 8 | `scene_normal`, `scene_material: texture_2d<f32>` | the G-buffer (below) |
|
||||
| 9 | `opaque_depth: texture_depth_2d` | the world's depth before translucent geometry (water, glass, ice) |
|
||||
| 10, 11 | `shadow_depth: texture_depth_2d`, `shadow_sampler: sampler_comparison` | the sun's (the moon's at night) shadow map |
|
||||
| 12, 13 | `noise_texture: texture_2d<f32>`, `repeat_sampler: sampler` | `[textures] noise`, linear, repeat |
|
||||
|
||||
Helpers: `opaque_depth_at(uv)`, `world_normal_at(uv)`, `material_at(uv)` (block light, sky light, translucent mask,
|
||||
roughness), `reproject_uv(world_offset)` (last frame's uv and depth), `sample_shadow(world_offset, normal)` (5-tap
|
||||
PCF, 1 lit .. 0 shadowed), `aces_tonemap(rgb)`.
|
||||
|
||||
What each costs, only while a stage reads it (naga reports the bindings each entry point uses): the opaque depth, a
|
||||
depth copy between the opaque and translucent halves of the world pass; the G-buffer, one full-screen pass after
|
||||
the world; the shadow map, a depth pass of the terrain and entities from the light. Limits of this first slice: the
|
||||
G-buffer is reconstructed from depth and colour (normals from neighbouring depths, block light estimated from
|
||||
brightness, sky light the camera's), not written by the world's shaders; the shadow map holds the sections the
|
||||
camera draws, so casters outside the view throw no shadow, and none of the terrain where Metal draws sections as one
|
||||
list (`gfx/flat.rs`, more than 4096 of them). The `deferred`, `gbuffer` and `shadow` stages above replace these.
|
||||
|
||||
### How it renders
|
||||
|
||||
With a pack on, the world pass draws into the world target of `gfx/world_post.rs` (it exists already for resolution
|
||||
|
||||
Reference in New Issue
Block a user