Skip to content

Ariadne: live textures, a raster stream on any node, uploaded a rectangle at a time (§5.4) - #1236

Merged
transfix merged 2 commits into
masterfrom
feat/ariadne-live-textures
Nov 15, 2026
Merged

transfix merged 2 commits into
masterfrom
feat/ariadne-live-textures

Conversation

@transfix

@transfix transfix commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

A node's texture today is an image read once, at realize. This makes it live: any node that draws a
mesh can wear a stream, and a raster stream re-uploads only the rectangles that changed. The
producer can paint from C++, from Python, or from a relay's server document, whose frames reach the
clients that subscribe.

The document

scene:
  nodes:
    - node: city
      source: { data: austin }
      material: { texture: { stream: fog.tint } }        # a raster mirror (a relay's namespace)
    - node: board
      source: { plane: { size: 4 } }
      material: { texture: { stream: streams.board } }   # a stream token
  • Who wears it. A geometry node (file, asset, primitive, heightfield, generated terrain), a
    custom type whose realizer returns a GeometryNode, a source: { data } node's terrain (UVs over
    its extent, as the aerial image has), and a type: stream node. A group warns. material: { uv }
    orients it. plane primitives now carry UVs (they had none, so any texture on one showed a
    single texel).
  • The name is a stream token, or a state path holding a raster mirror. It is looked up as
    written and resolved against the document's prefix. The node keeps looking every frame until the
    source is live, so the producer may start after the scene, and again after the stream closes.

