API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classShaderSource
Immutable shader source pair shared by Material instances. `ShaderSource` owns only the GLSL/WGSL text and its stable identity; it carries no uniform/texture state (that lives on the Material). One `ShaderSource` can back many materials, and renderers key their compiled program/pipeline caches on the source identity exposed via id. # Vertex layout The vertex layout for the mesh path is fixed and shared with the default mesh material, so custom vertex shaders MUST pin the standard attribute locations: ## GLSL (location-qualified) ```glsl layout(location = 0) in vec2 a_position; layout(location = 1) in vec2 a_texcoord; layout(location = 2) in vec4 a_color; ``` ## WGSL (location-qualified) ```wgsl struct VertexInput { @location(0) position: vec2<f32>, @location(1) texcoord: vec2<f32>, @location(2) color: vec4<f32>, }; ``` # Auto-bound uniforms Renderers auto-bind these when the source declares them. Declared but unused is fine; absent is fine too. Both backends carry the same logical uniforms, only the binding scheme differs. ## GLSL ```glsl uniform mat3 u_projection; // active view's projection uniform mat3 u_translation; // drawable's global transform uniform vec4 u_tint; // tint as RGBA in 0..1 uniform sampler2D u_texture; // bound to texture slot 0 ``` ## WGSL ```wgsl struct MeshUniforms { projection: mat3x3<f32>, translation: mat3x3<f32>, tint: vec4<f32>, }; @group(0) @binding(0) var<uniform> u_mesh: MeshUniforms; @group(1) @binding(0) var u_texture: texture_2d<f32>; @group(1) @binding(1) var u_sampler: sampler; ``` # User uniforms Anything in Material.uniforms is set after the auto-binds. `Texture`/`RenderTexture` values claim slots 1..N (slot 0 belongs to the drawable's own texture). ## WGSL user-uniform contract User uniforms live in `@group(2)`: - `@group(2) @binding(0) var<uniform> u_user: <UserUniformsStruct>;` for the packed scalar/vector/matrix uniforms. - `@group(2) @binding(N)` for each `Texture`/`RenderTexture` uniform, in declaration order, alongside its sampler at `@binding(N+1)`.
import { ShaderSource } from '@codexo/exojs' Immutable shader source pair shared by Material instances.
`ShaderSource` owns only the GLSL/WGSL text and its stable identity; it carries no uniform/texture state (that lives on the Material). One `ShaderSource` can back many materials, and renderers key their compiled program/pipeline caches on the source identity exposed via id.
# Vertex layout
The vertex layout for the mesh path is fixed and shared with the default mesh material, so custom vertex shaders MUST pin the standard attribute locations:
```glsl layout(location = 0) in vec2 a_position; layout(location = 1) in vec2 a_texcoord; layout(location = 2) in vec4 a_color; ```
```wgsl struct VertexInput { @location(0) position: vec2\<f32>, @location(1) texcoord: vec2\<f32>, @location(2) color: vec4\<f32>, }; ```
# Auto-bound uniforms
Renderers auto-bind these when the source declares them. Declared but unused is fine; absent is fine too. Both backends carry the same logical uniforms, only the binding scheme differs.
```glsl uniform mat3 u_projection; // active view's projection uniform mat3 u_translation; // drawable's global transform uniform vec4 u_tint; // tint as RGBA in 0..1 uniform sampler2D u_texture; // bound to texture slot 0 ```
```wgsl struct MeshUniforms { projection: mat3x3\<f32>, translation: mat3x3\<f32>, tint: vec4\<f32>, };
@group(0) @binding(0) var\<uniform> u_mesh: MeshUniforms;
@group(1) @binding(0) var u_texture: texture_2d\<f32>; @group(1) @binding(1) var u_sampler: sampler; ```
# User uniforms
Anything in Material.uniforms is set after the auto-binds. `Texture`/`RenderTexture` values claim slots 1..N (slot 0 belongs to the drawable's own texture).
@group(2) @binding(0) var\<uniform> u_user: \<UserUniformsStruct>; User uniforms live in `@group(2)`:
for the packed scalar/vector/matrix uniforms.
in declaration order, alongside its sampler at `@binding(N+1)`.
new(options: ShaderSourceOptions): ShaderSource detectUniformDrift(): object getDeclaredUniforms(): object glsl: object | null wgsl: string | null id: number