Skip to content

shader_vs_core

The standard Vertex Shader package. Defines the crucial attribute layout that matches the Vertex struct in Odin and provides helpers for coordinate space transformation.


layout(binding=0) uniform ShaderData {
mat4 uViewProjectionMatrix;
}

Binding 0: The global shader data. Automatically uploaded by flushBatch.


in vec4 aBytes;

Location 5: Packed data (texture index, layer, flags).


in vec4 aColor;

Location 1: Vertex color (rgba).


in vec4 aColorOverride;

Location 6: Color override.


in vec2 aLocalUv;

Location 3: Local UVs (0-1)


in vec4 aParams;

Location 7: Custom parameters for user shaders.


in vec3 aPosition;

Location 0: World space position (x, y). Z position is used for depth.


in vec2 aSize;

Location 4: Size of the sprite in pixels.


in vec2 aUv;

Location 2: Atlas texture coordinates (u, v).


vec4 getProjectedPosition(vec3 position) {
return uViewProjectionMatrix * vec4(position.xy, 0.0, 1.0);
}

Transforms a raw 2D world position into clip space (screen coordinates). Applies the current camera and projection matrices.

Arguments:

  • position: World space position.

void passVertexData() {
vPosition = aPosition;
vColor = aColor;
vUv = aUv;
vLocalUv = aLocalUv;
vSize = aSize;
vBytes = aBytes;
vColorOverride = aColorOverride;
vParams = aParams;
}

Passes all standard attributes (color, UVs, flags, etc.) to the Fragment Shader.