Skip to content

ariadne: declarative GLSL shader surface on scene nodes (shader: block) + preset registry - #562

Merged
transfix merged 1 commit into
masterfrom
feat/ariadne-shader-dsl
Oct 4, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/ariadne-shader-dsl

Conversation

@transfix

@transfix transfix commented Oct 4, 2026

Copy link
Copy Markdown
Owner

What — Phase 2a of the lsystem-forest refactor (a general DSL capability)

Makes GLSL a first-class Ariadne DSL surface, so a mesh that needed host C++ to be shaded can be authored entirely in the .ari — and run under the generic ariadne_hello host. This is the missing piece that lets the forest's terrain bump + tree bark leave the host .cpp.

DSL

A geometry node's shader: block either names a host-registered preset or splices raw GLSL at VTK injection markers:

shader: terrain_bump                       # scalar shorthand → a named preset
shader:                                    # or the full form
  preset: bark
  disable_coord_shift: true
  vertex:   [ { at: "//VTK::Normal::Dec",  code: "…" } ]
  fragment: [ { at: "//VTK::Normal::Impl", code: "…" } ]

Pieces

  • scene.h — SceneShader / SceneShaderStage (neutral data) + a shader field on SceneNode.
  • loader.cpp — parse_scene_shader (scalar-preset shorthand + the map form); shader is a known node key.
  • scene_realize.cpp (cvcGL, GL-specific) — a process-global shader-preset registry (register_shader_preset / has_shader_preset, mirroring the node-type registry) and apply_shader() on a realized GeometryNode: the coordinate-shift toggle, then the named preset (warn, never throw, on unknown), then the inline splices. register_default_shader_presets() installs the built-ins terrain_bump + bark (the demo's GROUND_GLSL/BARK_GLSL, including the GLES normal-name platform gate) — presets, not host code.

The forest/cvcGL extension bundle (register_cvcgl_extensions, Phase 2b) will call register_default_shader_presets().

Tests

  • Loader (2): preset shorthand + full-block parse (disable_coord_shift + ordered vertex/fragment stages); absent shader.
  • Realize (6): presets register; a known preset applies with no warning; an unknown preset warns but still realizes the node.

…k) + preset registry

Make GLSL a first-class Ariadne DSL capability so a mesh that needed host C++ to be shaded can be
authored entirely in the .ari (and run under the generic ariadne_hello host). A geometry node's
`shader:` block either names a host-registered PRESET or splices raw GLSL at VTK injection markers:

    shader: terrain_bump                       # scalar shorthand for a named preset
    shader:                                    # or the full form
      preset: bark
      disable_coord_shift: true
      vertex:   [ { at: "//VTK::Normal::Dec",  code: "…" } ]
      fragment: [ { at: "//VTK::Normal::Impl", code: "…" } ]

- scene.h: SceneShader / SceneShaderStage (neutral data) + a `shader` field on SceneNode.
- loader.cpp: parse_scene_shader (scalar-preset shorthand + the map form); `shader` is a known key.
- scene_realize.cpp (cvcGL — GL-specific): a process-global shader-preset registry
  (register_shader_preset / has_shader_preset, mirroring the node-type registry) and apply_shader()
  called when a realized GeometryNode has a shader: coordinate-shift toggle, then the named preset
  (warn, never throw, on an unknown one), then the inline vertex/fragment splices.
  register_default_shader_presets() installs the built-ins "terrain_bump" + "bark" (the demo's
  GROUND_GLSL/BARK_GLSL, incl. the GLES normal-name platform gate) — presets, not host code.

This is the general capability behind shrinking the lsystem_forest host: the terrain bump + tree
bark move from host addTerrainBump/addBark calls into the .ari. The forest/cvcGL extension bundle
(register_cvcgl_extensions) will call register_default_shader_presets().

Tests: loader (2) — preset shorthand + full block parse, absent shader; realize (6) — presets
register, a known preset applies with no warning, an unknown preset warns but still realizes.
@transfix
transfix enabled auto-merge (squash) October 4, 2026 06:41
@transfix
transfix merged commit 8f05a9b into master Oct 4, 2026
14 checks passed
@transfix
transfix deleted the feat/ariadne-shader-dsl branch October 29, 2026 20:52
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