JsonTree.js
There is currently no JSON to view.Import ...
⇪
Drag and drop your files to upload
Multiple files will be joined as an array
Loading Playground...
⇪
Drag and drop your files to upload
Multiple files will be joined as an array
Welcome to Slang Playground. Here you can write, compile and run Slang shaders locally within your browser. The Slang compiler runs locally in your browser and no data is sent to any server.
You can compile shaders to many targets supported by Slang here, including SPIR-V, HLSL, GLSL, Metal, and WGSL. Generating DXIL requires DXC, which doesn't run in the browser so it's not supported here.
In addition to compiling shaders, this playground can also run simple shaders via WebGPU. The playground supports running two types of shaders:
WebGPU shaders in browser can use certain commands to specify how they will run. Requires import playground;
.
[playground::ZEROS(512)]
float
buffer with zeros of the provided size. [playground::BLACK(512, 512)]
float
texture with zeros of the provided size. [playground::URL("https://example.com/image.png")]
[playground::RAND(1000)]
float
buffer with uniform random floats between 0 and 1. [playground::TIME]
float
uniform the current time in milliseconds. [playground::MOUSE_POSITION]
float4
uniform mouse data. xy
: mouse position (in pixels) during last button down.abs(zw)
: mouse position during last button click.sign(mouze.z)
: button is downsign(mouze.w)
: button is clicked[playground::SLIDER(0.3, 0.0, 1.0)]
float
uniform with a provided default, minimum, and maximum. [playground::COLOR_PICK(0.5, 0.5, 0.5)]
float3
color uniform with a provided default color. [playground::CALL::SIZE_OF("RESOURCE-NAME")]
[playground::CALL(512, 512, 1)]
[playground::CALL::ONCE]
The playground shader also provides the following functions:
void printf<each T>(String format, expand each T values) where T : IPrintf