Skip to content

Commit

Permalink
Add new shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed May 27, 2015
1 parent 2e86827 commit 02b11c0
Show file tree
Hide file tree
Showing 26 changed files with 1,213 additions and 8 deletions.
36 changes: 36 additions & 0 deletions screensaver.shadertoy/resources/ball.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const float PI=3.1415926535897932384626433832795;

// by maq/floppy
const float R=0.2; // to play
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec3 col;
vec2 uv = -0.5+fragCoord.xy / iResolution.xy;
uv.y*=0.66; // hack to get ar nice on 16:10
vec2 p = uv;
float d=sqrt(dot(p,p));
float fac,fac2;
if(d<R)
{
uv.x=p.x/(R+sqrt(R-d));
uv.y=p.y/(R+sqrt(R-d));
fac = 0.005;
fac2 = 5.0;
}
else
{
uv.x=p.x/(d*d);
uv.y=p.y/(d*d);
fac = 0.02;
fac2 = 25.0;
}

uv.x=uv.x-iMouse.x*fac+fac*500.0*sin(0.2*iGlobalTime);
uv.y=uv.y-iMouse.y*fac+fac*500.0*sin(0.4*iGlobalTime);
col = texture2D(iChannel0, uv/fac2).xyz;
col = col*exp(-3.0*(d-R)); // some lighting
col = col*(1.1-exp(-8.0*(abs(d-R)))); // and shading


fragColor = vec4(col,1.0);
}
21 changes: 21 additions & 0 deletions screensaver.shadertoy/resources/bleepyblocks.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// See: https://www.shadertoy.com/view/MsXSzM

#define TIMESCALE 0.25
#define TILES 8
#define COLOR 0.7, 1.6, 2.8

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord.xy / iResolution.xy;
uv.x *= iResolution.x / iResolution.y;

vec4 noise = texture2D(iChannel0, floor(uv * float(TILES)) / float(TILES));
float p = 1.0 - mod(noise.r + noise.g + noise.b + iGlobalTime * float(TIMESCALE), 1.0);
p = min(max(p * 3.0 - 1.8, 0.1), 2.0);

vec2 r = mod(uv * float(TILES), 1.0);
r = vec2(pow(r.x - 0.5, 2.0), pow(r.y - 0.5, 2.0));
p *= 1.0 - pow(min(1.0, 12.0 * dot(r, r)), 2.0);

fragColor = vec4(COLOR, 1.0) * p;
}
146 changes: 146 additions & 0 deletions screensaver.shadertoy/resources/fastclouds.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// https://www.shadertoy.com/view/XsjSRt

//Flaring by nimitz (twitter: @stormoid)

//change this value (1 to 5) or tweak the settings yourself.
//the gamma and spot brightness parameters can use negative values
#define TYPE 4

#if TYPE == 1
#define brightness 1.
#define ray_brightness 11.
#define gamma 5.
#define spot_brightness 4.
#define ray_density 1.5
#define curvature .1
#define red 7.
#define green 1.3
#define blue 1.
//1 -> ridged, 2 -> sinfbm, 3 -> pure fbm
#define noisetype 2
#define sin_freq 50. //for type 2
#elif TYPE == 2
#define brightness 1.5
#define ray_brightness 10.
#define gamma 8.
#define spot_brightness 15.
#define ray_density 3.5
#define curvature 15.
#define red 4.
#define green 1.
#define blue .1
#define noisetype 1
#define sin_freq 13.
#elif TYPE == 3
#define brightness 1.5
#define ray_brightness 20.
#define gamma 4.
#define spot_brightness .95
#define ray_density 3.14
#define curvature 17.
#define red 2.9
#define green .7
#define blue 3.5
#define noisetype 2
#define sin_freq 15.
#elif TYPE == 4
#define brightness 3.
#define ray_brightness 5.
#define gamma 6.
#define spot_brightness 1.5
#define ray_density 6.
#define curvature 90.
#define red 1.8
#define green 3.
#define blue .5
#define noisetype 1
#define sin_freq 6.
#define YO_DAWG
#elif TYPE == 5
#define brightness 2.
#define ray_brightness 5.
#define gamma 5.
#define spot_brightness 1.7
#define ray_density 30.
#define curvature 1.
#define red 1.
#define green 4.0
#define blue 4.9
#define noisetype 2
#define sin_freq 5. //for type 2
#endif


