Shadertoy Compatibility¶
Shader Studio is built around Shadertoy-style fragment shaders. For a conventional image shader, define a mainImage function:
VR shaders¶
Fullscreen GLSL, Slang and WGSL Image shaders can use mainVR for desktop preview and WebXR headsets. See VR shaders for setup, navigation, controller inputs and a downloadable interactive demo.
Optional Shader Studio controller inputs¶
Controller inputs are Shader Studio additions and require #define SHADER_STUDIO_VR_INPUTS. Shaders using them need adapting before running on Shadertoy. Ordinary Shadertoy shaders keep their own identifiers without this opt-in. See the controller input reference.
Supported Uniforms¶
| Uniform | Type | Description |
|---|---|---|
iTime |
float |
Elapsed time in seconds |
iTimeDelta |
float |
Time since last frame in seconds |
iFrameRate |
float |
Frames per second |
iFrame |
int |
Frame counter (starts at 0) |
iMouse |
vec4 |
xy = pointer position while a button is held, zw = click position; z > 0 while held, w > 0 only on the click frame |
iResolution |
vec3 |
Canvas dimensions: xy = width/height, z = 1.0 |
iChannelN |
sampler type follows the configured input | Input channel N (up to the configured channel limit) |
iChannelResolution[N] |
vec3 |
Resolution of input channel N |
iChannelTime[N] |
float |
Playback time for input channel N |
iChN |
metadata struct | Shader Studio accessor for channel N: .sampler, .size, .time, and .loaded |
iDate |
vec4 |
Year, month, day, seconds since midnight |
iSampleRate |
float |
Audio sample rate (44100) |
Shader Studio Extensions¶
These uniforms are provided by Shader Studio but are not part of the Shadertoy API:
| Uniform | Type | Description |
|---|---|---|
iCameraPos |
vec3 |
Camera position in world space (moved with WASD/QE) |
iCameraDir |
vec3 |
Camera look direction (controlled with mouse or IJKL) |
iVertexCount |
int |
Vertices the pass draws: the vertices geometry's vertexCount (default 3), 3 for fullscreen, or the mesh vertex count. See Vertices geometry |
iVertexUv |
vec2 |
Fragment-only perspective-correct interpolated uv written by mainVertex; available for every geometry and space |
iFrontFacing |
bool |
Fragment-only primitive orientation; always true for fullscreen geometry |
iViewMatrix, iProjectionMatrix, iViewProjection |
mat4 |
The orbit camera that meshes and world-space vertices are drawn with. See Camera matrices |
iInstanceCount |
int |
Copies of the geometry the pass draws: its instanceCount (default 1), or 1 for fullscreen. See Instancing |
iInstanceIndex |
int |
Which copy is being drawn, from 0 to iInstanceCount - 1, in the vertex and fragment shader |
Supported Input Types¶
| Type | Description |
|---|---|
| Buffer | Output from another configured pass (arbitrary names supported) |
| Texture | Image files (jpg, png, etc.) |
| Video | Video files (webm, mp4, mov, avi) |
| Audio | Audio files (mp3, wav, ogg, etc.) — provides FFT and waveform data as a texture |
| Cubemap | Cross-layout cubemap images — bound as samplerCube |
| Keyboard | Key state input |
Supported Passes¶
| Pass | Description |
|---|---|
| Image | Main output pass (required) |
| BufferA–D | Imported Shadertoy names work; Shader Studio also supports arbitrary names and more than 4 intermediate passes |
| Common | Shared code included in all passes |
Not Supported¶
| Feature | Notes |
|---|---|
| AR | Immersive augmented-reality sessions |
Webcam and microphone¶
Shadertoy's webcam and microphone inputs work in the browser. Choose Webcam in a channel's Misc tab or Mic in its Audio tab; Screen and Shared Audio are also available. VS Code panels can't use them: start the web server from the Shader Studio status menu and choose Open in Browser. See Webcam and Mic for setup and permissions.
Volume inputs¶
To use a 3D texture, open a channel's settings, choose Volumes, and select a supported KTX2 file. Sample it with a three-component coordinate in GLSL, Slang, or WGSL. Shadertoy BIN files need conversion to KTX2 first. See Volume inputs for downloadable samples, setup steps, and shader examples.
Cubemap buffers¶
Shadertoy cubemap fragment code using mainCubemap(out vec4, in vec2, in vec3, in vec3) can be used in a Cubemap pass. Copy its source into a GLSL file, choose + New → Cubemap, and bind that file and its channels. To sample the result in another pass, add a Buffer channel, select the cubemap pass in Misc, and use texture(iChannel0, direction) with a three-component direction. See Cubemap buffers for face sizes, feedback, and previews.