Added new manipulative shaders
This commit is contained in:
BIN
data/shaders/manipulative/ACII.frag.qsb
Normal file
BIN
data/shaders/manipulative/ACII.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Aberrating Aberrations.frag.qsb
Normal file
BIN
data/shaders/manipulative/Aberrating Aberrations.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Brannan Filter.frag.qsb
Normal file
BIN
data/shaders/manipulative/Brannan Filter.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Chroma Blur.frag.qsb
Normal file
BIN
data/shaders/manipulative/Chroma Blur.frag.qsb
Normal file
Binary file not shown.
Binary file not shown.
BIN
data/shaders/manipulative/Circular Pixels.frag.qsb
Normal file
BIN
data/shaders/manipulative/Circular Pixels.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Color Invert.frag.qsb
Normal file
BIN
data/shaders/manipulative/Color Invert.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Color Reduction.frag.qsb
Normal file
BIN
data/shaders/manipulative/Color Reduction.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Desaturate.frag.qsb
Normal file
BIN
data/shaders/manipulative/Desaturate.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/EGA.frag.qsb
Normal file
BIN
data/shaders/manipulative/EGA.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Fake Thermal.frag.qsb
Normal file
BIN
data/shaders/manipulative/Fake Thermal.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Gameboy.frag.qsb
Normal file
BIN
data/shaders/manipulative/Gameboy.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Gaussian Blur.frag.qsb
Normal file
BIN
data/shaders/manipulative/Gaussian Blur.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Italic.frag.qsb
Normal file
BIN
data/shaders/manipulative/Italic.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Median (Fast).frag.qsb
Normal file
BIN
data/shaders/manipulative/Median (Fast).frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Melting Snow.frag.qsb
Normal file
BIN
data/shaders/manipulative/Melting Snow.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Mirror (Bottom).frag.qsb
Normal file
BIN
data/shaders/manipulative/Mirror (Bottom).frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Mirror (Left).frag.qsb
Normal file
BIN
data/shaders/manipulative/Mirror (Left).frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Mirror (Quad).frag.qsb
Normal file
BIN
data/shaders/manipulative/Mirror (Quad).frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Mirror (Right).frag.qsb
Normal file
BIN
data/shaders/manipulative/Mirror (Right).frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Mirror (Top).frag.qsb
Normal file
BIN
data/shaders/manipulative/Mirror (Top).frag.qsb
Normal file
Binary file not shown.
Binary file not shown.
BIN
data/shaders/manipulative/Nearest Neighbor.frag.qsb
Normal file
BIN
data/shaders/manipulative/Nearest Neighbor.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Night Vision.frag.qsb
Normal file
BIN
data/shaders/manipulative/Night Vision.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Oil Painting.frag.qsb
Normal file
BIN
data/shaders/manipulative/Oil Painting.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Old Memory.frag.qsb
Normal file
BIN
data/shaders/manipulative/Old Memory.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Perlin Noise.frag.qsb
Normal file
BIN
data/shaders/manipulative/Perlin Noise.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Pixelation.frag.qsb
Normal file
BIN
data/shaders/manipulative/Pixelation.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Posterize.frag.qsb
Normal file
BIN
data/shaders/manipulative/Posterize.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Quadtree.frag.qsb
Normal file
BIN
data/shaders/manipulative/Quadtree.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Radial Blur.frag.qsb
Normal file
BIN
data/shaders/manipulative/Radial Blur.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Rain Drops.frag.qsb
Normal file
BIN
data/shaders/manipulative/Rain Drops.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Rainbow Filter.frag.qsb
Normal file
BIN
data/shaders/manipulative/Rainbow Filter.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Randomized Transitions (x2).frag.qsb
Normal file
BIN
data/shaders/manipulative/Randomized Transitions (x2).frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Ripple Distortion.frag.qsb
Normal file
BIN
data/shaders/manipulative/Ripple Distortion.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Scatter Blur.frag.qsb
Normal file
BIN
data/shaders/manipulative/Scatter Blur.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Sepia.frag.qsb
Normal file
BIN
data/shaders/manipulative/Sepia.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Soft Blur.frag.qsb
Normal file
BIN
data/shaders/manipulative/Soft Blur.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Solarize.frag.qsb
Normal file
BIN
data/shaders/manipulative/Solarize.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Stone Man.frag.qsb
Normal file
BIN
data/shaders/manipulative/Stone Man.frag.qsb
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
data/shaders/manipulative/Video Artifacts.frag.qsb
Normal file
BIN
data/shaders/manipulative/Video Artifacts.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Video Bubble.frag.qsb
Normal file
BIN
data/shaders/manipulative/Video Bubble.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Video Glitch 02.frag.qsb
Normal file
BIN
data/shaders/manipulative/Video Glitch 02.frag.qsb
Normal file
Binary file not shown.
Binary file not shown.
BIN
data/shaders/manipulative/Video Wall.frag.qsb
Normal file
BIN
data/shaders/manipulative/Video Wall.frag.qsb
Normal file
Binary file not shown.
BIN
data/shaders/manipulative/Water Ripples.frag.qsb
Normal file
BIN
data/shaders/manipulative/Water Ripples.frag.qsb
Normal file
Binary file not shown.
@@ -181,7 +181,7 @@ def compile():
|
|||||||
|
|
||||||
# Construct and execute the command
|
# Construct and execute the command
|
||||||
cmd = [
|
cmd = [
|
||||||
qsb, '--glsl', '330', '--hlsl', '50', '--msl', '12',
|
qsb, '--glsl', '330 es,330,320 es,320', '--hlsl', '50', '--msl', '12',
|
||||||
'-o', output_file_path, source_file_path
|
'-o', output_file_path, source_file_path
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -266,11 +266,15 @@ def process():
|
|||||||
common_file_contents = re.sub(r'void\s+main\s*\([^)]*\)\s*\{[\s\S]*?\}', '', common_file_contents)
|
common_file_contents = re.sub(r'void\s+main\s*\([^)]*\)\s*\{[\s\S]*?\}', '', common_file_contents)
|
||||||
|
|
||||||
# 3. Remove declarations in the common file that match the replacement vars
|
# 3. Remove declarations in the common file that match the replacement vars
|
||||||
for var in variables_to_update:
|
# -- This really needs to be moved into a detection function that checks for
|
||||||
pattern = r'(\w*\s*)(' + var + ')'
|
# -- ubuf names within function scopes. This is messing with correctly formatted
|
||||||
replacement = r'\1_\2'
|
# -- defines in the common file
|
||||||
|
|
||||||
|
# for var in variables_to_update:
|
||||||
|
# pattern = r'(\w*\s*)(' + var + ')'
|
||||||
|
# replacement = r'\1_\2'
|
||||||
|
|
||||||
common_file_contents = re.sub(pattern, replacement, common_file_contents)
|
# common_file_contents = re.sub(pattern, replacement, common_file_contents)
|
||||||
|
|
||||||
for file in files:# Stage for processing, if a shader
|
for file in files:# Stage for processing, if a shader
|
||||||
if file.endswith('.frag') and not file == 'Common.frag':
|
if file.endswith('.frag') and not file == 'Common.frag':
|
||||||
|
|||||||
102
tools/src/manipulative/ACII.frag
Normal file
102
tools/src/manipulative/ACII.frag
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
ASCII filter. Current version from July 7, 2024.
|
||||||
|
Based on the genius implementation by movAX13h and inspired by Acerola's video on ASCII rendering.
|
||||||
|
Original ones here:
|
||||||
|
- movAX13h : https://www.shadertoy.com/view/lssGDj
|
||||||
|
- Acerola : https://www.youtube.com/watch?v=gg40RWiaHRY
|
||||||
|
|
||||||
|
I plan to try implementing the border detection to render ASCII borders, so expect some update someday.
|
||||||
|
|
||||||
|
For more ASCII bitmap generation: https://thrill-project.com/archiv/coding/bitmap/
|
||||||
|
|
||||||
|
For this version, I focused on understanding the basic ideas and implementing it
|
||||||
|
in a legible way for me. For this, I have implemented:
|
||||||
|
- A helper grayscale function;
|
||||||
|
- A downsampled uv function to help downsample the coordinates, therefore the image;
|
||||||
|
- The original character function, that now deals more clearly with spacing and modulates
|
||||||
|
some more the original code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define CHAR_SIZE 5.0
|
||||||
|
#define SPACING 1.0
|
||||||
|
|
||||||
|
float grayscale(vec3 p){
|
||||||
|
/*Convertes a given pixel to grayscale.
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
|
||||||
|
p : vec3
|
||||||
|
rgb pixel.
|
||||||
|
*/
|
||||||
|
return 0.299*p.r + 0.587*p.g + 0.114*p.b;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 downsampled_uv(vec2 coord, float d){
|
||||||
|
/*Maps the current position to a downsampled position
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
|
||||||
|
coord : vec2
|
||||||
|
Current pixel position.
|
||||||
|
d : float
|
||||||
|
downsample proportion (image will be d times smaller)
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Below line maps the current position to a downsampled uv
|
||||||
|
// mod(fragCoord.x, d) is the distance from the current position from the target
|
||||||
|
// position, so it is just subtracted.
|
||||||
|
return vec2( coord.x - mod(coord.x, d), coord.y - mod(coord.y, d) ) / iResolution.xy;
|
||||||
|
}
|
||||||
|
|
||||||
|
float character(uint char, vec2 p){
|
||||||
|
/*Returns if current pixel corresponds to character bounds
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
|
||||||
|
char : uint
|
||||||
|
character 2^25 (5x5) bitmap value.
|
||||||
|
p : vec2
|
||||||
|
fragment position.
|
||||||
|
*/
|
||||||
|
vec2 local_p = vec2( mod(p.x + 0.5, CHAR_SIZE + 2.0*SPACING), // ALWAYS sum +0.5
|
||||||
|
mod(p.y + 0.5, CHAR_SIZE + 2.0*SPACING));// ALWAYS sum +0.5
|
||||||
|
|
||||||
|
//Checks if pixel position is beyond character limits, if yes then returns 0.0
|
||||||
|
if(local_p.x < SPACING || local_p.x >= CHAR_SIZE + (SPACING - 1.0))
|
||||||
|
return 0.0;
|
||||||
|
if(local_p.y < SPACING || local_p.y >= CHAR_SIZE + (SPACING - 1.0))
|
||||||
|
return 0.0;
|
||||||
|
|
||||||
|
//Starts at bottom-left position
|
||||||
|
uint start = 16u; //0b0000000000000000000010000
|
||||||
|
uint bit_pos = start >> int(local_p.x - SPACING); // x offset
|
||||||
|
bit_pos = bit_pos << int(CHAR_SIZE*(local_p.y - SPACING)); // y offset
|
||||||
|
uint result = bit_pos & char; // acts as a mask to filter only the pixel value
|
||||||
|
|
||||||
|
// bitshifts to the most significant bit so it does not overflow the output
|
||||||
|
return float(result >> int( CHAR_SIZE-(local_p.x - (SPACING - 1.0)) ) +
|
||||||
|
int( CHAR_SIZE*(local_p.y - (SPACING) ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
float levels_size = 8.0;
|
||||||
|
|
||||||
|
vec2 uv = downsampled_uv(fragCoord, CHAR_SIZE + 2.0*SPACING);
|
||||||
|
|
||||||
|
/*char levels = ( , . , : , > , * , o , @ , ▄ )*/
|
||||||
|
uint levels[8] = uint[8](0u, 16u, 65600u, 4357252u, 163153u, 15255086u, 13195790u, 1048544u);
|
||||||
|
|
||||||
|
vec3 tex = texture(iChannel0, uv).rgb;
|
||||||
|
float gray = grayscale(tex);
|
||||||
|
|
||||||
|
float ds = 1.0/levels_size; //levels size
|
||||||
|
|
||||||
|
uint final_value = 0u;
|
||||||
|
for(float i = 0.0; i < levels_size; i++) //Runs for every intensity level
|
||||||
|
if(gray > 0.0 + i*ds) final_value = levels[int(i)];
|
||||||
|
|
||||||
|
fragColor = vec4( tex*character(final_value, fragCoord) , 1.0);
|
||||||
|
}
|
||||||
53
tools/src/manipulative/Aberrating Aberrations.frag
Normal file
53
tools/src/manipulative/Aberrating Aberrations.frag
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
// https://www.shadertoy.com/view/sldGW2
|
||||||
|
|
||||||
|
// Fork of "aberrating aberrations on video" by morisil. https://shadertoy.com/view/7tdGW2
|
||||||
|
// 2021-11-13 05:24:16
|
||||||
|
|
||||||
|
// Fork of "depth of field focus study 2" by morisil. https://shadertoy.com/view/flc3zX
|
||||||
|
// 2021-11-13 05:16:16
|
||||||
|
|
||||||
|
// Fork of "depth of field focus study" by morisil. https://shadertoy.com/view/sld3zB
|
||||||
|
// 2021-11-08 19:52:49
|
||||||
|
|
||||||
|
const float SHAPE_SIZE = .7;
|
||||||
|
const float CHROMATIC_ABBERATION = .02;
|
||||||
|
const float ITERATIONS = 5.;
|
||||||
|
const float INITIAL_LUMA = .6;
|
||||||
|
|
||||||
|
float getColorComponent(in vec2 st, in float modScale, in float blur) {
|
||||||
|
vec2 modSt = mod(st, 1. / modScale) * modScale * 2. - 1.;
|
||||||
|
float dist = length(modSt);
|
||||||
|
float angle = atan(modSt.x, modSt.y);
|
||||||
|
float shapeMap = smoothstep(SHAPE_SIZE + blur, SHAPE_SIZE - blur, dist);
|
||||||
|
return shapeMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
||||||
|
vec2 uv = fragCoord / iResolution.xy;
|
||||||
|
vec2 st =
|
||||||
|
(2.* fragCoord - iResolution.xy)
|
||||||
|
/ min(iResolution.x, iResolution.y);
|
||||||
|
|
||||||
|
float modScale = 2.;
|
||||||
|
|
||||||
|
vec3 color = vec3(0);
|
||||||
|
float luma = INITIAL_LUMA;
|
||||||
|
float blur = .2;
|
||||||
|
for (float i = 0.; i < ITERATIONS; i++) {
|
||||||
|
vec2 center = st + vec2(sin(iTime * .4), cos(iTime * .45)) * .3;
|
||||||
|
//center += pow(length(center), 1.);
|
||||||
|
vec2 modSt = mod(st, 1. / modScale) * modScale * 2. - 1.;
|
||||||
|
vec3 shapeColor = vec3(
|
||||||
|
getColorComponent(center - st * CHROMATIC_ABBERATION, modScale, blur),
|
||||||
|
getColorComponent(center, modScale, blur),
|
||||||
|
getColorComponent(center + st * CHROMATIC_ABBERATION, modScale, blur)
|
||||||
|
) * luma * texture(iChannel0, (center * vec2(-1, 1) + 1.) * .5).rgb;
|
||||||
|
st *= 1.3;
|
||||||
|
color += shapeColor;
|
||||||
|
color = clamp(color, 0., 1.);
|
||||||
|
if (color == vec3(1)) break;
|
||||||
|
luma *= .63;
|
||||||
|
blur *= .63;
|
||||||
|
}
|
||||||
|
fragColor = vec4(color, 1.0);
|
||||||
|
}
|
||||||
89
tools/src/manipulative/Brannan Filter.frag
Normal file
89
tools/src/manipulative/Brannan Filter.frag
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
/**
|
||||||
|
* Brannan Filter by Ruofei Du (DuRuofei.com)
|
||||||
|
* Demo: https://www.shadertoy.com/view/4lSyDK
|
||||||
|
* starea @ ShaderToy,License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
|
||||||
|
* https://creativecommons.org/licenses/by-nc-sa/3.0/
|
||||||
|
*
|
||||||
|
* Reference:
|
||||||
|
* [1] Overlay function forked from ben's https://www.shadertoy.com/view/XdS3RW
|
||||||
|
* [2] starea's Dotted Drawing / Sketch Effect: https://www.shadertoy.com/view/ldSyzV
|
||||||
|
* [3] starea's BrightnessContrastSaturationHue: https://www.shadertoy.com/view/MdjBRy
|
||||||
|
*
|
||||||
|
* Write-ups:
|
||||||
|
* [1] http://blog.ruofeidu.com/implementing-instagram-filters-brannan/
|
||||||
|
**/
|
||||||
|
|
||||||
|
float overlay(in float s, in float d )
|
||||||
|
{
|
||||||
|
return (d < 0.5) ? 2.0 * s * d : 1.0 - 2.0 * (1.0 - s) * (1.0 - d);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 overlay(in vec3 s, in vec3 d )
|
||||||
|
{
|
||||||
|
vec3 c;
|
||||||
|
c.x = overlay(s.x,d.x);
|
||||||
|
c.y = overlay(s.y,d.y);
|
||||||
|
c.z = overlay(s.z,d.z);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
float greyScale(in vec3 col)
|
||||||
|
{
|
||||||
|
return dot(col, vec3(0.3, 0.59, 0.11));
|
||||||
|
}
|
||||||
|
|
||||||
|
mat3 saturationMatrix( float saturation ) {
|
||||||
|
vec3 luminance = vec3( 0.3086, 0.6094, 0.0820 );
|
||||||
|
float oneMinusSat = 1.0 - saturation;
|
||||||
|
vec3 red = vec3( luminance.x * oneMinusSat );
|
||||||
|
red.r += saturation;
|
||||||
|
|
||||||
|
vec3 green = vec3( luminance.y * oneMinusSat );
|
||||||
|
green.g += saturation;
|
||||||
|
|
||||||
|
vec3 blue = vec3( luminance.z * oneMinusSat );
|
||||||
|
blue.b += saturation;
|
||||||
|
|
||||||
|
return mat3(red, green, blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
void levels(inout vec3 col, in vec3 inleft, in vec3 inright, in vec3 outleft, in vec3 outright) {
|
||||||
|
col = clamp(col, inleft, inright);
|
||||||
|
col = (col - inleft) / (inright - inleft);
|
||||||
|
col = outleft + col * (outright - outleft);
|
||||||
|
}
|
||||||
|
|
||||||
|
void brightnessAdjust( inout vec3 color, in float b) {
|
||||||
|
color += b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void contrastAdjust( inout vec3 color, in float c) {
|
||||||
|
float t = 0.5 - c * 0.5;
|
||||||
|
color = color * c + t;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 uv = fragCoord.xy / iResolution.xy;
|
||||||
|
vec3 col = texture(iChannel0, uv).rgb;
|
||||||
|
if (iMouse.z > 0.5) {
|
||||||
|
fragColor = vec4(col, 1.0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vec3 grey = vec3(greyScale(col));
|
||||||
|
col = saturationMatrix(0.7) * col;
|
||||||
|
grey = overlay(grey, col);
|
||||||
|
col = mix(grey, col, 0.63);
|
||||||
|
levels(col, vec3(0., 0., 0.) / 255., vec3(228., 255., 239.) / 255.,
|
||||||
|
vec3(23., 3., 12.) / 255., vec3(255.) / 255.);
|
||||||
|
brightnessAdjust(col, -0.1);
|
||||||
|
contrastAdjust(col, 1.05);
|
||||||
|
vec3 tint = vec3(255., 248., 242.) / 255.;
|
||||||
|
levels(col, vec3(0., 0., 0.) / 255., vec3(255., 224., 255.) / 255.,
|
||||||
|
vec3(9., 20., 18.) / 255., vec3(255.) / 255.);
|
||||||
|
col = pow(col, vec3(0.91, 0.91, 0.91*0.94));
|
||||||
|
brightnessAdjust(col, -0.04);
|
||||||
|
contrastAdjust(col, 1.14);
|
||||||
|
col = tint * col;
|
||||||
|
fragColor = vec4(col, 1.0);
|
||||||
|
}
|
||||||
21
tools/src/manipulative/Chroma Blur.frag
Normal file
21
tools/src/manipulative/Chroma Blur.frag
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
// https://www.shadertoy.com/view/4dl3z8
|
||||||
|
|
||||||
|
const float blurAmount=.00017;
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 xy = fragCoord.xy/iResolution.xy;
|
||||||
|
vec2 center=iResolution.xy/2.;
|
||||||
|
vec2 diff=xy-center;
|
||||||
|
float dist=dot(diff,diff)*0.0004;
|
||||||
|
vec2 amount=vec2((center.x-xy.x)*blurAmount*dist,0.);
|
||||||
|
vec4 tx;
|
||||||
|
|
||||||
|
tx=texture(iChannel0, xy+amount*-0.02)*vec4(0.666,0.0,0.0,0.2);
|
||||||
|
tx+=texture(iChannel0, xy+amount*-0.01)*vec4(0.333,0.25,0.0,0.2);
|
||||||
|
tx+=texture(iChannel0, xy)*vec4(0.0,0.5,0.0,0.2);
|
||||||
|
tx+=texture(iChannel0, xy+amount*0.01)*vec4(0.0,0.25,0.333,0.2);
|
||||||
|
tx+=texture(iChannel0, xy+amount*0.02)*vec4(0.0,0.0,0.667,0.2);
|
||||||
|
|
||||||
|
fragColor = tx;
|
||||||
|
}
|
||||||
34
tools/src/manipulative/Circular Pixels.frag
Normal file
34
tools/src/manipulative/Circular Pixels.frag
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
// https://www.shadertoy.com/view/XlSBzm
|
||||||
|
// by Nikos Papadopoulos, 4rknova / 2018
|
||||||
|
// Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
|
||||||
|
#define LUM vec3(.2126, .7152, .0722)
|
||||||
|
|
||||||
|
// Configuration
|
||||||
|
#define CHROMA_KEY
|
||||||
|
#define CHROMA_BIAS (00.13)
|
||||||
|
|
||||||
|
#define BGCOLOR vec3(0.03, 0.1, 0.2)
|
||||||
|
#define GRID_SIZE (35.0)
|
||||||
|
#define BIAS (10.0)
|
||||||
|
#define SCALE (32.0)
|
||||||
|
|
||||||
|
void mainImage(out vec4 color, in vec2 fragc)
|
||||||
|
{
|
||||||
|
// Aspect corrected grid size.
|
||||||
|
vec2 gridsz = GRID_SIZE * vec2(iResolution.x/iResolution.y, 1);
|
||||||
|
// Grid coordinates with half a unit offset to sample
|
||||||
|
// the center of the cell.
|
||||||
|
vec2 pc = fragc.xy / iResolution.xy * gridsz;
|
||||||
|
vec2 cl = floor(pc)+0.5;
|
||||||
|
vec3 col = texture(iChannel0, cl / gridsz).rgb;
|
||||||
|
|
||||||
|
// Calculate the sample's distance from the cell center.
|
||||||
|
float dst = pow(1. - length(pc - cl), BIAS) * SCALE;
|
||||||
|
float lum = dot(LUM, col.rgb); // luminance
|
||||||
|
|
||||||
|
#ifdef CHROMA_KEY
|
||||||
|
if (lum > max(col.r, col.b) + CHROMA_BIAS) col = BGCOLOR;
|
||||||
|
#endif /* CHROMA_KEY */
|
||||||
|
|
||||||
|
color = vec4(mix(BGCOLOR, col, min(1., dst*lum)), 1);
|
||||||
|
}
|
||||||
16
tools/src/manipulative/Color Invert.frag
Normal file
16
tools/src/manipulative/Color Invert.frag
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
// https://www.shadertoy.com/view/cdcSz7
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
// Normalized pixel coordinates (from 0 to 1)
|
||||||
|
vec2 uv = fragCoord/iResolution.xy;
|
||||||
|
|
||||||
|
// Get the color of the video at the current pixel
|
||||||
|
vec3 col = texture(iChannel0, uv).rgb;
|
||||||
|
|
||||||
|
// Invert the color
|
||||||
|
col = vec3(1.0) - col;
|
||||||
|
|
||||||
|
// Output to screen
|
||||||
|
fragColor = vec4(col,1.0);
|
||||||
|
}
|
||||||
14
tools/src/manipulative/Color Reduction.frag
Normal file
14
tools/src/manipulative/Color Reduction.frag
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
//https://www.shadertoy.com/view/Ml33Dl
|
||||||
|
#define CFG_QUALITY 0.1
|
||||||
|
|
||||||
|
void mainImage(out vec4 fragColor,in vec2 fragCoord)
|
||||||
|
{
|
||||||
|
vec2 uv = fragCoord.xy/iResolution.xy;
|
||||||
|
vec4 col = texture(iChannel0,uv);
|
||||||
|
|
||||||
|
float colorQuality = 2.0 + (CFG_QUALITY)*8.0; // (1-255)
|
||||||
|
|
||||||
|
// output
|
||||||
|
vec3 q = vec3(colorQuality);
|
||||||
|
fragColor = vec4(floor(col.rgb*q)/q,col.a);
|
||||||
|
}
|
||||||
40
tools/src/manipulative/Desaturate.frag
Normal file
40
tools/src/manipulative/Desaturate.frag
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
// Source:
|
||||||
|
// http://stackoverflow.com/questions/9320953/what-algorithm-does-photoshop-use-to-desaturate-an-image
|
||||||
|
|
||||||
|
// comment out the algorithm you do not want to use below
|
||||||
|
#define USE_PHOTOSHOP_ALGORITHM
|
||||||
|
//#define USE_GENERIC_ALGORITHM
|
||||||
|
|
||||||
|
// Generic algorithm to desaturate images used in most game engines
|
||||||
|
vec4 generic_desaturate(vec3 color, float factor)
|
||||||
|
{
|
||||||
|
vec3 lum = vec3(0.299, 0.587, 0.114);
|
||||||
|
vec3 gray = vec3(dot(lum, color));
|
||||||
|
return vec4(mix(color, gray, factor), 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Algorithm employed by photoshop to desaturate the input
|
||||||
|
vec4 photoshop_desaturate(vec3 color)
|
||||||
|
{
|
||||||
|
float bw = (min(color.r, min(color.g, color.b)) + max(color.r, max(color.g, color.b))) * 0.5;
|
||||||
|
return vec4(bw, bw, bw, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 uv = fragCoord.xy / iResolution.xy;
|
||||||
|
|
||||||
|
# ifdef USE_GENERIC_ALGORITHM
|
||||||
|
fragColor = generic_desaturate(texture(iChannel0, uv).rgb, 1.0);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef USE_PHOTOSHOP_ALGORITHM
|
||||||
|
fragColor = photoshop_desaturate(texture(iChannel0, uv).rgb);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifndef USE_PHOTOSHOP_ALGORITHM
|
||||||
|
# ifndef USE_GENERIC_ALGORITHM
|
||||||
|
fragColor = texture(iChannel0, uv);
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
}
|
||||||
73
tools/src/manipulative/EGA.frag
Normal file
73
tools/src/manipulative/EGA.frag
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
// https://www.shadertoy.com/view/ddXBR7
|
||||||
|
|
||||||
|
// EGA palette colors
|
||||||
|
vec4 egaPalette[17] = vec4[](
|
||||||
|
vec4(0.000, 0.000, 0.000, 1.), // black
|
||||||
|
vec4(0.000, 0.000, 0.667, 1.), // dk blue
|
||||||
|
vec4(0.000, 0.667, 0.000, 1.), // dk green
|
||||||
|
vec4(0.000, 0.667, 0.667, 1.), // dk teal
|
||||||
|
vec4(0.667, 0.000, 0.000, 1.), // dk red
|
||||||
|
vec4(0.667, 0.000, 0.667, 1.), // magenta
|
||||||
|
vec4(0.667, 0.333, 0.000, 1.), // brown
|
||||||
|
vec4(0.33, 0.33, 0.33, 1.), // lt gray
|
||||||
|
vec4(0.333, 0.333, 0.333, 1.), // gray
|
||||||
|
vec4(0.333, 0.333, 1.000, 1.), // lt blue
|
||||||
|
vec4(0.333, 1.000, 0.333, 1.), // lt green
|
||||||
|
vec4(0.333, 1.000, 1.000, 1.), // lt cyan
|
||||||
|
vec4(1.000, 0.333, 0.333, 1.), // lt red (pink?)
|
||||||
|
vec4(1.000, 0.333, 1.000, 1.), // lt magenta
|
||||||
|
vec4(1.000, 1.000, 0.333, 1.), // lt yellow
|
||||||
|
vec4(1.000, 1.000, 1.000, 1.), // white
|
||||||
|
vec4(0.28, 0.7, 0.2, 1.) // clear index color for green bg
|
||||||
|
);
|
||||||
|
|
||||||
|
vec4 indexToEGA(vec3 color)
|
||||||
|
{
|
||||||
|
// Find the closest color in the EGA palette
|
||||||
|
float minDistance = distance(color, egaPalette[0].rgb);
|
||||||
|
vec4 closestColor = egaPalette[0];
|
||||||
|
|
||||||
|
for (int i = 1; i < 16; i++) {
|
||||||
|
float distanceToColor = distance(color, egaPalette[i].rgb);
|
||||||
|
if (distanceToColor < minDistance) {
|
||||||
|
minDistance = distanceToColor;
|
||||||
|
closestColor = egaPalette[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return closestColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 background(vec4 indexedColor, vec2 uv) {
|
||||||
|
float threshold = 0.35;
|
||||||
|
if (distance(indexedColor, vec4(0.28, 0.7, 0.2, 1.)) < threshold) {
|
||||||
|
indexedColor = egaPalette[11];
|
||||||
|
if (uv.y < .5) {
|
||||||
|
indexedColor = egaPalette[12];
|
||||||
|
}
|
||||||
|
if (uv.x < .5) {
|
||||||
|
indexedColor = egaPalette[14];
|
||||||
|
if (uv.y < .5) {
|
||||||
|
indexedColor = egaPalette[13];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return indexedColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage(out vec4 fragColor, in vec2 fragCoord)
|
||||||
|
{
|
||||||
|
// Normalize fragment coordinates to the range [0, 1]
|
||||||
|
vec2 uv = fragCoord / iResolution.xy;
|
||||||
|
|
||||||
|
// Sample video texture from iChannel0
|
||||||
|
vec4 videoColor = texture(iChannel0, uv);
|
||||||
|
|
||||||
|
// Index each color channel to the EGA palette
|
||||||
|
vec4 indexedColor = indexToEGA(videoColor.rgb);
|
||||||
|
|
||||||
|
vec4 background = background(indexedColor, uv);
|
||||||
|
|
||||||
|
// Set the fragment color using the indexed color
|
||||||
|
fragColor = background;
|
||||||
|
}
|
||||||
18
tools/src/manipulative/Fake Thermal.frag
Normal file
18
tools/src/manipulative/Fake Thermal.frag
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// https://www.shadertoy.com/view/lXBczw
|
||||||
|
|
||||||
|
vec3 thermal(vec3 color)
|
||||||
|
{
|
||||||
|
vec3 invColor = vec3(1.)- color;
|
||||||
|
float len = pow((length(invColor*2.2))/3.,2.);
|
||||||
|
vec3 col = vec3(len,len*pow((1.-color.r),2.),0.);
|
||||||
|
return vec3(len*1.5,len*pow((1.-color.r),2.),0)+dot(col,vec3(0,1,0))/1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
// Normalized pixel coordinates (from 0 to 1)
|
||||||
|
vec2 uv = fragCoord/iResolution.xy;
|
||||||
|
vec3 inColor = texture(iChannel0, uv).xyz;
|
||||||
|
// Output to screen
|
||||||
|
fragColor = vec4(thermal(inColor),1.0);
|
||||||
|
}
|
||||||
129
tools/src/manipulative/Gameboy.frag
Normal file
129
tools/src/manipulative/Gameboy.frag
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
float size = 128.; // Pixelated resolution x-component
|
||||||
|
float threshold = .006; // Threshold for dithering (0.0045 found to be optimal)
|
||||||
|
mat2 dither_2 = mat2(0.,1.,1.,0.);
|
||||||
|
|
||||||
|
struct dither_tile {
|
||||||
|
float height;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
vec3[4] gb_colors() {
|
||||||
|
vec3 gb_colors[4];
|
||||||
|
gb_colors[0] = vec3(15., 56., 15.) /255.;
|
||||||
|
gb_colors[1] = vec3(48., 98., 48.) /255.;
|
||||||
|
gb_colors[2] = vec3(139., 172., 15.) /255.;
|
||||||
|
gb_colors[3] = vec3(155., 188., 15.) /255.;
|
||||||
|
return gb_colors;
|
||||||
|
}
|
||||||
|
|
||||||
|
float[4] gb_colors_distance(vec3 color) {
|
||||||
|
float distances[4];
|
||||||
|
distances[0] = distance(color, gb_colors()[0]);
|
||||||
|
distances[1] = distance(color, gb_colors()[1]);
|
||||||
|
distances[2] = distance(color, gb_colors()[2]);
|
||||||
|
distances[3] = distance(color, gb_colors()[3]);
|
||||||
|
return distances;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 closest_gb(vec3 color) {
|
||||||
|
int best_i = 0;
|
||||||
|
float best_d = 2.;
|
||||||
|
|
||||||
|
vec3 gb_colors[4] = gb_colors();
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
float dis = distance(gb_colors[i], color);;
|
||||||
|
if (dis < best_d) {
|
||||||
|
best_d = dis;
|
||||||
|
best_i = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return gb_colors[best_i];
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 get_tile_sample(vec2 coords, vec2 res) {
|
||||||
|
return floor(coords * res / 2.) * 2. / res;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3[2] gb_2_closest(vec3 color) {
|
||||||
|
float distances[4] = gb_colors_distance(color);
|
||||||
|
|
||||||
|
int first_i = 0;
|
||||||
|
float first_d = 2.;
|
||||||
|
|
||||||
|
int second_i = 0;
|
||||||
|
float second_d = 2.;
|
||||||
|
|
||||||
|
for (int i = 0; i < distances.length(); i++) {
|
||||||
|
float d = distances[i];
|
||||||
|
if (distances[i] <= first_d) {
|
||||||
|
second_i = first_i;
|
||||||
|
second_d = first_d;
|
||||||
|
first_i = i;
|
||||||
|
first_d = d;
|
||||||
|
} else if (distances[i] <= second_d) {
|
||||||
|
second_i = i;
|
||||||
|
second_d = d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vec3 colors[4] = gb_colors();
|
||||||
|
vec3 result[2];
|
||||||
|
if (first_i < second_i) {
|
||||||
|
result = vec3[2](colors[first_i], colors[second_i]);
|
||||||
|
} else {
|
||||||
|
result = vec3[2](colors[second_i], colors[first_i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool needs_dither(vec3 color) {
|
||||||
|
float distances[4] = gb_colors_distance(color);
|
||||||
|
|
||||||
|
int first_i = 0;
|
||||||
|
float first_d = 2.;
|
||||||
|
|
||||||
|
int second_i = 0;
|
||||||
|
float second_d = 2.;
|
||||||
|
|
||||||
|
for (int i = 0; i < distances.length(); i++) {
|
||||||
|
float d = distances[i];
|
||||||
|
if (d <= first_d) {
|
||||||
|
second_i = first_i;
|
||||||
|
second_d = first_d;
|
||||||
|
first_i = i;
|
||||||
|
first_d = d;
|
||||||
|
} else if (d <= second_d) {
|
||||||
|
second_i = i;
|
||||||
|
second_d = d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return abs(first_d - second_d) <= threshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
|
||||||
|
|
||||||
|
vec2 resolution = vec2(size, iResolution.y / iResolution.x * size);
|
||||||
|
vec2 uv = floor(fragCoord/iResolution.xy * resolution) / resolution;
|
||||||
|
|
||||||
|
vec2 tileSample = get_tile_sample(uv, resolution);
|
||||||
|
vec3 sampleColor = texture(iChannel0, tileSample).xyz;
|
||||||
|
|
||||||
|
vec3 colors[2] = vec3[2](vec3(1.,1.,1.), vec3(0.,0.,0.));
|
||||||
|
|
||||||
|
if (needs_dither(sampleColor)) {
|
||||||
|
ivec2 ti = ivec2(floor((uv - tileSample) * 2. * resolution));
|
||||||
|
//fragColor = vec4(closest_gb(texture(iChannel0, uv).xyz),1.0);
|
||||||
|
fragColor = vec4(gb_2_closest(sampleColor)[int(dither_2[ti.x][ti.y])], 1.);
|
||||||
|
|
||||||
|
//fragColor = vec4(colors[int(dither_2[ti.x][ti.y])], 1.);
|
||||||
|
} else {
|
||||||
|
fragColor = vec4(closest_gb(texture(iChannel0, uv).xyz),1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output to screen
|
||||||
|
|
||||||
|
}
|
||||||
27
tools/src/manipulative/Gaussian Blur.frag
Normal file
27
tools/src/manipulative/Gaussian Blur.frag
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
// 16x acceleration of https://www.shadertoy.com/view/4tSyzy
|
||||||
|
// by applying gaussian at intermediate MIPmap level.
|
||||||
|
|
||||||
|
const int samples = 35,
|
||||||
|
LOD = 2, // gaussian done on MIPmap at scale LOD
|
||||||
|
sLOD = 1 << LOD; // tile size = 2^LOD
|
||||||
|
const float sigma = float(samples) * .25;
|
||||||
|
|
||||||
|
float gaussian(vec2 i) {
|
||||||
|
return exp( -.5* dot(i/=sigma,i) ) / ( 6.28 * sigma*sigma );
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 blur(sampler2D sp, vec2 U, vec2 scale) {
|
||||||
|
vec4 O = vec4(0);
|
||||||
|
int s = samples/sLOD;
|
||||||
|
|
||||||
|
for ( int i = 0; i < s*s; i++ ) {
|
||||||
|
vec2 d = vec2(i%s, i/s)*float(sLOD) - float(samples)/2.;
|
||||||
|
O += gaussian(d) * textureLod( sp, U + scale * d , float(LOD) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return O / O.a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage(out vec4 O, vec2 U) {
|
||||||
|
O = blur( iChannel0, U/iResolution.xy, 1./iChannelResolution[0].xy );
|
||||||
|
}
|
||||||
14
tools/src/manipulative/Italic.frag
Normal file
14
tools/src/manipulative/Italic.frag
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
// https://www.shadertoy.com/view/ldKfWc
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 uv = fragCoord / iResolution.xy;
|
||||||
|
vec2 shift = uv;
|
||||||
|
float offset = shift.y * .2;
|
||||||
|
shift.x -= offset - .2;
|
||||||
|
shift.x -= mod( exp(shift.x), shift.x * .8) * .5;
|
||||||
|
shift.x += offset - .1;
|
||||||
|
vec3 img = texture(iChannel0,shift).rgb;
|
||||||
|
img.bg *= uv.x * shift.x;
|
||||||
|
img.b += uv.x * .3;
|
||||||
|
fragColor = vec4(img ,1.0);
|
||||||
|
}
|
||||||
132
tools/src/manipulative/Median (Fast).frag
Normal file
132
tools/src/manipulative/Median (Fast).frag
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
// fastMedian
|
||||||
|
//
|
||||||
|
// Somewhat inspired by Oilify effect in oilArt shader
|
||||||
|
// https://www.shadertoy.com/view/lsKGDW
|
||||||
|
//
|
||||||
|
// Once in a while there is a need to perform median filtering in
|
||||||
|
// real-time at high frame rate on the GPU. Exact solution can be
|
||||||
|
// quite complicated and involves array sorting.
|
||||||
|
// However, if the exact solution is not needed, it is possible
|
||||||
|
// to estimate median using histogram only. Also, it turns out
|
||||||
|
// that you can get away with relatively low bin count if histogram
|
||||||
|
// is built knowing minimum and maximum values upfront via pre-pass.
|
||||||
|
//
|
||||||
|
// In real-world applications when shared/thread local storage
|
||||||
|
// is available such histogram calculation is trivial. In this
|
||||||
|
// shader due to WebGL limitations the inner loop is unrolled.
|
||||||
|
//
|
||||||
|
// Created by Dmitry Andreev - and'2019
|
||||||
|
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
|
||||||
|
|
||||||
|
//#define RADIUS 2 // 5x5
|
||||||
|
#define RADIUS 4 // 9x9
|
||||||
|
//#define RADIUS 6 // 13x13
|
||||||
|
|
||||||
|
#define ADAPTIVE_QUANTIZATION
|
||||||
|
|
||||||
|
//#define BIN_COUNT 4
|
||||||
|
//#define BIN_COUNT 8
|
||||||
|
#define BIN_COUNT 12
|
||||||
|
//#define BIN_COUNT 24
|
||||||
|
//#define BIN_COUNT 48
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
#if BIN_COUNT == 4
|
||||||
|
#define UNROLL(X) X(0)X(1)X(2)X(3)
|
||||||
|
|
||||||
|
#elif BIN_COUNT == 8
|
||||||
|
#define UNROLL(X) X(0)X(1)X(2)X(3)X(4)X(5)X(6)X(7)
|
||||||
|
|
||||||
|
#elif BIN_COUNT == 12
|
||||||
|
#define UNROLL(X) X(0)X(1)X(2)X(3)X(4)X(5)X(6)X(7)X(8)X(9)X(10)X(11)
|
||||||
|
|
||||||
|
#elif BIN_COUNT == 24
|
||||||
|
#define U00_11(X) X(0)X(1)X(2)X(3)X(4)X(5)X(6)X(7)X(8)X(9)X(10)X(11)
|
||||||
|
#define U12_23(X) X(12)X(13)X(14)X(15)X(16)X(17)X(18)X(19)X(20)X(21)X(22)X(23)
|
||||||
|
#define UNROLL(X) U00_11(X)U12_23(X)
|
||||||
|
|
||||||
|
#elif BIN_COUNT == 48
|
||||||
|
#define U00_11(X) X(0)X(1)X(2)X(3)X(4)X(5)X(6)X(7)X(8)X(9)X(10)X(11)
|
||||||
|
#define U12_23(X) X(12)X(13)X(14)X(15)X(16)X(17)X(18)X(19)X(20)X(21)X(22)X(23)
|
||||||
|
#define U24_35(X) X(24)X(25)X(26)X(27)X(28)X(29)X(30)X(31)X(32)X(33)X(34)X(35)
|
||||||
|
#define U36_47(X) X(36)X(37)X(38)X(39)X(40)X(41)X(42)X(43)X(44)X(45)X(46)X(47)
|
||||||
|
#define UNROLL(X) U00_11(X)U12_23(X)U24_35(X)U36_47(X)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
vec3 readInput(vec2 uv, int dx, int dy)
|
||||||
|
{
|
||||||
|
// Force nearest sampling for demonstration purposes
|
||||||
|
vec2 img_res = iChannelResolution[0].xy;
|
||||||
|
uv = (0.5 + floor(uv * img_res)) / img_res;
|
||||||
|
|
||||||
|
return texture(iChannel0, uv + vec2(dx, dy) / img_res, -10.0).rgb;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
void mainImage(out vec4 fragColor, in vec2 fragCoord)
|
||||||
|
{
|
||||||
|
// Fit image to touch screen from outside
|
||||||
|
vec2 img_res = iChannelResolution[0].xy;
|
||||||
|
vec2 res = iResolution.xy / img_res;
|
||||||
|
vec2 img_size = img_res * max(res.x, res.y);
|
||||||
|
vec2 img_org = 0.5 * (iResolution.xy - img_size);
|
||||||
|
vec2 uv = (fragCoord - img_org) / img_size;
|
||||||
|
|
||||||
|
vec3 ocol = readInput(uv, 0, 0);
|
||||||
|
vec3 col = ocol;
|
||||||
|
|
||||||
|
const int r = RADIUS;
|
||||||
|
|
||||||
|
vec4 bins[BIN_COUNT];
|
||||||
|
#define INIT(n) bins[n] = vec4(0);
|
||||||
|
UNROLL(INIT)
|
||||||
|
|
||||||
|
#ifdef ADAPTIVE_QUANTIZATION
|
||||||
|
float vmin = 1.0;
|
||||||
|
float vmax = 0.0;
|
||||||
|
|
||||||
|
for (int y = -r; y <= r; y++)
|
||||||
|
for (int x = -r; x <= r; x++)
|
||||||
|
{
|
||||||
|
vec3 img = readInput(uv, x, y);
|
||||||
|
float v = (img.r + img.g + img.b) / 3.0;
|
||||||
|
|
||||||
|
vmin = min(vmin, v);
|
||||||
|
vmax = max(vmax, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
float vmin = 0.0;
|
||||||
|
float vmax = 1.0;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (int y = -r; y <= r; y++)
|
||||||
|
for (int x = -r; x <= r; x++)
|
||||||
|
{
|
||||||
|
vec3 img = readInput(uv, x, y);
|
||||||
|
float v = (img.r + img.g + img.b) / 3.0;
|
||||||
|
|
||||||
|
int i = int(0.5 + ((v - vmin) / (vmax - vmin)) * float(BIN_COUNT));
|
||||||
|
|
||||||
|
#define UPDATE(n) if (i == n) bins[n] += vec4(img.rgb, 1.0);
|
||||||
|
UNROLL(UPDATE)
|
||||||
|
}
|
||||||
|
|
||||||
|
float mid = floor((float(r * 2 + 1) * float(r * 2 + 1)) / 2.0);
|
||||||
|
float pos = 0.0;
|
||||||
|
|
||||||
|
#define M1(i) col.rgb = pos <= mid && bins[i].a > 0.0 ?
|
||||||
|
#define M2(i) bins[i].rgb / bins[i].aaa : col.rgb;
|
||||||
|
#define M3(i) pos += bins[i].a;
|
||||||
|
#define MEDIAN(i) M1(i)M2(i)M3(i)
|
||||||
|
UNROLL(MEDIAN)
|
||||||
|
|
||||||
|
// Show original image on click
|
||||||
|
if (iMouse.w > 0.0) col = ocol;
|
||||||
|
|
||||||
|
fragColor = vec4(col, 1.0);
|
||||||
|
}
|
||||||
51
tools/src/manipulative/Melting Snow.frag
Normal file
51
tools/src/manipulative/Melting Snow.frag
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
//https://www.shadertoy.com/view/tt3XDf
|
||||||
|
#define SIZE 50.1
|
||||||
|
|
||||||
|
float rand(vec2 p)
|
||||||
|
{
|
||||||
|
vec3 p3 = fract(vec3(p.xyx) * .1031);
|
||||||
|
p3 += dot(p3, p3.yzx + 33.33);
|
||||||
|
return fract((p3.x + p3.y) * p3.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 uv = fragCoord/iResolution.y;
|
||||||
|
vec2 ouv = fragCoord/iResolution.xy;
|
||||||
|
|
||||||
|
float m = 0.;
|
||||||
|
float t = iTime*2.2 + 100.;
|
||||||
|
|
||||||
|
for(float i=0.; i<=1.0; i+=0.25){
|
||||||
|
vec2 iuv = uv + vec2(i*.05, 0.);
|
||||||
|
vec2 ruv = iuv*SIZE;
|
||||||
|
vec2 id = ceil(ruv);
|
||||||
|
|
||||||
|
for(float y=-1.; y<=1.; y+=1.){
|
||||||
|
for(float x=-1.; x<=1.; x+=1.0){
|
||||||
|
vec2 nuv = ruv + vec2(x,y);
|
||||||
|
vec2 nid = id + vec2(x,y);
|
||||||
|
|
||||||
|
nuv.y += t*2. * (rand(vec2(nid.x))*.75+.5) * i;
|
||||||
|
nuv.y += ceil(mod(nid.x, 3.))*0.3 * t;
|
||||||
|
|
||||||
|
vec2 guv = fract(nuv);
|
||||||
|
|
||||||
|
nuv = floor(nuv) ;
|
||||||
|
float g = length(guv - vec2(x,y));
|
||||||
|
|
||||||
|
float v = rand(nuv);
|
||||||
|
v *= step(0.9, v);
|
||||||
|
m += smoothstep(v,v-.8, g);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m = m*.2 + step(1.25, m) *.2 + step(2.0, m) *.1;
|
||||||
|
|
||||||
|
|
||||||
|
vec3 col = texture(iChannel0, ouv + m*.125).rgb;
|
||||||
|
|
||||||
|
|
||||||
|
fragColor = vec4(col ,1.0);
|
||||||
|
}
|
||||||
14
tools/src/manipulative/Mirror (Bottom).frag
Normal file
14
tools/src/manipulative/Mirror (Bottom).frag
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* Andor Salga
|
||||||
|
* March 2014
|
||||||
|
*
|
||||||
|
* Simple demo showing mirror effects.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 p = fragCoord.xy/iResolution.xy;
|
||||||
|
p.y += step(0.5, p.y) * (0.5-p.y) * 2.0;
|
||||||
|
|
||||||
|
fragColor = texture(iChannel0, p);
|
||||||
|
}
|
||||||
14
tools/src/manipulative/Mirror (Left).frag
Normal file
14
tools/src/manipulative/Mirror (Left).frag
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
Andor Salga
|
||||||
|
March 2014
|
||||||
|
|
||||||
|
Simple demo showing mirror effects.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 p = fragCoord.xy/iResolution.xy;
|
||||||
|
p.x -= step(0.5, p.x) * (p.x-0.5) * 2.0;
|
||||||
|
|
||||||
|
fragColor = texture(iChannel0, p);
|
||||||
|
}
|
||||||
15
tools/src/manipulative/Mirror (Quad).frag
Normal file
15
tools/src/manipulative/Mirror (Quad).frag
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Andor Salga
|
||||||
|
* March 2014
|
||||||
|
*
|
||||||
|
* Simple demo showing mirror effects.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 p = fragCoord.xy/iResolution.xy;
|
||||||
|
p.x += step(p.x, 0.5) * (0.5-p.x) * 2.0;
|
||||||
|
p.y += step(0.5, p.y) * (0.5-p.y) * 2.0;
|
||||||
|
|
||||||
|
fragColor = texture(iChannel0, p);
|
||||||
|
}
|
||||||
13
tools/src/manipulative/Mirror (Right).frag
Normal file
13
tools/src/manipulative/Mirror (Right).frag
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* Andor Salga
|
||||||
|
* March 2014
|
||||||
|
*
|
||||||
|
* Simple demo showing mirror effects.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 p = fragCoord.xy/iResolution.xy;
|
||||||
|
p.x += step(p.x, 0.5) * (0.5-p.x) * 2.0;
|
||||||
|
fragColor = texture(iChannel0, p);
|
||||||
|
}
|
||||||
14
tools/src/manipulative/Mirror (Top).frag
Normal file
14
tools/src/manipulative/Mirror (Top).frag
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* Andor Salga
|
||||||
|
* March 2014
|
||||||
|
*
|
||||||
|
* Simple demo showing mirror effects.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 p = fragCoord.xy/iResolution.xy;
|
||||||
|
p.y -= step(p.y, 0.5) * (p.y-.5) * 2.0;
|
||||||
|
|
||||||
|
fragColor = texture(iChannel0, p);
|
||||||
|
}
|
||||||
68
tools/src/manipulative/Nearest Neighbor.frag
Normal file
68
tools/src/manipulative/Nearest Neighbor.frag
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
const int half_width = 5;
|
||||||
|
|
||||||
|
// Calculate color distance
|
||||||
|
float CalcDistance(in vec3 c0, in vec3 c1) {
|
||||||
|
vec3 sub = c0 - c1;
|
||||||
|
return dot(sub, sub);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Symmetric Nearest Neighbor
|
||||||
|
vec3 CalcSNN(in vec2 fragCoord) {
|
||||||
|
vec2 src_size = iResolution.xy;
|
||||||
|
vec2 inv_src_size = 1.0f / src_size;
|
||||||
|
vec2 uv = fragCoord * inv_src_size;
|
||||||
|
|
||||||
|
vec3 c0 = texture(iChannel0, uv).rgb;
|
||||||
|
|
||||||
|
vec4 sum = vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
for (int i = 0; i <= half_width; ++i) {
|
||||||
|
vec3 c1 = texture(iChannel0, uv + vec2(+i, 0) * inv_src_size).rgb;
|
||||||
|
vec3 c2 = texture(iChannel0, uv + vec2(-i, 0) * inv_src_size).rgb;
|
||||||
|
|
||||||
|
float d1 = CalcDistance(c1, c0);
|
||||||
|
float d2 = CalcDistance(c2, c0);
|
||||||
|
if (d1 < d2) {
|
||||||
|
sum.rgb += c1;
|
||||||
|
} else {
|
||||||
|
sum.rgb += c2;
|
||||||
|
}
|
||||||
|
sum.a += 1.0f;
|
||||||
|
}
|
||||||
|
for (int j = 1; j <= half_width; ++j) {
|
||||||
|
for (int i = -half_width; i <= half_width; ++i) {
|
||||||
|
vec3 c1 = texture(iChannel0, uv + vec2(+i, +j) * inv_src_size).rgb;
|
||||||
|
vec3 c2 = texture(iChannel0, uv + vec2(-i, -j) * inv_src_size).rgb;
|
||||||
|
|
||||||
|
float d1 = CalcDistance(c1, c0);
|
||||||
|
float d2 = CalcDistance(c2, c0);
|
||||||
|
if (d1 < d2) {
|
||||||
|
sum.rgb += c1;
|
||||||
|
} else {
|
||||||
|
sum.rgb += c2;
|
||||||
|
}
|
||||||
|
sum.a += 1.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sum.rgb / sum.a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 src_size = iResolution.xy;
|
||||||
|
vec2 inv_src_size = 1.0f / src_size;
|
||||||
|
vec2 uv = fragCoord * inv_src_size;
|
||||||
|
|
||||||
|
float center = iMouse.x * inv_src_size.x;
|
||||||
|
float width = 3.0f * inv_src_size.x * 0.5f;
|
||||||
|
|
||||||
|
if (uv.x <= center - width) {
|
||||||
|
fragColor.rgb = CalcSNN(fragCoord);
|
||||||
|
} else if (uv.x >= center + width) {
|
||||||
|
fragColor.rgb = CalcSNN(fragCoord);
|
||||||
|
} else {
|
||||||
|
fragColor.rgb = vec3(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
fragColor.a = 1.0f;
|
||||||
|
}
|
||||||
25
tools/src/manipulative/Night Vision.frag
Normal file
25
tools/src/manipulative/Night Vision.frag
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// by Nikos Papadopoulos, 4rknova / 2013
|
||||||
|
// WTFPL
|
||||||
|
|
||||||
|
float hash(in float n) { return fract(sin(n)*43758.5453123); }
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 p = fragCoord.xy / iResolution.xy;
|
||||||
|
|
||||||
|
vec2 u = p * 2. - 1.;
|
||||||
|
vec2 n = u * vec2(iResolution.x / iResolution.y, 1.0);
|
||||||
|
vec3 c = texture(iChannel0, p).xyz;
|
||||||
|
|
||||||
|
|
||||||
|
// flicker, grain, vignette, fade in
|
||||||
|
c += sin(hash(iTime)) * 0.01;
|
||||||
|
c += hash((hash(n.x) + n.y) * iTime) * 0.5;
|
||||||
|
c *= smoothstep(length(n * n * n * vec2(0.075, 0.4)), 1.0, 0.4);
|
||||||
|
c *= smoothstep(0.001, 3.5, iTime) * 1.5;
|
||||||
|
|
||||||
|
c = dot(c, vec3(0.2126, 0.7152, 0.0722))
|
||||||
|
* vec3(0.2, 1.5 - hash(iTime) * 0.1,0.4);
|
||||||
|
|
||||||
|
fragColor = vec4(c,1.0);
|
||||||
|
}
|
||||||
97
tools/src/manipulative/Oil Painting.frag
Normal file
97
tools/src/manipulative/Oil Painting.frag
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
// https://www.shadertoy.com/view/ddlXz4
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// MMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||||
|
// MM. .MM
|
||||||
|
// MM. .MMMMMMMMMMMMMMMMMMMMMM. .MM
|
||||||
|
// MM. .MMMMMMMMMMMMMMMMMMMMMMMM. .MM
|
||||||
|
// MM. .MMMM MMMMMMM MMM. .MM
|
||||||
|
// MM. .MMM MMMMMM MMM. .MM
|
||||||
|
// MM. .MmM MMMM MMM. .MM
|
||||||
|
// MM. .MMM MM MMM. .MM
|
||||||
|
// MM. .MMM M MMM. .MM
|
||||||
|
// MM. .MMM MMM. .MM
|
||||||
|
// MM. .MMM MMM. .MM
|
||||||
|
// MM. .MMM M MMM. .MM
|
||||||
|
// MM. .MMM MM MMM. .MM
|
||||||
|
// MM. .MMM MMM MMM. .MM
|
||||||
|
// MM. .MMM MMMM MMM. .MM
|
||||||
|
// MM. .MMMMMMMMMMMMMMMMMMMMMMMM. .MM
|
||||||
|
// MM. .MMMMMMMMMMMMMMMMMMMMMM. .MM
|
||||||
|
// MM. .MM
|
||||||
|
// MMMMMMMMMMMMMMMMMMMMMMMMMMMM
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Adaptation pour Natron par F. Fernandez
|
||||||
|
// Code original : crok_kuwahara Matchbox pour Autodesk Flame
|
||||||
|
|
||||||
|
// Adapted to Natron by F.Fernandez
|
||||||
|
// Original code : crok_kuwahara Matchbox for Autodesk Flame
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// iChannel0: Source, filter = nearest
|
||||||
|
// BBox: iChannel0
|
||||||
|
|
||||||
|
|
||||||
|
int radius=12; // radius :, min=0, max=100.
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 iChannel0_size = vec2(iResolution.x, iResolution.y);
|
||||||
|
vec2 uv = fragCoord.xy / iResolution.xy;
|
||||||
|
float n = float((radius + 1) * (radius + 1));
|
||||||
|
|
||||||
|
vec3 m[4];
|
||||||
|
vec3 s[4];
|
||||||
|
for (int k = 0; k < 4; ++k) {
|
||||||
|
m[k] = vec3(0.0);
|
||||||
|
s[k] = vec3(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = -radius; j <= 0; ++j) {
|
||||||
|
for (int i = -radius; i <= 0; ++i) {
|
||||||
|
vec3 c = texture(iChannel0, uv + vec2(i,j) / iChannel0_size).rgb;
|
||||||
|
m[0] += c;
|
||||||
|
s[0] += c * c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = -radius; j <= 0; ++j) {
|
||||||
|
for (int i = 0; i <= radius; ++i) {
|
||||||
|
vec3 c = texture(iChannel0, uv + vec2(i,j) / iChannel0_size).rgb;
|
||||||
|
m[1] += c;
|
||||||
|
s[1] += c * c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j <= radius; ++j) {
|
||||||
|
for (int i = 0; i <= radius; ++i) {
|
||||||
|
vec3 c = texture(iChannel0, uv + vec2(i,j) / iChannel0_size).rgb;
|
||||||
|
m[2] += c;
|
||||||
|
s[2] += c * c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j <= radius; ++j) {
|
||||||
|
for (int i = -radius; i <= 0; ++i) {
|
||||||
|
vec3 c = texture(iChannel0, uv + vec2(i,j) / iChannel0_size).rgb;
|
||||||
|
m[3] += c;
|
||||||
|
s[3] += c * c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float min_sigma2 = 1e+2;
|
||||||
|
for (int k = 0; k < 4; ++k) {
|
||||||
|
m[k] /= n;
|
||||||
|
s[k] = abs(s[k] / n - m[k] * m[k]);
|
||||||
|
|
||||||
|
float sigma2 = s[k].r + s[k].g + s[k].b;
|
||||||
|
if (sigma2 < min_sigma2) {
|
||||||
|
min_sigma2 = sigma2;
|
||||||
|
fragColor = vec4(m[k], 1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
181
tools/src/manipulative/Old Memory.frag
Normal file
181
tools/src/manipulative/Old Memory.frag
Normal file
@@ -0,0 +1,181 @@
|
|||||||
|
// https://www.shadertoy.com/view/7sd3zX
|
||||||
|
|
||||||
|
//
|
||||||
|
// Description : Array and textureless GLSL 2D simplex noise function.
|
||||||
|
// Author : Ian McEwan, Ashima Arts.
|
||||||
|
// Maintainer : stegu
|
||||||
|
// Lastmod : 20110822 (ijm)
|
||||||
|
// License : Copyright (C) 2011 Ashima Arts. All rights reserved.
|
||||||
|
// Distributed under the MIT License. See LICENSE file.
|
||||||
|
// https://github.com/ashima/webgl-noise
|
||||||
|
// https://github.com/stegu/webgl-noise
|
||||||
|
//
|
||||||
|
|
||||||
|
vec3 mod289(vec3 x) {
|
||||||
|
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 mod289(vec2 x) {
|
||||||
|
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 permute(vec3 x) {
|
||||||
|
return mod289(((x*34.0)+10.0)*x);
|
||||||
|
}
|
||||||
|
|
||||||
|
float snoise(vec2 v)
|
||||||
|
{
|
||||||
|
const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
|
||||||
|
0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
|
||||||
|
-0.577350269189626, // -1.0 + 2.0 * C.x
|
||||||
|
0.024390243902439); // 1.0 / 41.0
|
||||||
|
// First corner
|
||||||
|
vec2 i = floor(v + dot(v, C.yy) );
|
||||||
|
vec2 x0 = v - i + dot(i, C.xx);
|
||||||
|
|
||||||
|
// Other corners
|
||||||
|
vec2 i1;
|
||||||
|
//i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0
|
||||||
|
//i1.y = 1.0 - i1.x;
|
||||||
|
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
|
||||||
|
// x0 = x0 - 0.0 + 0.0 * C.xx ;
|
||||||
|
// x1 = x0 - i1 + 1.0 * C.xx ;
|
||||||
|
// x2 = x0 - 1.0 + 2.0 * C.xx ;
|
||||||
|
vec4 x12 = x0.xyxy + C.xxzz;
|
||||||
|
x12.xy -= i1;
|
||||||
|
|
||||||
|
// Permutations
|
||||||
|
i = mod289(i); // Avoid truncation effects in permutation
|
||||||
|
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
|
||||||
|
+ i.x + vec3(0.0, i1.x, 1.0 ));
|
||||||
|
|
||||||
|
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
|
||||||
|
m = m*m ;
|
||||||
|
m = m*m ;
|
||||||
|
|
||||||
|
// Gradients: 41 points uniformly over a line, mapped onto a diamond.
|
||||||
|
// The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
|
||||||
|
|
||||||
|
vec3 x = 2.0 * fract(p * C.www) - 1.0;
|
||||||
|
vec3 h = abs(x) - 0.5;
|
||||||
|
vec3 ox = floor(x + 0.5);
|
||||||
|
vec3 a0 = x - ox;
|
||||||
|
|
||||||
|
// Normalise gradients implicitly by scaling m
|
||||||
|
// Approximation of: m *= inversesqrt( a0*a0 + h*h );
|
||||||
|
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
|
||||||
|
|
||||||
|
// Compute final noise value at P
|
||||||
|
vec3 g;
|
||||||
|
g.x = a0.x * x0.x + h.x * x0.y;
|
||||||
|
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
|
||||||
|
return 130.0 * dot(m, g);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 SCREEN(in vec4 src, in vec4 dst){
|
||||||
|
return ( src + dst ) - ( src * dst );
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 Blur(sampler2D tex, vec2 uv, float blurSize, float directions, float quality){
|
||||||
|
float TWO_PI = 6.28318530718;
|
||||||
|
|
||||||
|
vec2 radius = blurSize/iResolution.xy;
|
||||||
|
vec3 res = texture(tex, uv).rgb;
|
||||||
|
for(float i=1.0/quality; i<=1.0; i+=1.0/quality)
|
||||||
|
{
|
||||||
|
for( float d=0.0; d<TWO_PI; d+=TWO_PI/directions)
|
||||||
|
{
|
||||||
|
res += texture( tex, uv+vec2(cos(d),sin(d))*radius*i).rgb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res /= (quality-1.) * directions;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
vec3 Blur(sampler2D tex, vec2 uv){
|
||||||
|
return Blur(tex,uv, 4.,16.,4.);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 ShakeUV(vec2 uv, float time){
|
||||||
|
uv.x += 0.002 * sin(time*3.141) * sin(time*14.14);
|
||||||
|
uv.y += 0.002 * sin(time*1.618) * sin(time*17.32);
|
||||||
|
return uv;
|
||||||
|
}
|
||||||
|
|
||||||
|
float filmDirt(vec2 uv, float time){
|
||||||
|
uv += time * sin(time) * 10.;
|
||||||
|
float res = 1.0;
|
||||||
|
|
||||||
|
float rnd = fract(sin(time+1.)*31415.);
|
||||||
|
if(rnd>0.3){
|
||||||
|
float dirt =
|
||||||
|
texture(iChannel1,uv*0.1).r *
|
||||||
|
texture(iChannel1,uv*0.01).r *
|
||||||
|
texture(iChannel1,uv*0.002).r *
|
||||||
|
1.0;
|
||||||
|
res = 1.0 - smoothstep(0.4,0.6, dirt);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
float FpsTime(float time, float fps){
|
||||||
|
time = mod(time, 60.0);
|
||||||
|
time = float(int(time*fps)) / fps;
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 uv = fragCoord/iResolution.xy;
|
||||||
|
vec2 mUV = iMouse.xy/iResolution.xy;
|
||||||
|
|
||||||
|
mUV = vec2(0.5,0.7); /*fix mouse pos for thumbnail*/
|
||||||
|
|
||||||
|
vec4 col;
|
||||||
|
|
||||||
|
float time = FpsTime(iTime, 12.);
|
||||||
|
fragColor = vec4(mod(uv.x+time*0.5, 0.1)*10.);
|
||||||
|
//return; /* Debug FpsTime */
|
||||||
|
|
||||||
|
vec2 suv = ShakeUV(uv, time);
|
||||||
|
fragColor = vec4(mod(suv.xy,0.1)*10., 0., 1.0);
|
||||||
|
//return; /* Debug ShakeUV */
|
||||||
|
|
||||||
|
//float grain = mix(1.0, fract(sin(dot(suv.xy+time,vec2(12.9898,78.233))) * 43758.5453), 0.25); /* random */
|
||||||
|
float grain = mix(1.0, snoise(suv.xy*1234.), 0.15); /* simplex noise */
|
||||||
|
fragColor = vec4(vec3(grain), 1.0);
|
||||||
|
//return; /* Debug grain */
|
||||||
|
|
||||||
|
vec3 color = texture(iChannel0, suv).rgb;
|
||||||
|
color *= grain;
|
||||||
|
|
||||||
|
float Size = mUV.x * 8.;
|
||||||
|
float Directions = 16.0;
|
||||||
|
float Quality = 3.0;
|
||||||
|
vec3 blur = Blur(iChannel0, suv, Size, Directions, Quality);
|
||||||
|
blur *= grain;
|
||||||
|
|
||||||
|
float Threshold = mUV.y;
|
||||||
|
vec3 FilterRGB = normalize(vec3(1.5,1.2,1.0));
|
||||||
|
float HighlightPower = 3.0;
|
||||||
|
HighlightPower *= 1. + fract(sin(time)*3.1415) * 0.3;
|
||||||
|
vec3 highlight = clamp(color -Threshold,0.0,1.0)/(1.0-Threshold);
|
||||||
|
highlight = blur * Threshold * FilterRGB * HighlightPower;
|
||||||
|
|
||||||
|
/* dirt */
|
||||||
|
float dirt = filmDirt(uv, time);
|
||||||
|
fragColor = vec4(vec3(dirt), 1.0);
|
||||||
|
//return; /* Debug dirt */
|
||||||
|
|
||||||
|
col = SCREEN(vec4(color,1.0), vec4(highlight,1.0));
|
||||||
|
//col = vec4(highlight,1.0);
|
||||||
|
//col = vec4(blur,1.0);
|
||||||
|
col *= dirt;
|
||||||
|
|
||||||
|
vec2 v = uv * (1.0 - uv.yx);
|
||||||
|
float vig = v.x*v.y * 15.0;
|
||||||
|
vig = pow(vig, 0.5);
|
||||||
|
|
||||||
|
fragColor = col * vig;
|
||||||
|
//fragColor = uv.x>0.5 ? colR : colL;
|
||||||
|
}
|
||||||
47
tools/src/manipulative/Perlin Noise.frag
Normal file
47
tools/src/manipulative/Perlin Noise.frag
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
// https://www.shadertoy.com/view/43c3zf
|
||||||
|
|
||||||
|
vec2 GetGradient(vec2 intPos, float t) {
|
||||||
|
|
||||||
|
// Uncomment for calculated rand
|
||||||
|
//float rand = fract(sin(dot(intPos, vec2(12.9898, 78.233))) * 43758.5453);;
|
||||||
|
|
||||||
|
// Texture-based rand (a bit faster on my GPU)
|
||||||
|
float rand = texture(iChannel0, intPos / 64.0).r;
|
||||||
|
|
||||||
|
// Rotate gradient: random starting rotation, random rotation rate
|
||||||
|
float angle = 6.283185 * rand + 4.0 * t * rand;
|
||||||
|
return vec2(cos(angle), sin(angle));
|
||||||
|
}
|
||||||
|
|
||||||
|
float Pseudo3dNoise(vec3 pos) {
|
||||||
|
vec2 i = floor(pos.xy);
|
||||||
|
vec2 f = pos.xy - i;
|
||||||
|
vec2 blend = f * f * (3.0 - 2.0 * f);
|
||||||
|
float noiseVal =
|
||||||
|
mix(
|
||||||
|
mix(
|
||||||
|
dot(GetGradient(i + vec2(0, 0), pos.z), f - vec2(0, 0)),
|
||||||
|
dot(GetGradient(i + vec2(1, 0), pos.z), f - vec2(1, 0)),
|
||||||
|
blend.x),
|
||||||
|
mix(
|
||||||
|
dot(GetGradient(i + vec2(0, 1), pos.z), f - vec2(0, 1)),
|
||||||
|
dot(GetGradient(i + vec2(1, 1), pos.z), f - vec2(1, 1)),
|
||||||
|
blend.x),
|
||||||
|
blend.y
|
||||||
|
);
|
||||||
|
return noiseVal / 0.7; // normalize to about [-1..1]
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
||||||
|
vec2 noise_uv = fragCoord.xy/iResolution.y;
|
||||||
|
float noiseVal = 0.5 + 0.5 * Pseudo3dNoise(vec3(noise_uv * 10.0, iTime));
|
||||||
|
|
||||||
|
vec2 uv = fragCoord/iResolution.xy;
|
||||||
|
float noiseWeight = 0.05;
|
||||||
|
uv.x += noiseVal * noiseWeight;
|
||||||
|
uv.y += noiseVal * noiseWeight;
|
||||||
|
vec3 col = texture(iChannel0,uv).rgb;
|
||||||
|
|
||||||
|
fragColor.rgb = vec3(col);
|
||||||
|
|
||||||
|
}
|
||||||
17
tools/src/manipulative/Pixelation.frag
Normal file
17
tools/src/manipulative/Pixelation.frag
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
// https://www.shadertoy.com/view/ldVSW1
|
||||||
|
#define PIXEL_SIZE 5.0
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
|
||||||
|
vec2 uv = fragCoord.xy / iResolution.xy;
|
||||||
|
|
||||||
|
float plx = iResolution.x * PIXEL_SIZE / 500.0;
|
||||||
|
float ply = iResolution.y * PIXEL_SIZE / 275.0;
|
||||||
|
|
||||||
|
float dx = plx * (1.0 / iResolution.x);
|
||||||
|
float dy = ply * (1.0 / iResolution.y);
|
||||||
|
|
||||||
|
uv.x = dx * floor(uv.x / dx);
|
||||||
|
uv.y = dy * floor(uv.y / dy);
|
||||||
|
|
||||||
|
fragColor = texture(iChannel0, uv);
|
||||||
|
}
|
||||||
34
tools/src/manipulative/Posterize.frag
Normal file
34
tools/src/manipulative/Posterize.frag
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2023 Roel Bartstra
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
// Normalized pixel coordinates (from 0 to 1)
|
||||||
|
vec2 uv = fragCoord/iResolution.xy;
|
||||||
|
|
||||||
|
// Sample input texture
|
||||||
|
vec3 input_color = texture(iChannel0, uv).rgb;
|
||||||
|
|
||||||
|
// The actual "posterize"
|
||||||
|
const float color_length_steps = 5.0;
|
||||||
|
float color_length = length(input_color.rgb);
|
||||||
|
vec3 color_direction = input_color.rgb / color_length;
|
||||||
|
float stepped_color_length = round(color_length * color_length_steps) / color_length_steps;
|
||||||
|
vec3 posterized_color = stepped_color_length * color_direction;
|
||||||
|
|
||||||
|
// Debugging: Use left mouse for image slite to compare with input.
|
||||||
|
float debug_mask = step(uv.x, iMouse.x / iResolution.x);
|
||||||
|
vec3 output_color = mix(posterized_color, input_color, debug_mask);
|
||||||
|
|
||||||
|
// Output to screen
|
||||||
|
fragColor = vec4(output_color, 1);
|
||||||
|
}
|
||||||
147
tools/src/manipulative/Quadtree.frag
Normal file
147
tools/src/manipulative/Quadtree.frag
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
// @license MIT
|
||||||
|
// @author ciphrd
|
||||||
|
//
|
||||||
|
// This algorithm is sort of a probabilistic quad tree construction where quad divisions are
|
||||||
|
// added if the color variation (variance) in a quad is too important.
|
||||||
|
//
|
||||||
|
// The color variation is computed by taking n samples within the quad, and then we compute the
|
||||||
|
// variance on each color component of the samples.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Limitations
|
||||||
|
//
|
||||||
|
// If a certain area, which is large, has a small section of it being detailed while the rest
|
||||||
|
// is pretty much linear, divisions might not be added. Because this algorithm picks random
|
||||||
|
// points in the quad, the small detailed section has little to no infuence on the overall
|
||||||
|
// variations of the colors in the quad.
|
||||||
|
// You can observe this behavior on the Google logo when it appears.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
// the number of divisions at the start
|
||||||
|
#define MIN_DIVISIONS 4.0
|
||||||
|
|
||||||
|
// the numer of possible quad divisions
|
||||||
|
#define MAX_ITERATIONS 8
|
||||||
|
|
||||||
|
// the number of samples picked fter each quad division
|
||||||
|
#define SAMPLES_PER_ITERATION 55
|
||||||
|
#define F_SAMPLES_PER_ITERATION 54.95
|
||||||
|
|
||||||
|
// useless, kept it for reference for a personal usage
|
||||||
|
#define MAX_SAMPLES 200
|
||||||
|
|
||||||
|
// threshold min, max given the mouse.x
|
||||||
|
#define THRESHOLD_MIN 0.0001
|
||||||
|
#define THRESHOLD_MAX 0.01
|
||||||
|
|
||||||
|
vec2 centrePoints[4*4*4*4*4*4];
|
||||||
|
int centrePointCount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// taken from http://glslsandbox.com/e#41197.0
|
||||||
|
vec2 hash22(vec2 p) {
|
||||||
|
float n = sin(dot(p, vec2(41, 289)));
|
||||||
|
return fract(vec2(262144, 32768)*n);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Computes the color variation on a quad division of the space
|
||||||
|
// Basically, this method takes n random samples in a given quad, compute the average
|
||||||
|
// of each color component of the samples.
|
||||||
|
// Then, it computes the variance of the samples
|
||||||
|
// This is the way I thought for computing the color variation, there might be others,
|
||||||
|
// and there must be better ones
|
||||||
|
vec4 quadColorVariation (in vec2 center, in float size) {
|
||||||
|
// this array will store the grayscale of the samples
|
||||||
|
vec3 samplesBuffer[SAMPLES_PER_ITERATION];
|
||||||
|
|
||||||
|
// the average of the color components
|
||||||
|
vec3 avg = vec3(0);
|
||||||
|
|
||||||
|
// we sample the current space by picking pseudo random samples in it
|
||||||
|
for (int i = 0; i < SAMPLES_PER_ITERATION; i++) {
|
||||||
|
float fi = float(i);
|
||||||
|
// pick a random 2d point using the center of the active quad as input
|
||||||
|
// this ensures that for every point belonging to the active quad, we pick the same samples
|
||||||
|
vec2 r = hash22(center.xy + vec2(fi, 0.0)) - 0.5;
|
||||||
|
vec3 sp = texture(iChannel0, center + r * size).rgb;
|
||||||
|
avg+= sp;
|
||||||
|
samplesBuffer[i] = sp;
|
||||||
|
}
|
||||||
|
|
||||||
|
avg/= F_SAMPLES_PER_ITERATION;
|
||||||
|
|
||||||
|
// estimate the color variation on the active quad by computing the variance
|
||||||
|
vec3 var = vec3(0);
|
||||||
|
for (int i = 0; i < SAMPLES_PER_ITERATION; i++) {
|
||||||
|
var+= pow(samplesBuffer[i], vec3(2.0));
|
||||||
|
}
|
||||||
|
var/= F_SAMPLES_PER_ITERATION;
|
||||||
|
var-= pow(avg, vec3(2.0));
|
||||||
|
|
||||||
|
return vec4(avg, (var.x+var.y+var.z)/3.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
// Normalized pixel coordinates (from 0 to 1)
|
||||||
|
vec2 uv = fragCoord/iResolution.xy;
|
||||||
|
|
||||||
|
float threshold = mix(THRESHOLD_MIN, THRESHOLD_MAX, iMouse.x / iResolution.x);
|
||||||
|
|
||||||
|
// number of space divisions
|
||||||
|
float divs = MIN_DIVISIONS;
|
||||||
|
|
||||||
|
// the center of the active quad - we initialze with 2 divisions
|
||||||
|
vec2 quadCenter = (floor(uv * divs) + 0.5) / divs;
|
||||||
|
float quadSize = 1. / divs; // the length of a side of the active quad
|
||||||
|
|
||||||
|
// we store average and variance here
|
||||||
|
vec4 quadInfos = vec4(0);
|
||||||
|
|
||||||
|
for (int i = 0; i < MAX_ITERATIONS; i++) {
|
||||||
|
quadInfos = quadColorVariation(quadCenter, quadSize);
|
||||||
|
|
||||||
|
// if the variance is lower than the threshold, current quad is outputted
|
||||||
|
if (quadInfos.w < threshold) {
|
||||||
|
if(centrePointCount < MAX_ITERATIONS) centrePoints[centrePointCount++] = quadCenter;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise, we divide the space again
|
||||||
|
divs*= 2.0;
|
||||||
|
quadCenter = (floor(uv * divs) + 0.5) / divs;
|
||||||
|
quadSize/= 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
vec4 color = texture(iChannel0, uv);
|
||||||
|
|
||||||
|
// the coordinates of the quad
|
||||||
|
vec2 nUv = fract(uv * divs);
|
||||||
|
|
||||||
|
// we create lines from the uv coordinates
|
||||||
|
vec2 lWidth = vec2(0.5/iResolution.x, 0.5/iResolution.y);
|
||||||
|
vec2 uvAbs = abs(nUv-0.5);
|
||||||
|
float s = step(0.5-uvAbs.x, lWidth.x*divs) + step(0.5-uvAbs.y, lWidth.y*divs);
|
||||||
|
|
||||||
|
// we smooth the color between average and texture initial
|
||||||
|
color.rgb = mix(color.rgb, quadInfos.rgb, uv.x);
|
||||||
|
|
||||||
|
// we smooth the lines over the x axis
|
||||||
|
// s*= pow(1. - uv.x, 4.0);
|
||||||
|
|
||||||
|
// for black lines, we just subtract
|
||||||
|
color.r = mod(color.r, s);
|
||||||
|
color.g = mod(color.g, s);
|
||||||
|
color.b = mod(color.b, s);
|
||||||
|
color.a = mod(color.a, s);
|
||||||
|
|
||||||
|
// Output to screen
|
||||||
|
fragColor = color;
|
||||||
|
}
|
||||||
31
tools/src/manipulative/Radial Blur.frag
Normal file
31
tools/src/manipulative/Radial Blur.frag
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// by Nikos Papadopoulos, 4rknova / 2017
|
||||||
|
// WTFPL
|
||||||
|
|
||||||
|
#define JITTER
|
||||||
|
#define MOUSE
|
||||||
|
|
||||||
|
float hash(in vec2 p) { return fract(sin(dot(p,vec2(283.6,127.1))) * 43758.5453);}
|
||||||
|
|
||||||
|
#ifdef MOUSE
|
||||||
|
#define CENTER (iMouse.xy/iResolution.xy)
|
||||||
|
#else
|
||||||
|
#define CENTER vec2(.5)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SAMPLES 10
|
||||||
|
#define RADIUS .01
|
||||||
|
|
||||||
|
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
||||||
|
vec2 uv = fragCoord / iResolution.xy;
|
||||||
|
vec3 res = vec3(0);
|
||||||
|
for(int i = 0; i < SAMPLES; ++i) {
|
||||||
|
res += texture(iChannel0, uv).xyz;
|
||||||
|
vec2 d = CENTER-uv;
|
||||||
|
#ifdef JITTER
|
||||||
|
d *= .5 + .01*hash(d*iTime);
|
||||||
|
#endif
|
||||||
|
uv += d * RADIUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragColor = vec4(res/float(SAMPLES), 1);
|
||||||
|
}
|
||||||
57
tools/src/manipulative/Rain Drops.frag
Normal file
57
tools/src/manipulative/Rain Drops.frag
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
// Author: Élie Michel
|
||||||
|
// License: CC BY 3.0
|
||||||
|
// July 2017
|
||||||
|
|
||||||
|
vec2 rand(vec2 c){
|
||||||
|
mat2 m = mat2(12.9898,.16180,78.233,.31415);
|
||||||
|
return fract(sin(m * c) * vec2(43758.5453, 14142.1));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 noise(vec2 p){
|
||||||
|
vec2 co = floor(p);
|
||||||
|
vec2 mu = fract(p);
|
||||||
|
mu = 3.*mu*mu-2.*mu*mu*mu;
|
||||||
|
vec2 a = rand((co+vec2(0.,0.)));
|
||||||
|
vec2 b = rand((co+vec2(1.,0.)));
|
||||||
|
vec2 c = rand((co+vec2(0.,1.)));
|
||||||
|
vec2 d = rand((co+vec2(1.,1.)));
|
||||||
|
return mix(mix(a, b, mu.x), mix(c, d, mu.x), mu.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 f, in vec2 c )
|
||||||
|
{
|
||||||
|
vec2 u = c / iResolution.xy,
|
||||||
|
v = (c*.1)/ iResolution.xy,
|
||||||
|
n = noise(v*200.); // Displacement
|
||||||
|
|
||||||
|
f = textureLod(iChannel0, u, 2.5);
|
||||||
|
|
||||||
|
// Loop through the different inverse sizes of drops
|
||||||
|
for (float r = 4. ; r > 0. ; r--) {
|
||||||
|
vec2 x = iResolution.xy * r * .015, // Number of potential drops (in a grid)
|
||||||
|
p = 6.28 * u * x + (n - .5) * 2.,
|
||||||
|
s = sin(p);
|
||||||
|
|
||||||
|
// Current drop properties. Coordinates are rounded to ensure a
|
||||||
|
// consistent value among the fragment of a given drop.
|
||||||
|
//vec4 d = texture(iChannel1, round(u * x - 0.25) / x);
|
||||||
|
vec2 v = round(u * x - 0.25) / x;
|
||||||
|
vec4 d = vec4(noise(v*200.), noise(v));
|
||||||
|
|
||||||
|
// Drop shape and fading
|
||||||
|
float t = (s.x+s.y) * max(0., 1. - fract(iTime * (d.b + .1) + d.g) * 2.);;
|
||||||
|
|
||||||
|
// d.r -> only x% of drops are kept on, with x depending on the size of drops
|
||||||
|
if (d.r < (5.-r)*.08 && t > .5) {
|
||||||
|
// Drop normal
|
||||||
|
vec3 v = normalize(-vec3(cos(p), mix(.2, 2., t-.5)));
|
||||||
|
// fragColor = vec4(v * 0.5 + 0.5, 1.0); // show normals
|
||||||
|
|
||||||
|
// Poor man's refraction (no visual need to do more)
|
||||||
|
f = texture(iChannel0, u - v.xy * .3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debug noise function
|
||||||
|
//f = vec4(n, 0.0, 1.0);
|
||||||
|
}
|
||||||
36
tools/src/manipulative/Rainbow Filter.frag
Normal file
36
tools/src/manipulative/Rainbow Filter.frag
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
//https://www.shadertoy.com/view/MdffDS
|
||||||
|
#define posterSteps 4.0
|
||||||
|
#define lumaMult 0.5
|
||||||
|
#define timeMult 0.15
|
||||||
|
#define BW 0
|
||||||
|
|
||||||
|
float rgbToGray(vec4 rgba) {
|
||||||
|
const vec3 W = vec3(0.2125, 0.7154, 0.0721);
|
||||||
|
return dot(rgba.xyz, W);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 hsv2rgb(vec3 c) {
|
||||||
|
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||||
|
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||||
|
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 uv = fragCoord.xy / iResolution.xy;
|
||||||
|
vec4 color = texture(iChannel0, uv);
|
||||||
|
float luma = rgbToGray(color) * lumaMult;
|
||||||
|
float lumaIndex = floor(luma * posterSteps);
|
||||||
|
float lumaFloor = lumaIndex / posterSteps;
|
||||||
|
float lumaRemainder = (luma - lumaFloor) * posterSteps;
|
||||||
|
if(mod(lumaIndex, 2.) == 0.) lumaRemainder = 1.0 - lumaRemainder; // flip luma remainder for smooth color transitions
|
||||||
|
float timeInc = iTime * timeMult;
|
||||||
|
float lumaCycle = mod(luma + timeInc, 1.);
|
||||||
|
vec3 roygbiv = hsv2rgb(vec3(lumaCycle, 1., lumaRemainder));
|
||||||
|
if(BW == 1) {
|
||||||
|
float bw = rgbToGray(vec4(roygbiv, 1.));
|
||||||
|
fragColor = vec4(vec3(bw), 1.0);
|
||||||
|
} else {
|
||||||
|
fragColor = vec4(roygbiv, 1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
710
tools/src/manipulative/Randomized Transitions (x2).frag
Normal file
710
tools/src/manipulative/Randomized Transitions (x2).frag
Normal file
@@ -0,0 +1,710 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Video Transitions v2.0 by Mark Craig (Copyright © 2022)
|
||||||
|
|
||||||
|
I originally wrote this as a "filter" to create transition frames
|
||||||
|
for videos (C program which outputted PPM files). But eventually,
|
||||||
|
I figured it could be relatively easily ported to GLSL - this is the
|
||||||
|
result.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
int n = 100; // number of "frames" in transition
|
||||||
|
float sa = .05; // smooth amount - size of smooth edges
|
||||||
|
bool roto = true; // if true, rotate transitions that can optionally rotate
|
||||||
|
float rota = 360.0; // amount of rotation from start to end of transition
|
||||||
|
int rn = 1, rd = 0; // select based on whether to start with full
|
||||||
|
//int rn = 0, rd = -1; // frame of source1 (only for some transitions)
|
||||||
|
//bool altdir = false; // if true, change direction of rolls
|
||||||
|
bool altdir = true; // if true, change direction of rolls
|
||||||
|
int alttype = 0; // alternate slide up center type (0-8 or 9-17 for slide in)
|
||||||
|
|
||||||
|
#define SPEEDADJ .375
|
||||||
|
//#define NEEDMOD 1
|
||||||
|
//#define SELECTTRANS // uncomment to enable @morimea's transition selector mods
|
||||||
|
// If selector mods are chosen, click and hold down left
|
||||||
|
// mouse button on desired transition
|
||||||
|
|
||||||
|
#define imod(a,b) (int((float(a)-(float(b)*floor(float(a)/float(b))))))
|
||||||
|
|
||||||
|
#define iGlobalTime (iTime / SPEEDADJ)
|
||||||
|
|
||||||
|
#define num_transitions 38
|
||||||
|
|
||||||
|
// macros for selecting/mixing the textures
|
||||||
|
|
||||||
|
#define MEM2 col = alt ? col1 : col2;
|
||||||
|
#define MEM1 col = alt ? col2 : col1;
|
||||||
|
#define MEM12 col = alt ? v1 * col2 + v2 * col1 : v1 * col1 + v2 * col2;
|
||||||
|
#define MEM1S { col = alt ? texture2D(iChannel1, uv2).xyz : texture2D(iChannel0, uv2).xyz; }
|
||||||
|
#define MEM2S { col = alt ? texture2D(iChannel0, uv2).xyz : texture2D(iChannel1, uv2).xyz; }
|
||||||
|
|
||||||
|
// Solve some incompatibilities
|
||||||
|
|
||||||
|
#define atan2 atan
|
||||||
|
#define fmod mod
|
||||||
|
#define texture2D texture
|
||||||
|
|
||||||
|
// Useful values
|
||||||
|
|
||||||
|
#define _TWOPI 6.283185307
|
||||||
|
#define M_PI 3.141592654
|
||||||
|
|
||||||
|
float intersect(vec2, vec2, vec2, vec2);
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 uv = fragCoord.xy / iResolution.xy, uv2;
|
||||||
|
#ifdef SELECTTRANS
|
||||||
|
// I modified @morimea's mod to make effects start at top and progress in order to bottom
|
||||||
|
uv.y = 1.0 - uv.y;
|
||||||
|
uv *= vec2(6.,7.); int idx = int(floor(uv.x) + floor(uv.y) * 6.);
|
||||||
|
vec2 im = iMouse.xy / iResolution.xy; im.y = 1.0 - im.y;
|
||||||
|
if (iMouse.z > 0.) { im *= vec2(6., 7.); idx = int(floor(im.x) + floor(im.y) * 6.); uv /= vec2(6., 7.); }
|
||||||
|
else { uv = fract(uv); }
|
||||||
|
uv.y = 1.0 - uv.y;
|
||||||
|
#endif
|
||||||
|
bool alt = false;
|
||||||
|
int type, i, i2, j, v;
|
||||||
|
vec3 col, col3;
|
||||||
|
float v1, v2;
|
||||||
|
float ye, yfe, dx, dy, cx, cy, rad, slope, theta, xc1, yc1, b, rad0, rad2;
|
||||||
|
float xc2, yc2, b2, cx2, cy2, r1, vy1, vy2, dx2, dy2, ro, ri, ang, a, a1;
|
||||||
|
float r, r2, l, l2, theta2, theta3, tang, ang1, ang2, angt, angs, c1, s1;
|
||||||
|
float xc0, yc0;
|
||||||
|
vec2 p1, p2, po, pd;
|
||||||
|
|
||||||
|
float aspect = iResolution.y / iResolution.x;
|
||||||
|
vec3 col1 = texture2D(iChannel0, uv).xyz;
|
||||||
|
vec3 col2 = texture2D(iChannel1, uv).xyz;
|
||||||
|
#ifdef NEEDMOD
|
||||||
|
i = imod(int(iGlobalTime * 20.0) , n);
|
||||||
|
#ifndef SELECTTRANS
|
||||||
|
type = imod((int(iGlobalTime * 20.0) / n) , num_transitions);
|
||||||
|
if (imod(type , 2) == 1) { alt = true; } else { alt = false; }
|
||||||
|
#else
|
||||||
|
type = idx;
|
||||||
|
if (imod(int(iGlobalTime * 20.0) , (n*2)) < n) { alt = true; } else { alt = false; }
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
i = int(iGlobalTime * 20.0) % n;
|
||||||
|
#ifndef SELECTTRANS
|
||||||
|
type = (int(iGlobalTime * 20.0) / n) % num_transitions;
|
||||||
|
if (type % 2 == 1) { alt = true; } else { alt = false; }
|
||||||
|
#else
|
||||||
|
type = idx;
|
||||||
|
if (int(iGlobalTime * 20.0) % (n*2) < n) { alt = true; } else { alt = false; }
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//type = 32;
|
||||||
|
|
||||||
|
// some of these equations are long, so I'll forego extra spaces
|
||||||
|
|
||||||
|
// was a switch, but some GPUs won't do switch
|
||||||
|
|
||||||
|
if (type==0) // fade in/out
|
||||||
|
{
|
||||||
|
v1=float(n-(i+1))/float(n-1); v2=1.0-v1;
|
||||||
|
MEM12
|
||||||
|
}
|
||||||
|
else if (type==1) // window down with soft edge
|
||||||
|
{
|
||||||
|
ye=1.0-float(i)/float(n-1);
|
||||||
|
yfe=ye+sa;
|
||||||
|
if (uv.y<=ye) MEM1
|
||||||
|
else if (uv.y>yfe) MEM2
|
||||||
|
else
|
||||||
|
{
|
||||||
|
v2=float(uv.y-ye)/sa; if (v2>1.0) { v2=1.0; } v1=1.0-v2;
|
||||||
|
MEM12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type==2) // increasing box
|
||||||
|
{
|
||||||
|
cx=.5; cy=.5;
|
||||||
|
dx=cx*float(i+rn)/float(n+rd);
|
||||||
|
dy=cy*float(i+rn)/float(n+rd);
|
||||||
|
if ((uv.x>=cx-dx)&&(uv.x<=cx+dx)&&(uv.y>=cy-dy)&&(uv.y<=cy+dy)) MEM2
|
||||||
|
else MEM1
|
||||||
|
}
|
||||||
|
else if (type==3) // increasing diamond
|
||||||
|
{
|
||||||
|
cx=.5; cy=.5;
|
||||||
|
rad=sqrt(cx*cx+cy*cy)*(float(i+rn)/float(n+rd));
|
||||||
|
slope=-cy/cx;
|
||||||
|
theta=atan(-slope);
|
||||||
|
xc1=rad*cos(theta); yc1=rad*sin(theta);
|
||||||
|
b=yc1-slope*xc1;
|
||||||
|
cy=b; cx=(-b/slope);
|
||||||
|
dy=abs(.5-uv.y);
|
||||||
|
dx=abs(.5-uv.x);
|
||||||
|
if (dx>cx) MEM1
|
||||||
|
else if (dy>slope*dx+cy) MEM1
|
||||||
|
else MEM2
|
||||||
|
}
|
||||||
|
else if (type==4) // increasing circle
|
||||||
|
{
|
||||||
|
cx=.5; cy=.5;
|
||||||
|
rad=sqrt(cx/aspect*cx/aspect+cy*cy)*(float(i+rn)/float(n+rd));
|
||||||
|
if (sqrt((uv.x-cx)/aspect*(uv.x-cx)/aspect+(uv.y-cy)*(uv.y-cy))>rad) MEM1
|
||||||
|
else MEM2
|
||||||
|
}
|
||||||
|
else if (type==5) // increasing and decreasing diamonds
|
||||||
|
{
|
||||||
|
cx=.5; cy=.5;
|
||||||
|
rad0=sqrt(cx*cx+cy*cy)/2.0;
|
||||||
|
rad=sqrt(cx*cx+cy*cy)*(float(n-(i+1))/float(n+rd))/2.0;
|
||||||
|
rad2=rad0+(rad0-rad);
|
||||||
|
slope=-cy/cx;
|
||||||
|
theta=atan(-slope);
|
||||||
|
xc1=rad*cos(theta); yc1=rad*sin(theta);
|
||||||
|
xc2=rad2*cos(theta); yc2=rad2*sin(theta);
|
||||||
|
b=yc1-slope*xc1;
|
||||||
|
b2=yc2-slope*xc2;
|
||||||
|
cy=b; cx=(-b/slope);
|
||||||
|
cy2=b2; cx2=(-b2/slope);
|
||||||
|
dy=abs(.5-uv.y);
|
||||||
|
dx=abs(.5-uv.x);
|
||||||
|
if (dx>cx) MEM2
|
||||||
|
else if (dy>slope*dx+cy) MEM2
|
||||||
|
else MEM1
|
||||||
|
if (dy>slope*dx+cy2) MEM1
|
||||||
|
}
|
||||||
|
else if (type==6) // four corner vanish
|
||||||
|
{
|
||||||
|
cx=.5; cy=.5;
|
||||||
|
dx=cx*float(i+rn)/float(n+rd);
|
||||||
|
dy=cy*float(i+rn)/float(n+rd);
|
||||||
|
if ((uv.x>cx-dx)&&(uv.x<cx+dx)&&(uv.y>cy-dy)&&(uv.y<cy+dy)) MEM2
|
||||||
|
else if ((uv.y<cy)&&(uv.x>cx-dx)&&(uv.x<cx+dx)) MEM2
|
||||||
|
else if ((uv.y>cy)&&(uv.x>cx-dx)&&(uv.x<cx+dx)) MEM2
|
||||||
|
else if ((uv.x<cx)&&(uv.y>cy-dy)&&(uv.y<cy+dy)) MEM2
|
||||||
|
else if ((uv.x>cx)&&(uv.y>cy-dy)&&(uv.y<cy+dy)) MEM2
|
||||||
|
else MEM1
|
||||||
|
}
|
||||||
|
else if (type==7) // increasing circle with soft edge
|
||||||
|
{
|
||||||
|
cx=.5; cy=.5;
|
||||||
|
rad=sqrt(cx/aspect*cx/aspect+cy*cy)*(float(i+rn)/float(n+rd));
|
||||||
|
//rad2=rad+10.0*sa;
|
||||||
|
rad2=rad+sa;
|
||||||
|
r1=sqrt((uv.x-cx)/aspect*(uv.x-cx)/aspect+(uv.y-cy)*(uv.y-cy));
|
||||||
|
if (r1>rad2) MEM1
|
||||||
|
else if (r1>rad) { v1=(r1-rad)/(rad2-rad); v2=1.0-v1; MEM12 }
|
||||||
|
else MEM2
|
||||||
|
}
|
||||||
|
else if (type==8) // increasing diamond with soft edge
|
||||||
|
{
|
||||||
|
cx=.5; cy=.5;
|
||||||
|
rad=sqrt(cx*cx+cy*cy)*(float(i+rn)/float(n+rd));
|
||||||
|
//rad2=rad+7.0*sa;
|
||||||
|
rad2=rad+.7*sa;
|
||||||
|
slope=-cy/cx;
|
||||||
|
theta=atan(-slope);
|
||||||
|
xc1=rad*cos(theta); yc1=rad*sin(theta);
|
||||||
|
xc2=rad2*cos(theta); yc2=rad2*sin(theta);
|
||||||
|
b=yc1-slope*xc1;
|
||||||
|
b2=yc2-slope*xc2;
|
||||||
|
cy=b; cx=(-b/slope);
|
||||||
|
cy2=b2; cx2=(-b2/slope);
|
||||||
|
dy=abs(.5-uv.y);
|
||||||
|
dx=abs(.5-uv.x);
|
||||||
|
if (dx>cx2) MEM1
|
||||||
|
else if (dy>slope*dx+cy2) MEM1
|
||||||
|
else if (dy>slope*dx+cy)
|
||||||
|
{
|
||||||
|
vy1=slope*dx+b;
|
||||||
|
vy2=slope*dx+b2;
|
||||||
|
v1=(dy-vy1)/(vy2-vy1); v2=1.0-v1;
|
||||||
|
MEM12
|
||||||
|
}
|
||||||
|
else MEM2
|
||||||
|
}
|
||||||
|
else if (type==9) // increasing & decreasing diamonds w/ soft edge
|
||||||
|
{
|
||||||
|
float xc1s,yc1s,xc2s,yc2s,rads,rad2s,bs,b2s,cxs,cys,cx2s,cy2s;
|
||||||
|
|
||||||
|
cx=.5; cy=.5;
|
||||||
|
rad0=sqrt(cx*cx+cy*cy)/2.0;
|
||||||
|
rad=sqrt(cx*cx+cy*cy)*(float(n-(i+1))/float(n+rd))/2.0;
|
||||||
|
//rads=rad+7.0*sa;
|
||||||
|
rads=rad+.7*sa;
|
||||||
|
rad2=rad0+(rad0-rad);
|
||||||
|
//rad2s=rad2-7.0*sa;
|
||||||
|
rad2s=rad2-.7*sa;
|
||||||
|
slope=-cy/cx;
|
||||||
|
theta=atan(-slope);
|
||||||
|
xc1=rad*cos(theta); yc1=rad*sin(theta);
|
||||||
|
xc2=rad2*cos(theta); yc2=rad2*sin(theta);
|
||||||
|
xc1s=rads*cos(theta); yc1s=rads*sin(theta);
|
||||||
|
xc2s=rad2s*cos(theta); yc2s=rad2s*sin(theta);
|
||||||
|
b=yc1-slope*xc1;
|
||||||
|
b2=yc2-slope*xc2;
|
||||||
|
bs=yc1s-slope*xc1s;
|
||||||
|
b2s=yc2s-slope*xc2s;
|
||||||
|
cy=b; cx=(-b/slope);
|
||||||
|
cy2=b2; cx2=(-b2/slope);
|
||||||
|
cys=bs; cxs=(-bs/slope);
|
||||||
|
cy2s=b2s; cx2s=(-b2s/slope);
|
||||||
|
dy=abs(.5-uv.y);
|
||||||
|
dx=abs(.5-uv.x);
|
||||||
|
if (dx>cxs) MEM2
|
||||||
|
else if (dy>slope*dx+cys) MEM2
|
||||||
|
else if (dy>slope*dx+cy)
|
||||||
|
{
|
||||||
|
vy1=slope*dx+b;
|
||||||
|
vy2=slope*dx+bs;
|
||||||
|
v2=(dy-vy1)/(vy2-vy1); v1=1.0-v2;
|
||||||
|
MEM12
|
||||||
|
}
|
||||||
|
else MEM1
|
||||||
|
if (dy>slope*dx+cy2) MEM1
|
||||||
|
else if (dy>slope*dx+cy2s)
|
||||||
|
{
|
||||||
|
vy1=slope*dx+b2;
|
||||||
|
vy2=slope*dx+b2s;
|
||||||
|
v2=(dy-vy1)/(vy2-vy1); v1=1.0-v2;
|
||||||
|
MEM12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type==10) // increasing box with soft edge
|
||||||
|
{
|
||||||
|
cx=.5; cy=.5;
|
||||||
|
dx=(cx*float(i+rn)/float(n+rd));
|
||||||
|
dy=(cy*float(i+rn)/float(n+rd));
|
||||||
|
dx2=(cx*float(i+rn)/float(n+rd)+sa);
|
||||||
|
dy2=(cy*float(i+rn)/float(n+rd)+sa);
|
||||||
|
if ((uv.x>=cx-dx)&&(uv.x<=cx+dx)&&(uv.y>=cy-dy)&&(uv.y<=cy+dy)) MEM2
|
||||||
|
else if ((uv.x>=cx-dx2)&&(uv.x<=cx+dx2)&&(uv.y>=cy-dy2)&&(uv.y<=cy+dy2))
|
||||||
|
{
|
||||||
|
if ((abs(uv.x-cx)>dx)&&(abs(uv.y-cy)>dy))
|
||||||
|
{
|
||||||
|
if (abs(uv.y-cy)-dy>abs(uv.x-cx)-dx) v1=float(abs(uv.y-cy)-dy)/(sa);
|
||||||
|
else v1=float(abs(uv.x-cx)-dx)/(sa);
|
||||||
|
}
|
||||||
|
else if (abs(uv.x-cx)>dx) { v1=float(abs(uv.x-cx)-dx)/(sa); }
|
||||||
|
else if (abs(uv.y-cy)>dy) { v1=float(abs(uv.y-cy)-dy)/(sa); }
|
||||||
|
v2=1.0-v1; MEM12
|
||||||
|
}
|
||||||
|
else MEM1
|
||||||
|
}
|
||||||
|
else if (type==11) // rotating vanishing (gets smaller) square with fade in new/fade out old
|
||||||
|
{
|
||||||
|
theta=-_TWOPI*(float(i+rn)/float(n+rd));
|
||||||
|
c1=cos(theta); s1=sin(theta);
|
||||||
|
rad=max(0.00001,(float(n-(i+1))/float(n+rd)));
|
||||||
|
xc1=(uv.x-.5)*iResolution.x; yc1=(uv.y-.5)*iResolution.y;
|
||||||
|
xc2=(xc1*c1-yc1*s1)/rad;
|
||||||
|
yc2=(xc1*s1+yc1*c1)/rad;
|
||||||
|
uv2.x=xc2+iResolution.x/2.0; uv2.y=yc2+iResolution.y/2.0;
|
||||||
|
if ((uv2.x>=0.0)&&(uv2.x<=iResolution.x)&&(uv2.y>=0.0)&&(uv2.y<=iResolution.y))
|
||||||
|
{
|
||||||
|
uv2/=iResolution.xy;
|
||||||
|
col3 = alt ? texture2D(iChannel1, uv2).xyz : texture2D(iChannel0, uv2).xyz;
|
||||||
|
}
|
||||||
|
else { col3 = vec3(0,0,0); }
|
||||||
|
v1=float(n-(i+1))/float(n-1); v2=1.0-v1;
|
||||||
|
col = alt ? v1*col3+v2*col1 : v1*col3+v2*col2;
|
||||||
|
}
|
||||||
|
else if (type==12) // rotating vanishing (gets smaller) square with fade out old
|
||||||
|
{
|
||||||
|
theta=-_TWOPI*(float(i+rn)/float(n+rd));
|
||||||
|
c1=cos(theta); s1=sin(theta);
|
||||||
|
rad=max(0.00001,(float(n-(i+1))/float(n+rd)));
|
||||||
|
xc1=(uv.x-.5)*iResolution.x; yc1=(uv.y-.5)*iResolution.y;
|
||||||
|
xc2=(xc1*c1-yc1*s1)/rad;
|
||||||
|
yc2=(xc1*s1+yc1*c1)/rad;
|
||||||
|
uv2.x=xc2+iResolution.x/2.0; uv2.y=yc2+iResolution.y/2.0;
|
||||||
|
if ((uv2.x>=0.0)&&(uv2.x<=iResolution.x)&&(uv2.y>=0.0)&&(uv2.y<=iResolution.y))
|
||||||
|
{
|
||||||
|
uv2/=iResolution.xy;
|
||||||
|
col3 = alt ? texture2D(iChannel1, uv2).xyz : texture2D(iChannel0, uv2).xyz;
|
||||||
|
}
|
||||||
|
else { col3 = alt ? col1 : col2; }
|
||||||
|
v1=float(n-(i+1))/float(n-1); v2=1.0-v1;
|
||||||
|
col = alt ? v1*col3+v2*col1 : v1*col3+v2*col2;
|
||||||
|
}
|
||||||
|
else if (type==13) // increasing flower with soft edge
|
||||||
|
{
|
||||||
|
cx=.5; cy=.5;
|
||||||
|
ang=36.0*M_PI/180.0;
|
||||||
|
ro=(1.0/aspect)/.731*(float(i+rn)/float(n+rd));
|
||||||
|
a1=234.0*M_PI/180.0;
|
||||||
|
l=(sqrt((ro*cos(a1)*ro*cos(a1))+((ro*sin(a1)-ro)*(ro*sin(a1)-ro))))/2.0;
|
||||||
|
a1=162.0*M_PI/180.0;
|
||||||
|
l2=((ro*cos(a1)*ro*cos(a1))+((ro*sin(a1)-ro)*(ro*sin(a1)-ro)));
|
||||||
|
ri=(ro-sqrt(l2-l*l))/cos(36.0*M_PI/180.0);
|
||||||
|
if (roto) { vy1=float(i+rn-1)/float(n+rd)*rota*M_PI/180.0; }
|
||||||
|
else { vy1=0.0; }
|
||||||
|
yc1=1.0-uv.y-cy;
|
||||||
|
xc1=(uv.x-cx)/aspect;
|
||||||
|
theta=atan2(xc1,yc1)+vy1;
|
||||||
|
theta2=fmod(abs(theta),ang);
|
||||||
|
i2=int((180.0*theta/M_PI)/36.0);
|
||||||
|
#ifdef NEEDMOD
|
||||||
|
if (imod(i2,2)==0) { r=theta2/ang*(ro-ri)+ri; }
|
||||||
|
#else
|
||||||
|
if (i2%2==0) { r=theta2/ang*(ro-ri)+ri; }
|
||||||
|
#endif
|
||||||
|
else { r=(1.0-theta2/ang)*(ro-ri)+ri; }
|
||||||
|
r2=sqrt(xc1*xc1+yc1*yc1);
|
||||||
|
if (r2>r+sa) { MEM1 } else if (r2>r) { v1=(r2-r)/(sa); v2=1.0-v1; MEM12 } else { MEM2 }
|
||||||
|
}
|
||||||
|
else if (type==14) // increasing star with soft edge
|
||||||
|
{
|
||||||
|
cx=.5; cy=.5;
|
||||||
|
ang=36.0*M_PI/180.0;
|
||||||
|
ro=(1.0/aspect)/.731*(float(i+rn)/float(n+rd));
|
||||||
|
a1=234.0*M_PI/180.0;
|
||||||
|
l=(sqrt((ro*cos(a1)*ro*cos(a1))+((ro*sin(a1)-ro)*(ro*sin(a1)-ro))))/2.0;
|
||||||
|
a1=162.0*M_PI/180.0;
|
||||||
|
l2=((ro*cos(a1)*ro*cos(a1))+((ro*sin(a1)-ro)*(ro*sin(a1)-ro)));
|
||||||
|
ri=(ro-sqrt(l2-l*l))/cos(36.0*M_PI/180.0);
|
||||||
|
if (roto) { vy1=float(i+rn-1)/float(n+rd)*rota*M_PI/180.0; }
|
||||||
|
else { vy1=0.0; }
|
||||||
|
po.x=po.y=0.0;
|
||||||
|
yc1=1.0-uv.y-cy;
|
||||||
|
xc1=(uv.x-cx)/aspect;
|
||||||
|
theta=atan2(xc1,yc1)+vy1;
|
||||||
|
theta2=fmod(abs(theta),ang);
|
||||||
|
i2=int((180.0*theta/M_PI)/36.0);
|
||||||
|
#ifdef NEEDMOD
|
||||||
|
if (imod(i2,2)==0) { p1.x=ri; p1.y=0.0; p2.x=ro*cos(ang); p2.y=ro*sin(ang); }
|
||||||
|
#else
|
||||||
|
if (i2%2==0) { p1.x=ri; p1.y=0.0; p2.x=ro*cos(ang); p2.y=ro*sin(ang); }
|
||||||
|
#endif
|
||||||
|
else { p1.x=ro; p1.y=0.0; p2.x=ri*cos(ang); p2.y=ri*sin(ang); }
|
||||||
|
pd.x=cos(theta2); pd.y=sin(theta2);
|
||||||
|
r=intersect(po,pd,p1,p2);
|
||||||
|
r2=sqrt(xc1*xc1+yc1*yc1);
|
||||||
|
if (r2>r+sa) { MEM1 } else if (r2>r) { v1=(r2-r)/(sa); v2=1.0-v1; MEM12 } else { MEM2 }
|
||||||
|
}
|
||||||
|
else if (type==15) // dissolve
|
||||||
|
{
|
||||||
|
// easier to use this common shadertoy random number gen rather than the one I used in original
|
||||||
|
int v=int(fract(sin(dot(uv, vec2(12.9898, 78.233)))* 43758.5453)*float(n-1));
|
||||||
|
if (i>v) MEM2 else MEM1
|
||||||
|
}
|
||||||
|
else if (type==16) // split horizontal
|
||||||
|
{
|
||||||
|
cy=.5;
|
||||||
|
ye=1.0/2.0*float(i+rn)/float(n+rd);
|
||||||
|
if (uv.y<cy-ye) MEM1
|
||||||
|
else if (uv.y>=cy+ye) MEM1
|
||||||
|
else MEM2
|
||||||
|
}
|
||||||
|
else if (type==17) // split vertical
|
||||||
|
{
|
||||||
|
cx=.5;
|
||||||
|
ye=1.0/2.0*float(i+rn)/float(n+rd);
|
||||||
|
if (uv.x<cx-ye) MEM1
|
||||||
|
else if (uv.x>=cx+ye) MEM1
|
||||||
|
else MEM2
|
||||||
|
}
|
||||||
|
else if (type==18) // slide
|
||||||
|
{
|
||||||
|
ye=float(i+rn)/float(n+rd);
|
||||||
|
uv2.x=uv.x;
|
||||||
|
uv2.y=uv.y+ye;
|
||||||
|
if (uv.y>=1.0-ye) MEM2
|
||||||
|
else MEM1S
|
||||||
|
}
|
||||||
|
else if (type==19) // window right with soft edge
|
||||||
|
{
|
||||||
|
ye=float(i)/float(n-1);
|
||||||
|
yfe=ye+(10.0*sa);
|
||||||
|
if (uv.x<=ye) MEM2
|
||||||
|
else if (uv.x>yfe) MEM1
|
||||||
|
else
|
||||||
|
{
|
||||||
|
v1=(uv.x-ye)/(10.0*sa); if (v1>1.0) { v1=1.0; } v2=1.0-v1;
|
||||||
|
MEM12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type==20) // inset down right
|
||||||
|
{
|
||||||
|
dx=float(i+rn)/float(n+rd);
|
||||||
|
dy=float(i+rn)/float(n+rd);
|
||||||
|
if (uv.x>=dx) MEM1
|
||||||
|
else if (1.0-uv.y>=dy) MEM1
|
||||||
|
else MEM2
|
||||||
|
}
|
||||||
|
else if (type==21) // inset down left
|
||||||
|
{
|
||||||
|
dx=float(i+rn)/float(n+rd);
|
||||||
|
dy=float(i+rn)/float(n+rd);
|
||||||
|
if ((1.0-uv.x)>dx) MEM1
|
||||||
|
else if (1.0-uv.y>=dy) MEM1
|
||||||
|
else MEM2
|
||||||
|
}
|
||||||
|
else if (type==22) // inset up right
|
||||||
|
{
|
||||||
|
dx=float(i+rn)/float(n+rd);
|
||||||
|
dy=float(i+rn)/float(n+rd);
|
||||||
|
if (uv.x>=dx) MEM1
|
||||||
|
else if (uv.y>dy) MEM1
|
||||||
|
else MEM2
|
||||||
|
}
|
||||||
|
else if (type==23) // inset up left
|
||||||
|
{
|
||||||
|
dx=float(i+rn)/float(n+rd);
|
||||||
|
dy=float(i+rn)/float(n+rd);
|
||||||
|
if ((1.0-uv.x)>dx) MEM1
|
||||||
|
else if ((uv.y)>dy) MEM1
|
||||||
|
else MEM2
|
||||||
|
}
|
||||||
|
else if (type==24) // pixelate
|
||||||
|
{
|
||||||
|
// this is simpler (not as good) as my original non-glsl code
|
||||||
|
v1=float(n-(i+1))/float(n-1); v2=1.0-v1;
|
||||||
|
if (i<n/2) { j=int(float(i)/(float(n)/2.0)*50.0); }
|
||||||
|
else { j=int(float(n-i-1)/(float(n)/2.0)*50.0); }
|
||||||
|
if (j<1) { j=1; }
|
||||||
|
uv2.x=float(int(uv.x*iResolution.x/float(j))*j)/iResolution.x;
|
||||||
|
uv2.y=float(int(uv.y*iResolution.y/float(j))*j)/iResolution.y;
|
||||||
|
col = v1 * (alt ? texture2D(iChannel1, uv2).xyz : texture2D(iChannel0, uv2).xyz) + v2 * (alt ? texture2D(iChannel0, uv2).xyz : texture2D(iChannel1, uv2).xyz);
|
||||||
|
}
|
||||||
|
else if (type==25) // fan in
|
||||||
|
{
|
||||||
|
theta2=M_PI*float(i+rn)/float(n+rd);
|
||||||
|
dy=1.0/4.0; dx=1.0/2.0; dy2=1.0*3.0/4.0;
|
||||||
|
xc1=M_PI/180.0*sa; cy=.5;
|
||||||
|
theta=atan2(abs(dx-uv.x),dy-uv.y);
|
||||||
|
theta3=atan2(abs(dx-uv.x),uv.y-dy2);
|
||||||
|
if ((theta<theta2)||(theta3<theta2)) MEM2
|
||||||
|
else if (abs(theta2-M_PI)<=.00001) MEM2
|
||||||
|
else if ((theta<theta2+xc1)&&(uv.y<=cy)) { v1=(theta-theta2)/xc1; v2=1.0-v1; MEM12 }
|
||||||
|
else if (theta3<theta2+xc1) { v1=(theta3-theta2)/xc1; v2=1.0-v1; MEM12 }
|
||||||
|
else MEM1
|
||||||
|
}
|
||||||
|
else if (type==26) // fan out
|
||||||
|
{
|
||||||
|
theta2=_TWOPI*float(i+rn)/float(n+rd);
|
||||||
|
dx=1.0/4.0; dy=.5; dx2=1.0*3.0/4.0; cx=.5;
|
||||||
|
xc1=M_PI/180.0*sa;
|
||||||
|
theta=M_PI+atan2(1.0-uv.y-dy,dx-uv.x);
|
||||||
|
theta3=M_PI+atan2(1.0-uv.y-dy,uv.x-dx2);
|
||||||
|
if (theta2<=M_PI)
|
||||||
|
{
|
||||||
|
if ((theta<theta2)&&(theta3<theta2)) MEM2
|
||||||
|
else if ((theta<theta2+xc1)&&(uv.x<=cx)) { v1=(theta-theta2)/xc1; v2=1.0-v1; MEM12 }
|
||||||
|
else if ((theta3<theta2+xc1)&&(uv.x>=cx)) { v1=(theta3-theta2)/xc1; v2=1.0-v1; MEM12 }
|
||||||
|
else MEM1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((theta>theta2+xc1)&&(uv.x<=cx)) MEM1
|
||||||
|
else if ((theta3>theta2+xc1)&&(uv.x>=cx)) MEM1
|
||||||
|
else if (!((theta>theta2)&&(theta3>theta2))) MEM2
|
||||||
|
else if (uv.x<=cx) { v1=(theta-theta2)/xc1; v2=1.0-v1; MEM12 }
|
||||||
|
else { v1=(theta3-theta2)/xc1; v2=1.0-v1; MEM12 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type==27) // fan up
|
||||||
|
{
|
||||||
|
theta2=M_PI/2.0*float(i+rn)/float(n+rd);
|
||||||
|
dy=0.0; dx=1.0/2.0; xc1=M_PI/180.0*sa;
|
||||||
|
theta=atan2(abs(dx-uv.x),1.0-uv.y);
|
||||||
|
if (theta<theta2) MEM2
|
||||||
|
else if (theta<theta2+xc1) { v1=(theta-theta2)/xc1; v2=1.0-v1; MEM12 }
|
||||||
|
else MEM1
|
||||||
|
}
|
||||||
|
else if (type==34) // roll
|
||||||
|
{
|
||||||
|
theta=(altdir?M_PI:-M_PI)/2.0*(float(i+rn)/float(n+rd));
|
||||||
|
c1=cos(theta); s1=sin(theta);
|
||||||
|
uv2.x=((1.0-uv.x)*iResolution.x*c1-uv.y*iResolution.y*s1);
|
||||||
|
uv2.y=((1.0-uv.x)*iResolution.x*s1+uv.y*iResolution.y*c1);
|
||||||
|
if ((uv2.x>=0.0)&&(uv2.x<iResolution.x)&&(uv2.y>=0.0)&&(uv2.y<iResolution.y))
|
||||||
|
{ uv2/=iResolution.xy; uv2.x=1.0-uv2.x; MEM1S }
|
||||||
|
else { MEM2 }
|
||||||
|
}
|
||||||
|
else if (type==35) // roll2
|
||||||
|
{
|
||||||
|
theta=(altdir?M_PI:-M_PI)/2.0*(float(i+rn)/float(n+rd));
|
||||||
|
c1=cos(theta); s1=sin(theta);
|
||||||
|
uv2.x=(uv.x*iResolution.x*c1-uv.y*iResolution.y*s1);
|
||||||
|
uv2.y=(uv.x*iResolution.x*s1+uv.y*iResolution.y*c1);
|
||||||
|
if ((uv2.x>=0.0)&&(uv2.x<iResolution.x)&&(uv2.y>=0.0)&&(uv2.y<iResolution.y))
|
||||||
|
{ uv2/=iResolution.xy; MEM1S }
|
||||||
|
else { MEM2 }
|
||||||
|
}
|
||||||
|
else if (type==36) // roll3
|
||||||
|
{
|
||||||
|
theta=(altdir?-M_PI:M_PI)/2.0*(float(i+rn)/float(n+rd));
|
||||||
|
c1=cos(theta); s1=sin(theta);
|
||||||
|
uv2.x=(uv.x*iResolution.x*c1-(1.0-uv.y)*iResolution.y*s1);
|
||||||
|
uv2.y=(uv.x*iResolution.x*s1+(1.0-uv.y)*iResolution.y*c1);
|
||||||
|
if ((uv2.x>=0.0)&&(uv2.x<iResolution.x)&&(uv2.y>=0.0)&&(uv2.y<iResolution.y))
|
||||||
|
{ uv2/=iResolution.xy; uv2.y=1.0-uv2.y; MEM1S }
|
||||||
|
else { MEM2 }
|
||||||
|
}
|
||||||
|
else if (type==37) // roll4
|
||||||
|
{
|
||||||
|
theta=(altdir?-M_PI:M_PI)/2.0*(float(i+rn)/float(n+rd));
|
||||||
|
c1=cos(theta); s1=sin(theta);
|
||||||
|
uv2.x=((1.0-uv.x)*iResolution.x*c1-(1.0-uv.y)*iResolution.y*s1);
|
||||||
|
uv2.y=((1.0-uv.x)*iResolution.x*s1+(1.0-uv.y)*iResolution.y*c1);
|
||||||
|
if ((uv2.x>=0.0)&&(uv2.x<iResolution.x)&&(uv2.y>=0.0)&&(uv2.y<iResolution.y))
|
||||||
|
{ uv2/=iResolution.xy; uv2=1.0-uv2; MEM1S }
|
||||||
|
else { MEM2 }
|
||||||
|
}
|
||||||
|
else if (type==28) // bars
|
||||||
|
{
|
||||||
|
int v=int(fract(sin(dot(vec2(uv.y,0), vec2(12.9898, 78.233)))* 43758.5453)*float(n-1));
|
||||||
|
if (i>v) MEM2 else MEM1
|
||||||
|
}
|
||||||
|
else if (type==33) // slide up center
|
||||||
|
{
|
||||||
|
bool In=false;
|
||||||
|
if (alttype>8) { v=alttype-9; In=true; } else { v=alttype; }
|
||||||
|
if (In) { rad=(float(i+1)/float(n+rd)); }
|
||||||
|
else { rad=(float(n-(i+1))/float(n+rd)); }
|
||||||
|
if (v==0) { cx=.5; cy=0.0; xc1=.5-rad/2.0; yc1=0.0; }
|
||||||
|
else if (v==1) { cx=1.0; cy=.5; xc1=1.0-rad; yc1=.5-rad/2.0; }
|
||||||
|
else if (v==2) { cx=.5; cy=1.0; xc1=.5-rad/2.0; yc1=1.0-rad; }
|
||||||
|
else if (v==3) { cx=0.0; cy=.5; xc1=0.0; yc1=.5-rad/2.0; }
|
||||||
|
else if (v==4) { cx=1.0; cy=0.0; xc1=1.0-rad; yc1=0.0; }
|
||||||
|
else if (v==5) { cx=cy=1.0; xc1=1.0-rad; yc1=1.0-rad; }
|
||||||
|
else if (v==6) { cx=0.0; cy=1.0; xc1=0.0; yc1=1.0-rad; }
|
||||||
|
else if (v==7) { cx=cy=0.0; xc1=0.0; yc1=0.0; }
|
||||||
|
else if (v==8) { cx=cy=.5; xc1=.5-rad/2.0; yc1=.5-rad/2.0; }
|
||||||
|
uv.y=1.0-uv.y;
|
||||||
|
if ((uv.x>=xc1)&&(uv.x<=xc1+rad)&&(uv.y>=yc1)&&(uv.y<=yc1+rad))
|
||||||
|
{
|
||||||
|
uv2.x=(uv.x-xc1)/rad;
|
||||||
|
uv2.y=1.0-(uv.y-yc1)/rad;
|
||||||
|
if (In) { MEM2S } else { MEM1S }
|
||||||
|
}
|
||||||
|
else if (In) { MEM1 } else { MEM2 }
|
||||||
|
}
|
||||||
|
else if (type==29) // diagonal down right
|
||||||
|
{
|
||||||
|
rad=sqrt(2.0+2.0)*(1.0-(float(i+rn)/float(n+rd)));
|
||||||
|
slope=-1.0/1.0;
|
||||||
|
theta=atan(-slope);
|
||||||
|
xc1=rad*cos(theta); yc1=rad*sin(theta);
|
||||||
|
b=yc1-slope*xc1-sa;
|
||||||
|
cy=b; cx=(-b/slope);
|
||||||
|
dy=abs(uv.y);
|
||||||
|
dx=abs(1.0-uv.x);
|
||||||
|
//if (dx>cx-sa) MEM2
|
||||||
|
if (dy>slope*dx+cy+sa) MEM2
|
||||||
|
else if (dy>slope*dx+cy) { v2=(dy-(slope*dx+cy))/(sa); v1=1.0-v2; MEM12 }
|
||||||
|
else MEM1
|
||||||
|
}
|
||||||
|
else if (type==30) // diagonal cross out
|
||||||
|
{
|
||||||
|
cx=.5; cy=.5;
|
||||||
|
rad=sqrt(cx*cx+cy*cy)/2.0*(float(i+rn)/float(n+rd));
|
||||||
|
slope=-cy/cx;
|
||||||
|
theta=atan(-slope);
|
||||||
|
xc1=rad*cos(theta); yc1=rad*sin(theta);
|
||||||
|
b=yc1-slope*xc1;
|
||||||
|
cy=b; cx=(-b/slope); vy1=sa;
|
||||||
|
dy=(uv.y-.5);
|
||||||
|
dx=(uv.x-.5);
|
||||||
|
if (!(((dy>slope*dx+cy)||(dy<slope*dx-cy))&&((dy>(-slope)*dx+cy)||(dy<(-slope)*dx-cy)))) MEM2
|
||||||
|
else if ((sa!=0.0)&&(!(((dy>slope*dx+cy+vy1)||(dy<slope*dx-cy-vy1))&&
|
||||||
|
((dy>(-slope)*dx+cy+vy1)||(dy<(-slope)*dx-cy-vy1)))))
|
||||||
|
{
|
||||||
|
if ((dx>=0.0)&&(dy>=0.0))
|
||||||
|
{
|
||||||
|
v1=v2=0.0;
|
||||||
|
if (dy>-slope*dx) { v1=(dy-(-slope*dx+cy))/vy1; v2=1.0-v1; }
|
||||||
|
else { v1=((-slope*dx-cy)-dy)/vy1; v2=1.0-v1; }
|
||||||
|
MEM12
|
||||||
|
}
|
||||||
|
else if ((dx<0.0)&&(dy<0.0))
|
||||||
|
{
|
||||||
|
v1=v2=0.0;
|
||||||
|
if (dy>-slope*dx) { v1=(dy-(-slope*dx+cy))/vy1; v2=1.0-v1; }
|
||||||
|
else { v1=((-slope*dx-cy)-dy)/vy1; v2=1.0-v1; }
|
||||||
|
MEM12
|
||||||
|
}
|
||||||
|
else if ((dx>=0.0)&&(dy<0.0))
|
||||||
|
{
|
||||||
|
v1=v2=0.0;
|
||||||
|
if (dy>slope*dx) { v1=(dy-(slope*dx+cy))/vy1; v2=1.0-v1; }
|
||||||
|
else { v1=((slope*dx-cy)-dy)/vy1; v2=1.0-v1; }
|
||||||
|
MEM12
|
||||||
|
}
|
||||||
|
else if ((dx<0.0)&&(dy>=0.0))
|
||||||
|
{
|
||||||
|
v1=v2=0.0;
|
||||||
|
if (dy>slope*dx) { v1=(dy-(slope*dx+cy))/vy1; v2=1.0-v1; }
|
||||||
|
else { v1=((slope*dx-cy)-dy)/vy1; v2=1.0-v1; }
|
||||||
|
MEM12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else MEM1
|
||||||
|
}
|
||||||
|
else if (type==31) // increasing gear with soft edge
|
||||||
|
{
|
||||||
|
cx=.5; cy=.5;
|
||||||
|
ro=sqrt(cx*cx+cy*cy)/.9*float(i+rn)/float(n+rd);
|
||||||
|
if (roto) { vy1=float(i+rn-1)/float(n+rd)*rota*M_PI/180.0; }
|
||||||
|
else { vy1=0.0; }
|
||||||
|
ri=ro*.9;
|
||||||
|
po.x=po.y=0.0;
|
||||||
|
angt=5.0;
|
||||||
|
angs=2.5;
|
||||||
|
tang=(angt+angs)*2.0;
|
||||||
|
ang=tang*M_PI/180.0;
|
||||||
|
yc1=uv.y-cy;
|
||||||
|
xc1=(uv.x-cx)/aspect;
|
||||||
|
theta=atan2(xc1,yc1);
|
||||||
|
theta2=fmod(theta+M_PI+vy1,ang);
|
||||||
|
if (theta2<=angt*M_PI/180.0) { r1=r2=ri; ang2=angt; ang1=theta2; }
|
||||||
|
else if (theta2<=(angt+angs)*M_PI/180.0) { r1=ri; r2=ro; ang2=angs; ang1=theta2-angt*M_PI/180.0; }
|
||||||
|
else if (theta2<=(angt+angs+angt)*M_PI/180.0) { r1=r2=ro; ang2=angt; ang1=theta2-(angt+angs)*M_PI/180.0; }
|
||||||
|
else { r1=ro; r2=ri; ang2=angs; ang1=theta2-(angt+angs+angt)*M_PI/180.0; }
|
||||||
|
ang2*=(M_PI/180.0);
|
||||||
|
p1.x=r1; p1.y=0.0; p2.x=r2*cos(ang2); p2.y=r2*sin(ang2);
|
||||||
|
pd.x=cos(ang1); pd.y=sin(ang1);
|
||||||
|
r=intersect(po,pd,p1,p2);
|
||||||
|
r2=sqrt(xc1*xc1+yc1*yc1);
|
||||||
|
if (r2>r+sa) { MEM1 } else if (r2>r) { v1=(r2-r)/(sa); v2=1.0-v1; MEM12 } else { MEM2 }
|
||||||
|
}
|
||||||
|
else if (type==32) // rotating expanding square with fade in new/fade out old
|
||||||
|
{
|
||||||
|
theta=-_TWOPI*(float(i+rn)/float(n+rd));
|
||||||
|
c1=cos(theta); s1=sin(theta);
|
||||||
|
rad=(float(n-(i+1))/float(n+rd));
|
||||||
|
xc1=(uv.x-.5)*iResolution.x; yc1=(uv.y-.5)*iResolution.y;
|
||||||
|
xc2=rad*(xc1*c1-yc1*s1);
|
||||||
|
yc2=rad*(xc1*s1+yc1*c1);
|
||||||
|
uv2.x=xc2+iResolution.x/2.0; uv2.y=yc2+iResolution.y/2.0;
|
||||||
|
if ((uv2.x>=0.0)&&(uv2.x<=iResolution.x)&&(uv2.y>=0.0)&&(uv2.y<=iResolution.y))
|
||||||
|
{
|
||||||
|
uv2/=iResolution.xy;
|
||||||
|
col3 = alt ? texture2D(iChannel1, uv2).xyz : texture2D(iChannel0, uv2).xyz;
|
||||||
|
}
|
||||||
|
else { col3 = alt ? col1 : col2; }
|
||||||
|
v1=float(n-(i+1))/float(n-1); v2=1.0-v1;
|
||||||
|
//col=col3;
|
||||||
|
col = alt ? v1*col3+v2*col1 : v1*col3+v2*col2;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragColor = vec4(col, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
float intersect(vec2 origin, vec2 direction, vec2 point1, vec2 point2)
|
||||||
|
{
|
||||||
|
vec2 v1, v2, v3;
|
||||||
|
float dot, t1, t2;
|
||||||
|
|
||||||
|
v1.x = origin.x - point1.x;
|
||||||
|
v1.y = origin.y - point1.y;
|
||||||
|
v2.x = point2.x - point1.x;
|
||||||
|
v2.y = point2.y - point1.y;
|
||||||
|
v3.x = -direction.y;
|
||||||
|
v3.y = direction.x;
|
||||||
|
dot = v2.x * v3.x + v2.y * v3.y;
|
||||||
|
if (abs(dot) < 0.000001) return(-1000.0);
|
||||||
|
t1 = (v2.x * v1.y - v2.y * v1.x) / dot;
|
||||||
|
t2 = (v1.x * v3.x + v1.y * v3.y) / dot;
|
||||||
|
if ((t1 >= 0.0) && (t2 >= 0.0) && (t2 <= 1.0)) return(t1);
|
||||||
|
return(-1000.0);
|
||||||
|
}
|
||||||
37
tools/src/manipulative/Ripple Distortion.frag
Normal file
37
tools/src/manipulative/Ripple Distortion.frag
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
//based on the barrel deformation shader taken from:
|
||||||
|
//http://www.geeks3d.com/20140213/glsl-shader-library-fish-eye-and-dome-and-barrel-distortion-post-processing-filters/2/
|
||||||
|
|
||||||
|
//CONTROL VARIABLES
|
||||||
|
float uPower = 0.2; // barrel power - (values between 0-1 work well)
|
||||||
|
float uSpeed = 5.0;
|
||||||
|
float uFrequency = 5.0;
|
||||||
|
|
||||||
|
vec2 Distort(vec2 p, float power, float speed, float freq)
|
||||||
|
{
|
||||||
|
float theta = atan(p.y, p.x);
|
||||||
|
float radius = length(p);
|
||||||
|
radius = pow(radius, power*sin(radius*freq-iTime*speed)+1.0);
|
||||||
|
p.x = radius * cos(theta);
|
||||||
|
p.y = radius * sin(theta);
|
||||||
|
return 0.5 * (p + 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage(out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 xy = 2.0 * fragCoord.xy/iResolution.xy - 1.0;
|
||||||
|
vec2 uvt;
|
||||||
|
float d = length(xy);
|
||||||
|
|
||||||
|
//distance of distortion
|
||||||
|
if (d < 1.0 && uPower != 0.0)
|
||||||
|
{
|
||||||
|
//if power is 0, then don't call the distortion function since there's no reason to do it :)
|
||||||
|
uvt = Distort(xy, uPower, uSpeed, uFrequency);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uvt = fragCoord.xy / iResolution.xy;
|
||||||
|
}
|
||||||
|
vec4 c = texture(iChannel0, uvt);
|
||||||
|
fragColor = c;
|
||||||
|
}
|
||||||
23
tools/src/manipulative/Scatter Blur.frag
Normal file
23
tools/src/manipulative/Scatter Blur.frag
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
Blurring by scattering pixels
|
||||||
|
|
||||||
|
Based on https://github.com/FlexMonkey/Filterpedia/blob/7a0d4a7070894eb77b9d1831f689f9d8765c12ca/Filterpedia/customFilters/Scatter.swift
|
||||||
|
|
||||||
|
Simon Gladman | November 2017 | http://flexmonkey.blogspot.co.uk
|
||||||
|
*/
|
||||||
|
|
||||||
|
float noise(vec2 co) {
|
||||||
|
vec2 seed = vec2(sin(co.x), cos(co.y));
|
||||||
|
return fract(sin(dot(seed ,vec2(12.9898,78.233))) * 43758.5453);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
float radius = abs(25.0 * sin(12.0));
|
||||||
|
|
||||||
|
vec2 offset = -radius + vec2(noise(fragCoord), noise(fragCoord.yx)) * radius * 2.0;
|
||||||
|
|
||||||
|
vec2 uv = (fragCoord + offset ) / iResolution.xy;
|
||||||
|
|
||||||
|
fragColor = texture(iChannel0, uv);
|
||||||
|
}
|
||||||
38
tools/src/manipulative/Sepia.frag
Normal file
38
tools/src/manipulative/Sepia.frag
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
// Writer : Rasool Ghana <rasool.ghana@gmail.com>
|
||||||
|
// Sepia effect gives your images a warm brownish tone.
|
||||||
|
// Sepia filter improves the general look and feel of your image.
|
||||||
|
// Sepia tone photos appear hazy, warm, and a bit sentimental.
|
||||||
|
|
||||||
|
// this code is written based on FFMPEG's colorchannelmixer filter
|
||||||
|
// FFMPEG command line for same effect :
|
||||||
|
// colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 xy = fragCoord.xy / iResolution.xy;
|
||||||
|
vec4 texColor = texture(iChannel0,xy);
|
||||||
|
|
||||||
|
float rr = .3;
|
||||||
|
float rg = .769;
|
||||||
|
float rb = .189;
|
||||||
|
float ra = 0.0;
|
||||||
|
|
||||||
|
float gr = .3;
|
||||||
|
float gg = .686;
|
||||||
|
float gb = .168;
|
||||||
|
float ga = 0.0;
|
||||||
|
|
||||||
|
float br = .272;
|
||||||
|
float bg = .534;
|
||||||
|
float bb = .131;
|
||||||
|
float ba = 0.0;
|
||||||
|
|
||||||
|
float red = (rr * texColor.r) + (rb * texColor.b) + (rg * texColor.g) + (ra * texColor.a);
|
||||||
|
float green = (gr * texColor.r) + (gb * texColor.b) + (gg * texColor.g) + (ga * texColor.a);
|
||||||
|
float blue = (br * texColor.r) + (bb * texColor.b) + (bg * texColor.g) + (ba * texColor.a);
|
||||||
|
|
||||||
|
texColor = vec4(red,green,blue,1.0);
|
||||||
|
|
||||||
|
fragColor = texColor;
|
||||||
|
|
||||||
|
}
|
||||||
64
tools/src/manipulative/Soft Blur.frag
Normal file
64
tools/src/manipulative/Soft Blur.frag
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
#ifdef GL_ES
|
||||||
|
precision mediump float;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float normpdf(in float x, in float sigma)
|
||||||
|
{
|
||||||
|
return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;
|
||||||
|
}
|
||||||
|
|
||||||
|
float blendScreen(float base, float blend) {
|
||||||
|
return 1.0-((1.0-base)*(1.0-blend));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 blendScreen(vec3 base, vec3 blend) {
|
||||||
|
return vec3(blendScreen(base.r,blend.r),blendScreen(base.g,blend.g),blendScreen(base.b,blend.b));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 blendScreen(vec3 base, vec3 blend, float opacity) {
|
||||||
|
return (blendScreen(base, blend) * opacity + blend * (1.0 - opacity));
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec3 c = texture(iChannel0, fragCoord.xy / iResolution.xy).rgb;
|
||||||
|
if (fragCoord.x < iMouse.x)
|
||||||
|
{
|
||||||
|
fragColor = vec4(c, 1.0);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
//declare stuff
|
||||||
|
const int mSize = 11;
|
||||||
|
const int kSize = (mSize-1)/2;
|
||||||
|
float kernel[mSize];
|
||||||
|
vec3 final_colour = vec3(0.0);
|
||||||
|
|
||||||
|
//create the 1-D kernel
|
||||||
|
float sigma = 7.0;
|
||||||
|
float Z = 0.0;
|
||||||
|
for (int j = 0; j <= kSize; ++j)
|
||||||
|
{
|
||||||
|
kernel[kSize+j] = kernel[kSize-j] = normpdf(float(j), sigma);
|
||||||
|
}
|
||||||
|
|
||||||
|
//get the normalization factor (as the gaussian has been clamped)
|
||||||
|
for (int j = 0; j < mSize; ++j)
|
||||||
|
{
|
||||||
|
Z += kernel[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
//read out the texels
|
||||||
|
for (int i=-kSize; i <= kSize; ++i)
|
||||||
|
{
|
||||||
|
for (int j=-kSize; j <= kSize; ++j)
|
||||||
|
{
|
||||||
|
final_colour += kernel[kSize+j]*kernel[kSize+i]*texture(iChannel0, (fragCoord.xy+vec2(float(i),float(j))) / iResolution.xy).rgb;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 blenColor = blendScreen(c,final_colour/(Z*Z),0.8);
|
||||||
|
|
||||||
|
fragColor = vec4(blenColor.rgb, 1.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
tools/src/manipulative/Solarize.frag
Normal file
35
tools/src/manipulative/Solarize.frag
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
// https://www.shadertoy.com/view/ll2GWc
|
||||||
|
// by Nikos Papadopoulos, 4rknova / 2015
|
||||||
|
// WTFPL
|
||||||
|
|
||||||
|
#define THRESHOLD vec3(1.,.92,.1)
|
||||||
|
|
||||||
|
vec3 texsample(in vec2 uv)
|
||||||
|
{
|
||||||
|
return texture(iChannel0, uv).xyz;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 texfilter(in vec2 uv)
|
||||||
|
{
|
||||||
|
vec3 val = texsample(uv);
|
||||||
|
if (val.x < THRESHOLD.x) val.x = 1. - val.x;
|
||||||
|
if (val.y < THRESHOLD.y) val.y = 1. - val.y;
|
||||||
|
if (val.z < THRESHOLD.z) val.z = 1. - val.z;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
vec2 uv = fragCoord.xy / iResolution.xy;
|
||||||
|
uv.y = 1. - uv.y;
|
||||||
|
|
||||||
|
float m = 0.0;
|
||||||
|
|
||||||
|
float l = smoothstep(0., 1. / iResolution.y, abs(m - uv.x));
|
||||||
|
|
||||||
|
vec3 cf = texfilter(uv);
|
||||||
|
vec3 cl = texsample(uv);
|
||||||
|
vec3 cr = (uv.x < m ? cl : cf) * l;
|
||||||
|
|
||||||
|
fragColor = vec4(cr, 1);
|
||||||
|
}
|
||||||
121
tools/src/manipulative/Stone Man.frag
Normal file
121
tools/src/manipulative/Stone Man.frag
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
// https://www.shadertoy.com/view/l3dyRB
|
||||||
|
|
||||||
|
// Ruido pseudo-aleatorio basado en hash
|
||||||
|
float hash(vec2 p) {
|
||||||
|
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Función para calcular el mapa de normales a partir del mapa de altura
|
||||||
|
vec3 calculateNormal(vec2 uv, float heightScale) {
|
||||||
|
float d = 1.0 / iResolution.x; // Delta basado en la resolución
|
||||||
|
float hL = texture(iChannel0, uv - vec2(d, 0.0)).r * heightScale; // Izquierda
|
||||||
|
float hR = texture(iChannel0, uv + vec2(d, 0.0)).r * heightScale; // Derecha
|
||||||
|
float hT = texture(iChannel0, uv - vec2(0.0, d)).r * heightScale; // Arriba
|
||||||
|
float hB = texture(iChannel0, uv + vec2(0.0, d)).r * heightScale; // Abajo
|
||||||
|
|
||||||
|
// Normales derivadas
|
||||||
|
vec3 normal = normalize(vec3(hL - hR, hT - hB, 1.0));
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cálculo de Ambient Occlusion (AO)
|
||||||
|
float calculateAO(vec2 uv, float height, float radius, int samples) {
|
||||||
|
float ao = 0.0;
|
||||||
|
float angleStep = 6.28318530718 / float(samples); // Paso angular (2*PI / muestras)
|
||||||
|
|
||||||
|
for (int i = 0; i < samples; i++) {
|
||||||
|
float angle = float(i) * angleStep;
|
||||||
|
vec2 offset = vec2(cos(angle), sin(angle)) * radius;
|
||||||
|
|
||||||
|
// Altura en el punto de muestra
|
||||||
|
float sampleHeight = texture(iChannel0, uv + offset).r;
|
||||||
|
float diff = height - sampleHeight;
|
||||||
|
|
||||||
|
// Incremento AO si el punto de muestra está por debajo
|
||||||
|
ao += smoothstep(0.0, radius, diff);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalizar el AO (invertido para que las áreas ocluidas sean más oscuras)
|
||||||
|
return 1.0 - ao / float(samples);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calcular sombras fuertes basadas en luminancia
|
||||||
|
float calculateShadows(vec2 uv, float lowerThreshold, float upperThreshold) {
|
||||||
|
vec3 videoColor = texture(iChannel0, uv).rgb;
|
||||||
|
float luminance = dot(videoColor, vec3(0.299, 0.587, 0.114)); // Luminancia
|
||||||
|
|
||||||
|
// Máscara de sombras fuertes
|
||||||
|
return smoothstep(upperThreshold, lowerThreshold, luminance);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Luz puntual con PBR (metalness y roughness)
|
||||||
|
float pointLight(vec3 normal, vec2 uv, vec2 lightPos, vec3 lightDir, float intensity, float roughness, float metalness) {
|
||||||
|
vec2 toLight = lightPos - uv;
|
||||||
|
float distance = length(toLight);
|
||||||
|
vec3 dir = normalize(vec3(toLight, 0.5)); // Dirección ajustada
|
||||||
|
|
||||||
|
// Atenuación
|
||||||
|
float attenuation = intensity / (1.0 + distance * distance);
|
||||||
|
|
||||||
|
// Especularidad controlada por PBR
|
||||||
|
vec3 halfVector = normalize(dir + vec3(0.0, 0.0, 1.0));
|
||||||
|
float NdotH = max(dot(normal, halfVector), 0.0);
|
||||||
|
float specular = pow(NdotH, 1.0 / (roughness + 0.001)) * (1.0 - metalness);
|
||||||
|
|
||||||
|
// Difuso y especular
|
||||||
|
float diffuse = max(dot(normal, dir), 0.0) * attenuation;
|
||||||
|
return diffuse + specular * attenuation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
||||||
|
vec2 uv = fragCoord.xy / iResolution.xy; // Coordenadas normalizadas
|
||||||
|
|
||||||
|
// Luminancia del video como mapa de altura
|
||||||
|
vec3 videoColor = texture(iChannel0, uv).rgb;
|
||||||
|
float height = dot(videoColor, vec3(0.299, 0.587, 0.114)); // Altura basada en luminancia
|
||||||
|
|
||||||
|
// Generar normales
|
||||||
|
vec3 normal = calculateNormal(uv, 18.0);
|
||||||
|
|
||||||
|
// Calcular AO
|
||||||
|
float aoRadius = 0.02; // Radio del AO
|
||||||
|
int aoSamples = 32; // Número de muestras para AO
|
||||||
|
float aoIntensity = 0.4; // Intensidad del AO (0 = desactivado, 1 = máximo)
|
||||||
|
float ao = calculateAO(uv, height, aoRadius, aoSamples) * aoIntensity;
|
||||||
|
|
||||||
|
// Calcular sombras fuertes
|
||||||
|
float lowerThreshold = 0.2; // Inicio de sombras fuertes
|
||||||
|
float upperThreshold = 0.1; // Fin de sombras fuertes
|
||||||
|
float shadowIntensity = 0.3; // Intensidad de sombras fuertes
|
||||||
|
float shadows = calculateShadows(uv, lowerThreshold, upperThreshold) * shadowIntensity;
|
||||||
|
|
||||||
|
// Configuración de luces
|
||||||
|
vec2 light1Pos = vec2(0.1, 0.9); // Superior izquierda
|
||||||
|
vec2 light2Pos = vec2(0.9, 0.1); // Inferior derecha
|
||||||
|
vec3 light1Dir = vec3(0.0, -1.0, 0.5); // Rotación fija
|
||||||
|
vec3 light2Dir = vec3(0.0, 1.0, 0.5);
|
||||||
|
|
||||||
|
// Parámetros de luz y material
|
||||||
|
float intensity1 = 2.7;
|
||||||
|
float intensity2 = 0.4;
|
||||||
|
float roughness = 0.4; // Entre 0 y 1
|
||||||
|
float metalness = 0.5; // Entre 0 y 1
|
||||||
|
vec3 materialColor = vec3(0.5, 0.4, 0.3); // Color base del material
|
||||||
|
|
||||||
|
// Calcular iluminación de ambas luces
|
||||||
|
float light1 = pointLight(normal, uv, light1Pos, light1Dir, intensity1, roughness, metalness);
|
||||||
|
float light2 = pointLight(normal, uv, light2Pos, light2Dir, intensity2, roughness, metalness);
|
||||||
|
|
||||||
|
// Aplicar AO y sombras al material
|
||||||
|
float combinedAO = mix(1.0, ao, aoIntensity);
|
||||||
|
float combinedShadows = mix(1.0, shadows, shadowIntensity);
|
||||||
|
|
||||||
|
// Mezclar iluminación con AO, sombras y material
|
||||||
|
vec3 finalMaterial = (light1 + light2) * materialColor * combinedAO * combinedShadows;
|
||||||
|
|
||||||
|
// Mezcla con el video original (10%)
|
||||||
|
vec3 finalColor = mix(finalMaterial, videoColor, 0.1);
|
||||||
|
|
||||||
|
fragColor = vec4(finalColor, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
243
tools/src/manipulative/Video Bubble.frag
Normal file
243
tools/src/manipulative/Video Bubble.frag
Normal file
@@ -0,0 +1,243 @@
|
|||||||
|
//https://www.shadertoy.com/view/3d2BWz
|
||||||
|
|
||||||
|
//The MIT License
|
||||||
|
//Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
float smooth_max(in float x, in float y, in float s) {
|
||||||
|
float bridge =
|
||||||
|
clamp(abs(x-y)/s, 0.0, 1.0);
|
||||||
|
return max(x,y) + 0.25 * s * (bridge - 1.0) * (bridge - 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 smooth_max(in vec3 x, in vec3 y, float s) {
|
||||||
|
return vec3(smooth_max(x.x, y.x, s),
|
||||||
|
smooth_max(x.y, y.y, s),
|
||||||
|
smooth_max(x.z, y.z, s));
|
||||||
|
}
|
||||||
|
|
||||||
|
float smooth_min(in float x, in float y, in float s) {
|
||||||
|
|
||||||
|
float bridge =
|
||||||
|
clamp(abs(x-y)/s, 0.0, 1.0);
|
||||||
|
return min(x,y) - 0.25 * s * (bridge - 1.0) * (bridge - 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec3 smooth_min(in vec3 x, in vec3 y, float s) {
|
||||||
|
return vec3(smooth_min(x.x, y.x, s),
|
||||||
|
smooth_min(x.y, y.y, s),
|
||||||
|
smooth_min(x.z, y.z, s));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MAX_DIST 8.0
|
||||||
|
|
||||||
|
#define SUPERSAMPLE 1 // per IQ, enable at your own risk
|
||||||
|
// #define SUPERSAMPLE 1 // it's a boolean
|
||||||
|
|
||||||
|
float length_1 = 0.4;
|
||||||
|
const float crinkle = 0.01375; // make this smaller to make grid finer
|
||||||
|
|
||||||
|
vec2 bright_clamp = vec2(0.0, 1.0); // ramp brightness values in this range to 0.0,1.0
|
||||||
|
|
||||||
|
#define HOLES_OR_RODS 1 // 1 for holes, 0 for rods
|
||||||
|
|
||||||
|
const vec3 light_dir = normalize(vec3(0.05, 0.05, -0.15));
|
||||||
|
|
||||||
|
float do_bright_clamp(in float x) {
|
||||||
|
#if !HOLES_OR_RODS
|
||||||
|
// return clamp((x-bright_clamp.y)/(bright_clamp.x - bright_clamp.y), 0.0, 1.0);
|
||||||
|
return smoothstep(bright_clamp.y, bright_clamp.x, x);
|
||||||
|
#else
|
||||||
|
// return clamp((x-bright_clamp.x)/(bright_clamp.y - bright_clamp.x), 0.0, 1.0);
|
||||||
|
return smoothstep(bright_clamp.x, bright_clamp.y, x);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
float core_sdf(in vec3 pt) {
|
||||||
|
const vec3 p1 = vec3(0.0, 0.45, 0.7);
|
||||||
|
const vec3 p2 = -vec3(0.0, -0.1, 0.7);
|
||||||
|
float d1 = length((pt - p1)* vec3(1.6)) - 3.1 * length_1;
|
||||||
|
// float d1 = dot(pt - p1, normalize(p2 - p1)) - 1.85 * length_1;
|
||||||
|
// float d2 = length((pt - p2) * vec3(1.6)) - 3.0 * length_1;
|
||||||
|
float d2 = dot(pt - p2, normalize(p1 - p2)) - 1.9 * length_1;
|
||||||
|
// float d1 = length((pt.xy + vec2(0.0, -0.15))) -0.8 * length_1;
|
||||||
|
return smooth_max(d1, d2, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
float wavefront(vec3 p) {
|
||||||
|
return (1.0 - length_1) * smoothstep(0.0, length_1, abs(mod(p.x, 2.0 * length_1) - length_1))
|
||||||
|
+ length_1 * smoothstep(0.0, length_1, p.y * (p.x + p.y));
|
||||||
|
}
|
||||||
|
|
||||||
|
float sdf(in vec3 pt) {
|
||||||
|
float result = core_sdf(pt);
|
||||||
|
if (abs(result) < 14.0 * crinkle) {
|
||||||
|
vec3 cell_rel = mod(pt, vec3(2.0 * crinkle)) - 1.0 * vec3(crinkle);
|
||||||
|
cell_rel.z = 0.5 * result;
|
||||||
|
vec3 cell_center = pt - cell_rel;
|
||||||
|
cell_rel.xy = abs(cell_rel.xy);
|
||||||
|
vec2 uv = cell_center.xy * 2.0 * iResolution.yx/iResolution.x + vec2(0.5, 0.0);
|
||||||
|
float max_hole_size = crinkle * 1.0;
|
||||||
|
float hole_size = max_hole_size * do_bright_clamp(dot(texture(iChannel0, uv).rgb, 0.8 * vec3(1.0, 0.75, 0.75)));
|
||||||
|
float in_image = step(0.0, uv.x) * step(0.0, uv.y) * step(uv.x, 1.0) * step(uv.y, 1.0);
|
||||||
|
hole_size = mix(max_hole_size, hole_size, in_image);
|
||||||
|
cell_rel.xy = max(vec2(0.0), cell_rel.xy - vec2(0.5 * hole_size));
|
||||||
|
float hole_dist = 0.5 * hole_size - length(cell_rel.xy);
|
||||||
|
#if HOLES_OR_RODS
|
||||||
|
result = smooth_max(result, hole_dist, 0.05 * max_hole_size);
|
||||||
|
#else
|
||||||
|
result = smooth_max(result, -hole_dist, 0.05 * max_hole_size);
|
||||||
|
#endif
|
||||||
|
// result -= crinkle * smoothstep(0.0, 0.8, simple_noise(32.0 * pt, 28.1));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 sdf_grad(in vec3 pt) {
|
||||||
|
float f = sdf(pt);
|
||||||
|
const float h = 0.001;
|
||||||
|
const float h_inv = 1000.0;
|
||||||
|
|
||||||
|
return h_inv *
|
||||||
|
vec3(sdf(pt + vec3(h, 0.0, 0.0)) - f,
|
||||||
|
sdf(pt + vec3(0.0, h, 0.0)) - f,
|
||||||
|
sdf(pt + vec3(0.0, 0.0, h)) - f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float raymarch(in vec3 pt, in vec3 dir, out float sumdist) {
|
||||||
|
vec3 d = normalize(dir);
|
||||||
|
vec3 p = pt;
|
||||||
|
float accum = 0.0;
|
||||||
|
float s = sdf(pt);
|
||||||
|
sumdist = 0.0;
|
||||||
|
for(int i = 0; i < 512; ++i) {
|
||||||
|
if (accum > MAX_DIST || s < 1.0e-3) {
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
accum += 0.25 * s;
|
||||||
|
p = pt + accum * d;
|
||||||
|
s = sdf(p);
|
||||||
|
sumdist = sumdist + 0.25 * s / max(s, 1.0e-3);
|
||||||
|
}
|
||||||
|
if (s > 1.0e-3) {
|
||||||
|
return MAX_DIST + 1.0;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
float raymarch_out(in vec3 pt, in vec3 dir) {
|
||||||
|
vec3 d = normalize(dir);
|
||||||
|
vec3 p = pt;
|
||||||
|
float total_step = 0.0;
|
||||||
|
float accum = 0.0;
|
||||||
|
float s = core_sdf(pt);
|
||||||
|
for(int i = 0; i < 256; ++i) {
|
||||||
|
if (total_step > MAX_DIST) {
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
float curr_step = 0.75 * max(abs(s), 1.0e-3);
|
||||||
|
total_step += curr_step;
|
||||||
|
accum += curr_step * step(s, 0.0);
|
||||||
|
p = pt + total_step * d;
|
||||||
|
s = core_sdf(p);
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}
|
||||||
|
|
||||||
|
float ramp(in float a, in float b, in float x) {
|
||||||
|
float p = (x-a)/(b-a);
|
||||||
|
return clamp(p, 0.0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 color_at(in vec2 fragCoord ) {
|
||||||
|
// Normalized pixel coordinates (from 0 to 1)
|
||||||
|
vec2 uv = (2.0 * fragCoord - iResolution.xy) / iResolution.y;
|
||||||
|
|
||||||
|
vec3 dir = normalize(vec3(uv, 6.0));
|
||||||
|
|
||||||
|
vec3 orig = vec3(0.0, 0.25, -1.5);
|
||||||
|
|
||||||
|
float theta = 0.0625 * sin(0.25 * iTime) + 3.141592654;
|
||||||
|
float ct = cos(theta);
|
||||||
|
float st = sin(theta);
|
||||||
|
|
||||||
|
mat3 spin = mat3(ct, 0.0, st,
|
||||||
|
0.0, 1.0, 0.0,
|
||||||
|
-st, 0.0, ct);
|
||||||
|
|
||||||
|
theta = 0.25 * sin(iTime);
|
||||||
|
vec2 trigs = cos(vec2(theta, theta + 0.5 * 3.141592654));
|
||||||
|
ct = 0.8 * trigs.x - 0.6 * trigs.y;
|
||||||
|
st = 0.6 * trigs.x + 0.8 * trigs.y;
|
||||||
|
theta = 0.25 * sin(1.21 * iTime);
|
||||||
|
trigs = cos(vec2(theta, theta + 0.5 * 3.141592654));
|
||||||
|
ct = 0.6 * trigs.x - 0.8 * trigs.y;
|
||||||
|
st = 0.8 * trigs.x + 0.6 * trigs.y;
|
||||||
|
|
||||||
|
|
||||||
|
theta = 0.25 * sin(0.93 * iTime);
|
||||||
|
trigs = cos(vec2(theta, theta + 0.5 * 3.141592654));
|
||||||
|
ct = 0.8 * trigs.x - 0.6 * trigs.y;
|
||||||
|
st = 0.6 * trigs.x + 0.8 * trigs.y;
|
||||||
|
|
||||||
|
orig = spin * orig;
|
||||||
|
dir = spin * dir;
|
||||||
|
|
||||||
|
float cloud_integral = 0.0;
|
||||||
|
|
||||||
|
float dist = raymarch(orig, dir, cloud_integral);
|
||||||
|
|
||||||
|
vec3 color_mul = vec3(1.0);
|
||||||
|
|
||||||
|
|
||||||
|
vec3 col = vec3(0.0);
|
||||||
|
vec3 refl_color = 1.0 * vec3(0.8, 1.0, 0.5);
|
||||||
|
vec3 trans_color = 1.0 * vec3(1.0, 0.1, 0.5); // 1.0 , 0.5, 0.4);
|
||||||
|
float thru_dist = 1000.0;
|
||||||
|
vec3 n = dir;
|
||||||
|
if (dist < MAX_DIST) {
|
||||||
|
vec3 pt = orig + dir * dist;
|
||||||
|
thru_dist = raymarch_out(pt, light_dir);
|
||||||
|
n = normalize(sdf_grad(pt));
|
||||||
|
dir = normalize(reflect(dir, n));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
col = (0.8 * smoothstep(0.99, 1.0, dot(dir, light_dir)) + 0.5 * smoothstep(0.2, 1.0, dot(n, light_dir)))*
|
||||||
|
refl_color;
|
||||||
|
|
||||||
|
float pen_length = 0.1 * length_1; // 10.25 * crinkle;
|
||||||
|
float soften_subsurface = 1.0;
|
||||||
|
|
||||||
|
col += ( soften_subsurface * pen_length / max(abs(soften_subsurface * thru_dist), pen_length)) * trans_color;
|
||||||
|
|
||||||
|
}
|
||||||
|
float sweep = 20.0 * fragCoord.x / iResolution.x + smoothstep(0.0, iResolution.y, fragCoord.y);
|
||||||
|
float cloud_modulate = 0.25; // + 0.25 * sin(1.71 * iTime + sweep);
|
||||||
|
float cloud_contrib = 0.05 * cloud_modulate * cloud_integral;
|
||||||
|
// cloud_contrib *= smoothstep(0.4, 0.6, cloud_contrib);
|
||||||
|
col += 1.0 * vec3(-1.0, 1.0, 1.0) * cloud_contrib;
|
||||||
|
|
||||||
|
// col = vec3(freckles, 0.0);
|
||||||
|
// Output to screen
|
||||||
|
return vec4(color_mul * col,1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
// length_1 += 0.05 * length_1 * sin(0.11 * iTime);
|
||||||
|
|
||||||
|
|
||||||
|
vec4 col_out = color_at(fragCoord);
|
||||||
|
#if SUPERSAMPLE
|
||||||
|
col_out *= 0.25;
|
||||||
|
const float scatter_scale = 0.8;
|
||||||
|
col_out += 0.25 * color_at(fragCoord + scatter_scale * vec2(0.6, 0.8));
|
||||||
|
col_out += 0.25 * color_at(fragCoord + scatter_scale * vec2(-1.0, 0.0));
|
||||||
|
col_out += 0.25 * color_at(fragCoord + scatter_scale * vec2(0.0, -1.0));
|
||||||
|
#endif
|
||||||
|
fragColor = col_out;
|
||||||
|
}
|
||||||
93
tools/src/manipulative/Video Wall.frag
Normal file
93
tools/src/manipulative/Video Wall.frag
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
// https://www.shadertoy.com/view/MlX3Rs
|
||||||
|
|
||||||
|
vec4 white = vec4(1.0,1.0,1.0,0.0);
|
||||||
|
vec4 black = vec4(0.0,0.0,0.0,1.0);
|
||||||
|
|
||||||
|
vec4 noise(vec4 c,vec2 px)
|
||||||
|
{
|
||||||
|
vec2 uv = px / iResolution.xy;
|
||||||
|
|
||||||
|
vec4 r = texture(iChannel0,uv+vec2(sin(iTime*10.0),sin(iTime*20.0)));
|
||||||
|
|
||||||
|
c += r * 0.2;
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 colorFilter(vec4 c)
|
||||||
|
{
|
||||||
|
float g = (c.x + c.y + c.z) / 3.0;
|
||||||
|
c = vec4(g,g,g,1.0);
|
||||||
|
|
||||||
|
c.x *= 0.3;
|
||||||
|
c.y *= 0.5;
|
||||||
|
c.z *= 0.7;
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 frame(vec4 c,vec2 px)
|
||||||
|
{
|
||||||
|
vec2 uv = px / iResolution.xy;
|
||||||
|
|
||||||
|
float d = 0.59;
|
||||||
|
float e = 3.8;
|
||||||
|
|
||||||
|
c += 0.4*pow(distance(uv,vec2(0.5,0.5)) / d,e);
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 scanline(vec4 c, vec2 px)
|
||||||
|
{
|
||||||
|
vec2 uv = px / iResolution.xy;
|
||||||
|
|
||||||
|
float y = mod(-iTime / 10.0,1.1);
|
||||||
|
|
||||||
|
float d = sqrt(abs(uv.y - y));
|
||||||
|
|
||||||
|
float a = 1.0 - smoothstep(0.001,0.2,d);
|
||||||
|
|
||||||
|
c = noise(noise(noise(white,px),px),px) * (a*0.5) + (c * (1.0-a));
|
||||||
|
|
||||||
|
return c;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage( out vec4 fragColor, in vec2 fragCoord )
|
||||||
|
{
|
||||||
|
|
||||||
|
vec2 uv = fragCoord.xy / iResolution.xy;
|
||||||
|
|
||||||
|
float aspect = iResolution.x / iResolution.y;
|
||||||
|
|
||||||
|
float squares = pow((1.0 + float(int(mod(2.0+iTime / 3.5,5.0)))),2.0);
|
||||||
|
|
||||||
|
vec4 c = black;
|
||||||
|
|
||||||
|
float sw = sqrt(squares) / aspect;
|
||||||
|
float sh = sqrt(squares);
|
||||||
|
|
||||||
|
|
||||||
|
float b = float(int(mod(uv.y*sh,2.0)));
|
||||||
|
// a(0 || 1) selects square
|
||||||
|
float a = float(int(mod(uv.x*sw * aspect + b,2.0)));
|
||||||
|
|
||||||
|
// Texture coordinates
|
||||||
|
float vx = mod(uv.x * sw * aspect, 1.0);
|
||||||
|
float vy = mod(uv.y * sh*-1.0, 1.0);
|
||||||
|
|
||||||
|
c += texture(iChannel1,vec2(vx,vy)) * (1.0-a);
|
||||||
|
c += texture(iChannel2,vec2(vx,vy)) * a;
|
||||||
|
|
||||||
|
|
||||||
|
c = noise(c,fragCoord);
|
||||||
|
//c = scanline(c,fragCoord);
|
||||||
|
c = colorFilter(c);
|
||||||
|
|
||||||
|
c = frame(c,fragCoord);
|
||||||
|
|
||||||
|
c = clamp(black,c,white);
|
||||||
|
|
||||||
|
fragColor = c;
|
||||||
|
}
|
||||||
78
tools/src/manipulative/Water Ripples.frag
Normal file
78
tools/src/manipulative/Water Ripples.frag
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
#define CORRECT_TEXTURE_SIZE 0
|
||||||
|
#define TEXTURE_DOWNSCALE 2.0
|
||||||
|
|
||||||
|
#define VIEW_HEIGHT 0
|
||||||
|
#define VIEW_NORMALS 0
|
||||||
|
#define CHEAP_NORMALS 0
|
||||||
|
|
||||||
|
#define nsin(x) (sin(x) * 0.5 + 0.5)
|
||||||
|
|
||||||
|
float rand(vec2 uv, float t) {
|
||||||
|
float seed = dot(uv, vec2(12.3435, 25.3746));
|
||||||
|
return fract(sin(seed) * 234536.3254 + t);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 scale_uv(vec2 uv, vec2 scale, vec2 center) {
|
||||||
|
return (uv - center) * scale + center;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 scale_uv(vec2 uv, vec2 scale) {
|
||||||
|
return scale_uv(uv, scale, vec2(0.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
float create_ripple(vec2 coord, vec2 ripple_coord, float scale, float radius, float range, float height) {
|
||||||
|
float dist = distance(coord, ripple_coord);
|
||||||
|
return sin(dist / scale) * height * smoothstep(dist - range, dist + range, radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 get_normals(vec2 coord, vec2 ripple_coord, float scale, float radius, float range, float height) {
|
||||||
|
return vec2(
|
||||||
|
create_ripple(coord + vec2(1.0, 0.0), ripple_coord, scale, radius, range, height) -
|
||||||
|
create_ripple(coord - vec2(1.0, 0.0), ripple_coord, scale, radius, range, height),
|
||||||
|
create_ripple(coord + vec2(0.0, 1.0), ripple_coord, scale, radius, range, height) -
|
||||||
|
create_ripple(coord - vec2(0.0, 1.0), ripple_coord, scale, radius, range, height)
|
||||||
|
) * 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 get_center(vec2 coord, float t) {
|
||||||
|
t = round(t + 0.5);
|
||||||
|
return vec2(
|
||||||
|
nsin(t - cos(t + 2354.2345) + 2345.3),
|
||||||
|
nsin(t + cos(t - 2452.2356) + 1234.0)
|
||||||
|
) * iResolution.xy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mainImage(out vec4 color, vec2 coord) {
|
||||||
|
vec2 ps = vec2(1.0) / iResolution.xy;
|
||||||
|
vec2 uv = coord * ps;
|
||||||
|
|
||||||
|
#if CORRECT_TEXTURE_SIZE
|
||||||
|
vec2 tex_size = vec2(textureSize(iChannel0, 0));
|
||||||
|
uv = scale_uv(uv, (iResolution.xy / tex_size) * float(TEXTURE_DOWNSCALE));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
float timescale = 1.0;
|
||||||
|
float t = fract(iTime * timescale);
|
||||||
|
|
||||||
|
vec2 center = (iMouse.z > 0.0) ? iMouse.xy : get_center(coord, iTime * timescale);
|
||||||
|
|
||||||
|
#if CHEAP_NORMALS
|
||||||
|
float height = create_ripple(coord, center, t * 100.0 + 1.0, 100.0, 200.0, 1000.0);
|
||||||
|
vec2 normals = vec2(dFdx(height), dFdy(height));
|
||||||
|
#else
|
||||||
|
vec2 normals = get_normals(coord, center, t * 100.0 + 1.0, 100.0, 200.0, 1000.0);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if VIEW_HEIGHT
|
||||||
|
color = vec4(height);
|
||||||
|
#elif VIEW_NORMALS
|
||||||
|
color = vec4(normals, 0.5, 1.0);
|
||||||
|
#else
|
||||||
|
color = texture(iChannel0, uv + normals * ps);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//t = round(iTime) * 20.0;
|
||||||
|
|
||||||
|
//t = iTime;
|
||||||
|
//color = vec4(rand(uv, t));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user