Overlapping Slate Shingles shader

overlapping-slate-shingles.glsl · 75 lines · GLSL ES 3.00 · MIT

Overlapping Slate ShinglesStone & Masonry
Overlapping Slate Shingles WebGL2 procedural shader preview
FPS 60BUFFER 960×540SOURCE 75 linesSPEC GLSL ES 3.00

Seamless PNG Texture Baker
1-Click Engine Shader Export
WebGL2 .glsl
.glsl
Godot 4 .gdshader
Three.js GLSL3

Engine shader code & wrappers

Architectural Masonry
overlapping-slate-shingles.glsl (75 lines)
#version 300 es
// Overlapping Slate Shingles (overlapping-slate-shingles.glsl)
// Upstream study: https://github.com/gokayfem/glsl-studies/blob/main/construction/lib/10_overlapping_slate_shingles.glsl
// License: MIT (Copyright 2026 Gokay Aydogan) + MIT/CC0 helpers — https://pixelfx.io/LICENSE-SHADERS.txt
// Uniforms: uResolution (vec2), uTime (float)
// Credits: https://github.com/gokayfem/glsl-studies/blob/main/credit.md#shader-construction-lib-10-overlapping-slate-shingles
// Blue slate | double-lapped courses and a clipped-corner ornamental band.
// WebGL2: draw a fullscreen triangle. Set uResolution to the viewport in pixels.
precision highp float;
precision highp int;
uniform vec2 uResolution;
out vec4 fragColor;
vec2 screen(){return (gl_FragCoord.xy-.5*uResolution)/max(1.,min(uResolution.x,uResolution.y));}
float rnd(vec2 id){
    uvec2 p=uvec2(ivec2(floor(id)));
    uint v=p.x*1597334677u ^ p.y*3812015801u ^ 1013904223u;
    v=(v^(v>>16u))*2246822519u;
    return float(v^(v>>13u))*(1./4294967296.);
}
float noiseAt(vec2 p){
    vec2 i=floor(p),f=fract(p);f=f*f*(3.-2.*f);
    return mix(mix(rnd(i),rnd(i+vec2(1,0)),f.x),mix(rnd(i+vec2(0,1)),rnd(i+1.),f.x),f.y);
}
float fb(vec2 p){
    mat2 m=mat2(1.74,1.01,-1.01,1.74);
    return .55*noiseAt(p)+.27*noiseAt(m*p+11.)+.13*noiseAt(m*m*p-7.)+.05*noiseAt(m*m*m*p+29.);
}
mat2 rot(float a){return mat2(cos(a),sin(a),-sin(a),cos(a));}
float sq(float a){return a*a;}
float mask(float d,float aa){return 1.-smoothstep(-aa,aa,d);}
vec3 finish(vec3 col,vec2 uv){
    return clamp(col*(1.-.12*smoothstep(.16,.9,length(uv)))+.009*(rnd(gl_FragCoord.xy)-.5),0.,1.);
}

float cleavage(vec2 q,float seed){
    vec2 f=rot(seed*.6-.18)*q;
    return fb(f*vec2(2.3,8.)+seed*31.)+.19*noiseAt(f*vec2(9.,42.));
}
void main(){
    vec2 v=screen(),p=rot(-.185)*v*3.1;
    p.y*=1.42; p/=max(.68,1.-.12*p.y);
    vec3 col=vec3(.069,.080,.086);
    float aa=max(length(fwidth(p))*.42,.0003);
    for(int j=-1;j<=1;j++){
        float row=floor(p.y/.55)+float(j);
        float shift=.5*mod(row,2.)+.055*sin(row*7.);
        float cx=floor(p.x+shift);
        for(int i=-1;i<=1;i++){
            vec2 id=vec2(cx+float(i),row); float seed=rnd(id);
            vec2 q=p-vec2(id.x+.5-shift,row*.55);
            q=rot(.028*(seed-.5))*q;
            q.y+=.040*(rnd(id+31.)-.5);
            float tooth=.026*(fb(vec2(q.x*17.+id.x,row*14.))-.5)
                       +.010*(noiseAt(vec2(q.x*73.,seed*25.))-.5);
            float cut=(abs(row)<=.1 || abs(row-1.)<=.1)?.20:.021;
            float outline=max(max(abs(q.x)-.492,abs(q.y-.43)-.43),abs(q.x)-.492+cut-q.y);
            outline+=tooth;
            // Back, fractured laminae and top face are displaced along the view direction.
            float bottom=max(max(abs(q.x-.008)-.492,-q.y-.027),abs(q.x-.008)-.492+cut-q.y-.027)+tooth;
            float castEdge=max(max(abs(q.x-.022)-.505,-q.y-.061),abs(q.x-.022)-.51+cut-q.y-.061)+tooth*.6;
            col*=1.-.44*(1.-smoothstep(-.018,.065,castEdge))*step(q.y,.86);
            float side=max(bottom,q.y-.85);
            vec3 lamina=mix(vec3(.105,.132,.148),vec3(.32,.356,.36),
                            .41+.18*sin((q.y+tooth)*395.+6.*fb(q*24.+id))+.16*(noiseAt(q*93.+id)-.5));
            col=mix(col,lamina,mask(side,aa));
            float cleft=cleavage(q,seed);
            float terrace=fract(cleft*4.8);
            float lip=exp(-sq((terrace-.07)/.073));
            float frost=fb(q*4.+id*8.);
            vec3 rock=mix(vec3(.198,.249,.286),vec3(.39,.425,.428),.72*seed+.23*frost);
            rock+=.22*(cleft-.53)+.042*lip+.035*(noiseAt(q*105.+id)-.5);
            rock+=vec3(.085,.067,.038)*smoothstep(.58,.79,frost);
            rock+=.064*exp(-abs(outline+.008)*159.);
            col=mix(col,rock,mask(outline,aa));
        }
    }
    fragColor=vec4(finish(col,v),1);
}

Mathematical models & shader specifications

Identifieroverlapping-slate-shingles
CategoryStone & Masonry Shaders · Architectural Masonry
Upstream studyconstruction/lib/10_overlapping_slate_shingles.glsl (commit 1fbd084)
Animation cycleStatic analytical PBR surface
Declared uniformsuResolution
Source size75 lines · 3.4 KB standalone GLSL ES 3.00
PNG baker outputs512px · 1024px · 2048px RGBA8 (4-tap seamless + alpha key)
Companion pixel VFXFree MIT weather sprite sheets
LicenseMIT License + CC0 / MIT Helpers

Physical & shading models implemented

Procedural signed-distance and analytic surface shading

Adapted upstream mathematical helpers

Standalone GLSL ES 3.00 math primitives

All stone & masonry shaders
Board-Formed Concrete WebGL2 procedural shaderAnimated

Brutalist poured concrete imprinted with timber plank grain, form-tie cones, and air bug-holes.

Stone & Masonry