# Portable Shader Material Spec

This project treats each daily shader as a portable material package, not a single app.

## Package Shape

```txt
works/YYYY-MM-DD-slug/
  material.json
  README.md
  notes.md
  index.html
  main.js
  style.css
  liquid-metal-cursor.fs
  adapters/
    web/
      input-mapping.md
      input-sources.js
    touchdesigner/
      README.md
    vj/
      vj-material.json
```

## Canonical Inputs

Use the same input names across WebGL, ISF, TouchDesigner, VJ tools, and render automation.

| Name | Type | Range | Meaning |
| --- | --- | --- | --- |
| `pointer` | `vec2` / `point2D` | `0..1, 0..1` | Primary 2D control point. |
| `pointerVelocity` | `vec2` / `point2D` | usually `-1..1` | Motion direction and force. |
| `intensity` | `float` | `0..2` | Overall interaction strength. |
| `heat` | `float` | `0..1` | Warm/cool color balance. |
| `speed` | `float` | `0..2` | Time multiplier. |

## Input Strategy

Every environment should translate its native data into canonical inputs before touching the shader.

```txt
native input
  -> normalizer
  -> canonical material inputs
  -> shader uniforms / ISF inputs / VJ material params
```

Examples:

- Mouse: screen coordinates become `pointer`.
- Hand tracking: index-finger tip becomes `pointer`; frame-to-frame delta becomes `pointerVelocity`.
- Weather: wind speed can drive `speed`; temperature can drive `heat`; precipitation can drive `intensity`.
- Audio: RMS can drive `intensity`; spectral centroid can drive `heat`.
- OSC/MIDI: controller values map directly to any float input.

## Adapter Targets

- **ISF / TouchDesigner:** use `.fs` file directly when the host supports ISF. Otherwise copy the GLSL body into a GLSL TOP and expose matching uniforms.
- **Web:** use `tools/web-material-player/` to load `material.json`, parse the ISF metadata, build controls, pick input sources, and set WebGL uniforms.
- **Browser VJ software:** read the VJ manifest and load the shader as a generator material.
- **Video rendering:** use deterministic inputs and fixed time steps for repeatable captures.

## Authoring Rule

When creating a new daily shader, define the canonical input list first. The visual can change wildly, but the integration layer should stay predictable.
