Files
OldThink/Resources/Textures/Shaders/White/cyberglitch.swsl
Valtos f6b107353a - add: OldNeoInterface (#108)
* ebal

* setup gui

* AAAAAAAAAA EBLAN
2024-03-20 22:54:45 +03:00

79 lines
2.5 KiB
Plaintext

highp float hash11(highp float p)
{
p = fract(p * 0.1031);
p *= p + 33.33;
p *= p + p;
return fract(p);
}
highp float hash12(highp vec2 p)
{
highp vec3 p3 = fract(vec3(p.xyx) * 0.1031);
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.x + p3.y) * p3.z);
}
////////////////////////////////////////
highp float noise11( in highp float f ) //gradient noise 1D
{
highp float i = floor( f );
f -= i;
highp float u = f*f*(3.0-2.0*f);
return mix(hash11( i ), hash11( i + 1.0 ) , u);
}
highp float noise12( in highp vec2 f ) //gradient noise 2D
{
highp vec2 i = floor( f );
f -= i;
highp vec2 u = f*f*(3.0-2.0*f);
return mix( mix( hash12( i + vec2(0,0) ),
hash12( i + vec2(1,0) ), u.x),
mix( hash12( i + vec2(0,1) ),
hash12( i + vec2(1,1) ), u.x), u.y);
}
void fragment()
{
highp vec2 r = FRAGCOORD.xy;
highp vec2 uv = UV * 4.0;
highp float xs = noise11 (floor(uv.y*20.0))*sin(floor(uv.y*0.5)+TIME); //x-shift for big horizontal stripes
xs*=xs*xs;
highp float x = (uv.x+xs*0.0)*20.0 //vertical stripes
, cl = floor(x); //stripe id
x -= cl; //stripe local x
highp float h = hash11(cl-1.0); //color of previous stripe
h = mix(hash11(cl),h,step(x,sin(TIME+h*10.0)*0.4+0.4)); //mixing color of current and previous stripe to draw moving stripes
h = sin(h*0.7-noise11(uv.x-TIME*1.2)*2.0)*0.5+0.5; //adding big moving noise for stripes color
highp vec3 C = (vec3(0.5,0.5,0.6)+vec3(0.6,0.6,0.7)*cos(6.28318*(vec3(0.8,0.8,0.9)*h+vec3(0.3,0.3,0.4))))*0.5-0.45; //define background color using palette function
C = C * (0.5 + sin(uv.y*600.0)*0.5); //add small horizontal strips (like on analog TV)
cl = noise11 (floor((uv.x+xs*0.05)*200.0)+TIME)*noise12(vec2(uv.x*5.0,TIME)); // adding cyan vertical stripes to background
C = mix (C, vec3(1,1,1),cl*cl*cl*0.6);
cl = noise11 (floor(uv.y*200.0)+TIME)*noise12(vec2(uv.y*10.0,0)+TIME); //adding orange horizontal stripes to background
cl*=cl*cl;
C = mix (C, vec3(0.8,0.8,0.9),cl);
highp vec2 xy = uv+vec2((xs-cl)*0.05+0.1,0); //define the coords for the logo with offsets on the horizontal wide stripes and thin orange ones
h = noise11(TIME); //adding periodical "block coding artifacts"
x = 50.0; //num of cells
h = h*h*h*noise12(floor(uv*x)); //noise strength
xy = ((xy*x-floor(xy*x))*(1.0-h*0.6)+floor(xy*x))/x; //scale cells
C *= (0.9 + sin(uv.y*600.0)*0.2); //add small horizontal strips (like on analog TV)
COLOR = vec4(C,1.0);
}