GPULang
Finally, a user friendly shader programming language
Experience the elegance and power of GPULang with this example
// GPULang Billboard Example
struct BillboardData
{
BaseColor : f32x4;
};
uniform AlbedoMap : *texture2D;
uniform Billboard : *BillboardData;
struct ViewConstants
{
ViewProjection : f32x4x4;
};
uniform ViewConstants : *ViewConstants;
struct ObjectConstants
{
Model : f32x4x4;
};
uniform ObjectConstants : *ObjectConstants;
sampler_state BillboardSampler {};
render_state BillboardState
{
Cull = CullFace.None;
};
//------------------------------------------------------------------------------
/**
*/
entry_point
BillboardVS(
binding(0) in position : f32x2,
binding(2) in uv : f32x2,
out UV : f32x2
) void
{
vertexExportCoordinates(ViewConstants.ViewProjection * ObjectConstants.Model * f32x4(position, 0, 1));
UV = uv;
}
//------------------------------------------------------------------------------
/**
*/
entry_point
BillboardPS(
in UV : f32x2
) void
{
const diffColor = textureSample(AlbedoMap, BillboardSampler, UV) * Billboard.Color;
const alpha = diffColor.w;
if (alpha < 0.5f)
discard;
pixelExportColor(diffColor * Billboard.BaseColor, 0);
}
//------------------------------------------------------------------------------
/**
*/
@Mask("Static")
program Render
{
VertexShader = BillboardVS;
PixelShader = BillboardPS;
RenderState = BillboardState;
};
}
Why GPULang?
Lightning Fast
The compiler is highly optimized to not waste CPU cycles. This means you don't have to wait for shaders to compile.
Games
GPULang is designed to make shaders accessible for game engines. By assembling your shader stages in code, GPULang can validate and prepare pipeline creation for you, so you don't have to sweat.
Native
GPULang compiles directly to SPIR-V, and plans to target DXIL, WebGPU and Metal IR in the future. The compiler can also produce a C/C++ header file for static shader reflection, as well as a binary which can be used for dynamic shader reflection.
Rich Tooling
GPULang comes with a language server which doesn't just provide syntax introspection, but runs the compiler on the server side to ensure every error and warning is captured and reported.