Rasters (cvc/ariadne/stream/raster.h)

  • Frames. Codec rgba8.patch: the frame number, the rectangles that changed, and their pixels.
    A key frame (the whole raster) goes out on the first publish, every key_every frames (30), and
    on the first publish after a subscriber joins. Frames are self-describing, so they cross any
    transport unchanged.

  • The consumer (raster_canvas, LiveTextureBinding). The texture aliases a canvas the frames
    draw into:

    • the first frame, and the first after a gap, uploads it whole;
    • every other frame uploads only its rectangles (GeometryNode::texture_modified_rect,
      glTexSubImage2D);
    • a frame with nothing new uploads nothing.

    A raw stream (a camera's rgba8) still shows each frame whole.

  • State. Each raster keeps its frames in state at its token: .w, .h, .codec, the last key
    frame, a ring of the last 8 frames, and .frame, written last. So a consumer that subscribes late
    catches up. mirror: names a second path.

  • The producer (raster_stream): fill, paint(image), paint_grid(values, …, colormap, lo, hi, alpha) (mesh_ops' colour maps; NaN is transparent), or pixels() then mark(). Then
    publish() / publish_key().

    • C++: raster_stream::open(app, {id, root_path, w, h, key_every, mirror}).
    • pycvc: pycvc.raster_open(app, id, w, h[, key_every, mirror]) returns a RasterStream, whose
      pixels() is a writable view. The hosts have host.open_raster(...).
    • DSL, beside the stream verbs: raster-open, raster-fill, raster-grid, raster-publish,
      raster-key, raster-close. A document owns its rasters as it owns its streams.

Across a relay. A server document mirrors its raster into a namespace it publishes
(server: publish: [fog]). The relay sends the frames there, and a client that subscribes
(relay: { subscribe: [fog] }) names the mirror.

  • On the client, raster_follower turns the mirror into a local stream. It keeps a canvas of its
    own, so each new subscriber gets a key frame of the picture as it is.
  • A client too far behind for the ring starts again at the next key frame.
  • Each frame is one state write; a key frame is the whole raster (1024² is 4 MiB, inside the
    transports' 64 MiB cap). Bandwidth is the real limit: the WebSocket relay skips a client whose
    send queue passes 2 MiB until it drains, then its periodic broadcast re-sends the mirror's
    current values, from which the follower catches up. The docs say to size the raster and
    key_every to the slowest link.

Stock hosts

  • AriRuntime, so arigl, arigl-web, ariglx and pycvc_gl's Host (not only with streaming=True),
    now registers the stream and raster verbs and type: stream.
  • arisrv registers the stream and raster verbs for its server document.
  • A node's live texture needs nothing registered.

Tests

  • stream_raster_test (new, 6 tests):
    • the codec round trip, and refusal of bad bytes;
    • the canvas in order, across a gap and on a key frame;
    • the producer sends only what was painted, keys on schedule and paints grids;
    • a mirror followed on one app, including a late join and falling out of the ring;
    • the verbs from a document;
    • the relay round trip: a ServerDocument with server: publish: [fog] paints a raster each
      room step; an inproc transport replicates it to a second app; the client's follower stream
      draws it there pixel for pixel.
  • cvcgl_live_texture (new, offscreen):
    • pixels: a plane wears the raster north up, and a painted rectangle shows;
    • upload counts at the driver (gl_upload_counter):
      • the first picture is one glTexImage2D;
      • an 8 × 8 rectangle is one 256-byte glTexSubImage2D and no glTexImage2D;
      • a frame with nothing new uploads nothing;
      • two frames give two sub-uploads, and a 16 × 16 grid gives its 1024 bytes;
    • a heightfield on a mirror path resolved against the prefix;
    • a stream that closes and reopens;
    • a type: stream node on a raster;
    • AriRuntime's default registrations.
  • test_pycvc_raster.py (new, registered as pycvc_raster).

Locally (Linux, Release, pycvc built), these pass:

  • the new tests;
  • cvcgl_stream_node, cvcgl_stream_texture, cvcgl_stream_bind, cvcgl_stream_view,
    stream_test, stream_to_image_test;
  • the ariadne_* gtests;
  • the cvcGL scene/streaming ctest entries.

gRPC-only relay tests did not run here (gRPC is off in this build), so arisrv's two-line change is
compile-checked by CI only.

With #1230 (scene repeat:). The two merge with each other cleanly. The one
line that lets a copy's {i} reach its stream name is in its own follow-up PR, to merge after both
(see that PR).

Docs: docs/ARIADNE.md §5.4 ("Live textures", "Producing a raster", "Across a relay"), §9.7
("Rasters") and the Python host table.

…ngle at a time (§5.4)

material: { texture: { stream: <name> } } feeds a node's texture from a stream while the scene
runs: any node that draws a mesh (a geometry node, a custom type returning a GeometryNode, a
source: { data } node's terrain) and type: stream nodes. The name is a stream token or a state
path holding a raster mirror, looked up as written and against the document's prefix, every frame
until live, so the producer may start after the scene. plane primitives now carry UVs.

- Raster streams (cvc/ariadne/stream/raster.h), codec rgba8.patch: each frame is the rectangles
  that changed and their pixels, with a key frame on the first publish, every key_every frames and
  after a subscriber joins. The consumer (raster_canvas, LiveTextureBinding) draws into a canvas
  the texture aliases: the first frame and one after a gap upload it whole, every other frame only
  its rectangles (texture_modified_rect, glTexSubImage2D), a frame with nothing new nothing. Raw
  streams still show each frame whole.
- Each raster keeps its frames in state at its token (size, codec, last key frame, a ring of 8,
  the frame number written last), so a late subscriber catches up; mirror: names a second path.
  raster_follower turns a mirror back into a local stream, with a key frame of its own canvas for
  each new subscriber.
- Producers: raster_stream (fill, paint, paint_grid through mesh_ops' colour maps with NaN
  transparent, pixels() + mark, publish, publish_key); pycvc.raster_open / RasterStream and
  host.open_raster; the DSL's raster-open, raster-fill, raster-grid, raster-publish, raster-key and
  raster-close beside the stream verbs, owned by the calling document.
- Across a relay: a server document mirrors its raster into a namespace it publishes; a client
  that subscribes names the mirror.
- AriRuntime (arigl, arigl-web, ariglx, pycvc_gl's Host) registers the stream and raster verbs and
  type: stream by default; arisrv registers the verbs for its server document.

Tests: stream_raster_test (codec, canvas, producer, mirror followed locally, the verbs, and a
server document's raster replicated over an inproc transport and drawn by a client),
cvcgl_live_texture (pixels, upload counts at the driver, a mirrored heightfield, a reopened
stream, a type: stream node, AriRuntime's registrations), test_pycvc_raster.py and
AriadneScene.MaterialTextureStream. docs/ARIADNE.md §5.4 and §9.7.
…e (64 MiB transports, the WebSocket relay's 2 MiB backlog)
@transfix
transfix force-pushed the feat/ariadne-live-textures branch from 3f14662 to 1950cd0 Compare November 15, 2026 02:27
@transfix
transfix merged commit d2c500e into master Nov 15, 2026
28 checks passed
@transfix
transfix deleted the feat/ariadne-live-textures branch November 15, 2026 11:14
transfix added a commit that referenced this pull request Nov 15, 2026
- stream_intrinsics.cpp: the stream provider stays `any`, and #1236's raster verbs are a provider
  of their own, registered `host_proxied`: they are synchronous, raster-open and raster-publish
  write the raster's mirrors into the state tree raw (write_node), and one thread paints and
  publishes a raster, so in an `any` group they run on the host thread. Registered host_only (the
  default) they would have put every isolated document of an app with the stream verbs in a
  host-affinity group.
- STATE_EXEC_THREADED.md: the raster verbs and #1171's skeleton provider in the provider table,
  and the file list.
transfix added a commit that referenced this pull request Nov 15, 2026
Master now has P5 parts 1 and 2 (#1248 and #1250, the GenSeg core and its clean-up), the
4.0.0 bump (#1221), live textures (#1236) and Ewave's timeout (#1261). No conflicts: this
branch's CLI, pycvc and DSL sit on the cleaned-up genseg.cpp unchanged.
transfix added a commit that referenced this pull request Nov 15, 2026
No conflicts. Master brings 26 commits (#1171, #1191, #1221, #1236,
#1245, #1248, #1250 and others); none adds a writable global, a function
static or a signal handler to the hosts or examples, and none touches
the allowlist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant