A project to allow Slang playground shaders to run outside of a web environment. It bundles shaders in compilation for easy deployment/sharing.
This is a library. See slang-native-playground-example for usage.
Depends on slang-rs. See that repo if it is having trouble recognizing your version of Slang.
| Name | Status | Reason |
|---|---|---|
| Simple Print | ✅ | |
| Simple Image | ✅ | |
| Image From URL | ✅ | |
| Multi-kernel Demo | ✅ | |
| ShaderToy: Circle | ✅ | |
| ShaderToy: Ocean | ✅ | |
| 2D Splatter | ✅ | |
| Differentiable 2D Splatter | ✅ | |
| Properties | ✅ | |
| Generics & Extensions | ✅ | |
| Operator Overload | ✅ | |
| Variadic generics | ✅ | |
| Automatic Differentiation | ✅ | |
| Graphics Entrypoints | ❌ | Compilation only support not planned |
| Atomics | ✅ |
This app also has a number of additional features that are not(yet) in the official playground.
Controls a float uniform to give the difference in time between frames. Useful for making things not break at high framerates.
Acts the same as BLACK but is automatically scaled based on screen size.
Acts the same as BLACK but for 3d textures.
playground::DRAWon a vertex shader allows creating a fixed size draw that will run every frameplayground::REBIND_FOR_DRAWon a texture or buffer allows specifying a resource that will mirror another resource so it becomes accessible in a graphics context. Generally neccesary to make writable resources available.playground::SAMPLERallows a sampler to be used
Takes a buffer and a offset and makes an indirect dispatch using them. The buffer is not accessible from the shader being called.
Allows loading *.obj files into a buffer. Element type must be a struct with only position, normal, and uv fields.
Example:
[playground::MODEL("static/teapot.obj")]
StructuredBuffer<Vertex> verticies;
struct Vertex
{
float3 position;
float3 normal;
}Allows controlling a GPU buffer from Rust.
There are examples of use of the extra features in the examples folder. These can be run using cargo run -p examples --example. For example cargo run -p examples --example cube_raster.
| Name | Description |
|---|---|
cube_raster |
Textured cube rasterizer with basic lighting |
free_flight_camera |
A rasterizer of the Utah Teacup with keyboard control for the camera |
painting |
A simple painting app demonstrating storage textures and indirect dispatch |
You can also compile examples for web:
cargo build --target wasm32-unknown-unknown -p examples --example painting
wasm-bindgen --out-dir target/generated/ --web target/wasm32-unknown-unknown/debug/examples/painting.wasmYou can then use the example from examples/index.html. You may need to update the js import in that file to point to the correct example.
| Name | Description |
|---|---|
| slang-voxels | A voxel rendering engine with simple falling sand physics |