Skip to main content

Module shared_wgsl

Module shared_wgsl 

Source
Expand description

WGSL helper catalog.

Each helper is a &'static str of WGSL that a plugin shader prefixes (or concatenates into its own shader source) to gain access to the lib’s shared bindings, shading helpers, and target conventions.

Versioning: each helper carries a // @viewport-wgsl-version: N comment. The version is bumped whenever a function signature, struct field, or binding number changes. Plugins compare against WGSL_VERSION at build time to detect breakage early. Function bodies and private fields are not part of the contract and may change between patch releases.

Composition: plugin shaders typically build their source as:

let src = format!(
    "{bindings}\n{pbr}\n{this_pipeline_specific_wgsl}",
    bindings = viewport_lib::plugin_api::shared_wgsl::SHARED_BINDINGS_WGSL,
    pbr      = viewport_lib::plugin_api::shared_wgsl::SHARED_PBR_WGSL,
    this_pipeline_specific_wgsl = include_str!("my_shader.wgsl"),
);

Constants§

SHARED_BINDINGS_WGSL
Group-0 bind declarations and shared scene-data structs.
SHARED_MASK_WGSL
Fragment helper for the outline mask pass.
SHARED_OIT_WGSL
Fragment-output struct and packing helper for the OIT pass.
SHARED_PBR_WGSL
Shared PBR shading helper.
SHARED_PICK_WGSL
Fragment helper for the pick-id pass.
WGSL_VERSION
Catalog version. Bumped on any breaking change to a helper signature, struct field, or binding number. Plugins should assert against this at build time: