Back to shaders

Shader test bench

Wood Grain Material

stronghold-curated material glsl runnable fragment MIT
Source
runnable fragment

Complete GLSL fragment shader. Stronghold runs it directly when the browser can compile it.

Code

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);
}