el plan.md 3.1 KB

The Master Plan: "N64 Node Shader Studio" in Rust

Since i have real hardware and a flashcart (which is ideal, because emulators often inaccuracies-mask RDP quirks that real hardware catches), here is a clean, realistic roadmap to build this in Rust.

Phase 1: The Rust + N64 Toolchain Setup

  • Option B: Pure Rust (cargo-n64 / n64-pac) — Zero C dependencies, super clean #[no_std] Rust, great if you want to write the low-level hardware drivers yourself, though you'll write more boilerplate for fonts and UI rendering.

Phase 2: Architecture of the App (Split-Screen Workspace)

Because the N64 runs best at 320×240 (or 640×480 interlaced if you want extra crisp text for a node editor—and you have an Expansion Pak), we can split the screen into two zones:

  • Left 65% of Screen: The Node Canvas
  • Dark SGI-style grid background.
  • Movable node boxes (Input nodes on left $\rightarrow$ Math/Combiner nodes in middle $\rightarrow$ Material Output on right).
  • Bezier/segmented wires connecting pins.
  • Cursor controlled by the N64 Analog Stick (with D-Pad snapping to pins for precision!) or a real N64 Mouse.

  • Right 35% of Screen: Live 3D Preview Viewport

  • Renders a spinning 3D primitive (Sphere, Torus, Cube, or Classic Teapot) using the compiled shader in real time.

  • A-button or C-buttons let you rotate the mesh, toggle wireframe, or switch preview shapes/lighting presets.

Phase 3: The Rust Node Graph & Compiler Core (#[no_std])

This is the heart of the project. You can build and unit-test this pure Rust module on your PC before even flashing it to the N64!

  1. Data Model:
  2. NodeId, PinId, and NodeType (Texture0, Texture1, VertexColor, PrimColor, EnvColor, Noise, Mix, Multiply, Add, Fresnel, Output).
  3. An arena or fixed-size array (heapless::Vec<Node, 32>) so you never deal with heap fragmentation in 4 MB of RDRAM.

  4. The Graph-to-RDP Compiler:

  5. Runs only when a wire is connected, disconnected, or a slider/color value changes (is_dirty = true).

  6. Walks backward from the Output node.

  7. Maps up to two math operations into RDP Cycle 1 and RDP Cycle 2 ((A - B) * C + D).

  8. Packs the result into an rdpq_combiner_t configuration (or raw 64-bit G_SETCOMBINE command word).

  9. If the graph exceeds what the RDP can do in 2 cycles (e.g., trying to multiply 4 different textures together), the compiler returns Err(CompileError::ExceedsTwoCycles(node_id)) and highlights that node red!

Phase 4: Polish & "Wow" Features for Real Hardware

  • Preset Library (Start Menu): Include 5–6 pre-wired node graphs (e.g., Mario 64 Metal Cap Chrome, Lava Flow, Hologram, Toon Cel-Shader, Water Caustics) so anyone booting the ROM immediately sees cool visuals and can dissect how the nodes are wired.
  • Hardware Performance Overlay: Show live RSP/RDP cycle counts and frame time in microseconds—flexing how fast the real 1996 silicon renders your custom node graph.
  • Controller Pak / Flashcart Save: Allow saving/loading custom node graphs to SRAM/EEPROM so you can show off your shaders on real hardware without rewiring them every boot.