//#define PROCEDURAL_NOISE
//#define YO_DAWG


float hash( float n ){return fract(sin(n)*43758.5453);}

float noise( in vec2 x )
{
#ifdef PROCEDURAL_NOISE
x *= 1.75;
vec2 p = floor(x);
vec2 f = fract(x);

f = f*f*(3.0-2.0*f);

float n = p.x + p.y*57.0;

float res = mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x),
mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y);
return res;
#else
return texture2D(iChannel0, x*.01).x;
#endif
}

mat2 m2 = mat2( 0.80, 0.60, -0.60, 0.80 );
float fbm( in vec2 p )
{
float z=2.;
float rz = 0.;
p *= 0.25;
for (float i= 1.;i < 6.;i++ )
{
#if noisetype == 1
rz+= abs((noise(p)-0.5)*2.)/z;
#elif noisetype == 2
rz+= (sin(noise(p)*sin_freq)*0.5+0.5) /z;
#else
rz+= noise(p)/z;
#endif
z = z*2.;
p = p*2.*m2;
}
return rz;
}

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
float t = -iGlobalTime*0.03;
vec2 uv = fragCoord.xy / iResolution.xy-0.5;
uv.x *= iResolution.x/iResolution.y;
uv*= curvature*.05+0.0001;

float r = sqrt(dot(uv,uv));
float x = dot(normalize(uv), vec2(.5,0.))+t;
float y = dot(normalize(uv), vec2(.0,.5))+t;

#ifdef YO_DAWG
x = fbm(vec2(y*ray_density*0.5,r+x*ray_density*.2));
y = fbm(vec2(r+y*ray_density*0.1,x*ray_density*.5));
#endif

float val;
val = fbm(vec2(r+y*ray_density,r+x*ray_density-y));
val = smoothstep(gamma*.02-.1,ray_brightness+(gamma*0.02-.1)+.001,val);
val = sqrt(val);

vec3 col = val/vec3(red,green,blue);
col = clamp(1.-col,0.,1.);
col = mix(col,vec3(1.),spot_brightness-r/0.1/curvature*200./brightness);

fragColor = vec4(col,1.0);
}
146 changes: 146 additions & 0 deletions screensaver.shadertoy/resources/flaring.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// https://www.shadertoy.com/view/XsjSRt

//Flaring by nimitz (twitter: @stormoid)

//change this value (1 to 5) or tweak the settings yourself.
//the gamma and spot brightness parameters can use negative values
#define TYPE 4

#if TYPE == 1
#define brightness 1.
#define ray_brightness 11.
#define gamma 5.
#define spot_brightness 4.
#define ray_density 1.5
#define curvature .1
#define red 7.
#define green 1.3
#define blue 1.
//1 -> ridged, 2 -> sinfbm, 3 -> pure fbm
#define noisetype 2
#define sin_freq 50. //for type 2
#elif TYPE == 2
#define brightness 1.5
#define ray_brightness 10.
#define gamma 8.
#define spot_brightness 15.
#define ray_density 3.5
#define curvature 15.
#define red 4.
#define green 1.
#define blue .1
#define noisetype 1
#define sin_freq 13.
#elif TYPE == 3
#define brightness 1.5
#define ray_brightness 20.
#define gamma 4.
#define spot_brightness .95
#define ray_density 3.14
#define curvature 17.
#define red 2.9
#define green .7
#define blue 3.5
#define noisetype 2
#define sin_freq 15.
#elif TYPE == 4
#define brightness 3.
#define ray_brightness 5.
#define gamma 6.
#define spot_brightness 1.5
#define ray_density 6.
#define curvature 90.
#define red 1.8
#define green 3.
#define blue .5
#define noisetype 1
#define sin_freq 6.
#define YO_DAWG
#elif TYPE == 5
#define brightness 2.
#define ray_brightness 5.
#define gamma 5.
#define spot_brightness 1.7
#define ray_density 30.
#define curvature 1.
#define red 1.
#define green 4.0
#define blue 4.9
#define noisetype 2
#define sin_freq 5. //for type 2
#endif


//#define PROCEDURAL_NOISE
//#define YO_DAWG


float hash( float n ){return fract(sin(n)*43758.5453);}

float noise( in vec2 x )
{
#ifdef PROCEDURAL_NOISE
x *= 1.75;
vec2 p = floor(x);
vec2 f = fract(x);

f = f*f*(3.0-2.0*f);

float n = p.x + p.y*57.0;

float res = mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x),
mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y);
return res;
#else
return texture2D(iChannel0, x*.01).x;
#endif
}

mat2 m2 = mat2( 0.80, 0.60, -0.60, 0.80 );
float fbm( in vec2 p )
{
float z=2.;
float rz = 0.;
p *= 0.25;
for (float i= 1.;i < 6.;i++ )
{
#if noisetype == 1
rz+= abs((noise(p)-0.5)*2.)/z;
#elif noisetype == 2
rz+= (sin(noise(p)*sin_freq)*0.5+0.5) /z;
#else
rz+= noise(p)/z;
#endif
z = z*2.;
p = p*2.*m2;
}
return rz;
}

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
float t = -iGlobalTime*0.03;
vec2 uv = fragCoord.xy / iResolution.xy-0.5;
uv.x *= iResolution.x/iResolution.y;
uv*= curvature*.05+0.0001;

float r = sqrt(dot(uv,uv));
float x = dot(normalize(uv), vec2(.5,0.))+t;
float y = dot(normalize(uv), vec2(.0,.5))+t;

#ifdef YO_DAWG
x = fbm(vec2(y*ray_density*0.5,r+x*ray_density*.2));
y = fbm(vec2(r+y*ray_density*0.1,x*ray_density*.5));
#endif

float val;
val = fbm(vec2(r+y*ray_density,r+x*ray_density-y));
val = smoothstep(gamma*.02-.1,ray_brightness+(gamma*0.02-.1)+.001,val);
val = sqrt(val);

vec3 col = val/vec3(red,green,blue);
col = clamp(1.-col,0.,1.);
col = mix(col,vec3(1.),spot_brightness-r/0.1/curvature*200./brightness);

fragColor = vec4(col,1.0);
}
35 changes: 35 additions & 0 deletions screensaver.shadertoy/resources/juliasm.frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// See: https://www.shadertoy.com/view/XssXDr

const int max_iterations = 14;

vec2 complex_square( vec2 v ) {
return vec2(
v.x * v.x - v.y * v.y,
v.x * v.y * 2.0
);
}


void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord.yx - iResolution.yx * 0.5;
uv *= 2.5 / min( iResolution.x, iResolution.y );

vec2 c = vec2( 0.37+cos(iGlobalTime*1.23462673423)*0.04, sin(iGlobalTime*1.43472384234)*0.10+0.50);
vec2 v = uv;
float scale = 0.01;

float smoothcolor = exp(-length(v));

for ( int i = 0 ; i < max_iterations; i++ ) {
v = c + complex_square( v );
smoothcolor += exp(-length(v));
if ( dot( v, v ) > 4.0 ) {
break;
}
}
float r = 0.6+0.4*(sin(smoothcolor*0.1+iGlobalTime*0.63));
float g = r * r;
float b = r * g;
fragColor = vec4(r,g,b,0);
}
Loading

0 comments on commit 02b11c0

Please sign in to comment.