diff options
| author | Jeremy Goldberg <goldberg.jeremy02@gmail.com> | 2026-11-22 17:50:46 -0500 |
|---|---|---|
| committer | Jeremy Goldberg <goldberg.jeremy02@gmail.com> | 2026-11-22 17:50:46 -0500 |
| commit | 3b598a9be4bf9f4bc5adc0dfb8729308f5a3d5d6 (patch) | |
| tree | d1e588030ba2bf78b09326d06d453801c17b35d4 /docs/first_light.md | |
| parent | 3302d4ec81d17c2bb4ea8f45b8f09872eff1734f (diff) | |
| parent | aa2988cc555bad7ecd508b48a702adbb32fe7c95 (diff) | |
docs(first-light): distinguish UV and textured draw defaults
Refs: #3350
Diffstat (limited to 'docs/first_light.md')
| -rw-r--r-- | docs/first_light.md | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/docs/first_light.md b/docs/first_light.md index f68285b0e..7ed0d8c1c 100644 --- a/docs/first_light.md +++ b/docs/first_light.md | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | # First light: a game model's UVs drawn with translated game shaders | 1 | # Drawing model UVs and textures with First Light |
| 2 | 2 | ||
| 3 | **Status: measured** on the 1.0.2.1 package and an NVIDIA RTX 2060 SUPER (driver 620.73.04, Vulkan 1.4.357, | 3 | **Status: measured** on the 1.0.2.1 package and an NVIDIA RTX 2060 SUPER (driver 620.73.04, Vulkan 1.4.357, |
| 4 | CachyOS). The fixture draws a model from the package with a vertex and pixel shader chosen to display its UVs. The image | 4 | CachyOS). The untextured fixture draws a model from the package with a shader pair chosen to display its UVs. |
| 5 | stays in the user's work folder; this note records the counts and the recipe, not the model, the shaders or a | 5 | With `--dds`, the default pixel shader samples the supplied texture at those UVs. Section 6 gives the textured |
| 6 | screenshot. | 6 | draw recipe. The image stays in the user's work folder. |
| 7 | 7 | ||
| 8 | ## 1. What was drawn | 8 | ## 1. What was drawn |
| 9 | 9 | ||
| @@ -14,7 +14,7 @@ those counts and has SHA-256 | |||
| 14 | assembles it, `tools/first_light.py`, centres and fits X/Y to NDC and flattens Z (the chosen VS applies no | 14 | assembles it, `tools/first_light.py`, centres and fits X/Y to NDC and flattens Z (the chosen VS applies no |
| 15 | matrix), so the draw is an orthographic projection of the model's own geometry. | 15 | matrix), so the draw is an orthographic projection of the model's own geometry. |
| 16 | 16 | ||
| 17 | The shaders are two ordinary containers from `shaders.rpf`, carved and translated by the repository's own tools: | 17 | The untextured fixture uses two containers from `shaders.rpf`, carved and translated by the repository's tools. |
| 18 | 18 | ||
| 19 | | stage | FSSM SHA-256 | what it does | | 19 | | stage | FSSM SHA-256 | what it does | |
| 20 | |---|---|---| | 20 | |---|---|---| |
| @@ -25,7 +25,7 @@ The model's authored shader assignment can be checked separately. In the model e | |||
| 25 | above, `MeshShaders[0]` selects material slot 0, the only slot. Looking up its `Materials[0].Shader` in the | 25 | above, `MeshShaders[0]` selects material slot 0, the only slot. Looking up its `Materials[0].Shader` in the |
| 26 | native shader database yields one effect with one technique and four compute-only passes. The VS and PS | 26 | native shader database yields one effect with one technique and four compute-only passes. The VS and PS |
| 27 | in the table are the fixture's chosen pair. The model's use during gameplay remains unverified. | 27 | in the table are the fixture's chosen pair. The model's use during gameplay remains unverified. |
| 28 | See the [effect lookup](https://github.com/ItsNotRexed/Leonida/pull/3036) and the | 28 | See the [effect lookup tool](../tools/sgd5_effects.py) and the |
| 29 | [Windows reproduction of the UV draw](https://github.com/ItsNotRexed/Leonida/pull/2893#issuecomment-7084947193). | 29 | [Windows reproduction of the UV draw](https://github.com/ItsNotRexed/Leonida/pull/2893#issuecomment-7084947193). |
| 30 | 30 | ||
| 31 | Both disassemble with no invalid word, translate, and pass `spirv-val`; `tools/shader_link_check.py check` reports | 31 | Both disassemble with no invalid word, translate, and pass `spirv-val`; `tools/shader_link_check.py check` reports |
| @@ -110,12 +110,41 @@ LEONIDA_FIRST_LIGHT_DIR=~/leonida-work/first_light/out ctest --test-dir <build> | |||
| 110 | 110 | ||
| 111 | Without `LEONIDA_FIRST_LIGHT_DIR` the test prints SKIP and exits 77. | 111 | Without `LEONIDA_FIRST_LIGHT_DIR` the test prints SKIP and exits 77. |
| 112 | 112 | ||
| 113 | ## 6. Limits and next | 113 | ## 6. With a texture (`TEST-524`) |
| 114 | |||
| 115 | Passing `--dds <exported.dds>` to `tools/first_light.py` switches the default pixel shader to a translated | ||
| 116 | single-sample game pixel shader (`PS_Copy_3ea4b38a_Wrapped`, FSSM SHA-256 | ||
| 117 | `19e2e7612505b9d3b19e6607b47e09dcdde02a2c9987a63e834d9586f217090f`, wave32, `inputs=[0]`, `outputs=[0]`, | ||
| 118 | `shader_link_check.py check`: compatible with `VS_main_170e32e6_Wrapped`). `first_light.py` decodes the DDS | ||
| 119 | (for example a BCPack-decoded TTPF albedo) with `tools/dds_png.py`, writes `texture.rgba` (`u32 width, u32 height` + | ||
| 120 | `R8G8B8A8_UNORM` texels) into the output folder, and passes `VKH_TEX_RGBA`, `VKH_TSHARP_VA` (`0x100`), | ||
| 121 | `VKH_SSHARP` (the shader's literal sampler `0x92, 0xc00000, 0x14500000, 0`, bilinear + clamp-to-edge) and | ||
| 122 | `VKH_SGPRS` (`s9 = 0x100`) to `vk_harness`. | ||
| 123 | |||
| 124 | `vk_harness` enables `bufferDeviceAddress`, `runtimeDescriptorArray` and `descriptorIndexing` only when | ||
| 125 | `VKH_TEX_RGBA` is set (inert otherwise), writes the 8-dword `T#` at `VKH_TSHARP_VA` in the 64 KiB heap, binds | ||
| 126 | set 0 (`binding 0` 2D images with a 1×1 magenta fallback at index 0 and the decoded texture at index 1; `binding 1` | ||
| 127 | samplers with the decoded `S#` at index 1; `binding 2` the `DescriptorTable` hash buffer), and draws the mesh. | ||
| 128 | |||
| 129 | The CPU oracle (`check_image`) samples the decoded `R8G8B8A8_UNORM` texture bilinearly (clamp-to-edge) at | ||
| 130 | `centre_uv` and each `uv_probes` entry and requires the GPU readback to match within `0.02` (rejecting the | ||
| 131 | magenta unbound-texture fallback and wrong-colour probes). Verified on Windows 11 with an NVIDIA GeForce RTX 3060 | ||
| 132 | (driver 621.24, Vulkan 1.4.357): **12,804/16,384 (0.781)** covered. Without `LEONIDA_FIRST_LIGHT_DIR`, | ||
| 133 | `python -I tests/test_first_light.py -v` runs **14 tests: 11 passed, 3 skipped** (the 3 package-gated | ||
| 134 | `FirstLightTests` require `LEONIDA_FIRST_LIGHT_DIR`; the 4 `OracleTests` and 7 `TexturedOracleTests` run without a | ||
| 135 | package). With `LEONIDA_FIRST_LIGHT_DIR` set against a local package run, all **14/14** tests pass. | ||
| 136 | |||
| 137 | ```sh | ||
| 138 | python -I tools/first_light.py --game "<package>" --work ~/leonida-work \ | ||
| 139 | --obj ~/leonida-work/assets/data/models/<model>.obj \ | ||
| 140 | --dds ~/leonida-work/assets/ttpf/<pool>/<texture>.dds --no-fit --run | ||
| 141 | LEONIDA_FIRST_LIGHT_DIR=~/leonida-work/first_light/out python -I tests/test_first_light.py -v | ||
| 142 | ``` | ||
| 143 | |||
| 144 | ## 7. Limits and next | ||
| 114 | 145 | ||
| 115 | * The chosen VS applies no matrix; the tool's fit is an orthographic stand-in for the game's view/projection. A | 146 | * The chosen VS applies no matrix; the tool's fit is an orthographic stand-in for the game's view/projection. A |
| 116 | real camera needs a VS that reads its constants, which is the next model/shader pair. | 147 | real camera needs a VS that reads its constants, which is the next model/shader pair. |
| 117 | * No texture: the PS writes the UV map. A texture path needs a TTPF albedo, BCPack decode, a T# in the bindless | ||
| 118 | set and the game's sampler. | ||
| 119 | * One model and one draw. The `levels.rpf` windows have world props with POSITION/NORMAL/COLOUR/UV layouts that | 148 | * One model and one draw. The `levels.rpf` windows have world props with POSITION/NORMAL/COLOUR/UV layouts that |
| 120 | match the `sga_dr_*`/`Rage_Transform*` families by signature; pairing one of those is the natural next image. | 149 | match the `sga_dr_*`/`Rage_Transform*` families by signature; pairing one of those is the natural next image. |
| 121 | * The game still cannot boot: the executable is not in the package (RT-5), so no call site selects these programs. | 150 | * The game still cannot boot: the executable is not in the package (RT-5), so no call site selects these programs. |