Galaxy Shell / docs

Plan: loadable textures and black flame with N64 Fire

openspec/changes/archive/2026-10-28-theme-textures-plan/design.md · Editar no GitHub ↗

Esta página ainda não tem tradução em português. O conteúdo abaixo está em inglês.

Este documento registra decisões, planejamento ou evidências de uma etapa do projeto. Não implica que todos os itens estejam implementados ou validados na versão atual.

Nesta página

Plan: loadable textures and black flame with N64 Fire

Doc status: history. Plan of 2026-10-28 with its implementation record; the contract is docs/themes.md. Checked 2026-11-10.

Written on 2026-10-28, before the implementation of texture support. The user authorized adding textures to theme.json and using N64 Fire with noise to bring the black-flame effect closer to the Shadow Fire reference from Steam. Implementation by GPT-6 Luna at high effort; review, validation and operation by the main agent.

Starting point and result

The css-window-effects worktree holds an unpublished draft of the procedural frame. Preserve it and reuse its checks for alpha, identity and proportion, replacing the drawing with sampling of assets. The active folder in the home directory is at version 390cf3d; in the last survey, Studio was active in Smithay with only black-flame enabled. Discover the session and processes again before any real operation.

The theme declares PNG images and each effect chooses the samplers it uses. The compositor provides generic loading and composition. The interpretation of the atlas frames, the movement of the noise, the silhouette, the colors and the glow stay in the external GLSL/CSS. After this version of the engine is installed, changing images, shaders, parameters and metadata requires a reload, without recompiling.

Proposed contract

Add manifest v2 and keep accepting v1 without textures. A v1 manifest must not be able to declare textures silently. Example of the core of the contract, with final names to be confirmed while inspecting the APIs:

{
  "version": 2,
  "id": "studio",
  "name": "Studio",
  "textures": [
    {
      "id": "flame",
      "path": "assets/black-flame/n64-fire-atlas.png",
      "filter": "linear",
      "wrap": "clamp",
      "atlas": { "columns": 6, "rows": 5, "frames": 30, "fps": 30 }
    },
    {
      "id": "noise",
      "path": "assets/black-flame/turbulence.png",
      "filter": "linear",
      "wrap": "repeat"
    }
  ],
  "effects": [
    {
      "id": "black-flame",
      "path": "effects/black-flame",
      "target": "overview-f9",
      "enabled": true,
      "textures": { "flame": "flame", "noise": "noise" }
    }
  ]
}

IDs stay strict and unique. The binding names will be validated short ASCII identifiers and will produce a reserved namespace such as u_tex_flame. Provide the real dimensions and atlas metadata through documented uniforms; avoid collisions with CSS parameters, tex, alpha, u_time and u_size. The shader will use u_time to pick the frame. Do not put N64 Fire constants or flame formulas in Rust.

Loading, limits and GPU

  • Static PNG only; animations live in PNG atlases. Refuse APNG or formats that are not explicitly supported. Decode to RGBA8 with a maintained library and a dependency pinned in the lockfile. Handle grayscale/RGB/alpha explicitly, limit the decoder memory and convert to premultiplied alpha at load. No decoding, upload or disk read per frame.
  • Proposed limits: up to eight textures per theme, four bindings per effect, maximum side of 1024 pixels, PNG file up to 4 MiB, encoded sum up to 8 MiB and decoded sum up to 16 MiB. Keep the previous limit of 512 KiB for the manifest/CSS/GLSL, separate from the PNGs. Confirm memory and effective limits in the documentation and in the tests. Textures are shared across passes and windows of the same runtime, with no copy per thumbnail. Transactional validation can hold the images of the current theme and of the candidate at the same time.
  • Validate all listed files, including those of disabled effects: relative paths, regular files, no symlinks/traversal, bounded reading even if the file grows, dimensions and decoded size before allocating. Validate the whole atlas, capacity and division into cells. Do not accept URLs or embedded data.
  • Inspect the local Smithay 0.7.0 GLES API. Reserve unit zero for the window texture and extra units for the assets. Query the real device limit. Restore all modified GL state, including the active unit and bindings, also on failures. Sampler uniforms use integers; do not treat them as CSS floats. Do not change files in the Cargo cache or create an implicit dependency on a local patch.
  • In GLES2, repeated textures must respect the power-of-two dimension restrictions; the atlas can use clamp. Do not generate mipmaps that mix cells. Sample the atlas inside the half-texel margin to avoid leaking neighboring frames. Handle orientation and alpha consistently with the window texture.
  • Read, decode, compile and send the whole candidate to the GPU before switching the theme or persisting the selection. Any error preserves the previous shaders and textures. A failure to draw a pass keeps the fallback to the original surfaces. Free resources by ownership when replacing the runtime, with no leak per reload.

