Interactive Shader Parameters
by GameDev.net · GLSL ES 3.00 (WebGL2) · 25 Aug 2026
Run the shader to adjust these controls.
What it demonstrates
This project presents every parameter type supported by ShaderLab's source annotations in one coherent shader. Radius is a float slider, Ray count is an integer stepper, Animate is a checkbox, Center is a vec2 control, Tint is a vec3 color picker, and Background RGBA is a four-component control. Together they shape a radial flower motif.
Shader inputs
void mainImage(out vec4 fragColor, in vec2 fragCoord)
Called once per pixel. Write the colour to fragColor.
-
iResolutionvec3 - Viewport size in pixels (z is the pixel aspect ratio).
-
iTimefloat - Seconds since the shader started.
-
iTimeDeltafloat - Seconds since the previous frame.
-
iFrameRatefloat - Frames per second, smoothed.
-
iFrameint - Frames rendered since the start.
-
iMousevec4 - Mouse position: xy while held, zw of the last click.
-
iDatevec4 - Year, month, day, and seconds within the day.
-
iChannel0sampler2D - Texture bound to channel 0.
-
iChannel1sampler2D - Texture bound to channel 1.
-
iChannel2sampler2D - Texture bound to channel 2.
-
iChannel3sampler2D - Texture bound to channel 3.
-
iChannelResolutionvec3[4] - Pixel size of each bound channel texture.
-
iChannelTimefloat[4] - Playback time of each channel, in seconds.
-
iSampleRatefloat - Audio sample rate, always 44100.
Main Image8
uniform float uRadius; // @param 0.08..0.42 = 0.27 "Radius"
uniform int uRays; // @param 3..12 = 7 "Ray count"
uniform bool uAnimate; // @param = 1 "Animate"
uniform vec2 uCenter; // @param 0.2..0.8 = 0.5, 0.5 "Center"
uniform vec3 uTint; // @param 0.0..1.0 = 0.18, 0.78, 0.95 color "Tint"
uniform vec4 uBackground; // @param 0.0..1.0 = 0.025, 0.04, 0.09, 1.0 "Background RGBA"
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = fragCoord / iResolution.xy;
vec2 p = uv - uCenter;
p.x *= iResolution.x / iResolution.y;
float angle = atan(p.y, p.x);
float phase = uAnimate ? iTime * 0.7 : 0.0;
float petals = 0.75 + 0.25 * cos(float(uRays) * angle + phase);
float shapeRadius = uRadius * petals;
float shape = 1.0 - smoothstep(shapeRadius, shapeRadius + 0.012, length(p));
vec3 color = mix(uBackground.rgb, uTint, shape);
fragColor = vec4(color, uBackground.a);
}
Learn from this shader
How it works
Each uniform has a same-line @param comment. Numeric ranges define control bounds, equals signs provide defaults, quoted text supplies labels, and the word color requests a picker for the vec3. The shader converts fragments to coordinates around Center and aspect-corrects x. atan gives the angle around the center. Ray count multiplies that angle to create repeated lobes; optional time advances their phase. The cosine result modulates Radius, and a smooth radial threshold blends Tint over the background. The fourth background component becomes output alpha.
Try changing
Adjust each control independently before combining them. Use an even and odd Ray count, disable Animate to inspect a fixed phase, move Center near the range limits, and compare saturated with muted colors. In a fork, change defaults in the comments, narrow a range, or remove the color marker to see the same three values represented as ordinary sliders.
Using it in a game
Source-declared controls are useful when exposing safe material variations to artists, technical designers, or tutorial readers. An engine would normally define equivalent properties in a material inspector rather than parse these comments. Preserve sensible bounds and defaults when recreating the interface, and confirm the target pipeline's alpha blending behavior.
Explore the techniques
Continue with curated explanations and progressively related examples.
Discussion