runnable fragment

Brushed Metal Anisotropy

stronghold-curated material glsl runnable fragment MIT
code snippet
precision mediump float;
uniform vec2 resolution;
uniform float time;
float hash(float n){return fract(sin(n)*43758.5453);} 
void main(){
 vec2 uv=gl_FragCoord.xy/resolution.xy;
 float row=floor(uv.y*520.0);
 float streak=hash(row)*0.18+hash(row+17.0)*0.08;
 float wave=0.08*sin(uv.x*46.0+hash(row)*6.283)+0.05*sin(uv.x*113.0+time*0.15);
 float shine=pow(max(0.0,1.0-abs(uv.y-0.48-wave)*3.2),3.0);
 vec3 base=mix(vec3(0.18,0.19,0.2),vec3(0.72,0.74,0.76),uv.x*0.35+0.35+streak);
 gl_FragColor=vec4(base+shine*vec3(0.42,0.5,0.58),1.0);
}
runnable fragment

Crystal Lattice Refraction

stronghold-curated material glsl runnable fragment MIT
code snippet
precision mediump float;
uniform vec2 resolution;
uniform float time;
vec2 hash(vec2 p){p=vec2(dot(p,vec2(127.1,311.7)),dot(p,vec2(269.5,183.3)));return fract(sin(p)*43758.5453);} 
void main(){
 vec2 uv=gl_FragCoord.xy/resolution.xy; uv.x*=resolution.x/resolution.y;
 vec2 g=uv*6.0; vec2 id=floor(g); vec2 f=fract(g);
 float d=9.0; vec2 nearest=vec2(0.0);
 for(int y=-1;y<=1;y++)for(int x=-1;x<=1;x++){vec2 o=vec2(float(x),float(y));vec2 r=hash(id+o);float nd=length(o+r-f);if(nd<d){d=nd;nearest=r;}}
 float facet=smoothstep(0.0,0.9,d);
 vec3 col=0.45+0.45*cos(vec3(0.0,2.2,4.1)+facet*6.0+nearest.x*3.0+time*0.15);
 gl_FragColor=vec4(col*(1.0-d*0.55)+0.18,1.0);
}
runnable fragment

Dune Height Lines

stronghold-curated material glsl runnable fragment MIT
code snippet
precision mediump float;
uniform vec2 resolution;
uniform float time;
float hash(vec2 p){return fract(sin(dot(p,vec2(13.1,117.7)))*43758.5453);} float noise(vec2 p){vec2 i=floor(p),f=fract(p);f=f*f*(3.0-2.0*f);return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),mix(hash(i+vec2(0,1)),hash(i+1.0),f.x),f.y);} 
float fbm(vec2 p){float v=0.0,a=.5;for(int i=0;i<5;i++){v+=a*noise(p);p*=2.;a*=.5;}return v;}
void main(){
 vec2 uv=gl_FragCoord.xy/resolution.xy; uv.x*=resolution.x/resolution.y; float h=fbm(uv*4.0+vec2(time*.015,0)); float ridges=sin((uv.x*2.5+h*1.4)*28.0); float crest=smoothstep(.65,1.0,ridges); vec3 sand=mix(vec3(.45,.28,.11),vec3(.95,.72,.38),h); gl_FragColor=vec4(sand+crest*.16,1.0);
}
runnable fragment

Iridescent Oil Slick

stronghold-curated material glsl runnable fragment MIT
code snippet
precision mediump float;
uniform vec2 resolution;
uniform float time;
float hash(vec2 p){return fract(sin(dot(p,vec2(12.989,78.233)))*43758.5453);} 
float noise(vec2 p){vec2 i=floor(p),f=fract(p);f=f*f*(3.0-2.0*f);return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),mix(hash(i+vec2(0,1)),hash(i+1.0),f.x),f.y);} 
void main(){
 vec2 uv=gl_FragCoord.xy/resolution.xy; uv.x*=resolution.x/resolution.y;
 float n=noise(uv*5.0+time*0.05)+0.5*noise(uv*13.0-time*0.04);
 float phase=n*8.0+uv.x*4.0-uv.y*3.0+time*0.15;
 vec3 rainbow=0.5+0.5*cos(phase+vec3(0.0,2.09,4.18));
 float sheen=smoothstep(0.2,1.0,n);
 gl_FragColor=vec4(mix(vec3(0.015,0.012,0.018), rainbow, sheen),1.0);
}
runnable fragment

Liquid Marble Material

