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

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

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

SHKDynamicGrayNoise

shaderkit generative glsl runnable fragment MIT
code snippet
precision mediump float;
uniform float u_time;
varying vec2 v_tex_coord;
varying vec4 v_color_mix;
vec4 SKDefaultShading(){ return vec4(1.0); }
//
// Creates moving grayscale noise.
//
// This works using a simple (but brilliant!) and well-known trick: if you
// calculate the dot product of a texture coordinate with a vec2 containing
// two numbers that are unlikely to repeat, then calculate the sine of that
// and multiply it by a large number, you'll end up with what looks more or
// less like random numbers in the fraction digits – i.e., everything after
// the decimal place.
runnable fragment

SHKDynamicRainbowNoise

shaderkit material glsl runnable fragment MIT
code snippet
precision mediump float;
uniform float u_time;
varying vec2 v_tex_coord;
varying vec4 v_color_mix;
vec4 SKDefaultShading(){ return vec4(1.0); }
//
// Creates moving multi-colored noise.
//
// This works using a simple (but brilliant!) and well-known trick: if you
// calculate the dot product of a texture coordinate with a vec2 containing
// two numbers that are unlikely to repeat, then calculate the sine of that
// and multiply it by a large number, you'll end up with what looks more or
// less like random numbers in the fraction digits – i.e., everything after
// the decimal place.
runnable fragment

SHKStaticGrayNoise

shaderkit generative glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_tex_coord;
varying vec4 v_color_mix;
vec4 SKDefaultShading(){ return vec4(1.0); }
//
// Creates fixed grayscale noise.
//
// This works using a simple (but brilliant!) and well-known trick: if you
// calculate the dot product of a texture coordinate with a vec2 containing
// two numbers that are unlikely to repeat, then calculate the sine of that
// and multiply it by a large number, you'll end up with what looks more or
// less like random numbers in the fraction digits – i.e., everything after
// the decimal place.
//
runnable fragment

SHKStaticRainbowNoise

shaderkit material glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_tex_coord;
varying vec4 v_color_mix;
vec4 SKDefaultShading(){ return vec4(1.0); }
//
// Creates fixed multi-colored noise.
//
// This works using a simple (but brilliant!) and well-known trick: if you
// calculate the dot product of a texture coordinate with a vec2 containing
// two numbers that are unlikely to repeat, then calculate the sine of that
// and multiply it by a large number, you'll end up with what looks more or
// less like random numbers in the fraction digits – i.e., everything after
// the decimal place.
//
runnable fragment

SHKWater

shaderkit material glsl runnable fragment MIT
code snippet
precision mediump float;
uniform float u_time;
uniform sampler2D u_texture;
varying vec2 v_tex_coord;
varying vec4 v_color_mix;
//
// Warps a textured node to create a water rippling effect.
// NOTE: This must be applied to something that has a texture.
// Uniform: u_speed, how many fast to make the water ripple. Ranges from 0.5 to 10 work best; try starting with 3.
// Uniform: u_strength, how pronounced the rippling effect should be. Ranges from 1 to 5 work best; try starting with 3.
// Uniform: u_frequency, how often ripples should be created. Ranges from 5 to 25 work best; try starting with 10.
//
// This works by using a nearby pixel color rather than the original pixel color. Which neighbour is
// chosen depends on the algorithm: we pass the original coordinate, speed, and frequency
runnable fragment

Sidegrid

tangram-procedural-textures pattern glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texcoord;
vec2 tile(vec2 _st, float _zoom){
  _st *= _zoom;
  return fract(_st);
}

float X(vec2 _st, float _width){
  float pct0 = smoothstep(_st.x-_width,_st.x,_st.y);
  pct0 *= 1.-smoothstep(_st.x,_st.x+_width,_st.y);

  float pct1 = smoothstep(_st.x-_width,_st.x,1.0-_st.y);
  pct1 *= 1.-smoothstep(_st.x,_st.x+_width,1.0-_st.y);
runnable fragment

Star

tangram-procedural-textures pattern glsl runnable fragment MIT
code snippet
precision mediump float;
uniform float u_time;
varying vec2 v_texcoord;
#define PI 3.14159265358979323846
#define TWO_PI 6.28318530717958647693
#define PHI 1.618033988749894848204586834

vec2 radialTile(vec2 _st, vec2 _vel, float _zoom){
  vec2 toExtreme = vec2(0.5)-_st;
  vec2 polar = vec2( (PI+atan(toExtreme.y,toExtreme.x))/TWO_PI,   // Angle
                      log(length(toExtreme))*PHI*0.1);            // Radius
  polar *= _zoom;

  polar.y += _vel.y;
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

Wave

tangram-procedural-textures pattern glsl runnable fragment MIT
code snippet
precision mediump float;
varying vec2 v_texcoord;
#define PI 3.14159265358979323846

float plotX(vec2 _st, float _pct,float _antia){
  return  smoothstep( _pct-_antia, _pct, _st.x) - 
          smoothstep( _pct, _pct+_antia, _st.x);
}

float plotY(vec2 _st, float _pct,float _antia){
  return  smoothstep( _pct-_antia, _pct, _st.y) - 
          smoothstep( _pct, _pct+_antia, _st.y);
}
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);
}