Code
Write GLSL shaders in DASCA, tune them with live sliders, animate uniforms with keyframes and record the result as video.
These docs cover Dasca 2.3.
Code mode is a live GLSL shader editor. You write a fragment shader (and optionally a vertex shader), DASCA compiles it as you type, and the canvas shows the result in real time on an image, a video or no media at all.
Opening Code mode
Click Code in the mode tabs at the top of the window, or press Ctrl+Tab (Control+Tab on macOS) to switch to Code mode and back. Code mode keeps its state while you work in other modes, and your shader, uniform values, keyframes and loaded media are saved in your project file (see Project Files).
The workspace has three areas:
- Canvas in the middle, with the texture strip and the timeline dock below it.
- Code panel on the right, with the editor sections and the Uniforms list. Drag its left edge to make it wider or narrower.
- Toolbar at the top: New shader, Example shaders, Save frame, Record clip, Performance info and Fullscreen preview.
The code panel
The code panel has three collapsible sections:
| Section | What it holds |
|---|---|
| Vertex | The vertex shader. Closed by default. The default one passes vUv to the fragment shader and draws a full-screen quad. |
| Fragment | The fragment shader. Open by default. This is where most of your work happens. |
| Uniforms | Controls for your own uniforms. Appears only when the shader declares at least one custom uniform. The header shows how many there are. |
The buttons at the top of the panel:
| Button | What it does |
|---|---|
| Play (auto compile) | Compiles automatically after about 1 second without typing. The status text reads Auto compile. This is the default. |
| Stop (syntax only) | Only checks your code for errors. The canvas keeps running the last compiled shader until you compile again. The status text reads Syntax only. |
| Reset to last compiled | Puts the last shader that compiled successfully back into the editor and recompiles it. Use it when an edit broke something and you want to go back. |
| Code handbook | Opens the handbook panel (see Code handbook). |
Press Ctrl+Enter at any time to compile immediately, in either mode.
Editor features
- Drag numbers. Hover a number in the code and drag it left or right to change it. The shader recompiles quickly while you drag. Hold
Shiftfor steps 10 times larger andAltfor finer steps. Dragged values do not go below 0. - Suggestions. The editor suggests GLSL types, keywords, built-in functions and the uniforms DASCA provides.
Tabaccepts a suggestion. - Closing brackets. A missing
),]or}is shown in gray.Tabinserts it. - Indent.
Tabindents the selection andShift+Taboutdents it.
Errors
Error messages are hidden while you type. When a compile or syntax check fails:
- The error appears directly under the line it refers to, and the line number is highlighted.
- The section header shows the first error line (for example
L12) in red, and a closed section opens on its own. - Up to four errors are listed per shader.
- Bracket problems are reported before the shader is sent to the GPU, so the message points to the line you wrote.
- Common messages are rewritten in plain language, such as "Unknown name" for an undeclared identifier.
The canvas keeps showing the last shader that compiled, so a typo never leaves you with a blank screen.
Custom uniforms
Every uniform of type float, int, bool, vec2, vec3 or vec4 that is not a system uniform gets a control in the Uniforms section after the shader compiles. The label is made from the name: u_tintColor becomes "Tint color".
Setting defaults and ranges
Add a comment on the same line as the declaration:
uniform float u_intensity; // 1.5
uniform float u_angle; // 45 [0, 360]
uniform vec3 u_tintColor; // color picker
uniform bool u_invert; // 1
- The first number after
//sets the default value. [min, max]sets the slider range.- For
bool, any non-zero number makes the toggle start on.
Controls by type
| Type | Control |
|---|---|
float, int | Slider with an editable value. int sliders move in whole steps. |
bool | Toggle. |
vec3, vec4 with "color" or "colour" in the name | Color picker. Starts at white. For vec4 the fourth component is kept. |
Other vec2, vec3, vec4 | One number field per component (x, y, z, w). Each starts at 0.5. |
Automatic ranges
When there is no [min, max] comment, the slider range comes from the uniform name:
| Name contains | Range | Default |
|---|---|---|
| scale | 0.1 to 8 | 1 |
| levels | 2 to 16 | 4 |
| bias, brightness | -1 to 1 | 0 |
| intensity, strength | 0 to 2 | 1 |
| mode, invert, enabled | 0 to 1 (whole steps) | 0 |
| count, size | 1 to 512 (int: 1 to 64) | 64 (int: 4) |
| decay, smoothness | 0 to 1 | 0.5 |
anything else (float) | 0 to 1 | 0.5 |
anything else (int) | 0 to 10 | 0 |
Working with the controls
- Click a value to type it. Hold
Shiftwhile dragging a slider for fine adjustment. - Double-click a slider or its name to reset it to the default.
- The reset button in the Uniforms header resets all uniforms to their defaults.
- Values you set are kept when you recompile, as long as the uniform still exists.
- When the focus is not in the code editor,
Ctrl+Zundoes andCtrl+Y(orCtrl+Shift+Z) redoes uniform and keyframe changes. Inside the editor these keys undo and redo text.
Textures and media
The texture strip under the canvas holds your inputs. Click a tile to load an image or video into it.
| Tile | Uniform | Notes |
|---|---|---|
| tDiffuse | tDiffuse | Main input. Without media it shows a built-in sample image. A video gets play/pause, a scrubber and a time readout on the canvas. |
| tCustom1 to tCustom8 | tCustom1 ... tCustom8 | Eight extra slots for images or videos. Drag a filled tile onto another slot to swap them. |
| Audio | tAudioFFT and the audio uniforms | Load an audio file to drive the audio uniforms. |
Hover a filled tile and click its small X to clear it. Videos loop and play muted. If a project refers to a video that is not on this computer, its tile is outlined in red; click it to choose the file again.
The default shader and the example shaders read tCustom1 when it holds media and fall back to tDiffuse otherwise.
Output size
The size of the rendered image comes from the first of these that applies:
- The media in tDiffuse.
- The media in tCustom1.
- The resolution picker on the canvas, shown only when neither slot holds media: 1920 × 1080, 1280 × 720, 1080 × 1080 (default), 1080 × 1920, 854 × 480, 512 × 512.
The canvas is letterboxed to keep this aspect ratio.
Audio input
After you load an audio file, the Audio tile shows Play audio/Pause audio, Mute speakers, a seek bar, the current time and Remove audio. The file loops. Muting only silences the speakers; the shader still receives the audio data.
System uniforms
Declare any of these in your shader and DASCA fills them in every frame. Uniforms you do not declare are not bound.
| Uniform | Type | Value |
|---|---|---|
tDiffuse | sampler2D | Current input frame (image or video). |
tPrevFrame | sampler2D | The previous rendered frame. Use it for feedback and trails. |
tNoise | sampler2D | 256 x 256 random RGBA noise. Static, repeat wrap, nearest filtering. |
tBlueNoise | sampler2D | 64 x 64 grayscale ordered pattern (an 8 x 8 Bayer matrix, tiled). Static, repeat wrap, nearest filtering. |
tCustom1 ... tCustom8 | sampler2D | Media from the custom texture slots. |
u_resolution | vec2 | Canvas size in pixels. |
u_mediaResolution | vec2 | Natural size of the media in pixels. |
u_time | float | Elapsed seconds. |
u_deltaTime | float | Seconds since the last frame. |
u_frame | int | Frame counter, starts at 0. |
u_mouse | vec2 | Mouse position on the canvas in pixels, origin at the bottom left. |
u_mouseNorm | vec2 | Mouse position normalized to 0-1. |
u_mouseDown | float | 1.0 while the left mouse button is held on the canvas, otherwise 0.0. |
The feedback buffers use floating-point textures, so long trails stay smooth.
Audio uniforms
These work after you load a file in the Audio tile.
| Uniform | Type | Value |
|---|---|---|
tAudioFFT | sampler2D | 256 x 1 texture. The red channel holds the magnitude of each frequency bin, 0-1, from low (left) to high (right). |
u_audioBass | float | Average of the lowest 10% of the bins. |
u_audioMid | float | Average of the bins from 10% to 60%. |
u_audioHigh | float | Average of the bins from 60% to 100%. |
u_audioAmplitude | float | Average of all bins. |
The analysis uses a 512-sample FFT with smoothing. To read one frequency, sample the texture at a normalized position (0 = bass, 1 = treble):
uniform sampler2D tAudioFFT;
float audioFreq(float f) {
return texture2D(tAudioFFT, vec2(clamp(f, 0.0, 1.0), 0.5)).r;
}
Preprocessor
You can write WebGL 1 style GLSL. When the GPU supports WebGL 2, DASCA converts it automatically:
texture2D(becomestexture(.varyingbecomesoutin the vertex shader andinin the fragment shader.gl_FragColorbecomes an output namedfragColor.
#version and precision lines in your code are removed; DASCA adds the right ones. Line numbers in error messages still match the editor.
Defines
DASCA adds #define NAME 1 for every feature your shader mentions, so you can write code that adapts with #ifdef:
| Define | Added when the shader uses |
|---|---|
HAS_PREV_FRAME | tPrevFrame |
HAS_NOISE | tNoise |
HAS_BLUE_NOISE | tBlueNoise |
HAS_MOUSE | any u_mouse uniform |
HAS_TIME | u_time |
HAS_FRAME | u_frame |
HAS_AUDIO | tAudioFFT, u_audioBass, u_audioMid, u_audioHigh or u_audioAmplitude |
WEBGL_VERSION is always defined, as 1 or 2.
Loop unrolling
Put #pragma unroll on the line before a for loop to unroll it:
#pragma unroll
for (int i = 0; i < 8; i++) {
// ...
}
The loop must use an int counter with constant start and end values and i++. Loops with more than 256 iterations are left as they are.
Example shaders
Click Example shaders in the toolbar to load a ready-made shader. Each one starts with a comment that explains how to use it. All of them react to audio and still animate without it.
| Example | What it does |
|---|---|
| Spectrum Halo | A glowing ring driven by music: bass shapes the bottom, treble the top, and kicks make it pulse. Needs no image. |
| Pulse Halftone | Turns your image or video into a print-style dot pattern. Dots swell on the bass. |
| Bass Shockwave | Hits your image with a zoom punch, color split and ring wave on every kick. Pulses on a steady beat without audio. |
| Liquid Echo | Bright areas leave flowing trails that fade into one color. Bass speeds up the zoom and mids stir the flow. |
Loading an example replaces the code in both editors, clears the undo history and removes keyframes for uniforms the example does not have. New shader does the same with the default shader, which simply shows the input.
Code handbook
Click Code handbook (the question mark in the code panel) to open a floating reference. It covers the compile modes, editor tips, system and audio uniforms, custom uniform syntax, the preprocessor and the keyboard shortcuts, shown with your current key bindings. Drag its header to move it. It stays open until you click its close button.
Timeline and keyframes
Any custom uniform can be animated. The timeline works the same way as in the other modes; see Keyframes and Timeline for the full guide.
- Click the diamond next to a uniform to add a keyframe at the playhead. Click it again on that frame to remove the keyframe. The timeline opens when you add a keyframe.
- Use Open timeline / Close timeline in the dock under the canvas to show or hide the timeline. The dock also has Play / Pause.
- The Code timeline starts with a duration of 10 seconds. Click the duration next to the time readout to type a new one.
- Auto key (
Alt+K): when on, changing an animated uniform adds a keyframe at the playhead. When off, changes only update existing keyframes. - Snap (
Alt+S): snaps keyframes while you drag them. HoldShiftwhile dragging to bypass it. - Click a keyframe's curve to change its easing: Linear, Ease In, Ease Out, Ease In Out (the default) or Hold. Drag the curve handles to make a Custom curve.
JandKjump to the previous and next keyframe.HomeandEndgo to the start and end. The arrow keys step one frame;Shiftplus an arrow steps ten.- Toggle (
bool) uniforms always change in steps, without easing.
Recording video
Click Record clip in the toolbar, or press Ctrl+Shift+R, to open the recording panel. Choose a mode first:
| Mode | How it works |
|---|---|
| Real-time | Records the canvas as it plays. If any uniform has keyframes, recording starts the timeline from the beginning and stops at its end. Otherwise you stop it yourself. You can pause and resume. |
| Offscreen | Renders the timeline frame by frame at the output size, then encodes the video. u_time, u_deltaTime and u_frame follow the exact frame time, so the result is smooth even if the shader is too heavy to play in real time. The length is the timeline duration. It cannot be paused. |
Settings:
| Control | Options | Mode |
|---|---|---|
| Frame rate | 24 fps, 30 fps (default), 60 fps | Both |
| Bitrate | Low, Balanced, High (default) | Real-time |
| Format | WebM, MP4 (default) | Real-time |
| Format | MKV (lossless, default), MP4 (H.264) | Offscreen |
The panel also shows the frame count, the content size and the output format. Real-time recordings are scaled down so neither side is larger than 1920 pixels.
During a Real-time recording you can use Pause, Resume, Stop and review and Discard. Ctrl+Shift+R stops the recording and Ctrl+Shift+P pauses or resumes it. After you stop, a Preview of the clip plays in the panel. Click Save video to choose where to save it, or Clear to throw it away.
An Offscreen export shows its progress and a Cancel export button. When all frames are captured, choose a destination and DASCA encodes the file. Your recording settings are remembered between sessions.
Saving a frame
Click Save frame in the toolbar to save the current frame as a PNG at the output size. A save dialog opens in your default save location. Ctrl+Shift+E does the same.
Performance info and fullscreen
- Performance info (
G) shows an overlay with FPS, CPU frame time, WebGL version, GPU name, maximum texture size, texture units and maximum uniforms. - Fullscreen preview (
F11) hides the code panel and toolbar and shows only the canvas. Click Exit fullscreen or pressF11again to return.
Keyboard shortcuts
You can change these in Preferences > Shortcuts.
| Shortcut | Action |
|---|---|
Ctrl+Enter | Compile shader |
Ctrl+Tab | Switch to or from Code mode |
Ctrl+Shift+E | Save current frame as image |
Ctrl+Shift+R | Start / stop recording |
Ctrl+Shift+P | Pause / resume recording |
F11 | Toggle fullscreen preview |
G | Toggle performance info |
Ctrl+Z | Undo |
Ctrl+Y or Ctrl+Shift+Z | Redo |
Space | Timeline play / pause |
J / K | Previous / next keyframe |
Home / End | Go to start / end |
Left / Right | Step one frame |
Shift+Left / Shift+Right | Step ten frames |
Alt+K | Toggle auto key |
Alt+S | Toggle snap |
Tab / Shift+Tab | Indent / outdent in the editor |
Ctrl+S | Save project |
Ctrl+O | Open project |