Assets and appearance

Use the N64 Fire package by n64guy, published as CC0 at https://opengameart.org/content/n64-fire. The research file is at /tmp/agent-native-open-vfx-research/n64-fire.zip. Check the contents and record the origin, the license, the hashes of the files used and the transformation into an atlas. Reuse the drawn sequence, preferring a white mask/gradient for controlled recoloring. Do not bundle the Steam APNG in the product.

Choose a small continuous-noise PNG from the CC0 pack by Screaming Brain Studios, such as Turbulence or Swirl: https://opengameart.org/content/noise-texture-pack. Download only from the verified source and keep the license/provenance. Version only the small assets the theme needs, never the ZIPs, Blender files, research material or QA captures. A deterministic preparation tool can generate the atlas and record the frame order; the PNGs are data of the interpretable effect, not compositor code.

The intended appearance is a frame with a black core, a glowing violet filament and irregular organic tongues on all four sides and corners. Use the animated texture as a mask and noise to deform the outline. Avoid a central strip, a dominant straight line or a train of regular spikes. Reserve a margin inside the limits of the existing thumbnail, shrinking the content uniformly to keep the proportion. Legible center; zero intensity reproduces the exact identity. The effects stay restricted to eligible F9 thumbnails, with no change to the web overview, input or the host's web frames.

Integration and checks

  1. Update the Rust and Node loaders and their tests with the same schema and limits. The import of the interface CSS stays separate and uses the existing journal/preview. The Node reader validates the manifest, paths and image limits; the effective acceptance of PNG and GLSL in the compositor must not be confused with the CSS import.
  2. Add the bindings to the compilation and to the GPU pipeline without changing the DRM/Winit frame cycle or the workspace transitions. Status/inspect must report limited metadata, counts and useful errors, without image bytes or GLSL sources.
  3. Test v1/v2 manifests, missing references, limits, names/collisions, an invalid atlas, a truncated/corrupt PNG, symlinks, and an upload/compilation error that keeps the last valid theme. Test switching images and metadata through reload.
  4. Use real offscreen EGL in the production chain: a synthetic texture with asymmetric colors for orientation/channels, an atlas with distinct frames, repeat/clamp, sampler isolation per pass, no contamination of GL state, premultiplied alpha, identity, center, animation and pass order. Inspect the flame with real assets over light and dark backgrounds, wide and square sizes, and frozen time. It is not enough to prove that the JSON accepts textures.
  5. Luna runs fmt, the default/session Rust tests, Clippy and builds. The main agent runs npm ci, format:check, check/test and Python when relevant. Run the EGL tests explicitly; keep captures out of Git. Prepare an optimized release and check hashes, libraries and smoke checks, without opening another compositor or host.
  6. Publish validated commits directly to main and synchronize the active folder only if clean, by fast-forward under coordination.lock, with preparation and preservation of the runtime. The initial incorporation of the samplers into the compositor requires a new build in execution. Do not end this session on the basis of the previous authorization, which referred to the session that already ended. Before activating, prepare an independent rollback and ask for explicit authorization for the new logout, if needed; tell apart prepared build, installed theme and completed native test.

Completion criterion

A v2 theme can use PNGs and atlases through real bindings in GLSL, without recompiling on each change. N64 Fire and noise take part in the black-flame pixels; the frame visually approaches the reference and stays legible at different sizes. An invalid reload keeps the whole previous chain. Licenses and limits are documented. The delivery reports the visual proof obtained and any activation step still pending.