stronghold-curated material glsl runnable fragment MIT
code snippet
precision mediump float;
uniform vec2 resolution;
uniform float time;
float hash(vec2 p){ return fract(sin(dot(p, vec2(41.0, 289.0))) * 45758.5453); }
float noise(vec2 p){ vec2 i=floor(p), f=fract(p); f=f*f*(3.0-2.0*f); return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),mix(hash(i+vec2(0,1)),hash(i+1.0),f.x),f.y); }
float fbm(vec2 p){ float v=0.0; float a=0.5; for(int i=0;i<5;i++){ v += a*noise(p); p*=2.05; a*=0.5; } return v; }
void main(){
  vec2 uv = gl_FragCoord.xy / resolution.xy;
  uv.x *= resolution.x / resolution.y;
  float n = fbm(uv * 3.0 + vec2(time * 0.035, -time * 0.02));
  float veins = sin((uv.x + n * 1.8) * 22.0);
  float line = smoothstep(0.72, 1.0, veins);
  vec3 stone = mix(vec3(0.08,0.09,0.11), vec3(0.78,0.82,0.86), n);
  vec3 vein = mix(vec3(0.02,0.025,0.035), vec3(0.9,0.75,0.55), line);
runnable fragment

Ocean Caustic Mesh

stronghold-curated material glsl runnable fragment MIT
code snippet
precision mediump float;
uniform vec2 resolution;
uniform float time;
void main(){
  vec2 uv=gl_FragCoord.xy/resolution.xy; uv.x*=resolution.x/resolution.y;
  float c=0.0;
  for(int i=0;i<5;i++){
    float fi=float(i)+1.0;
    vec2 p=uv*fi*2.4 + vec2(sin(time*0.25*fi), cos(time*0.18*fi));
    c += abs(sin(p.x*3.14159 + sin(p.y*2.2+time))) / fi;
    c += abs(sin(p.y*3.14159 + cos(p.x*2.0-time*0.7))) / fi;
  }
  c=pow(1.0-smoothstep(0.8,1.45,c/2.4),3.0);
  vec3 water=vec3(0.0,0.18,0.28)+vec3(0.02,0.28,0.38)*uv.y;
runnable fragment

Procedural Brick Weathering

stronghold-curated material glsl runnable fragment MIT
code snippet
precision mediump float;
uniform vec2 resolution;
uniform float time;
float hash(vec2 p){return fract(sin(dot(p,vec2(91.7,45.3)))*43758.5453);} 
float noise(vec2 p){vec2 i=floor(p),f=fract(p);f=f*f*(3.0-2.0*f);return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),mix(hash(i+vec2(0,1)),hash(i+1.0),f.x),f.y);} 
void main(){
 vec2 uv=gl_FragCoord.xy/resolution.xy; uv.x*=resolution.x/resolution.y; vec2 p=uv*vec2(8.0,5.0); p.x+=mod(floor(p.y),2.0)*0.5; vec2 f=fract(p); vec2 id=floor(p);
 float mortar=step(f.x,0.06)+step(0.94,f.x)+step(f.y,0.08)+step(0.92,f.y); float n=noise(uv*28.0)+0.5*noise(uv*71.0); vec3 brick=mix(vec3(0.32,0.08,0.035),vec3(0.72,0.24,0.12),hash(id)*0.6+n*0.25); vec3 col=mix(brick,vec3(0.48,0.43,0.36),clamp(mortar,0.0,1.0)); gl_FragColor=vec4(col,1.0);
}
runnable fragment

Solar Flare Surface

stronghold-curated material glsl runnable fragment MIT
code snippet
precision mediump float;
uniform vec2 resolution;
uniform float time;
float hash(vec2 p){return fract(sin(dot(p,vec2(19.19,73.17)))*43758.5453);} 
float noise(vec2 p){vec2 i=floor(p),f=fract(p);f=f*f*(3.0-2.0*f);return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),mix(hash(i+vec2(0,1)),hash(i+1.0),f.x),f.y);} 
float fbm(vec2 p){float v=0.0,a=0.5;for(int i=0;i<5;i++){v+=a*noise(p);p*=2.1;a*=0.5;}return v;}
void main(){
 vec2 uv=(gl_FragCoord.xy*2.0-resolution.xy)/min(resolution.x,resolution.y);
 float r=length(uv);
 float n=fbm(uv*4.0+time*0.22);
 float disk=smoothstep(0.72,0.66,r+n*0.05);
 float flare=pow(max(0.0,1.0-r),2.0)*0.7;
 vec3 col=mix(vec3(0.1,0.0,0.0), vec3(1.0,0.25,0.02), disk);
 col+=vec3(1.0,0.75,0.18)*(n*disk+flare);
runnable fragment

Velvet Fiber Sheen

stronghold-curated material glsl runnable fragment MIT
code snippet
precision mediump float;
uniform vec2 resolution;
uniform float time;
float hash(vec2 p){return fract(sin(dot(p,vec2(27.1,61.7)))*43758.5453);} 
void main(){
 vec2 uv=gl_FragCoord.xy/resolution.xy;
 float fibers=0.0;
 for(int i=0;i<4;i++){float fi=float(i); vec2 p=uv*vec2(30.0+fi*12.0,180.0); float r=hash(floor(p)+fi); fibers+=smoothstep(0.985,1.0,sin((uv.x*45.0+uv.y*9.0+fi)*3.14159+r*6.283));}
 float nap=pow(max(0.0,1.0-distance(uv,vec2(0.5+0.15*sin(time*.2),0.45))*1.7),2.0);
 vec3 col=mix(vec3(0.08,0.01,0.07),vec3(0.55,0.08,0.38),nap)+fibers*0.035;
 gl_FragColor=vec4(col,1.0);
}
runnable fragment

Wood Grain Material

stronghold-curated material glsl runnable fragment MIT
code snippet
precision mediump float;
uniform vec2 resolution;
uniform float time;
float hash(vec2 p){ return fract(sin(dot(p, vec2(13.13, 117.17))) * 43758.5453); }
float noise(vec2 p){ vec2 i=floor(p), f=fract(p); f=f*f*(3.0-2.0*f); return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),mix(hash(i+vec2(0,1)),hash(i+1.0),f.x),f.y); }
void main(){
 vec2 uv = gl_FragCoord.xy / resolution.xy; uv.x *= resolution.x/resolution.y;
 float n = noise(uv*9.0) + 0.5*noise(uv*22.0);
 float rings = sin((uv.x + n*0.09 + 0.02*sin(uv.y*18.0)) * 55.0);
 float grain = smoothstep(-0.2, 1.0, rings);
 vec3 dark = vec3(0.22,0.10,0.035), light = vec3(0.72,0.38,0.13);
 gl_FragColor = vec4(mix(dark, light, grain) * (0.75 + 0.25*n), 1.0);
}