This shader creates colored rings that move away from a given center. It's similar to the shockwave shader by laserhosen but with colors rather than distortion.
https://gfycat.com/SpryPhonyGossamerwingedbutterflyHere are the properties of the shader that you can set:
enabled (bool) -- This is used to control whether most of the shader code is run. It's useful if you want to disable the shader without needing to reapply shaders. If not using the custom block it defaults to false so you'll need to set it to true first.
centerX (float) -- This is the X center of the rings.
centerY (float) -- This is the Y center of the rings.
counter (float) -- This controls the current position of the shader and it must be 0 or higher. Set this under the always/updating event or in a timer. Increase to expand the rings, but you can also decrease to reverse the ring movement. The example GIF changes the counter by +6 in the always/updating event.
thickness (float) -- This is the thickness of each ring.
ringSpacing (float) -- This is the empty space between each ring if you have more than 1.
ringCount (float) -- This is the number of rings that will be created in total if you keep increasing the counter.
red (float) -- This is the red value and is either added to or multiplied with the current screen. (range: 0-2)
green (float) -- This is the red value and is either added to or multiplied with the current screen. (range: 0-2)
blue (float) -- This is the red value and is either added to or multiplied with the current screen. (range: 0-2)
multiply (bool) -- If true, the color values are multiplied with the screen values. If false, the color values are added to the screen values.
Shadertoy Codebool enabled = true;
float counter = 0.0;
float thickness = 25.0;
float ringSpacing = 100.0;
const float ringCount = 6.0;
float red = 1.6;
float green = 1.4;
float blue = 0.5;
bool multiply = false;
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
float centerX = iMouse.x;
float centerY = iMouse.y;
vec2 uv = fragCoord.xy / iResolution.xy;
vec4 tex = texture(iChannel0, uv);
if (!enabled)
{
fragColor = tex;
return;
}
vec2 fragPt = fragCoord;
counter = iTime;
float outerRad = counter * 300.0;
float innerRad = outerRad - thickness;
float xDiff = centerX - fragPt.x;
float yDiff = centerY - fragPt.y;
float dist = sqrt((xDiff * xDiff) + (yDiff * yDiff));
fragColor = tex;
for(float i = 0.0; i < ringCount; i++)
{
if (dist < outerRad - i * ringSpacing && dist > innerRad - i * ringSpacing)
{
if (multiply)
{
fragColor = vec4(tex.r * red, tex.g * green, tex.b * blue, 1.0);
}
else
{
fragColor = vec4(tex.r + red, tex.g + green, tex.b + blue, 1.0);
}
}
}
}
Stencyl Code#ifdef GL_ES
precision mediump float;
#endif
varying vec2 vTexCoord;
uniform vec2 uResolution;
uniform vec2 uResolutionUs;
uniform sampler2D uImage0;
uniform bool enabled;
uniform float centerX;
uniform float centerY;
uniform float counter;
uniform float thickness;
uniform float ringSpacing;
uniform float ringCount;
uniform float red;
uniform float green;
uniform float blue;
uniform bool multiply;
void main()
{
vec2 uv = vTexCoord;
vec4 tex = texture2D(uImage0, uv);
if (!enabled)
{
gl_FragColor = tex;
return;
}
vec2 scale = uResolution.xy / uResolutionUs.xy;
float scaleAvg = (scale.x + scale.y) / 2.0;
vec2 fragPt = uv * uResolution;
float outerRad = counter * scaleAvg;
float innerRad = outerRad - thickness * scaleAvg;
float xDiff = centerX * scale.x - fragPt.x;
float yDiff = (uResolutionUs.y - centerY) * scale.y - fragPt.y;
float dist = sqrt((xDiff * xDiff) + (yDiff * yDiff));
gl_FragColor = tex;
for(float i = 0.0; i < ringCount; i++)
{
if (dist < outerRad - i * ringSpacing * scaleAvg && dist > innerRad - i * ringSpacing * scaleAvg)
{
if (multiply)
{
gl_FragColor = vec4(tex.r * red, tex.g * green, tex.b * blue, 1.0);
}
else
{
gl_FragColor = vec4(tex.r + red, tex.g + green, tex.b + blue, 1.0);
}
}
}
}