@ignifx/core 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{environment-DPi0_0SP.js → environment-DZ6WUHbm.js} +2 -2
- package/dist/{environment-DPi0_0SP.js.map → environment-DZ6WUHbm.js.map} +1 -1
- package/dist/{hdr-output-BrUvpAsE.js → hdr-output-Dbv0lhFl.js} +4 -3
- package/dist/{hdr-output-BrUvpAsE.js.map → hdr-output-Dbv0lhFl.js.map} +1 -1
- package/dist/{ignifx-error-oYdVnT1S.js → ignifx-error-B8ByiSfJ.js} +16 -1
- package/dist/ignifx-error-B8ByiSfJ.js.map +1 -0
- package/dist/index.d.ts +128 -14654
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1501 -4037
- package/dist/index.js.map +1 -1
- package/dist/{instanced-mesh-instance-NnODkvqK.js → instanced-mesh-instance-BMhREEfx.js} +3 -2
- package/dist/{instanced-mesh-instance-NnODkvqK.js.map → instanced-mesh-instance-BMhREEfx.js.map} +1 -1
- package/dist/light-probe-asset-B60_X-yN.js +331 -0
- package/dist/light-probe-asset-B60_X-yN.js.map +1 -0
- package/dist/light-probes-DkYN89Qw.js +284 -0
- package/dist/light-probes-DkYN89Qw.js.map +1 -0
- package/dist/{material-plugin-BUlqLsap.js → material-plugin-CiAmriQ_.js} +2 -2
- package/dist/{material-plugin-BUlqLsap.js.map → material-plugin-CiAmriQ_.js.map} +1 -1
- package/dist/node-DznSvwap.js +301 -0
- package/dist/node-DznSvwap.js.map +1 -0
- package/dist/{post-effect-BHl7U56q.js → post-effect-CQnlX1RH.js} +3 -30
- package/dist/post-effect-CQnlX1RH.js.map +1 -0
- package/dist/{post-effect-compiler-CRek8VxQ.js → post-effect-compiler-C_7HTHZy.js} +3 -3
- package/dist/{post-effect-compiler-CRek8VxQ.js.map → post-effect-compiler-C_7HTHZy.js.map} +1 -1
- package/dist/prefab-overrides-BLQn5yHS.d.ts +15149 -0
- package/dist/prefab-overrides-BLQn5yHS.d.ts.map +1 -0
- package/dist/prefab-overrides-DT-wHHAJ.js +2396 -0
- package/dist/prefab-overrides-DT-wHHAJ.js.map +1 -0
- package/dist/prefab.d.ts +2 -0
- package/dist/prefab.js +2 -0
- package/dist/reflection-probe-DlVsl3zJ.js +1883 -0
- package/dist/reflection-probe-DlVsl3zJ.js.map +1 -0
- package/dist/reflection-probes-B8S9WnVX.js +551 -0
- package/dist/reflection-probes-B8S9WnVX.js.map +1 -0
- package/dist/{render-path-Be7WgN7r.js → render-path-D11i_7X8.js} +3 -2
- package/dist/{render-path-Be7WgN7r.js.map → render-path-D11i_7X8.js.map} +1 -1
- package/dist/{render-texture-C_TnaSz2.js → render-texture-UqRHRLQy.js} +15 -2
- package/dist/{render-texture-C_TnaSz2.js.map → render-texture-UqRHRLQy.js.map} +1 -1
- package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
- package/dist/{scene-color-passes-DlNr-qyZ.js → scene-color-passes-B93qTOka.js} +35 -12
- package/dist/scene-color-passes-B93qTOka.js.map +1 -0
- package/dist/{shader-material-B6p66wB8.js → shader-material-C2_UCYdO.js} +6 -17
- package/dist/{shader-material-B6p66wB8.js.map → shader-material-C2_UCYdO.js.map} +1 -1
- package/dist/{shader-material-C0TAUr4t.js → shader-material-CaAkv5nT.js} +2 -2
- package/dist/{shader-material-C0TAUr4t.js.map → shader-material-CaAkv5nT.js.map} +1 -1
- package/dist/{shader-pragma-BKCoZTTA.js → shader-pragma-DmZpxGUo.js} +2 -2
- package/dist/{shader-pragma-BKCoZTTA.js.map → shader-pragma-DmZpxGUo.js.map} +1 -1
- package/dist/{surface-shader-BaK0kvBB.js → surface-shader-BeDRofOV.js} +4 -4
- package/dist/{surface-shader-BaK0kvBB.js.map → surface-shader-BeDRofOV.js.map} +1 -1
- package/dist/{vec3-D-0Y2mzE.js → vec3-Cc19wl4r.js} +3 -300
- package/dist/vec3-Cc19wl4r.js.map +1 -0
- package/package.json +8 -4
- package/dist/ignifx-error-oYdVnT1S.js.map +0 -1
- package/dist/json-CzZZ6K4x.js +0 -24
- package/dist/json-CzZZ6K4x.js.map +0 -1
- package/dist/post-effect-BHl7U56q.js.map +0 -1
- package/dist/scene-color-passes-DlNr-qyZ.js.map +0 -1
- package/dist/vec3-D-0Y2mzE.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as readSceneEnvironment } from "./environment-
|
|
1
|
+
import { i as readSceneEnvironment } from "./environment-DZ6WUHbm.js";
|
|
2
2
|
import { createShaderMaterial, createTexture2DArrayFromPixels, createTexture2DFromPixels, enableShaderMaterialUniformCaching, setShaderMatrix, setShaderStorageBuffer, setShaderTexture, setShaderUniform } from "@babylonjs/lite";
|
|
3
3
|
//#region src/lite/gpu/shader-material.ts
|
|
4
4
|
/** The RGBA bytes of each 1x1 fallback texture. */
|
|
@@ -302,4 +302,4 @@ function readSceneAmbient(scene, out) {
|
|
|
302
302
|
//#endregion
|
|
303
303
|
export { createFallbackTexture, createShaderMaterialFromOptions, enableShaderUniformCaching, linearOutputFragment, readSceneAmbient, resolveFallbackTexture, writeShaderMatrix, writeShaderStorageBuffer, writeShaderTexture, writeShaderUniform };
|
|
304
304
|
|
|
305
|
-
//# sourceMappingURL=shader-material-
|
|
305
|
+
//# sourceMappingURL=shader-material-CaAkv5nT.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-material-C0TAUr4t.js","names":[],"sources":["../src/lite/gpu/shader-material.ts"],"sourcesContent":["import {\n createShaderMaterial,\n createTexture2DArrayFromPixels,\n createTexture2DFromPixels,\n enableShaderMaterialUniformCaching,\n setShaderMatrix,\n setShaderStorageBuffer,\n setShaderTexture,\n setShaderUniform,\n} from \"@babylonjs/lite\";\nimport { readSceneEnvironment } from \"./environment.js\";\nimport type {\n EngineContext,\n SceneContext,\n ShaderAttributeName,\n ShaderMaterial,\n ShaderSystemUniformName,\n ShaderUniformType,\n StorageBuffer,\n Texture2D,\n} from \"@babylonjs/lite\";\n\n/**\n * The custom-WGSL half of the Babylon Lite adapter: `createShaderMaterial`, the `setShader*`\n * setters, and the 1x1 fallback textures a declared sampler falls back to\n * (`docs/plan/2026-09-terrain-particles-shaders.md` §3.1, ADR-0024). Everything here is `@internal`.\n *\n * Lite exports one barrel, so a static import of `createShaderMaterial` anywhere in the reachable\n * graph pulls `lib/material/shader/**` into every entry chunk. This module is therefore reached with\n * `await import(...)` from `../../render/shader-support.ts`, and only loading a `.wgsl` triggers the\n * fetch. `./storage-buffer.ts` is a separate file for the same reason: `StorageBufferAsset`\n * allocates synchronously, so it cannot wait for this chunk.\n *\n * Two Lite facts it is written around:\n *\n * - Nothing may be left unbound: `createShaderBindGroup` throws (errors 309 and 310) when a declared\n * sampler has no texture or a declared storage buffer has no buffer, which is what\n * {@link createFallbackTexture} exists for.\n * - There is no front-face culling; `ShaderMaterialOptions` carries only `backFaceCulling`\n * (`lib/material/shader/shader-pipeline.js`), so the pragma parser refuses `cull front`.\n */\n\n/**\n * A Babylon Lite custom WGSL material, re-exported under an ignifx name\n * (`CONSTITUTION.md` §3.4, coding standards §4).\n *\n * @remarks\n * Unstable; excluded from the stability guarantees of `CONSTITUTION.md` Article IV.\n *\n * @public\n */\nexport type LiteShaderMaterial = ShaderMaterial;\n\n/** The RGBA bytes of each 1x1 fallback texture. */\nconst FALLBACK_PIXELS: Readonly<Record<string, readonly [number, number, number, number]>> = Object.freeze({\n white: [255, 255, 255, 255],\n black: [0, 0, 0, 255],\n transparent: [0, 0, 0, 0],\n});\n\n/**\n * One declared uniform in the form Babylon Lite's factory takes: either the name of a system\n * uniform it fills in itself, or a custom declaration with its initial value.\n *\n * @internal\n */\nexport type ShaderUniformEntry =\n | ShaderSystemUniformName\n | {\n /** The WGSL identifier. */\n readonly name: string;\n /** The WGSL type. */\n readonly type: ShaderUniformType;\n /** The initial value, **linear** for a colour. */\n readonly defaultValue: number | readonly number[];\n };\n\n/**\n * One declared sampler in the form Babylon Lite's factory takes.\n *\n * @internal\n */\nexport interface ShaderSamplerEntry {\n /** The WGSL identifier; Lite generates `<name>Sampler` beside it. */\n readonly name: string;\n /** `\"2d-array\"` for a `texture_2d_array<f32>` binding. */\n readonly viewDimension: \"2d\" | \"2d-array\";\n}\n\n/**\n * One declared storage buffer in the form Babylon Lite's factory takes.\n *\n * @internal\n */\nexport interface ShaderStorageEntry {\n /** The WGSL identifier. */\n readonly name: string;\n /** The WGSL variable type, verbatim. */\n readonly type: string;\n}\n\n/**\n * Everything Babylon Lite's `createShaderMaterial` needs, in ignifx's own vocabulary so that the\n * mapping from a `ShaderDeclaration` can be built and asserted without a device or a Lite import\n * (`src/render/shader-material.ts`).\n *\n * @remarks\n * A `null` blend state or depth comparison means \"leave Babylon Lite's own default in place\", so\n * this module never restates a Lite default that could change.\n *\n * @internal\n */\nexport interface ShaderMaterialBuildOptions {\n /** The material's name, used in pipeline and shader-module labels. */\n readonly name: string;\n /** The WGSL source, handed to Lite as both the vertex and the fragment source. */\n readonly source: string;\n /**\n * Whether the scene renders through `rendering.hdr`, where the fragment's display colour is\n * decoded to linear before it is written (see {@link linearOutputFragment}). Absent means `false`.\n */\n readonly linearOutput?: boolean;\n /** The vertex attributes the vertex stage reads; `position` is mandatory. */\n readonly attributes: readonly ShaderAttributeName[];\n /** The system and custom uniforms, in binding-declaration order. */\n readonly uniforms: readonly ShaderUniformEntry[];\n /** The samplers. */\n readonly samplers: readonly ShaderSamplerEntry[];\n /** The read-only storage buffers. */\n readonly storageBuffers: readonly ShaderStorageEntry[];\n /** The WGSL `const` declarations, resolved from the file's defaults and the material's overrides. */\n readonly defines: Readonly<Record<string, boolean | number>>;\n /** Whether the thin-instance RGBA stream is bound and injected into `VertexInput`. */\n readonly useThinInstanceColors: boolean;\n /** Whether the surface is alpha-blended. */\n readonly needAlphaBlending: boolean;\n /** Which of Lite's two blend equations to use when no explicit state is given. */\n readonly blendMode: \"alpha\" | \"additive\";\n /** An explicit colour-target blend state, which replaces the derived one; `null` to derive it. */\n readonly blend: GPUBlendState | null;\n /** Whether the surface samples the opaque scene colour behind it. */\n readonly transmissive: boolean;\n /** Whether back faces are culled. */\n readonly backFaceCulling: boolean;\n /** Whether the draw writes depth. */\n readonly depthWrite: boolean;\n /** The depth comparison, or `null` for Lite's own reverse-Z default. */\n readonly depthCompare: GPUCompareFunction | null;\n}\n\n/**\n * Builds a Babylon Lite custom WGSL material.\n *\n * @remarks\n * Validation is eager and compilation is lazy, so this runs under the null engine; the pipeline is\n * compiled the first time a mesh wearing the material is drawn.\n *\n * @param options - The sources and the declared attribute, uniform, sampler, and storage layout.\n * @returns The material.\n * @throws Error from Babylon Lite when the declaration is not one it can build.\n *\n * @internal\n */\nexport function createShaderMaterialFromOptions(options: ShaderMaterialBuildOptions): ShaderMaterial {\n const premultiplied = options.blend?.color.srcFactor === \"one\";\n return createShaderMaterial({\n name: options.name,\n vertexSource: options.source,\n fragmentSource:\n options.linearOutput === true ? linearOutputFragment(options.source, premultiplied) : options.source,\n attributes: options.attributes,\n uniforms: options.uniforms,\n samplers: options.samplers,\n storageBuffers: options.storageBuffers,\n defines: options.defines,\n useThinInstanceColors: options.useThinInstanceColors,\n needAlphaBlending: options.needAlphaBlending,\n blendMode: options.blendMode,\n ...(options.blend === null ? {} : { blend: options.blend }),\n transmissive: options.transmissive,\n backFaceCulling: options.backFaceCulling,\n depthWrite: options.depthWrite,\n ...(options.depthCompare === null ? {} : { depthCompare: options.depthCompare }),\n });\n}\n\n/** The name a wrapped `mainFragment` is renamed to. */\nconst WRAPPED_FRAGMENT = \"ignifxDisplayFragment\";\n\n/**\n * Wraps a custom shader's `mainFragment` so that, under `rendering.hdr`, it writes linear colour\n * (`docs/plan/2026-11-gi-phase-1-execution-plan.md`, step G3).\n *\n * @remarks\n * A custom shader writes the colour that is displayed: with HDR off it lands on the swapchain as\n * is. With HDR on it lands in the linear scene target and the output pass encodes it, so the\n * wrapper decodes it first with the exact inverse of that encode (`pow(c, 2.2)`). The user's entry\n * point loses its `@fragment` and is renamed; a new `mainFragment` with the same parameters calls\n * it. A premultiplied colour is divided by alpha before the decode and multiplied after it, so the\n * blend still sees premultiplied colour. Only a single `@location(0) vec4<f32>` return can be\n * wrapped; anything else (a struct of outputs) is returned unchanged.\n *\n * @param source - The `.wgsl` file.\n * @param premultiplied - Whether the material blends premultiplied colour.\n * @returns The fragment source.\n *\n * @internal\n */\nexport function linearOutputFragment(source: string, premultiplied: boolean): string {\n const entry = /@fragment\\s+fn\\s+mainFragment\\s*\\(/u.exec(source);\n if (entry === null) {\n return source;\n }\n const open = entry.index + entry[0].length - 1;\n const close = matchingParen(source, open);\n if (close < 0) {\n return source;\n }\n const after = source.slice(close + 1);\n const result = /^\\s*->\\s*@location\\(\\s*0\\s*\\)\\s*vec4\\s*<\\s*f32\\s*>\\s*\\{/u.exec(after);\n if (result === null) {\n return source;\n }\n const parameters = source.slice(open + 1, close);\n const names = parameterNames(parameters);\n const decode = premultiplied\n ? \"select(pow(max(c.rgb,vec3<f32>(0.0)),vec3<f32>(2.2)),pow(max(c.rgb/c.a,vec3<f32>(0.0)),vec3<f32>(2.2))*c.a,c.a>0.0)\"\n : \"pow(max(c.rgb,vec3<f32>(0.0)),vec3<f32>(2.2))\";\n return [\n // A plain function may not carry the entry point's `@location(0)` on its return type.\n `${source.slice(0, entry.index)}fn ${WRAPPED_FRAGMENT}(${stripAttributes(parameters)})->vec4<f32>{${after.slice(result[0].length)}`,\n `@fragment fn mainFragment(${parameters})->@location(0) vec4<f32>{`,\n `let c=${WRAPPED_FRAGMENT}(${names.join(\",\")});`,\n `return vec4<f32>(${decode},c.a);`,\n \"}\",\n ].join(\"\\n\");\n}\n\n/**\n * Finds the parenthesis that closes the one at `open`.\n *\n * @param text - The source.\n * @param open - The index of a `(`.\n * @returns The index of its `)`, or `-1`.\n */\nfunction matchingParen(text: string, open: number): number {\n let depth = 0;\n for (let index = open; index < text.length; index += 1) {\n const char = text[index];\n if (char === \"(\") {\n depth += 1;\n } else if (char === \")\") {\n depth -= 1;\n if (depth === 0) {\n return index;\n }\n }\n }\n return -1;\n}\n\n/**\n * Removes WGSL attributes (`@builtin(position)`, `@location(0)`, `@interpolate(flat)`) from a\n * parameter list, which a plain function's parameters may not carry.\n *\n * @param parameters - The parameter list.\n * @returns The list without attributes.\n */\nfunction stripAttributes(parameters: string): string {\n return parameters.replaceAll(/@\\w+\\s*(\\([^)]*\\))?\\s*/gu, \"\");\n}\n\n/**\n * The parameter names of a WGSL parameter list, attributes stripped.\n *\n * @param parameters - The text between an entry point's parentheses.\n * @returns The names, in order.\n */\nfunction parameterNames(parameters: string): string[] {\n const names: string[] = [];\n let depth = 0;\n let start = 0;\n const take = (end: number): void => {\n const piece = stripAttributes(parameters.slice(start, end)).trim();\n const colon = piece.indexOf(\":\");\n if (colon > 0) {\n names.push(piece.slice(0, colon).trim());\n }\n };\n for (let index = 0; index < parameters.length; index += 1) {\n const char = parameters[index];\n if (char === \"(\" || char === \"<\") {\n depth += 1;\n } else if (char === \")\" || char === \">\") {\n depth -= 1;\n } else if (char === \",\" && depth === 0) {\n take(index);\n start = index + 1;\n }\n }\n take(parameters.length);\n return names;\n}\n\n/**\n * Writes a declared scalar, vector, or matrix uniform.\n *\n * @remarks\n * Lite compares the incoming numbers with the ones it holds and bumps the material's uniform\n * version only when one changed, so calling this every frame with an unchanged value costs a few\n * comparisons and no upload (`lib/material/shader/shader-material.js`, `setUniformValue`).\n *\n * @param material - The material to write to.\n * @param name - The declared uniform name.\n * @param value - The value; its length must match the declared type.\n * @throws Error from Babylon Lite when the name is not declared or the length is wrong.\n *\n * @internal\n */\nexport function writeShaderUniform(\n material: ShaderMaterial,\n name: string,\n value: number | readonly number[] | Float32Array,\n): void {\n setShaderUniform(material, name, value);\n}\n\n/**\n * Writes a declared `mat4x4<f32>` uniform from sixteen column-major floats.\n *\n * @param material - The material to write to.\n * @param name - The declared uniform name.\n * @param value - The matrix.\n *\n * @internal\n */\nexport function writeShaderMatrix(material: ShaderMaterial, name: string, value: Float32Array): void {\n setShaderMatrix(material, name, value);\n}\n\n/**\n * Binds or clears a declared sampler's texture.\n *\n * @param material - The material to write to.\n * @param name - The declared sampler name.\n * @param texture - The texture, or `null` to unbind. An unbound sampler makes the material\n * unbuildable, so ignifx always binds a fallback instead.\n *\n * @internal\n */\nexport function writeShaderTexture(material: ShaderMaterial, name: string, texture: Texture2D | null): void {\n setShaderTexture(material, name, texture);\n}\n\n/**\n * Binds or clears a declared storage buffer.\n *\n * @param material - The material to write to.\n * @param name - The declared storage buffer name.\n * @param buffer - The buffer, or `null` to unbind.\n *\n * @internal\n */\nexport function writeShaderStorageBuffer(material: ShaderMaterial, name: string, buffer: StorageBuffer | null): void {\n setShaderStorageBuffer(material, name, buffer);\n}\n\n/**\n * The 1x1 texture a declared-but-unbound sampler is filled with, created on first use and shared for\n * the life of the app.\n *\n * @param engine - The engine that owns the texture.\n * @param cache - The app's fallback textures, keyed by kind; a miss is created and stored.\n * @param fallback - `\"white\"`, `\"black\"`, or `\"transparent\"`; `null` means white.\n * @param array - `true` for a one-layer `texture_2d_array<f32>`.\n * @returns The texture.\n *\n * @internal\n */\nexport function resolveFallbackTexture(\n engine: EngineContext,\n cache: Map<string, Texture2D>,\n fallback: string | null,\n array: boolean,\n): Texture2D {\n const kind = fallback ?? \"white\";\n const key = array ? `${kind}:array` : kind;\n const cached = cache.get(key);\n if (cached !== undefined) {\n return cached;\n }\n const created = createFallbackTexture(engine, kind, array);\n cache.set(key, created);\n return created;\n}\n\n/**\n * Creates the 1x1 texture a declared-but-unbound sampler is filled with.\n *\n * @remarks\n * Babylon Lite refuses to build a bind group for a sampler with nothing bound (error 309), so a\n * material whose file declares `// @ignifx texture noise` and whose `.material.json` binds nothing\n * would be undrawable. One 1x1 texture per fallback kind per app is what makes it legal, which is\n * also Godot's `hint_default_white` behaviour.\n *\n * @param engine - The engine that owns the texture.\n * @param fallback - `\"white\"`, `\"black\"`, or `\"transparent\"`.\n * @param array - `true` for a one-layer `texture_2d_array<f32>`, which is what a sampler declared\n * `array` binds.\n * @returns The texture.\n *\n * @internal\n */\nexport function createFallbackTexture(engine: EngineContext, fallback: string, array: boolean): Texture2D {\n const rgba = FALLBACK_PIXELS[fallback] ?? FALLBACK_PIXELS[\"white\"];\n const pixels = Uint8Array.from(rgba ?? [255, 255, 255, 255]);\n return array\n ? createTexture2DArrayFromPixels(engine, pixels, 1, 1, 1, { mipMaps: false })\n : createTexture2DFromPixels(engine, pixels, 1, 1, {});\n}\n\n/**\n * Turns on Babylon Lite's cached uniform serialization plans for shader materials.\n *\n * @remarks\n * Process-global and idempotent: it installs two writer functions that keep a `WeakMap` of layout\n * plans per material and rewrite only the custom uniform slots whose value changed\n * (`lib/material/shader/enable-shader-material-uniform-caching.js`). That is exactly the shape of\n * ignifx's per-frame `time` upload, so the adapter enables it as it loads rather than making every\n * project remember to.\n *\n * @internal\n */\nexport function enableShaderUniformCaching(): void {\n enableShaderMaterialUniformCaching();\n}\n\n/**\n * Reads the installed environment's ambient irradiance — the `L00` band of its diffuse spherical\n * harmonics — into `out`.\n *\n * @remarks\n * `EnvironmentTextures.sphericalHarmonics` is declared: 36 floats in a stride-4 layout beginning\n * `[L00.rgb, 0, …]` (`index.d.ts`), the same block Babylon Lite writes into the scene uniform buffer\n * as `scene.vSphericalL00` and friends (`lib/scene/scene-ubo-extras.js`, `writeEnvUbo`). So the\n * value ignifx uploads as `ambientColor` is exactly what a shader could read for itself as\n * `scene.vSphericalL00.rgb`, which is the documented alternative for a shader that would rather not\n * declare the uniform. Reaching the slot goes through `./environment.ts`, which is the one place\n * ignifx touches the undeclared `scene._envTextures` field\n * (`docs/architecture/07-rendering.md` §2.5, §8).\n *\n * @param scene - The render scene.\n * @param out - Receives the three linear channels; left untouched when nothing is installed.\n * @returns `true` when an environment supplied harmonics.\n *\n * @internal\n */\nexport function readSceneAmbient(scene: SceneContext, out: Float32Array): boolean {\n const harmonics = readSceneEnvironment(scene)?.sphericalHarmonics;\n if (harmonics === undefined || harmonics.length < 3) {\n return false;\n }\n out[0] = harmonics[0] ?? 0;\n out[1] = harmonics[1] ?? 0;\n out[2] = harmonics[2] ?? 0;\n return true;\n}\n\n/**\n * The subset of this module `src/render/shader-material.ts` reaches through its dynamic `import()`,\n * named so the memo has a type that does not have to be written as `typeof import(…)` (which the\n * `consistent-type-imports` rule forbids).\n *\n * @remarks\n * Assigning the imported module namespace to this type is what checks the two against each other,\n * so a signature that drifts is a compile error rather than a runtime surprise.\n *\n * @internal\n */\nexport interface ShaderMaterialAdapter {\n /** {@link createShaderMaterialFromOptions}. */\n readonly createShaderMaterialFromOptions: (options: ShaderMaterialBuildOptions) => ShaderMaterial;\n /** {@link writeShaderUniform}. */\n readonly writeShaderUniform: (\n material: ShaderMaterial,\n name: string,\n value: number | readonly number[] | Float32Array,\n ) => void;\n /** {@link writeShaderMatrix}. */\n readonly writeShaderMatrix: (material: ShaderMaterial, name: string, value: Float32Array) => void;\n /** {@link writeShaderTexture}. */\n readonly writeShaderTexture: (material: ShaderMaterial, name: string, texture: Texture2D | null) => void;\n /** {@link writeShaderStorageBuffer}. */\n readonly writeShaderStorageBuffer: (material: ShaderMaterial, name: string, buffer: StorageBuffer | null) => void;\n /** {@link resolveFallbackTexture}. */\n readonly resolveFallbackTexture: (\n engine: EngineContext,\n cache: Map<string, Texture2D>,\n fallback: string | null,\n array: boolean,\n ) => Texture2D;\n /** {@link enableShaderUniformCaching}. */\n readonly enableShaderUniformCaching: () => void;\n /** {@link readSceneAmbient}. */\n readonly readSceneAmbient: (scene: SceneContext, out: Float32Array) => boolean;\n}\n"],"mappings":";;;;AAsDA,MAAM,kBAAuF,OAAO,OAAO;CACzG,OAAO;EAAC;EAAK;EAAK;EAAK;CAAG;CAC1B,OAAO;EAAC;EAAG;EAAG;EAAG;CAAG;CACpB,aAAa;EAAC;EAAG;EAAG;EAAG;CAAC;AAC1B,CAAC;;;;;;;;;;;;;;AAyGD,SAAgB,gCAAgC,SAAqD;CACnG,MAAM,gBAAgB,QAAQ,OAAO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;;;;AAYA,SAAgB,mBAAmB,UAA0B,MAAc,SAAiC;CAC1G,iBAAiB,UAAU,MAAM,OAAO;AAC1C;;;;;;;;;;AAWA,SAAgB,yBAAyB,UAA0B,MAAc,QAAoC;CACnH,uBAAuB,UAAU,MAAM,MAAM;AAC/C;;;;;;;;;;;;;AAcA,SAAgB,uBACd,QACA,OACA,UACA,OACW;CACX,MAAM,OAAO,YAAY;CACzB,MAAM,MAAM,QAAQ,GAAG,KAAK,UAAU;CACtC,MAAM,SAAS,MAAM,IAAI,GAAG;CAC5B,IAAI,WAAW,KAAA,GACb,OAAO;CAET,MAAM,UAAU,sBAAsB,QAAQ,MAAM,KAAK;CACzD,MAAM,IAAI,KAAK,OAAO;CACtB,OAAO;AACT;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,sBAAsB,QAAuB,UAAkB,OAA2B;CACxG,MAAM,OAAO,gBAAgB,aAAa,gBAAgB;CAC1D,MAAM,SAAS,WAAW,KAAK,QAAQ;EAAC;EAAK;EAAK;EAAK;CAAG,CAAC;CAC3D,OAAO,QACH,+BAA+B,QAAQ,QAAQ,GAAG,GAAG,GAAG,EAAE,SAAS,MAAM,CAAC,IAC1E,0BAA0B,QAAQ,QAAQ,GAAG,GAAG,CAAC,CAAC;AACxD;;;;;;;;;;;;;AAcA,SAAgB,6BAAmC;CACjD,mCAAmC;AACrC;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,iBAAiB,OAAqB,KAA4B;CAChF,MAAM,YAAY,qBAAqB,KAAK,CAAC,EAAE;CAC/C,IAAI,cAAc,KAAA,KAAa,UAAU,SAAS,GAChD,OAAO;CAET,IAAI,KAAK,UAAU,MAAM;CACzB,IAAI,KAAK,UAAU,MAAM;CACzB,IAAI,KAAK,UAAU,MAAM;CACzB,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"shader-material-CaAkv5nT.js","names":[],"sources":["../src/lite/gpu/shader-material.ts"],"sourcesContent":["import {\n createShaderMaterial,\n createTexture2DArrayFromPixels,\n createTexture2DFromPixels,\n enableShaderMaterialUniformCaching,\n setShaderMatrix,\n setShaderStorageBuffer,\n setShaderTexture,\n setShaderUniform,\n} from \"@babylonjs/lite\";\nimport { readSceneEnvironment } from \"./environment.js\";\nimport type {\n EngineContext,\n SceneContext,\n ShaderAttributeName,\n ShaderMaterial,\n ShaderSystemUniformName,\n ShaderUniformType,\n StorageBuffer,\n Texture2D,\n} from \"@babylonjs/lite\";\n\n/**\n * The custom-WGSL half of the Babylon Lite adapter: `createShaderMaterial`, the `setShader*`\n * setters, and the 1x1 fallback textures a declared sampler falls back to\n * (`docs/plan/2026-09-terrain-particles-shaders.md` §3.1, ADR-0024). Everything here is `@internal`.\n *\n * Lite exports one barrel, so a static import of `createShaderMaterial` anywhere in the reachable\n * graph pulls `lib/material/shader/**` into every entry chunk. This module is therefore reached with\n * `await import(...)` from `../../render/shader-support.ts`, and only loading a `.wgsl` triggers the\n * fetch. `./storage-buffer.ts` is a separate file for the same reason: `StorageBufferAsset`\n * allocates synchronously, so it cannot wait for this chunk.\n *\n * Two Lite facts it is written around:\n *\n * - Nothing may be left unbound: `createShaderBindGroup` throws (errors 309 and 310) when a declared\n * sampler has no texture or a declared storage buffer has no buffer, which is what\n * {@link createFallbackTexture} exists for.\n * - There is no front-face culling; `ShaderMaterialOptions` carries only `backFaceCulling`\n * (`lib/material/shader/shader-pipeline.js`), so the pragma parser refuses `cull front`.\n */\n\n/**\n * A Babylon Lite custom WGSL material, re-exported under an ignifx name\n * (`CONSTITUTION.md` §3.4, coding standards §4).\n *\n * @remarks\n * Unstable; excluded from the stability guarantees of `CONSTITUTION.md` Article IV.\n *\n * @public\n */\nexport type LiteShaderMaterial = ShaderMaterial;\n\n/** The RGBA bytes of each 1x1 fallback texture. */\nconst FALLBACK_PIXELS: Readonly<Record<string, readonly [number, number, number, number]>> = Object.freeze({\n white: [255, 255, 255, 255],\n black: [0, 0, 0, 255],\n transparent: [0, 0, 0, 0],\n});\n\n/**\n * One declared uniform in the form Babylon Lite's factory takes: either the name of a system\n * uniform it fills in itself, or a custom declaration with its initial value.\n *\n * @internal\n */\nexport type ShaderUniformEntry =\n | ShaderSystemUniformName\n | {\n /** The WGSL identifier. */\n readonly name: string;\n /** The WGSL type. */\n readonly type: ShaderUniformType;\n /** The initial value, **linear** for a colour. */\n readonly defaultValue: number | readonly number[];\n };\n\n/**\n * One declared sampler in the form Babylon Lite's factory takes.\n *\n * @internal\n */\nexport interface ShaderSamplerEntry {\n /** The WGSL identifier; Lite generates `<name>Sampler` beside it. */\n readonly name: string;\n /** `\"2d-array\"` for a `texture_2d_array<f32>` binding. */\n readonly viewDimension: \"2d\" | \"2d-array\";\n}\n\n/**\n * One declared storage buffer in the form Babylon Lite's factory takes.\n *\n * @internal\n */\nexport interface ShaderStorageEntry {\n /** The WGSL identifier. */\n readonly name: string;\n /** The WGSL variable type, verbatim. */\n readonly type: string;\n}\n\n/**\n * Everything Babylon Lite's `createShaderMaterial` needs, in ignifx's own vocabulary so that the\n * mapping from a `ShaderDeclaration` can be built and asserted without a device or a Lite import\n * (`src/render/shader-material.ts`).\n *\n * @remarks\n * A `null` blend state or depth comparison means \"leave Babylon Lite's own default in place\", so\n * this module never restates a Lite default that could change.\n *\n * @internal\n */\nexport interface ShaderMaterialBuildOptions {\n /** The material's name, used in pipeline and shader-module labels. */\n readonly name: string;\n /** The WGSL source, handed to Lite as both the vertex and the fragment source. */\n readonly source: string;\n /**\n * Whether the scene renders through `rendering.hdr`, where the fragment's display colour is\n * decoded to linear before it is written (see {@link linearOutputFragment}). Absent means `false`.\n */\n readonly linearOutput?: boolean;\n /** The vertex attributes the vertex stage reads; `position` is mandatory. */\n readonly attributes: readonly ShaderAttributeName[];\n /** The system and custom uniforms, in binding-declaration order. */\n readonly uniforms: readonly ShaderUniformEntry[];\n /** The samplers. */\n readonly samplers: readonly ShaderSamplerEntry[];\n /** The read-only storage buffers. */\n readonly storageBuffers: readonly ShaderStorageEntry[];\n /** The WGSL `const` declarations, resolved from the file's defaults and the material's overrides. */\n readonly defines: Readonly<Record<string, boolean | number>>;\n /** Whether the thin-instance RGBA stream is bound and injected into `VertexInput`. */\n readonly useThinInstanceColors: boolean;\n /** Whether the surface is alpha-blended. */\n readonly needAlphaBlending: boolean;\n /** Which of Lite's two blend equations to use when no explicit state is given. */\n readonly blendMode: \"alpha\" | \"additive\";\n /** An explicit colour-target blend state, which replaces the derived one; `null` to derive it. */\n readonly blend: GPUBlendState | null;\n /** Whether the surface samples the opaque scene colour behind it. */\n readonly transmissive: boolean;\n /** Whether back faces are culled. */\n readonly backFaceCulling: boolean;\n /** Whether the draw writes depth. */\n readonly depthWrite: boolean;\n /** The depth comparison, or `null` for Lite's own reverse-Z default. */\n readonly depthCompare: GPUCompareFunction | null;\n}\n\n/**\n * Builds a Babylon Lite custom WGSL material.\n *\n * @remarks\n * Validation is eager and compilation is lazy, so this runs under the null engine; the pipeline is\n * compiled the first time a mesh wearing the material is drawn.\n *\n * @param options - The sources and the declared attribute, uniform, sampler, and storage layout.\n * @returns The material.\n * @throws Error from Babylon Lite when the declaration is not one it can build.\n *\n * @internal\n */\nexport function createShaderMaterialFromOptions(options: ShaderMaterialBuildOptions): ShaderMaterial {\n const premultiplied = options.blend?.color.srcFactor === \"one\";\n return createShaderMaterial({\n name: options.name,\n vertexSource: options.source,\n fragmentSource:\n options.linearOutput === true ? linearOutputFragment(options.source, premultiplied) : options.source,\n attributes: options.attributes,\n uniforms: options.uniforms,\n samplers: options.samplers,\n storageBuffers: options.storageBuffers,\n defines: options.defines,\n useThinInstanceColors: options.useThinInstanceColors,\n needAlphaBlending: options.needAlphaBlending,\n blendMode: options.blendMode,\n ...(options.blend === null ? {} : { blend: options.blend }),\n transmissive: options.transmissive,\n backFaceCulling: options.backFaceCulling,\n depthWrite: options.depthWrite,\n ...(options.depthCompare === null ? {} : { depthCompare: options.depthCompare }),\n });\n}\n\n/** The name a wrapped `mainFragment` is renamed to. */\nconst WRAPPED_FRAGMENT = \"ignifxDisplayFragment\";\n\n/**\n * Wraps a custom shader's `mainFragment` so that, under `rendering.hdr`, it writes linear colour\n * (`docs/plan/2026-11-gi-phase-1-execution-plan.md`, step G3).\n *\n * @remarks\n * A custom shader writes the colour that is displayed: with HDR off it lands on the swapchain as\n * is. With HDR on it lands in the linear scene target and the output pass encodes it, so the\n * wrapper decodes it first with the exact inverse of that encode (`pow(c, 2.2)`). The user's entry\n * point loses its `@fragment` and is renamed; a new `mainFragment` with the same parameters calls\n * it. A premultiplied colour is divided by alpha before the decode and multiplied after it, so the\n * blend still sees premultiplied colour. Only a single `@location(0) vec4<f32>` return can be\n * wrapped; anything else (a struct of outputs) is returned unchanged.\n *\n * @param source - The `.wgsl` file.\n * @param premultiplied - Whether the material blends premultiplied colour.\n * @returns The fragment source.\n *\n * @internal\n */\nexport function linearOutputFragment(source: string, premultiplied: boolean): string {\n const entry = /@fragment\\s+fn\\s+mainFragment\\s*\\(/u.exec(source);\n if (entry === null) {\n return source;\n }\n const open = entry.index + entry[0].length - 1;\n const close = matchingParen(source, open);\n if (close < 0) {\n return source;\n }\n const after = source.slice(close + 1);\n const result = /^\\s*->\\s*@location\\(\\s*0\\s*\\)\\s*vec4\\s*<\\s*f32\\s*>\\s*\\{/u.exec(after);\n if (result === null) {\n return source;\n }\n const parameters = source.slice(open + 1, close);\n const names = parameterNames(parameters);\n const decode = premultiplied\n ? \"select(pow(max(c.rgb,vec3<f32>(0.0)),vec3<f32>(2.2)),pow(max(c.rgb/c.a,vec3<f32>(0.0)),vec3<f32>(2.2))*c.a,c.a>0.0)\"\n : \"pow(max(c.rgb,vec3<f32>(0.0)),vec3<f32>(2.2))\";\n return [\n // A plain function may not carry the entry point's `@location(0)` on its return type.\n `${source.slice(0, entry.index)}fn ${WRAPPED_FRAGMENT}(${stripAttributes(parameters)})->vec4<f32>{${after.slice(result[0].length)}`,\n `@fragment fn mainFragment(${parameters})->@location(0) vec4<f32>{`,\n `let c=${WRAPPED_FRAGMENT}(${names.join(\",\")});`,\n `return vec4<f32>(${decode},c.a);`,\n \"}\",\n ].join(\"\\n\");\n}\n\n/**\n * Finds the parenthesis that closes the one at `open`.\n *\n * @param text - The source.\n * @param open - The index of a `(`.\n * @returns The index of its `)`, or `-1`.\n */\nfunction matchingParen(text: string, open: number): number {\n let depth = 0;\n for (let index = open; index < text.length; index += 1) {\n const char = text[index];\n if (char === \"(\") {\n depth += 1;\n } else if (char === \")\") {\n depth -= 1;\n if (depth === 0) {\n return index;\n }\n }\n }\n return -1;\n}\n\n/**\n * Removes WGSL attributes (`@builtin(position)`, `@location(0)`, `@interpolate(flat)`) from a\n * parameter list, which a plain function's parameters may not carry.\n *\n * @param parameters - The parameter list.\n * @returns The list without attributes.\n */\nfunction stripAttributes(parameters: string): string {\n return parameters.replaceAll(/@\\w+\\s*(\\([^)]*\\))?\\s*/gu, \"\");\n}\n\n/**\n * The parameter names of a WGSL parameter list, attributes stripped.\n *\n * @param parameters - The text between an entry point's parentheses.\n * @returns The names, in order.\n */\nfunction parameterNames(parameters: string): string[] {\n const names: string[] = [];\n let depth = 0;\n let start = 0;\n const take = (end: number): void => {\n const piece = stripAttributes(parameters.slice(start, end)).trim();\n const colon = piece.indexOf(\":\");\n if (colon > 0) {\n names.push(piece.slice(0, colon).trim());\n }\n };\n for (let index = 0; index < parameters.length; index += 1) {\n const char = parameters[index];\n if (char === \"(\" || char === \"<\") {\n depth += 1;\n } else if (char === \")\" || char === \">\") {\n depth -= 1;\n } else if (char === \",\" && depth === 0) {\n take(index);\n start = index + 1;\n }\n }\n take(parameters.length);\n return names;\n}\n\n/**\n * Writes a declared scalar, vector, or matrix uniform.\n *\n * @remarks\n * Lite compares the incoming numbers with the ones it holds and bumps the material's uniform\n * version only when one changed, so calling this every frame with an unchanged value costs a few\n * comparisons and no upload (`lib/material/shader/shader-material.js`, `setUniformValue`).\n *\n * @param material - The material to write to.\n * @param name - The declared uniform name.\n * @param value - The value; its length must match the declared type.\n * @throws Error from Babylon Lite when the name is not declared or the length is wrong.\n *\n * @internal\n */\nexport function writeShaderUniform(\n material: ShaderMaterial,\n name: string,\n value: number | readonly number[] | Float32Array,\n): void {\n setShaderUniform(material, name, value);\n}\n\n/**\n * Writes a declared `mat4x4<f32>` uniform from sixteen column-major floats.\n *\n * @param material - The material to write to.\n * @param name - The declared uniform name.\n * @param value - The matrix.\n *\n * @internal\n */\nexport function writeShaderMatrix(material: ShaderMaterial, name: string, value: Float32Array): void {\n setShaderMatrix(material, name, value);\n}\n\n/**\n * Binds or clears a declared sampler's texture.\n *\n * @param material - The material to write to.\n * @param name - The declared sampler name.\n * @param texture - The texture, or `null` to unbind. An unbound sampler makes the material\n * unbuildable, so ignifx always binds a fallback instead.\n *\n * @internal\n */\nexport function writeShaderTexture(material: ShaderMaterial, name: string, texture: Texture2D | null): void {\n setShaderTexture(material, name, texture);\n}\n\n/**\n * Binds or clears a declared storage buffer.\n *\n * @param material - The material to write to.\n * @param name - The declared storage buffer name.\n * @param buffer - The buffer, or `null` to unbind.\n *\n * @internal\n */\nexport function writeShaderStorageBuffer(material: ShaderMaterial, name: string, buffer: StorageBuffer | null): void {\n setShaderStorageBuffer(material, name, buffer);\n}\n\n/**\n * The 1x1 texture a declared-but-unbound sampler is filled with, created on first use and shared for\n * the life of the app.\n *\n * @param engine - The engine that owns the texture.\n * @param cache - The app's fallback textures, keyed by kind; a miss is created and stored.\n * @param fallback - `\"white\"`, `\"black\"`, or `\"transparent\"`; `null` means white.\n * @param array - `true` for a one-layer `texture_2d_array<f32>`.\n * @returns The texture.\n *\n * @internal\n */\nexport function resolveFallbackTexture(\n engine: EngineContext,\n cache: Map<string, Texture2D>,\n fallback: string | null,\n array: boolean,\n): Texture2D {\n const kind = fallback ?? \"white\";\n const key = array ? `${kind}:array` : kind;\n const cached = cache.get(key);\n if (cached !== undefined) {\n return cached;\n }\n const created = createFallbackTexture(engine, kind, array);\n cache.set(key, created);\n return created;\n}\n\n/**\n * Creates the 1x1 texture a declared-but-unbound sampler is filled with.\n *\n * @remarks\n * Babylon Lite refuses to build a bind group for a sampler with nothing bound (error 309), so a\n * material whose file declares `// @ignifx texture noise` and whose `.material.json` binds nothing\n * would be undrawable. One 1x1 texture per fallback kind per app is what makes it legal, which is\n * also Godot's `hint_default_white` behaviour.\n *\n * @param engine - The engine that owns the texture.\n * @param fallback - `\"white\"`, `\"black\"`, or `\"transparent\"`.\n * @param array - `true` for a one-layer `texture_2d_array<f32>`, which is what a sampler declared\n * `array` binds.\n * @returns The texture.\n *\n * @internal\n */\nexport function createFallbackTexture(engine: EngineContext, fallback: string, array: boolean): Texture2D {\n const rgba = FALLBACK_PIXELS[fallback] ?? FALLBACK_PIXELS[\"white\"];\n const pixels = Uint8Array.from(rgba ?? [255, 255, 255, 255]);\n return array\n ? createTexture2DArrayFromPixels(engine, pixels, 1, 1, 1, { mipMaps: false })\n : createTexture2DFromPixels(engine, pixels, 1, 1, {});\n}\n\n/**\n * Turns on Babylon Lite's cached uniform serialization plans for shader materials.\n *\n * @remarks\n * Process-global and idempotent: it installs two writer functions that keep a `WeakMap` of layout\n * plans per material and rewrite only the custom uniform slots whose value changed\n * (`lib/material/shader/enable-shader-material-uniform-caching.js`). That is exactly the shape of\n * ignifx's per-frame `time` upload, so the adapter enables it as it loads rather than making every\n * project remember to.\n *\n * @internal\n */\nexport function enableShaderUniformCaching(): void {\n enableShaderMaterialUniformCaching();\n}\n\n/**\n * Reads the installed environment's ambient irradiance — the `L00` band of its diffuse spherical\n * harmonics — into `out`.\n *\n * @remarks\n * `EnvironmentTextures.sphericalHarmonics` is declared: 36 floats in a stride-4 layout beginning\n * `[L00.rgb, 0, …]` (`index.d.ts`), the same block Babylon Lite writes into the scene uniform buffer\n * as `scene.vSphericalL00` and friends (`lib/scene/scene-ubo-extras.js`, `writeEnvUbo`). So the\n * value ignifx uploads as `ambientColor` is exactly what a shader could read for itself as\n * `scene.vSphericalL00.rgb`, which is the documented alternative for a shader that would rather not\n * declare the uniform. Reaching the slot goes through `./environment.ts`, which is the one place\n * ignifx touches the undeclared `scene._envTextures` field\n * (`docs/architecture/07-rendering.md` §2.5, §8).\n *\n * @param scene - The render scene.\n * @param out - Receives the three linear channels; left untouched when nothing is installed.\n * @returns `true` when an environment supplied harmonics.\n *\n * @internal\n */\nexport function readSceneAmbient(scene: SceneContext, out: Float32Array): boolean {\n const harmonics = readSceneEnvironment(scene)?.sphericalHarmonics;\n if (harmonics === undefined || harmonics.length < 3) {\n return false;\n }\n out[0] = harmonics[0] ?? 0;\n out[1] = harmonics[1] ?? 0;\n out[2] = harmonics[2] ?? 0;\n return true;\n}\n\n/**\n * The subset of this module `src/render/shader-material.ts` reaches through its dynamic `import()`,\n * named so the memo has a type that does not have to be written as `typeof import(…)` (which the\n * `consistent-type-imports` rule forbids).\n *\n * @remarks\n * Assigning the imported module namespace to this type is what checks the two against each other,\n * so a signature that drifts is a compile error rather than a runtime surprise.\n *\n * @internal\n */\nexport interface ShaderMaterialAdapter {\n /** {@link createShaderMaterialFromOptions}. */\n readonly createShaderMaterialFromOptions: (options: ShaderMaterialBuildOptions) => ShaderMaterial;\n /** {@link writeShaderUniform}. */\n readonly writeShaderUniform: (\n material: ShaderMaterial,\n name: string,\n value: number | readonly number[] | Float32Array,\n ) => void;\n /** {@link writeShaderMatrix}. */\n readonly writeShaderMatrix: (material: ShaderMaterial, name: string, value: Float32Array) => void;\n /** {@link writeShaderTexture}. */\n readonly writeShaderTexture: (material: ShaderMaterial, name: string, texture: Texture2D | null) => void;\n /** {@link writeShaderStorageBuffer}. */\n readonly writeShaderStorageBuffer: (material: ShaderMaterial, name: string, buffer: StorageBuffer | null) => void;\n /** {@link resolveFallbackTexture}. */\n readonly resolveFallbackTexture: (\n engine: EngineContext,\n cache: Map<string, Texture2D>,\n fallback: string | null,\n array: boolean,\n ) => Texture2D;\n /** {@link enableShaderUniformCaching}. */\n readonly enableShaderUniformCaching: () => void;\n /** {@link readSceneAmbient}. */\n readonly readSceneAmbient: (scene: SceneContext, out: Float32Array) => boolean;\n}\n"],"mapp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A,KAAa,UAAU,SAAS,GAChD,OAAO;CAET,IAAI,KAAK,UAAU,MAAM;CACzB,IAAI,KAAK,UAAU,MAAM;CACzB,IAAI,KAAK,UAAU,MAAM;CACzB,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as CoreErrorCode, t as IgnifxError } from "./ignifx-error-
|
|
1
|
+
import { o as CoreErrorCode, t as IgnifxError } from "./ignifx-error-B8ByiSfJ.js";
|
|
2
2
|
import { a as SHADER_BLEND_MODES, i as SHADER_ATTRIBUTE_NAMES, l as SHADER_TEXTURE_FALLBACKS, o as SHADER_CULL_MODES, r as LITE_SYSTEM_UNIFORM_NAMES, s as SHADER_INSTANCING_MODES, t as IGNIFX_UNIFORM_NAMES, u as SHADER_UNIFORM_TYPES } from "./shader-declaration-5q__jycG.js";
|
|
3
3
|
//#region src/render/shader-pragma.ts
|
|
4
4
|
/**
|
|
@@ -703,4 +703,4 @@ function pragmaError(address, line, message) {
|
|
|
703
703
|
//#endregion
|
|
704
704
|
export { parseShaderDeclaration };
|
|
705
705
|
|
|
706
|
-
//# sourceMappingURL=shader-pragma-
|
|
706
|
+
//# sourceMappingURL=shader-pragma-DmZpxGUo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-pragma-BKCoZTTA.js","names":[],"sources":["../src/render/shader-pragma.ts"],"sourcesContent":["import { CoreErrorCode } from \"../errors/error-codes.js\";\nimport { IgnifxError } from \"../errors/ignifx-error.js\";\nimport {\n IGNIFX_UNIFORM_NAMES,\n LITE_SYSTEM_UNIFORM_NAMES,\n SHADER_ATTRIBUTE_NAMES,\n SHADER_BLEND_MODES,\n SHADER_CULL_MODES,\n SHADER_INSTANCING_MODES,\n SHADER_TEXTURE_FALLBACKS,\n SHADER_UNIFORM_TYPES,\n} from \"./shader-declaration.js\";\nimport type {\n IgnifxUniformName,\n LiteSystemUniformName,\n ShaderAttributeName,\n ShaderBlendMode,\n ShaderCullMode,\n ShaderDeclaration,\n ShaderDefineDeclaration,\n ShaderInstancingMode,\n ShaderKind,\n ShaderStorageDeclaration,\n ShaderTextureDeclaration,\n ShaderTextureFallback,\n ShaderUniformDeclaration,\n ShaderUniformType,\n} from \"./shader-declaration.js\";\n\n/**\n * Reads the `// @ignifx …` comment pragmas of a `.wgsl` file into a {@link ShaderDeclaration}\n * (grammar: `docs/plan/2026-09-terrain-particles-shaders.md` §3.1; rationale: ADR-0024).\n *\n * Pure string work with no Babylon Lite import, so the build-time validator and the runtime loader\n * can share it. Four rules the grammar itself does not show:\n *\n * - `@ignifx system` mixes Lite's names with ignifx's, and the WGSL reads them from different\n * structs, so they are split into `declaration.system` and `declaration.ignifx`.\n * - An omitted `attributes` directive means `position`; Lite refuses a shader material without it\n * (`lib/material/shader/shader-material.js`, error 293).\n * - A `color(…)` default keeps the authored sRGB numbers; `./shader-material.ts` converts.\n * - `cull front` and `transmissive` on an opaque surface are refused here, with a line number,\n * because Lite has no front-face culling and throws on the second combination (error 295).\n */\n\n/** Matches an `// @ignifx …` line and captures the directive text after it. */\nconst PRAGMA_LINE = /^\\s*\\/\\/\\s*@ignifx\\b(.*)$/;\n\n/** Matches a WGSL identifier. */\nconst IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/** Splits `name: type` at the colon, capturing the identifier and the rest of the line. */\nconst NAME_AND_TYPE = /^([A-Za-z_][A-Za-z0-9_]*)\\s*:\\s*(.*)$/;\n\n/** Matches a leading `tooltip(\"…\")` modifier, capturing the quoted text. */\nconst TOOLTIP_MODIFIER = /^tooltip\\(\\s*\"((?:[^\"\\\\]|\\\\.)*)\"\\s*\\)\\s*/;\n\n/** Matches a leading `range(…)`, `step(…)`, or `color(…)`/`color` modifier. */\nconst CALL_MODIFIER = /^(range|step|color)\\s*(?:\\(([^)]*)\\))?\\s*/;\n\n/** Matches a leading `color(…)` default value, capturing the arguments. */\nconst COLOR_DEFAULT = /^color\\s*\\(([^)]*)\\)\\s*/;\n\n/** Matches a leading parenthesised numeric list, capturing the arguments. */\nconst TUPLE_DEFAULT = /^\\(([^)]*)\\)\\s*/;\n\n/** Matches a leading decimal number, with optional sign and exponent. */\nconst NUMBER_DEFAULT = /^([+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?)\\s*/;\n\n/** How many elements each uniform type holds. */\nconst ELEMENT_COUNTS: Readonly<Record<ShaderUniformType, number>> = Object.freeze({\n f32: 1,\n u32: 1,\n i32: 1,\n \"vec2<f32>\": 2,\n \"vec3<f32>\": 3,\n \"vec4<f32>\": 4,\n \"mat4x4<f32>\": 16,\n});\n\n/** The identity matrix a `mat4x4<f32>` uniform starts at when the file declares no default. */\nconst IDENTITY_MATRIX: readonly number[] = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);\n\n/** The mutable declaration the parser fills in, line by line. */\ninterface DeclarationDraft {\n kind: ShaderKind | null;\n attributes: ShaderAttributeName[] | null;\n readonly system: LiteSystemUniformName[];\n readonly ignifx: IgnifxUniformName[];\n readonly uniforms: ShaderUniformDeclaration[];\n readonly textures: ShaderTextureDeclaration[];\n readonly storage: ShaderStorageDeclaration[];\n readonly defines: ShaderDefineDeclaration[];\n readonly names: Set<string>;\n blend: ShaderBlendMode | null;\n cull: ShaderCullMode | null;\n depthWrite: boolean | null;\n depthTest: boolean | null;\n transmissive: boolean;\n instancing: ShaderInstancingMode | null;\n displace: number | null;\n}\n\n/**\n * Reads a `.wgsl` file's `// @ignifx` pragmas into the declaration the loader, the material\n * builder, and the inspector all read.\n *\n * @param source - The whole file, as text.\n * @param address - The asset address, so a failure names the file.\n * @returns The declaration, with every default filled in.\n * @throws IgnifxError with code `IGX-0719`, carrying the offending `line`, for an unknown directive,\n * a malformed one, a duplicate binding name, an attribute or uniform type Babylon Lite does not\n * have, or a combination it cannot express.\n *\n * @example\n * ```ts\n * const declaration = parseShaderDeclaration(\"// @ignifx shader\\n\", \"shaders/flat.wgsl\");\n * declaration.attributes; // [\"position\"]\n * ```\n *\n * @public\n */\nexport function parseShaderDeclaration(source: string, address: string): ShaderDeclaration {\n const draft: DeclarationDraft = {\n kind: null,\n attributes: null,\n system: [],\n ignifx: [],\n uniforms: [],\n textures: [],\n storage: [],\n defines: [],\n names: new Set<string>(),\n blend: null,\n cull: null,\n depthWrite: null,\n depthTest: null,\n transmissive: false,\n instancing: null,\n displace: null,\n };\n const lines = source.split(\"\\n\");\n for (let index = 0; index < lines.length; index += 1) {\n const matched = PRAGMA_LINE.exec(lines[index] ?? \"\");\n if (matched === null) {\n continue;\n }\n readDirective(draft, (matched[1] ?? \"\").trim(), address, index + 1);\n }\n return finish(draft, address);\n}\n\n/**\n * Applies one `// @ignifx …` line to the draft.\n *\n * @param draft - The declaration being built.\n * @param text - The directive text, already trimmed.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readDirective(draft: DeclarationDraft, text: string, address: string, line: number): void {\n if (text.length === 0) {\n throw pragmaError(address, line, \"an @ignifx comment declares no directive\");\n }\n const separator = text.search(/\\s/);\n const directive = separator < 0 ? text : text.slice(0, separator);\n const rest = separator < 0 ? \"\" : text.slice(separator + 1).trim();\n switch (directive) {\n case \"shader\":\n case \"surface\":\n case \"post\":\n readKind(draft, directive, rest, address, line);\n return;\n case \"attributes\":\n readAttributes(draft, rest, address, line);\n return;\n case \"system\":\n readSystem(draft, rest, address, line);\n return;\n case \"uniform\":\n draft.uniforms.push(readUniform(draft, rest, address, line));\n return;\n case \"texture\":\n draft.textures.push(readTexture(draft, rest, address, line));\n return;\n case \"storage\":\n draft.storage.push(readStorage(draft, rest, address, line));\n return;\n case \"define\":\n draft.defines.push(readDefine(draft, rest, address, line));\n return;\n case \"blend\":\n case \"cull\":\n case \"depthWrite\":\n case \"depthTest\":\n case \"transmissive\":\n case \"instancing\":\n readPipeline(draft, text, address, line);\n return;\n case \"displace\":\n readDisplace(draft, rest, address, line);\n return;\n default:\n throw pragmaError(address, line, `${JSON.stringify(directive)} is not an @ignifx directive`);\n }\n}\n\n/**\n * Records the file's form, refusing a second one.\n *\n * @param draft - The declaration being built.\n * @param kind - The declared form.\n * @param rest - Whatever followed it, which must be nothing.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readKind(draft: DeclarationDraft, kind: ShaderKind, rest: string, address: string, line: number): void {\n if (rest.length > 0) {\n throw pragmaError(address, line, `@ignifx ${kind} takes no arguments, but found ${JSON.stringify(rest)}`);\n }\n if (draft.kind !== null) {\n throw pragmaError(address, line, `the file already declared @ignifx ${draft.kind}`);\n }\n draft.kind = kind;\n}\n\n/**\n * Records the vertex attributes the vertex stage reads.\n *\n * @param draft - The declaration being built.\n * @param rest - The comma-separated attribute names.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readAttributes(draft: DeclarationDraft, rest: string, address: string, line: number): void {\n if (draft.attributes !== null) {\n throw pragmaError(address, line, \"the file already declared @ignifx attributes\");\n }\n const names = splitList(rest, address, line, \"attributes\");\n const attributes: ShaderAttributeName[] = [];\n for (const name of names) {\n const attribute = matchLiteral(SHADER_ATTRIBUTE_NAMES, name);\n if (attribute === null) {\n throw pragmaError(\n address,\n line,\n `${JSON.stringify(name)} is not a vertex attribute; Babylon Lite has ${SHADER_ATTRIBUTE_NAMES.join(\", \")}`,\n );\n }\n if (attributes.includes(attribute)) {\n throw pragmaError(address, line, `the attribute ${attribute} is declared twice`);\n }\n attributes.push(attribute);\n }\n draft.attributes = attributes;\n}\n\n/**\n * Records the system uniforms, splitting Babylon Lite's names from ignifx's own.\n *\n * @param draft - The declaration being built.\n * @param rest - The comma-separated uniform names.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readSystem(draft: DeclarationDraft, rest: string, address: string, line: number): void {\n const names = splitList(rest, address, line, \"system\");\n for (const name of names) {\n const lite = matchLiteral(LITE_SYSTEM_UNIFORM_NAMES, name);\n if (lite !== null) {\n claimName(draft, lite, address, line, \"system uniform\");\n draft.system.push(lite);\n continue;\n }\n const ignifx = matchLiteral(IGNIFX_UNIFORM_NAMES, name);\n if (ignifx !== null) {\n claimName(draft, ignifx, address, line, \"system uniform\");\n draft.ignifx.push(ignifx);\n continue;\n }\n throw pragmaError(\n address,\n line,\n `${JSON.stringify(name)} is not a system uniform; Babylon Lite has ${LITE_SYSTEM_UNIFORM_NAMES.join(\", \")} and ignifx adds ${IGNIFX_UNIFORM_NAMES.join(\", \")}`,\n );\n }\n}\n\n/**\n * Reads one `// @ignifx uniform name: type [= default] [modifiers]` line.\n *\n * @param draft - The declaration being built, for the name namespace.\n * @param rest - The directive body.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The declaration.\n */\nfunction readUniform(draft: DeclarationDraft, rest: string, address: string, line: number): ShaderUniformDeclaration {\n const split = NAME_AND_TYPE.exec(rest);\n if (split === null) {\n throw pragmaError(address, line, `@ignifx uniform expects \"name: type\", but found ${JSON.stringify(rest)}`);\n }\n const name = split[1] ?? \"\";\n let tail = (split[2] ?? \"\").trim();\n const typeSeparator = tail.search(/[\\s=]/);\n const typeName = typeSeparator < 0 ? tail : tail.slice(0, typeSeparator);\n tail = (typeSeparator < 0 ? \"\" : tail.slice(typeName.length)).trim();\n const type = matchLiteral(SHADER_UNIFORM_TYPES, typeName);\n if (type === null) {\n throw pragmaError(\n address,\n line,\n `${JSON.stringify(typeName)} is not a uniform type; Babylon Lite has ${SHADER_UNIFORM_TYPES.join(\", \")}`,\n );\n }\n claimName(draft, name, address, line, \"uniform\");\n let defaultValue: number | readonly number[] | null = null;\n let isColor = false;\n if (tail.startsWith(\"=\")) {\n tail = tail.slice(1).trim();\n const parsed = readDefaultValue(tail, type, name, address, line);\n defaultValue = parsed.value;\n isColor = parsed.color;\n tail = parsed.tail;\n }\n const modifiers = readModifiers(tail, name, type, address, line);\n return {\n name,\n type,\n defaultValue: defaultValue ?? implicitDefault(type),\n color: isColor || modifiers.color,\n range: modifiers.range,\n step: modifiers.step,\n tooltip: modifiers.tooltip,\n };\n}\n\n/** A parsed `= …` default value and whatever followed it. */\ninterface ParsedDefault {\n /** The numbers the file wrote. */\n readonly value: number | readonly number[];\n /** Whether the value was written as `color(…)`. */\n readonly color: boolean;\n /** The rest of the line. */\n readonly tail: string;\n}\n\n/**\n * Reads the `= …` half of a uniform declaration.\n *\n * @param text - The text after the `=`.\n * @param type - The declared type, which fixes the element count.\n * @param name - The uniform's name, for diagnostics.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The value, whether it was a colour, and the rest of the line.\n */\nfunction readDefaultValue(\n text: string,\n type: ShaderUniformType,\n name: string,\n address: string,\n line: number,\n): ParsedDefault {\n const expected = ELEMENT_COUNTS[type];\n const colorMatch = COLOR_DEFAULT.exec(text);\n if (colorMatch !== null) {\n const numbers = readNumbers(colorMatch[1] ?? \"\", name, address, line);\n if (type !== \"vec3<f32>\" && type !== \"vec4<f32>\") {\n throw pragmaError(address, line, `${name} is a ${type}, so color(…) does not apply to it`);\n }\n assertArity(numbers.length, expected, name, type, address, line);\n return { value: numbers, color: true, tail: text.slice(colorMatch[0].length).trim() };\n }\n const tupleMatch = TUPLE_DEFAULT.exec(text);\n if (tupleMatch !== null) {\n const numbers = readNumbers(tupleMatch[1] ?? \"\", name, address, line);\n assertArity(numbers.length, expected, name, type, address, line);\n return { value: numbers, color: false, tail: text.slice(tupleMatch[0].length).trim() };\n }\n const numberMatch = NUMBER_DEFAULT.exec(text);\n if (numberMatch !== null) {\n assertArity(1, expected, name, type, address, line);\n return { value: Number(numberMatch[1]), color: false, tail: text.slice(numberMatch[0].length).trim() };\n }\n throw pragmaError(address, line, `${name} declares no readable default value after \"=\"`);\n}\n\n/** The optional hints an inspector renders a uniform with. */\ninterface ParsedModifiers {\n /** Whether the bare `color` modifier was present. */\n readonly color: boolean;\n /** The `range(a, b)` bounds, or `null`. */\n readonly range: readonly [number, number] | null;\n /** The `step(s)` increment, or `null`. */\n readonly step: number | null;\n /** The `tooltip(\"…\")` text, or `null`. */\n readonly tooltip: string | null;\n}\n\n/**\n * Reads the `range(…)`, `step(…)`, `color`, and `tooltip(\"…\")` modifiers that close a uniform line.\n *\n * @param text - What is left of the line.\n * @param name - The uniform's name, for diagnostics.\n * @param type - The declared type, which decides whether `color` applies.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The hints.\n */\nfunction readModifiers(\n text: string,\n name: string,\n type: ShaderUniformType,\n address: string,\n line: number,\n): ParsedModifiers {\n let rest = text;\n let color = false;\n let range: readonly [number, number] | null = null;\n let step: number | null = null;\n let tooltip: string | null = null;\n while (rest.length > 0) {\n const tooltipMatch = TOOLTIP_MODIFIER.exec(rest);\n if (tooltipMatch !== null) {\n if (tooltip !== null) {\n throw pragmaError(address, line, `${name} declares tooltip twice`);\n }\n tooltip = (tooltipMatch[1] ?? \"\").replaceAll('\\\\\"', '\"');\n rest = rest.slice(tooltipMatch[0].length);\n continue;\n }\n const callMatch = CALL_MODIFIER.exec(rest);\n if (callMatch === null) {\n throw pragmaError(address, line, `${name} declares ${JSON.stringify(rest)}, which is not a uniform modifier`);\n }\n const modifier = callMatch[1] ?? \"\";\n const argumentText = callMatch[2];\n if (modifier === \"color\") {\n if (argumentText !== undefined) {\n throw pragmaError(address, line, `${name} declares color(…) after its default value`);\n }\n if (type !== \"vec3<f32>\" && type !== \"vec4<f32>\") {\n throw pragmaError(address, line, `${name} is a ${type}, so color does not apply to it`);\n }\n color = true;\n } else if (modifier === \"range\") {\n if (range !== null) {\n throw pragmaError(address, line, `${name} declares range twice`);\n }\n const bounds = readNumbers(argumentText ?? \"\", name, address, line);\n const low = bounds[0];\n const high = bounds[1];\n if (bounds.length !== 2 || low === undefined || high === undefined) {\n throw pragmaError(address, line, `${name} declares range(…) with ${String(bounds.length)} bounds, not 2`);\n }\n range = [low, high];\n } else {\n if (step !== null) {\n throw pragmaError(address, line, `${name} declares step twice`);\n }\n const increments = readNumbers(argumentText ?? \"\", name, address, line);\n const increment = increments[0];\n if (increments.length !== 1 || increment === undefined) {\n throw pragmaError(address, line, `${name} declares step(…) with ${String(increments.length)} values, not 1`);\n }\n step = increment;\n }\n rest = rest.slice(callMatch[0].length);\n }\n return { color, range, step, tooltip };\n}\n\n/**\n * Reads one `// @ignifx texture name [srgb] [normal] [default white|black|transparent] [array]`\n * line.\n *\n * @param draft - The declaration being built, for the name namespace.\n * @param rest - The directive body.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The declaration.\n */\nfunction readTexture(draft: DeclarationDraft, rest: string, address: string, line: number): ShaderTextureDeclaration {\n const tokens = rest.split(/\\s+/).filter((token) => token.length > 0);\n const name = tokens[0];\n if (name === undefined) {\n throw pragmaError(address, line, \"@ignifx texture declares no name\");\n }\n assertIdentifier(name, address, line, \"texture\");\n claimName(draft, name, address, line, \"texture\");\n claimName(draft, `${name}Sampler`, address, line, \"texture sampler\");\n let srgb = false;\n let normal = false;\n let array = false;\n let fallback: ShaderTextureFallback | null = null;\n for (let index = 1; index < tokens.length; index += 1) {\n const token = tokens[index] ?? \"\";\n if (token === \"srgb\") {\n srgb = true;\n } else if (token === \"normal\") {\n normal = true;\n } else if (token === \"array\") {\n array = true;\n } else if (token === \"default\") {\n index += 1;\n const named = matchLiteral(SHADER_TEXTURE_FALLBACKS, tokens[index] ?? \"\");\n if (named === null) {\n throw pragmaError(\n address,\n line,\n `${name} declares default ${JSON.stringify(tokens[index] ?? \"\")}; expected ${SHADER_TEXTURE_FALLBACKS.join(\", \")}`,\n );\n }\n fallback = named;\n } else {\n throw pragmaError(address, line, `${JSON.stringify(token)} is not a texture modifier`);\n }\n }\n return { name, srgb, normal, fallback, array };\n}\n\n/**\n * Reads one `// @ignifx storage name: array<T>` line.\n *\n * @param draft - The declaration being built, for the name namespace.\n * @param rest - The directive body.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The declaration.\n */\nfunction readStorage(draft: DeclarationDraft, rest: string, address: string, line: number): ShaderStorageDeclaration {\n const split = NAME_AND_TYPE.exec(rest);\n if (split === null) {\n throw pragmaError(address, line, `@ignifx storage expects \"name: type\", but found ${JSON.stringify(rest)}`);\n }\n const name = split[1] ?? \"\";\n const type = (split[2] ?? \"\").trim();\n if (type.length === 0) {\n throw pragmaError(address, line, `${name} declares no storage buffer type`);\n }\n claimName(draft, name, address, line, \"storage buffer\");\n return { name, type };\n}\n\n/**\n * Reads one `// @ignifx define NAME = value` line.\n *\n * @param draft - The declaration being built, for the name namespace.\n * @param rest - The directive body.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The declaration.\n */\nfunction readDefine(draft: DeclarationDraft, rest: string, address: string, line: number): ShaderDefineDeclaration {\n const equals = rest.indexOf(\"=\");\n if (equals < 0) {\n throw pragmaError(address, line, `@ignifx define expects \"NAME = value\", but found ${JSON.stringify(rest)}`);\n }\n const name = rest.slice(0, equals).trim();\n const text = rest.slice(equals + 1).trim();\n assertIdentifier(name, address, line, \"define\");\n claimName(draft, name, address, line, \"define\");\n if (text === \"true\" || text === \"false\") {\n return { name, value: text === \"true\" };\n }\n const numberMatch = NUMBER_DEFAULT.exec(text);\n if (numberMatch === null || numberMatch[0].trim().length !== text.length) {\n throw pragmaError(address, line, `${name} declares ${JSON.stringify(text)}; a define is true, false, or a number`);\n }\n return { name, value: Number(numberMatch[1]) };\n}\n\n/**\n * Reads the `// @ignifx displace <metres>` line: how far the vertex stage may move a vertex.\n *\n * @param draft - The declaration being built.\n * @param rest - The directive body, which must be one number of zero or more.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readDisplace(draft: DeclarationDraft, rest: string, address: string, line: number): void {\n if (draft.displace !== null) {\n throw pragmaError(address, line, \"displace is declared twice\");\n }\n const numberMatch = NUMBER_DEFAULT.exec(rest);\n const value = numberMatch === null ? Number.NaN : Number(numberMatch[1]);\n if (\n numberMatch === null ||\n numberMatch[0].trim().length !== rest.length ||\n !(value >= 0) ||\n !Number.isFinite(value)\n ) {\n throw pragmaError(\n address,\n line,\n `displace ${JSON.stringify(rest)} is not a distance; write the furthest a vertex moves, in metres, such as displace 0.25`,\n );\n }\n draft.displace = value;\n}\n\n/**\n * Reads a pipeline-state line, merging it into whatever earlier lines declared.\n *\n * @param draft - The declaration being built.\n * @param text - The whole directive text, starting at its first keyword.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readPipeline(draft: DeclarationDraft, text: string, address: string, line: number): void {\n const tokens = text.split(/\\s+/).filter((token) => token.length > 0);\n for (let index = 0; index < tokens.length; index += 1) {\n const keyword = tokens[index] ?? \"\";\n if (keyword === \"transmissive\") {\n draft.transmissive = true;\n continue;\n }\n index += 1;\n const value = tokens[index] ?? \"\";\n switch (keyword) {\n case \"blend\":\n draft.blend = readPipelineValue(SHADER_BLEND_MODES, draft.blend, keyword, value, address, line);\n break;\n case \"cull\": {\n const cull = readPipelineValue(SHADER_CULL_MODES, draft.cull, keyword, value, address, line);\n if (cull === \"front\") {\n throw pragmaError(\n address,\n line,\n \"Babylon Lite 1.27.0 has no front-face culling for a shader material; declare cull back or cull none and flip the winding\",\n );\n }\n draft.cull = cull;\n break;\n }\n case \"depthWrite\":\n draft.depthWrite = readToggle(draft.depthWrite, keyword, value, address, line);\n break;\n case \"depthTest\":\n draft.depthTest = readToggle(draft.depthTest, keyword, value, address, line);\n break;\n case \"instancing\":\n draft.instancing = readPipelineValue(SHADER_INSTANCING_MODES, draft.instancing, keyword, value, address, line);\n break;\n default:\n throw pragmaError(address, line, `${JSON.stringify(keyword)} is not a pipeline keyword`);\n }\n }\n}\n\n/**\n * Reads one pipeline keyword's value out of a fixed list, refusing a second declaration of it.\n *\n * @typeParam Value - The literal union the keyword accepts.\n * @param allowed - The accepted values.\n * @param current - What an earlier line declared, or `null`.\n * @param keyword - The keyword, for diagnostics.\n * @param value - The token that followed it.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The value.\n */\nfunction readPipelineValue<Value extends string>(\n allowed: readonly Value[],\n current: Value | null,\n keyword: string,\n value: string,\n address: string,\n line: number,\n): Value {\n if (current !== null) {\n throw pragmaError(address, line, `${keyword} is declared twice`);\n }\n const matched = matchLiteral(allowed, value);\n if (matched === null) {\n throw pragmaError(address, line, `${keyword} ${JSON.stringify(value)} is not one of ${allowed.join(\", \")}`);\n }\n return matched;\n}\n\n/**\n * Reads an `on`/`off` toggle, refusing a second declaration of it.\n *\n * @param current - What an earlier line declared, or `null`.\n * @param keyword - The keyword, for diagnostics.\n * @param value - The token that followed it.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns `true` for `on`, `false` for `off`.\n */\nfunction readToggle(current: boolean | null, keyword: string, value: string, address: string, line: number): boolean {\n if (current !== null) {\n throw pragmaError(address, line, `${keyword} is declared twice`);\n }\n if (value !== \"on\" && value !== \"off\") {\n throw pragmaError(address, line, `${keyword} ${JSON.stringify(value)} is not on or off`);\n }\n return value === \"on\";\n}\n\n/**\n * Fills in the defaults and checks the whole-file rules.\n *\n * @param draft - The declaration the parser built.\n * @param address - The asset address, for diagnostics.\n * @returns The finished declaration.\n */\nfunction finish(draft: DeclarationDraft, address: string): ShaderDeclaration {\n const kind = draft.kind;\n if (kind === null) {\n throw pragmaError(address, 1, \"the file declares no @ignifx shader, @ignifx surface, or @ignifx post directive\");\n }\n const declared = draft.attributes;\n if (declared !== null && kind === \"shader\" && !declared.includes(\"position\")) {\n throw pragmaError(address, 1, \"an @ignifx shader file must declare the position attribute\");\n }\n const attributes: readonly ShaderAttributeName[] = declared ?? (kind === \"shader\" ? [\"position\"] : []);\n if (kind === \"post\" && draft.displace !== null) {\n throw pragmaError(address, 1, \"an @ignifx post file draws no mesh, so it has nothing to displace\");\n }\n const blend = draft.blend ?? \"opaque\";\n if (draft.transmissive && blend === \"opaque\") {\n throw pragmaError(\n address,\n 1,\n \"transmissive needs a blended surface; declare blend alpha, additive, or premultiplied\",\n );\n }\n return {\n kind,\n attributes,\n system: draft.system,\n ignifx: draft.ignifx,\n uniforms: draft.uniforms,\n textures: draft.textures,\n storage: draft.storage,\n defines: draft.defines,\n pipeline: {\n blend,\n cull: draft.cull ?? \"back\",\n // Babylon Lite defaults a blended material to depth-read-only and lets an explicit value win\n // (`lib/material/shader/shader-material.js`), which is the rule reproduced here so the\n // declaration itself carries the effective value.\n depthWrite: draft.depthWrite ?? blend === \"opaque\",\n depthTest: draft.depthTest ?? true,\n transmissive: draft.transmissive,\n instancing: draft.instancing ?? \"none\",\n },\n displace: draft.displace ?? 0,\n };\n}\n\n/**\n * Splits a comma-separated directive body, refusing an empty entry.\n *\n * @param rest - The directive body.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @param directive - The directive name, for diagnostics.\n * @returns The trimmed entries.\n */\nfunction splitList(rest: string, address: string, line: number, directive: string): readonly string[] {\n if (rest.length === 0) {\n throw pragmaError(address, line, `@ignifx ${directive} declares nothing`);\n }\n const parts = rest.split(\",\");\n const names: string[] = [];\n for (let index = 0; index < parts.length; index += 1) {\n const name = (parts[index] ?? \"\").trim();\n if (name.length === 0) {\n throw pragmaError(address, line, `@ignifx ${directive} has an empty entry`);\n }\n names.push(name);\n }\n return names;\n}\n\n/**\n * Reads a comma-separated list of numbers.\n *\n * @param text - The argument text, without the parentheses.\n * @param name - The declaration's name, for diagnostics.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The numbers.\n */\nfunction readNumbers(text: string, name: string, address: string, line: number): readonly number[] {\n const parts = text.split(\",\");\n const numbers: number[] = [];\n for (let index = 0; index < parts.length; index += 1) {\n const part = (parts[index] ?? \"\").trim();\n const value = Number(part);\n if (part.length === 0 || !Number.isFinite(value)) {\n throw pragmaError(address, line, `${name} declares ${JSON.stringify(part)}, which is not a number`);\n }\n numbers.push(value);\n }\n return numbers;\n}\n\n/**\n * Checks that a default value has as many numbers as its type needs.\n *\n * @param actual - How many numbers the file wrote.\n * @param expected - How many the type holds.\n * @param name - The uniform's name, for diagnostics.\n * @param type - The uniform's type, for diagnostics.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction assertArity(\n actual: number,\n expected: number,\n name: string,\n type: ShaderUniformType,\n address: string,\n line: number,\n): void {\n if (actual !== expected) {\n throw pragmaError(\n address,\n line,\n `${name} is a ${type}, which takes ${String(expected)} numbers, but its default has ${String(actual)}`,\n );\n }\n}\n\n/**\n * The value a uniform starts at when the file declares no default: zeros, or the identity matrix.\n *\n * @param type - The declared type.\n * @returns The default.\n */\nfunction implicitDefault(type: ShaderUniformType): number | readonly number[] {\n if (type === \"mat4x4<f32>\") {\n return IDENTITY_MATRIX;\n }\n const count = ELEMENT_COUNTS[type];\n if (count === 1) {\n return 0;\n }\n const zeros: number[] = [];\n for (let index = 0; index < count; index += 1) {\n zeros.push(0);\n }\n return zeros;\n}\n\n/**\n * Claims one WGSL binding name, refusing a duplicate.\n *\n * @remarks\n * Babylon Lite puts uniforms, samplers, `<name>Sampler` pairs, storage buffers, and defines in one\n * namespace (`assertUniqueName`, `lib/material/shader/shader-material.js`), so the parser checks it\n * here and reports the line instead of letting Lite throw without one.\n *\n * @param draft - The declaration being built.\n * @param name - The name being claimed.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @param what - What kind of binding is claiming it, for diagnostics.\n */\nfunction claimName(draft: DeclarationDraft, name: string, address: string, line: number, what: string): void {\n if (draft.names.has(name)) {\n throw pragmaError(address, line, `${name} is already declared; the ${what} name must be unique in the file`);\n }\n draft.names.add(name);\n}\n\n/**\n * Checks that a name is a WGSL identifier.\n *\n * @param name - The candidate.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @param what - What kind of binding it names, for diagnostics.\n */\nfunction assertIdentifier(name: string, address: string, line: number, what: string): void {\n if (!IDENTIFIER.test(name)) {\n throw pragmaError(address, line, `${JSON.stringify(name)} is not a WGSL identifier for a ${what}`);\n }\n}\n\n/**\n * Narrows a token to one of a fixed list of literals.\n *\n * @typeParam Value - The literal union.\n * @param allowed - The accepted values.\n * @param token - The candidate.\n * @returns The matching literal, or `null`.\n */\nfunction matchLiteral<Value extends string>(allowed: readonly Value[], token: string): Value | null {\n for (let index = 0; index < allowed.length; index += 1) {\n const candidate = allowed[index];\n if (candidate !== undefined && candidate === token) {\n return candidate;\n }\n }\n return null;\n}\n\n/**\n * Builds the `IGX-0719` failure a malformed pragma produces.\n *\n * @param address - The asset address.\n * @param line - The 1-based line number.\n * @param message - What is wrong.\n * @returns The error to throw.\n */\nfunction pragmaError(address: string, line: number, message: string): IgnifxError {\n return new IgnifxError(CoreErrorCode.invalidShaderPragma, `${address} line ${String(line)}: ${message}.`, {\n context: { asset: address, line, message },\n hint: \"The @ignifx pragma grammar is in skills/ignifx/references/formats/wgsl.md.\",\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8CA,MAAM,cAAc;;AAGpB,MAAM,aAAa;;AAGnB,MAAM,gBAAgB;;AAGtB,MAAM,mBAAmB;;AAGzB,MAAM,gBAAgB;;AAGtB,MAAM,gBAAgB;;AAGtB,MAAM,gBAAgB;;AAGtB,MAAM,iBAAiB;;AAGvB,MAAM,iBAA8D,OAAO,OAAO;CAChF,KAAK;CACL,KAAK;CACL,KAAK;CACL,aAAa;CACb,aAAa;CACb,aAAa;CACb,eAAe;AACjB,CAAC;;AAGD,MAAM,kBAAqC,OAAO,OAAO;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;CAAG;AAAC,CAAC;;;;;;;;;;;;;;;;;;;;AAyCzG,SAAgB,uBAAuB,QAAgB,SAAoC;CACzF,MAAM,QAA0B;EAC9B,MAA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AAO;GAAS;GAAM;EAAQ;EACzC,MAAM;CACR,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"shader-pragma-DmZpxGUo.js","names":[],"sources":["../src/render/shader-pragma.ts"],"sourcesContent":["import { CoreErrorCode } from \"../errors/error-codes.js\";\nimport { IgnifxError } from \"../errors/ignifx-error.js\";\nimport {\n IGNIFX_UNIFORM_NAMES,\n LITE_SYSTEM_UNIFORM_NAMES,\n SHADER_ATTRIBUTE_NAMES,\n SHADER_BLEND_MODES,\n SHADER_CULL_MODES,\n SHADER_INSTANCING_MODES,\n SHADER_TEXTURE_FALLBACKS,\n SHADER_UNIFORM_TYPES,\n} from \"./shader-declaration.js\";\nimport type {\n IgnifxUniformName,\n LiteSystemUniformName,\n ShaderAttributeName,\n ShaderBlendMode,\n ShaderCullMode,\n ShaderDeclaration,\n ShaderDefineDeclaration,\n ShaderInstancingMode,\n ShaderKind,\n ShaderStorageDeclaration,\n ShaderTextureDeclaration,\n ShaderTextureFallback,\n ShaderUniformDeclaration,\n ShaderUniformType,\n} from \"./shader-declaration.js\";\n\n/**\n * Reads the `// @ignifx …` comment pragmas of a `.wgsl` file into a {@link ShaderDeclaration}\n * (grammar: `docs/plan/2026-09-terrain-particles-shaders.md` §3.1; rationale: ADR-0024).\n *\n * Pure string work with no Babylon Lite import, so the build-time validator and the runtime loader\n * can share it. Four rules the grammar itself does not show:\n *\n * - `@ignifx system` mixes Lite's names with ignifx's, and the WGSL reads them from different\n * structs, so they are split into `declaration.system` and `declaration.ignifx`.\n * - An omitted `attributes` directive means `position`; Lite refuses a shader material without it\n * (`lib/material/shader/shader-material.js`, error 293).\n * - A `color(…)` default keeps the authored sRGB numbers; `./shader-material.ts` converts.\n * - `cull front` and `transmissive` on an opaque surface are refused here, with a line number,\n * because Lite has no front-face culling and throws on the second combination (error 295).\n */\n\n/** Matches an `// @ignifx …` line and captures the directive text after it. */\nconst PRAGMA_LINE = /^\\s*\\/\\/\\s*@ignifx\\b(.*)$/;\n\n/** Matches a WGSL identifier. */\nconst IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/** Splits `name: type` at the colon, capturing the identifier and the rest of the line. */\nconst NAME_AND_TYPE = /^([A-Za-z_][A-Za-z0-9_]*)\\s*:\\s*(.*)$/;\n\n/** Matches a leading `tooltip(\"…\")` modifier, capturing the quoted text. */\nconst TOOLTIP_MODIFIER = /^tooltip\\(\\s*\"((?:[^\"\\\\]|\\\\.)*)\"\\s*\\)\\s*/;\n\n/** Matches a leading `range(…)`, `step(…)`, or `color(…)`/`color` modifier. */\nconst CALL_MODIFIER = /^(range|step|color)\\s*(?:\\(([^)]*)\\))?\\s*/;\n\n/** Matches a leading `color(…)` default value, capturing the arguments. */\nconst COLOR_DEFAULT = /^color\\s*\\(([^)]*)\\)\\s*/;\n\n/** Matches a leading parenthesised numeric list, capturing the arguments. */\nconst TUPLE_DEFAULT = /^\\(([^)]*)\\)\\s*/;\n\n/** Matches a leading decimal number, with optional sign and exponent. */\nconst NUMBER_DEFAULT = /^([+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?)\\s*/;\n\n/** How many elements each uniform type holds. */\nconst ELEMENT_COUNTS: Readonly<Record<ShaderUniformType, number>> = Object.freeze({\n f32: 1,\n u32: 1,\n i32: 1,\n \"vec2<f32>\": 2,\n \"vec3<f32>\": 3,\n \"vec4<f32>\": 4,\n \"mat4x4<f32>\": 16,\n});\n\n/** The identity matrix a `mat4x4<f32>` uniform starts at when the file declares no default. */\nconst IDENTITY_MATRIX: readonly number[] = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);\n\n/** The mutable declaration the parser fills in, line by line. */\ninterface DeclarationDraft {\n kind: ShaderKind | null;\n attributes: ShaderAttributeName[] | null;\n readonly system: LiteSystemUniformName[];\n readonly ignifx: IgnifxUniformName[];\n readonly uniforms: ShaderUniformDeclaration[];\n readonly textures: ShaderTextureDeclaration[];\n readonly storage: ShaderStorageDeclaration[];\n readonly defines: ShaderDefineDeclaration[];\n readonly names: Set<string>;\n blend: ShaderBlendMode | null;\n cull: ShaderCullMode | null;\n depthWrite: boolean | null;\n depthTest: boolean | null;\n transmissive: boolean;\n instancing: ShaderInstancingMode | null;\n displace: number | null;\n}\n\n/**\n * Reads a `.wgsl` file's `// @ignifx` pragmas into the declaration the loader, the material\n * builder, and the inspector all read.\n *\n * @param source - The whole file, as text.\n * @param address - The asset address, so a failure names the file.\n * @returns The declaration, with every default filled in.\n * @throws IgnifxError with code `IGX-0719`, carrying the offending `line`, for an unknown directive,\n * a malformed one, a duplicate binding name, an attribute or uniform type Babylon Lite does not\n * have, or a combination it cannot express.\n *\n * @example\n * ```ts\n * const declaration = parseShaderDeclaration(\"// @ignifx shader\\n\", \"shaders/flat.wgsl\");\n * declaration.attributes; // [\"position\"]\n * ```\n *\n * @public\n */\nexport function parseShaderDeclaration(source: string, address: string): ShaderDeclaration {\n const draft: DeclarationDraft = {\n kind: null,\n attributes: null,\n system: [],\n ignifx: [],\n uniforms: [],\n textures: [],\n storage: [],\n defines: [],\n names: new Set<string>(),\n blend: null,\n cull: null,\n depthWrite: null,\n depthTest: null,\n transmissive: false,\n instancing: null,\n displace: null,\n };\n const lines = source.split(\"\\n\");\n for (let index = 0; index < lines.length; index += 1) {\n const matched = PRAGMA_LINE.exec(lines[index] ?? \"\");\n if (matched === null) {\n continue;\n }\n readDirective(draft, (matched[1] ?? \"\").trim(), address, index + 1);\n }\n return finish(draft, address);\n}\n\n/**\n * Applies one `// @ignifx …` line to the draft.\n *\n * @param draft - The declaration being built.\n * @param text - The directive text, already trimmed.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readDirective(draft: DeclarationDraft, text: string, address: string, line: number): void {\n if (text.length === 0) {\n throw pragmaError(address, line, \"an @ignifx comment declares no directive\");\n }\n const separator = text.search(/\\s/);\n const directive = separator < 0 ? text : text.slice(0, separator);\n const rest = separator < 0 ? \"\" : text.slice(separator + 1).trim();\n switch (directive) {\n case \"shader\":\n case \"surface\":\n case \"post\":\n readKind(draft, directive, rest, address, line);\n return;\n case \"attributes\":\n readAttributes(draft, rest, address, line);\n return;\n case \"system\":\n readSystem(draft, rest, address, line);\n return;\n case \"uniform\":\n draft.uniforms.push(readUniform(draft, rest, address, line));\n return;\n case \"texture\":\n draft.textures.push(readTexture(draft, rest, address, line));\n return;\n case \"storage\":\n draft.storage.push(readStorage(draft, rest, address, line));\n return;\n case \"define\":\n draft.defines.push(readDefine(draft, rest, address, line));\n return;\n case \"blend\":\n case \"cull\":\n case \"depthWrite\":\n case \"depthTest\":\n case \"transmissive\":\n case \"instancing\":\n readPipeline(draft, text, address, line);\n return;\n case \"displace\":\n readDisplace(draft, rest, address, line);\n return;\n default:\n throw pragmaError(address, line, `${JSON.stringify(directive)} is not an @ignifx directive`);\n }\n}\n\n/**\n * Records the file's form, refusing a second one.\n *\n * @param draft - The declaration being built.\n * @param kind - The declared form.\n * @param rest - Whatever followed it, which must be nothing.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readKind(draft: DeclarationDraft, kind: ShaderKind, rest: string, address: string, line: number): void {\n if (rest.length > 0) {\n throw pragmaError(address, line, `@ignifx ${kind} takes no arguments, but found ${JSON.stringify(rest)}`);\n }\n if (draft.kind !== null) {\n throw pragmaError(address, line, `the file already declared @ignifx ${draft.kind}`);\n }\n draft.kind = kind;\n}\n\n/**\n * Records the vertex attributes the vertex stage reads.\n *\n * @param draft - The declaration being built.\n * @param rest - The comma-separated attribute names.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readAttributes(draft: DeclarationDraft, rest: string, address: string, line: number): void {\n if (draft.attributes !== null) {\n throw pragmaError(address, line, \"the file already declared @ignifx attributes\");\n }\n const names = splitList(rest, address, line, \"attributes\");\n const attributes: ShaderAttributeName[] = [];\n for (const name of names) {\n const attribute = matchLiteral(SHADER_ATTRIBUTE_NAMES, name);\n if (attribute === null) {\n throw pragmaError(\n address,\n line,\n `${JSON.stringify(name)} is not a vertex attribute; Babylon Lite has ${SHADER_ATTRIBUTE_NAMES.join(\", \")}`,\n );\n }\n if (attributes.includes(attribute)) {\n throw pragmaError(address, line, `the attribute ${attribute} is declared twice`);\n }\n attributes.push(attribute);\n }\n draft.attributes = attributes;\n}\n\n/**\n * Records the system uniforms, splitting Babylon Lite's names from ignifx's own.\n *\n * @param draft - The declaration being built.\n * @param rest - The comma-separated uniform names.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readSystem(draft: DeclarationDraft, rest: string, address: string, line: number): void {\n const names = splitList(rest, address, line, \"system\");\n for (const name of names) {\n const lite = matchLiteral(LITE_SYSTEM_UNIFORM_NAMES, name);\n if (lite !== null) {\n claimName(draft, lite, address, line, \"system uniform\");\n draft.system.push(lite);\n continue;\n }\n const ignifx = matchLiteral(IGNIFX_UNIFORM_NAMES, name);\n if (ignifx !== null) {\n claimName(draft, ignifx, address, line, \"system uniform\");\n draft.ignifx.push(ignifx);\n continue;\n }\n throw pragmaError(\n address,\n line,\n `${JSON.stringify(name)} is not a system uniform; Babylon Lite has ${LITE_SYSTEM_UNIFORM_NAMES.join(\", \")} and ignifx adds ${IGNIFX_UNIFORM_NAMES.join(\", \")}`,\n );\n }\n}\n\n/**\n * Reads one `// @ignifx uniform name: type [= default] [modifiers]` line.\n *\n * @param draft - The declaration being built, for the name namespace.\n * @param rest - The directive body.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The declaration.\n */\nfunction readUniform(draft: DeclarationDraft, rest: string, address: string, line: number): ShaderUniformDeclaration {\n const split = NAME_AND_TYPE.exec(rest);\n if (split === null) {\n throw pragmaError(address, line, `@ignifx uniform expects \"name: type\", but found ${JSON.stringify(rest)}`);\n }\n const name = split[1] ?? \"\";\n let tail = (split[2] ?? \"\").trim();\n const typeSeparator = tail.search(/[\\s=]/);\n const typeName = typeSeparator < 0 ? tail : tail.slice(0, typeSeparator);\n tail = (typeSeparator < 0 ? \"\" : tail.slice(typeName.length)).trim();\n const type = matchLiteral(SHADER_UNIFORM_TYPES, typeName);\n if (type === null) {\n throw pragmaError(\n address,\n line,\n `${JSON.stringify(typeName)} is not a uniform type; Babylon Lite has ${SHADER_UNIFORM_TYPES.join(\", \")}`,\n );\n }\n claimName(draft, name, address, line, \"uniform\");\n let defaultValue: number | readonly number[] | null = null;\n let isColor = false;\n if (tail.startsWith(\"=\")) {\n tail = tail.slice(1).trim();\n const parsed = readDefaultValue(tail, type, name, address, line);\n defaultValue = parsed.value;\n isColor = parsed.color;\n tail = parsed.tail;\n }\n const modifiers = readModifiers(tail, name, type, address, line);\n return {\n name,\n type,\n defaultValue: defaultValue ?? implicitDefault(type),\n color: isColor || modifiers.color,\n range: modifiers.range,\n step: modifiers.step,\n tooltip: modifiers.tooltip,\n };\n}\n\n/** A parsed `= …` default value and whatever followed it. */\ninterface ParsedDefault {\n /** The numbers the file wrote. */\n readonly value: number | readonly number[];\n /** Whether the value was written as `color(…)`. */\n readonly color: boolean;\n /** The rest of the line. */\n readonly tail: string;\n}\n\n/**\n * Reads the `= …` half of a uniform declaration.\n *\n * @param text - The text after the `=`.\n * @param type - The declared type, which fixes the element count.\n * @param name - The uniform's name, for diagnostics.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The value, whether it was a colour, and the rest of the line.\n */\nfunction readDefaultValue(\n text: string,\n type: ShaderUniformType,\n name: string,\n address: string,\n line: number,\n): ParsedDefault {\n const expected = ELEMENT_COUNTS[type];\n const colorMatch = COLOR_DEFAULT.exec(text);\n if (colorMatch !== null) {\n const numbers = readNumbers(colorMatch[1] ?? \"\", name, address, line);\n if (type !== \"vec3<f32>\" && type !== \"vec4<f32>\") {\n throw pragmaError(address, line, `${name} is a ${type}, so color(…) does not apply to it`);\n }\n assertArity(numbers.length, expected, name, type, address, line);\n return { value: numbers, color: true, tail: text.slice(colorMatch[0].length).trim() };\n }\n const tupleMatch = TUPLE_DEFAULT.exec(text);\n if (tupleMatch !== null) {\n const numbers = readNumbers(tupleMatch[1] ?? \"\", name, address, line);\n assertArity(numbers.length, expected, name, type, address, line);\n return { value: numbers, color: false, tail: text.slice(tupleMatch[0].length).trim() };\n }\n const numberMatch = NUMBER_DEFAULT.exec(text);\n if (numberMatch !== null) {\n assertArity(1, expected, name, type, address, line);\n return { value: Number(numberMatch[1]), color: false, tail: text.slice(numberMatch[0].length).trim() };\n }\n throw pragmaError(address, line, `${name} declares no readable default value after \"=\"`);\n}\n\n/** The optional hints an inspector renders a uniform with. */\ninterface ParsedModifiers {\n /** Whether the bare `color` modifier was present. */\n readonly color: boolean;\n /** The `range(a, b)` bounds, or `null`. */\n readonly range: readonly [number, number] | null;\n /** The `step(s)` increment, or `null`. */\n readonly step: number | null;\n /** The `tooltip(\"…\")` text, or `null`. */\n readonly tooltip: string | null;\n}\n\n/**\n * Reads the `range(…)`, `step(…)`, `color`, and `tooltip(\"…\")` modifiers that close a uniform line.\n *\n * @param text - What is left of the line.\n * @param name - The uniform's name, for diagnostics.\n * @param type - The declared type, which decides whether `color` applies.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The hints.\n */\nfunction readModifiers(\n text: string,\n name: string,\n type: ShaderUniformType,\n address: string,\n line: number,\n): ParsedModifiers {\n let rest = text;\n let color = false;\n let range: readonly [number, number] | null = null;\n let step: number | null = null;\n let tooltip: string | null = null;\n while (rest.length > 0) {\n const tooltipMatch = TOOLTIP_MODIFIER.exec(rest);\n if (tooltipMatch !== null) {\n if (tooltip !== null) {\n throw pragmaError(address, line, `${name} declares tooltip twice`);\n }\n tooltip = (tooltipMatch[1] ?? \"\").replaceAll('\\\\\"', '\"');\n rest = rest.slice(tooltipMatch[0].length);\n continue;\n }\n const callMatch = CALL_MODIFIER.exec(rest);\n if (callMatch === null) {\n throw pragmaError(address, line, `${name} declares ${JSON.stringify(rest)}, which is not a uniform modifier`);\n }\n const modifier = callMatch[1] ?? \"\";\n const argumentText = callMatch[2];\n if (modifier === \"color\") {\n if (argumentText !== undefined) {\n throw pragmaError(address, line, `${name} declares color(…) after its default value`);\n }\n if (type !== \"vec3<f32>\" && type !== \"vec4<f32>\") {\n throw pragmaError(address, line, `${name} is a ${type}, so color does not apply to it`);\n }\n color = true;\n } else if (modifier === \"range\") {\n if (range !== null) {\n throw pragmaError(address, line, `${name} declares range twice`);\n }\n const bounds = readNumbers(argumentText ?? \"\", name, address, line);\n const low = bounds[0];\n const high = bounds[1];\n if (bounds.length !== 2 || low === undefined || high === undefined) {\n throw pragmaError(address, line, `${name} declares range(…) with ${String(bounds.length)} bounds, not 2`);\n }\n range = [low, high];\n } else {\n if (step !== null) {\n throw pragmaError(address, line, `${name} declares step twice`);\n }\n const increments = readNumbers(argumentText ?? \"\", name, address, line);\n const increment = increments[0];\n if (increments.length !== 1 || increment === undefined) {\n throw pragmaError(address, line, `${name} declares step(…) with ${String(increments.length)} values, not 1`);\n }\n step = increment;\n }\n rest = rest.slice(callMatch[0].length);\n }\n return { color, range, step, tooltip };\n}\n\n/**\n * Reads one `// @ignifx texture name [srgb] [normal] [default white|black|transparent] [array]`\n * line.\n *\n * @param draft - The declaration being built, for the name namespace.\n * @param rest - The directive body.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The declaration.\n */\nfunction readTexture(draft: DeclarationDraft, rest: string, address: string, line: number): ShaderTextureDeclaration {\n const tokens = rest.split(/\\s+/).filter((token) => token.length > 0);\n const name = tokens[0];\n if (name === undefined) {\n throw pragmaError(address, line, \"@ignifx texture declares no name\");\n }\n assertIdentifier(name, address, line, \"texture\");\n claimName(draft, name, address, line, \"texture\");\n claimName(draft, `${name}Sampler`, address, line, \"texture sampler\");\n let srgb = false;\n let normal = false;\n let array = false;\n let fallback: ShaderTextureFallback | null = null;\n for (let index = 1; index < tokens.length; index += 1) {\n const token = tokens[index] ?? \"\";\n if (token === \"srgb\") {\n srgb = true;\n } else if (token === \"normal\") {\n normal = true;\n } else if (token === \"array\") {\n array = true;\n } else if (token === \"default\") {\n index += 1;\n const named = matchLiteral(SHADER_TEXTURE_FALLBACKS, tokens[index] ?? \"\");\n if (named === null) {\n throw pragmaError(\n address,\n line,\n `${name} declares default ${JSON.stringify(tokens[index] ?? \"\")}; expected ${SHADER_TEXTURE_FALLBACKS.join(\", \")}`,\n );\n }\n fallback = named;\n } else {\n throw pragmaError(address, line, `${JSON.stringify(token)} is not a texture modifier`);\n }\n }\n return { name, srgb, normal, fallback, array };\n}\n\n/**\n * Reads one `// @ignifx storage name: array<T>` line.\n *\n * @param draft - The declaration being built, for the name namespace.\n * @param rest - The directive body.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The declaration.\n */\nfunction readStorage(draft: DeclarationDraft, rest: string, address: string, line: number): ShaderStorageDeclaration {\n const split = NAME_AND_TYPE.exec(rest);\n if (split === null) {\n throw pragmaError(address, line, `@ignifx storage expects \"name: type\", but found ${JSON.stringify(rest)}`);\n }\n const name = split[1] ?? \"\";\n const type = (split[2] ?? \"\").trim();\n if (type.length === 0) {\n throw pragmaError(address, line, `${name} declares no storage buffer type`);\n }\n claimName(draft, name, address, line, \"storage buffer\");\n return { name, type };\n}\n\n/**\n * Reads one `// @ignifx define NAME = value` line.\n *\n * @param draft - The declaration being built, for the name namespace.\n * @param rest - The directive body.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The declaration.\n */\nfunction readDefine(draft: DeclarationDraft, rest: string, address: string, line: number): ShaderDefineDeclaration {\n const equals = rest.indexOf(\"=\");\n if (equals < 0) {\n throw pragmaError(address, line, `@ignifx define expects \"NAME = value\", but found ${JSON.stringify(rest)}`);\n }\n const name = rest.slice(0, equals).trim();\n const text = rest.slice(equals + 1).trim();\n assertIdentifier(name, address, line, \"define\");\n claimName(draft, name, address, line, \"define\");\n if (text === \"true\" || text === \"false\") {\n return { name, value: text === \"true\" };\n }\n const numberMatch = NUMBER_DEFAULT.exec(text);\n if (numberMatch === null || numberMatch[0].trim().length !== text.length) {\n throw pragmaError(address, line, `${name} declares ${JSON.stringify(text)}; a define is true, false, or a number`);\n }\n return { name, value: Number(numberMatch[1]) };\n}\n\n/**\n * Reads the `// @ignifx displace <metres>` line: how far the vertex stage may move a vertex.\n *\n * @param draft - The declaration being built.\n * @param rest - The directive body, which must be one number of zero or more.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readDisplace(draft: DeclarationDraft, rest: string, address: string, line: number): void {\n if (draft.displace !== null) {\n throw pragmaError(address, line, \"displace is declared twice\");\n }\n const numberMatch = NUMBER_DEFAULT.exec(rest);\n const value = numberMatch === null ? Number.NaN : Number(numberMatch[1]);\n if (\n numberMatch === null ||\n numberMatch[0].trim().length !== rest.length ||\n !(value >= 0) ||\n !Number.isFinite(value)\n ) {\n throw pragmaError(\n address,\n line,\n `displace ${JSON.stringify(rest)} is not a distance; write the furthest a vertex moves, in metres, such as displace 0.25`,\n );\n }\n draft.displace = value;\n}\n\n/**\n * Reads a pipeline-state line, merging it into whatever earlier lines declared.\n *\n * @param draft - The declaration being built.\n * @param text - The whole directive text, starting at its first keyword.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction readPipeline(draft: DeclarationDraft, text: string, address: string, line: number): void {\n const tokens = text.split(/\\s+/).filter((token) => token.length > 0);\n for (let index = 0; index < tokens.length; index += 1) {\n const keyword = tokens[index] ?? \"\";\n if (keyword === \"transmissive\") {\n draft.transmissive = true;\n continue;\n }\n index += 1;\n const value = tokens[index] ?? \"\";\n switch (keyword) {\n case \"blend\":\n draft.blend = readPipelineValue(SHADER_BLEND_MODES, draft.blend, keyword, value, address, line);\n break;\n case \"cull\": {\n const cull = readPipelineValue(SHADER_CULL_MODES, draft.cull, keyword, value, address, line);\n if (cull === \"front\") {\n throw pragmaError(\n address,\n line,\n \"Babylon Lite 1.27.0 has no front-face culling for a shader material; declare cull back or cull none and flip the winding\",\n );\n }\n draft.cull = cull;\n break;\n }\n case \"depthWrite\":\n draft.depthWrite = readToggle(draft.depthWrite, keyword, value, address, line);\n break;\n case \"depthTest\":\n draft.depthTest = readToggle(draft.depthTest, keyword, value, address, line);\n break;\n case \"instancing\":\n draft.instancing = readPipelineValue(SHADER_INSTANCING_MODES, draft.instancing, keyword, value, address, line);\n break;\n default:\n throw pragmaError(address, line, `${JSON.stringify(keyword)} is not a pipeline keyword`);\n }\n }\n}\n\n/**\n * Reads one pipeline keyword's value out of a fixed list, refusing a second declaration of it.\n *\n * @typeParam Value - The literal union the keyword accepts.\n * @param allowed - The accepted values.\n * @param current - What an earlier line declared, or `null`.\n * @param keyword - The keyword, for diagnostics.\n * @param value - The token that followed it.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The value.\n */\nfunction readPipelineValue<Value extends string>(\n allowed: readonly Value[],\n current: Value | null,\n keyword: string,\n value: string,\n address: string,\n line: number,\n): Value {\n if (current !== null) {\n throw pragmaError(address, line, `${keyword} is declared twice`);\n }\n const matched = matchLiteral(allowed, value);\n if (matched === null) {\n throw pragmaError(address, line, `${keyword} ${JSON.stringify(value)} is not one of ${allowed.join(\", \")}`);\n }\n return matched;\n}\n\n/**\n * Reads an `on`/`off` toggle, refusing a second declaration of it.\n *\n * @param current - What an earlier line declared, or `null`.\n * @param keyword - The keyword, for diagnostics.\n * @param value - The token that followed it.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns `true` for `on`, `false` for `off`.\n */\nfunction readToggle(current: boolean | null, keyword: string, value: string, address: string, line: number): boolean {\n if (current !== null) {\n throw pragmaError(address, line, `${keyword} is declared twice`);\n }\n if (value !== \"on\" && value !== \"off\") {\n throw pragmaError(address, line, `${keyword} ${JSON.stringify(value)} is not on or off`);\n }\n return value === \"on\";\n}\n\n/**\n * Fills in the defaults and checks the whole-file rules.\n *\n * @param draft - The declaration the parser built.\n * @param address - The asset address, for diagnostics.\n * @returns The finished declaration.\n */\nfunction finish(draft: DeclarationDraft, address: string): ShaderDeclaration {\n const kind = draft.kind;\n if (kind === null) {\n throw pragmaError(address, 1, \"the file declares no @ignifx shader, @ignifx surface, or @ignifx post directive\");\n }\n const declared = draft.attributes;\n if (declared !== null && kind === \"shader\" && !declared.includes(\"position\")) {\n throw pragmaError(address, 1, \"an @ignifx shader file must declare the position attribute\");\n }\n const attributes: readonly ShaderAttributeName[] = declared ?? (kind === \"shader\" ? [\"position\"] : []);\n if (kind === \"post\" && draft.displace !== null) {\n throw pragmaError(address, 1, \"an @ignifx post file draws no mesh, so it has nothing to displace\");\n }\n const blend = draft.blend ?? \"opaque\";\n if (draft.transmissive && blend === \"opaque\") {\n throw pragmaError(\n address,\n 1,\n \"transmissive needs a blended surface; declare blend alpha, additive, or premultiplied\",\n );\n }\n return {\n kind,\n attributes,\n system: draft.system,\n ignifx: draft.ignifx,\n uniforms: draft.uniforms,\n textures: draft.textures,\n storage: draft.storage,\n defines: draft.defines,\n pipeline: {\n blend,\n cull: draft.cull ?? \"back\",\n // Babylon Lite defaults a blended material to depth-read-only and lets an explicit value win\n // (`lib/material/shader/shader-material.js`), which is the rule reproduced here so the\n // declaration itself carries the effective value.\n depthWrite: draft.depthWrite ?? blend === \"opaque\",\n depthTest: draft.depthTest ?? true,\n transmissive: draft.transmissive,\n instancing: draft.instancing ?? \"none\",\n },\n displace: draft.displace ?? 0,\n };\n}\n\n/**\n * Splits a comma-separated directive body, refusing an empty entry.\n *\n * @param rest - The directive body.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @param directive - The directive name, for diagnostics.\n * @returns The trimmed entries.\n */\nfunction splitList(rest: string, address: string, line: number, directive: string): readonly string[] {\n if (rest.length === 0) {\n throw pragmaError(address, line, `@ignifx ${directive} declares nothing`);\n }\n const parts = rest.split(\",\");\n const names: string[] = [];\n for (let index = 0; index < parts.length; index += 1) {\n const name = (parts[index] ?? \"\").trim();\n if (name.length === 0) {\n throw pragmaError(address, line, `@ignifx ${directive} has an empty entry`);\n }\n names.push(name);\n }\n return names;\n}\n\n/**\n * Reads a comma-separated list of numbers.\n *\n * @param text - The argument text, without the parentheses.\n * @param name - The declaration's name, for diagnostics.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @returns The numbers.\n */\nfunction readNumbers(text: string, name: string, address: string, line: number): readonly number[] {\n const parts = text.split(\",\");\n const numbers: number[] = [];\n for (let index = 0; index < parts.length; index += 1) {\n const part = (parts[index] ?? \"\").trim();\n const value = Number(part);\n if (part.length === 0 || !Number.isFinite(value)) {\n throw pragmaError(address, line, `${name} declares ${JSON.stringify(part)}, which is not a number`);\n }\n numbers.push(value);\n }\n return numbers;\n}\n\n/**\n * Checks that a default value has as many numbers as its type needs.\n *\n * @param actual - How many numbers the file wrote.\n * @param expected - How many the type holds.\n * @param name - The uniform's name, for diagnostics.\n * @param type - The uniform's type, for diagnostics.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n */\nfunction assertArity(\n actual: number,\n expected: number,\n name: string,\n type: ShaderUniformType,\n address: string,\n line: number,\n): void {\n if (actual !== expected) {\n throw pragmaError(\n address,\n line,\n `${name} is a ${type}, which takes ${String(expected)} numbers, but its default has ${String(actual)}`,\n );\n }\n}\n\n/**\n * The value a uniform starts at when the file declares no default: zeros, or the identity matrix.\n *\n * @param type - The declared type.\n * @returns The default.\n */\nfunction implicitDefault(type: ShaderUniformType): number | readonly number[] {\n if (type === \"mat4x4<f32>\") {\n return IDENTITY_MATRIX;\n }\n const count = ELEMENT_COUNTS[type];\n if (count === 1) {\n return 0;\n }\n const zeros: number[] = [];\n for (let index = 0; index < count; index += 1) {\n zeros.push(0);\n }\n return zeros;\n}\n\n/**\n * Claims one WGSL binding name, refusing a duplicate.\n *\n * @remarks\n * Babylon Lite puts uniforms, samplers, `<name>Sampler` pairs, storage buffers, and defines in one\n * namespace (`assertUniqueName`, `lib/material/shader/shader-material.js`), so the parser checks it\n * here and reports the line instead of letting Lite throw without one.\n *\n * @param draft - The declaration being built.\n * @param name - The name being claimed.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @param what - What kind of binding is claiming it, for diagnostics.\n */\nfunction claimName(draft: DeclarationDraft, name: string, address: string, line: number, what: string): void {\n if (draft.names.has(name)) {\n throw pragmaError(address, line, `${name} is already declared; the ${what} name must be unique in the file`);\n }\n draft.names.add(name);\n}\n\n/**\n * Checks that a name is a WGSL identifier.\n *\n * @param name - The candidate.\n * @param address - The asset address, for diagnostics.\n * @param line - The 1-based line number, for diagnostics.\n * @param what - What kind of binding it names, for diagnostics.\n */\nfunction assertIdentifier(name: string, address: string, line: number, what: string): void {\n if (!IDENTIFIER.test(name)) {\n throw pragmaError(address, line, `${JSON.stringify(name)} is not a WGSL identifier for a ${what}`);\n }\n}\n\n/**\n * Narrows a token to one of a fixed list of literals.\n *\n * @typeParam Value - The literal union.\n * @param allowed - The accepted values.\n * @param token - The candidate.\n * @returns The matching literal, or `null`.\n */\nfunction matchLiteral<Value extends string>(allowed: readonly Value[], token: string): Value | null {\n for (let index = 0; index < allowed.length; index += 1) {\n const candidate = allowed[index];\n if (candidate !== undefined && candidate === token) {\n return candidate;\n }\n }\n return null;\n}\n\n/**\n * Builds the `IGX-0719` failure a malformed pragma produces.\n *\n * @param address - The asset address.\n * @param line - The 1-based line number.\n * @param message - What is wrong.\n * @returns The error to throw.\n */\nfunction pragmaError(address: string, line: number, message: string): IgnifxError {\n return new IgnifxError(CoreErrorCode.invalidShaderPragma, `${address} line ${String(line)}: ${message}.`, {\n context: { asset: address, line, message },\n hint: \"The @ignifx pragma grammar is in skills/ignifx/references/formats/wgsl.md.\",\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8CA,MAAM,cAAc;;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,MAAc,SAAiB,MAAc,MAAoB;CACzF,IAAI,CAAC,WAAW,KAAK,IAAI,GACvB,MAAM,YAAY,SAAS,MAAM,GAAG,KAAK,UAAU,IAAI,EAAE,kCAAkC,MAAM;AAErG;;;;;;;;;AAUA,SAAS,aAAmC,SAA2B,OAA6B;CAClG,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,QAAQ,SAAS,GAAG;EACtD,MAAM,YAAY,QAAQ;EAC1B,IAAI,cAAc,KAAA,KAAa,cAAc,OAC3C,OAAO;CAEX;CACA,OAAO;AACT;;;;;;;;;AAUA,SAAS,YAAY,SAAiB,MAAc,SAA8B;CAChF,OAAO,IAAI,YAAY,cAAc,qBAAqB,GAAG,QAAQ,QAAQ,OAAO,IAAI,EAAE,IAAI,QAAQ,IAAI;EACxG,SAAS;GAAE,OAAO;GAAS;GAAM;EAAQ;EACzC,MAAM;CACR,CAAC;AACH"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { o as CoreErrorCode, t as IgnifxError } from "./ignifx-error-oYdVnT1S.js";
|
|
1
|
+
import { o as CoreErrorCode, t as IgnifxError } from "./ignifx-error-B8ByiSfJ.js";
|
|
3
2
|
import { t as Color } from "./color-DrR6GFTd.js";
|
|
4
3
|
import { a as markMaterialDirty, o as rebuildMaterialPipelines } from "./material-CGk5mAah.js";
|
|
5
4
|
import { d as SURFACE_HOOK_NAMES, f as SURFACE_UNIFORM_BLOCK } from "./shader-declaration-5q__jycG.js";
|
|
6
|
-
import { a as defineMaterialPlugin, s as uniformComponentCount } from "./material-plugin-
|
|
5
|
+
import { a as defineMaterialPlugin, s as uniformComponentCount } from "./material-plugin-CiAmriQ_.js";
|
|
6
|
+
import { t as shaderMaterialsOf } from "./shader-material-C2_UCYdO.js";
|
|
7
7
|
//#region src/lite/gpu/material-plugin.ts
|
|
8
8
|
/** The Lite point names that belong to the vertex stage. */
|
|
9
9
|
const VERTEX_POINTS = Object.freeze([
|
|
@@ -1397,4 +1397,4 @@ function describeNames(names) {
|
|
|
1397
1397
|
//#endregion
|
|
1398
1398
|
export { SurfaceShaderBinding, attachSurfaceShaders, detachSurfaceShaders, surfaceShaderBinding, surfaceShaderName, surfaceShaders };
|
|
1399
1399
|
|
|
1400
|
-
//# sourceMappingURL=surface-shader-
|
|
1400
|
+
//# sourceMappingURL=surface-shader-BeDRofOV.js.map
|