Add WIP shaders

This commit is contained in:
polyfloyd 2018-05-19 17:23:49 +02:00
parent 07d6d1dee5
commit ae07b0daf8
27 changed files with 3172 additions and 0 deletions

60
cyan-bubbles.glsl Normal file
View file

@ -0,0 +1,60 @@
#define ROWS 9
#define COLS 12.
#define PI 3.14159265359
#define TAU 6.28318530718
#define es (4./iResolution.y)
#define initialRad .175
#define waveCenter .4325
#define waveWidth .205
#define colDelta PI/COLS
#define rMat(x) mat2(cos(x), -sin(x), sin(x), cos(x))
#define dotRad(x) TAU*x/float(COLS)*.25
#define CLR vec3(.388, .843, .976)
float rm(float value, float min, float max) {
return clamp((value - min) / (max - min), 0., 1.);
}
float calcRowRad(int rowNum){
float rad = initialRad;
//FIXME codeblock below could be replaced with non conditional expression,
// but in some reason it don't work. Any ideas?
//rad += step(0., sin(iTime)) * step(0., cos(iTime)) * .066;
{
float s = sin(iTime * 4.);
float c = cos(iTime * 4.);
if(s > 0. && c > 0.)
rad += s * .066;
}
for(int i=0; i<rowNum; i++)
rad += dotRad(rad) * 1.33;
return rad;
}
float clr(float r, float a){
vec2 st = vec2(r * cos(a), r * sin(a));
float clr = 0.;
for(int j = 0; j < ROWS; j++){
float rowRad = calcRowRad(j);
vec2 dotCenter = vec2(rowRad, 0.) * rMat(colDelta * mod(float(j), 2.));
float dotRad = dotRad(rowRad);
float dotClr = smoothstep(dotRad, dotRad - es, length(st - dotCenter));
float thickness = pow(rm(abs(length(dotCenter) - waveCenter), 0., waveWidth), 1.25);
dotClr *= smoothstep(dotRad * thickness - es, dotRad * thickness, length(st - dotCenter));
dotClr *= step(es, 1. - thickness);
clr += dotClr;
}
return clr;
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 st = (fragCoord.xy * 2. - iResolution.xy)/iResolution.y;
float delta = PI/COLS*2.;
float l = length(st);
float a = mod(atan(st.y, st.x), delta) - delta/4.;
fragColor = vec4(clr(l, a) * CLR, 1.);
}
// https://www.shadertoy.com/view/Xl2Bz3