Implemented result

  • Final v2 schema: textures[] declares {id,path,filter,wrap,atlas?}; each effects[].textures maps an ASCII alias to an ID. Derived uniforms are u_tex_<alias> (int sampler), u_tex_<alias>_size (vec2), and _atlas (vec4 columns/rows/frames/fps). V1 stays compatible and has no bindings. The aliases check collisions among all derived names, and the CSS reserves --tex-*.
  • Effective limits: 8 PNGs, 4 samplers per effect, sides up to 1024, 4 MiB per file, 8 MiB encoded and 16 MiB decoded. The png decoder is pinned in the lockfile. Binary reading is limited during I/O, does not follow a final symlink and does not block on a FIFO. Header and chunks are checked, APNG is refused, text metadata is ignored and RGBA/RGB/grayscale/grayscale-alpha are normalized to premultiplied RGBA8.
  • Upload queries MAX_TEXTURE_SIZE and MAX_TEXTURE_IMAGE_UNITS, reserves unit0 for tex, binds images to the following units and restores the active unit and bindings per pass. An upload/compilation error rejects the candidate. The current theme stays active until the whole package is validated. There is no decoding/upload in the frame loop.
  • The catalog/inspect reads only the manifest and the path structure, without decoding PNGs or claiming GPU compilation; selection/reload decodes, sends all listed PNGs and compiles, including disabled effects, before the switch. The snapshot offers the maximum supported v2 and the version/count/decoded bytes in the loaded theme.
  • Studio v2 contains black-flame enabled; elastic and wave stay independent and disabled by default. The GLSL really uses the N64 atlas and turbulence, and does the frame choice and deformation on the GPU. It is a stylized approximation of the reference, not a copy and not exact fidelity.
  • The two Node/Rust readers validate schema, file limits, paths, dimensions, atlas and APNG. Node validates header/bounds and does not claim decoding or GPU capacity; only Smithay selection/reload proves upload/compilation.
  • Real EGL proof completed with effect_pipeline::tests::egl_theme_pipeline_order_isolation_identity_and_atomic_reload: production sampled both PNGs, independently switching the atlas and the turbulence changed pixels, frame/time changed pixels, identity at zero intensity, premultiplied alpha, wide and square thumbnails, light/dark backgrounds, GLSL/CSS reload and full preservation of the previous chain after an error. The same proof compiles and runs the sampler alias noise_size (u_tex_noise_size) together with the CSS parameters --border-size and --foo-atlas; this covers names ending in _size/_atlas without inferring the type from the suffix. The PPMs and GIF stay out of Git in /tmp/anos-texture-qa/ (black-flame-light.png, black-flame-dark.png, black-flame-square.png, black-flame-loop.gif). The other three ignored EGL tests also passed, 4/4.
  • Rust checks: cargo fmt -- --check; cargo test --locked (53 passed, 4 ignored); cargo test --locked --features session (53 passed, 4 ignored); cargo clippy --locked --all-targets --features session -- -D warnings; cargo build --locked --features session; cargo build --locked; explicit run of all ignored EGL tests (4/4 passed). The runs use the crate manifest native/smithay/Cargo.toml.
  • Web and Python checks done by the main agent: npm format/check/build and 171/171 Node tests; Python 49/49 with AGENT_NATIVE_SUPERVISOR_SCRIPTS removed from the test environment to keep the fixtures isolated. The Node v2 manifest tests also cover a safe reference, atlas, limit and binding collision, NPOT repeat, APNG, truncated PNG and dimensions above the maximum.
  • Visual proofs outside Git: /tmp/anos-texture-qa/black-flame-light.png, /tmp/anos-texture-qa/black-flame-dark.png, /tmp/anos-texture-qa/black-flame-square.png, /tmp/anos-texture-qa/black-flame-loop.gif (30 frames, 1 second). The images show the stylized approximation approved by the main agent. No QA PNG/GIF is versioned.
  • Runtime activation: none in this task. The proof is synthetic offscreen EGL; it did not start a compositor or a session, did not change activeRoot/the user's configuration and did not install the theme. A build with samplers must be installed before loading Studio v2 by hot reload.

Final integration with main

After incorporating the concurrent changes for window frames and wallpaper, 53 Rust tests with session, Clippy, formatting and the 5 explicit EGL tests passed again, including the new rounded-corners test. The full Node suite passed 175/175 with serial concurrency to avoid timeouts during parallel builds. The preparer finished the optimized release build; the hashes of sources/artifacts, the shared libraries, the compositor --help and the native Electron smoke check were verified. This preparation did not start a graphical session and does not prove activation on the desktop.