Terracotta Clay Roof Tiles shader

terracotta-clay-roof-tiles.glsl · 95 lines · GLSL ES 3.00 · MIT

Terracotta Clay Roof TilesStone & Masonry
Terracotta Clay Roof Tiles WebGL2 procedural shader preview
FPS 60BUFFER 960×540SOURCE 95 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
terracotta-clay-roof-tiles.glsl (95 lines)
#version 300 es
// Terracotta Clay Roof Tiles (terracotta-clay-roof-tiles.glsl)
// Upstream study: https://github.com/gokayfem/glsl-studies/blob/main/construction/lib/13_clay_roof_tiles.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-13-clay-roof-tiles
// Mission clay roof | tapered cover shells over concave pans, seen at the open eave.
// 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 sat(float a){return clamp(a,0.,1.);}
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.);
}

vec3 fired(vec2 p,float seed,float light){
    vec2 k=p+seed*27.;
    float kiln=fb(k*2.9),sand=noiseAt(k*145.);
    float ash=fb(k*vec2(6.,2.1))+.23*fb(k*36.);
    vec3 clay=mix(vec3(.52,.225,.115),vec3(.87,.475,.255),.52*seed+.48*kiln);
    clay=mix(clay,vec3(.52,.343,.25),.72*smoothstep(.64,.87,ash));
    clay+=.10*(sand-.5)+.085*(fb(k*31.)-.5);
    return clay*light;
}
void main(){
    vec2 v=screen(),p=rot(-.16)*v*3.5; p.y*=1.37;
    p/=max(.71,1.-.095*p.y);
    float bottom=-1.58,aa=max(length(fwidth(p))*.58,.0005);
    // Eave board and limewashed wall are visible below open barrel mouths.
    vec3 col=vec3(.71,.636,.51)*(.83+.19*fb(p*5.));
    col*=.68+.32*smoothstep(.10,.53,bottom-p.y);
    if(p.y>bottom-.19)col=vec3(.245,.181,.127)*(.71+.44*fb(p*vec2(4.,57.)));
    float x=fract(p.x+.5)-.5,column=floor(p.x+.5);
    float row=floor((p.y-bottom)/.85),py=mod(p.y-bottom,.85);
    float panX=fract(p.x)-.5;
    float panLap=p.y-bottom-.13-.12*panX*panX+.030*(rnd(vec2(floor(p.x),11))-.5);
    py=mod(panLap,.85);
    float panSeed=rnd(vec2(floor(p.x),floor(panLap/.85)));
    float panDepth=sq(min(abs(x)-.50,0.)*2.);
    float panFront=bottom-.075+.15*panDepth;
    float panLight=.74+.34*sin((abs(x)-.5)*4.)+.22*(.5-x)-.18*panDepth;
    vec3 pan=fired(p,panSeed,panLight)*(.72+.28*smoothstep(0.,.09,py));
    pan+=vec3(.047,.026,.014)*exp(-sq((py-.018)/.012));
    col=mix(col,pan,mask(panFront-p.y,aa));
    for(int j=-1;j<=1;j++){
        float course=max(-1.,row)+float(j);
        if(course<0.)continue;
        float seed=rnd(vec2(column,course));float start=bottom+course*.85+.043*(seed-.5);
        float y=p.y-start;
        // Offset the front by the projected height of the outer and inner half-ellipses.
        float width=mix(.344,.276,sat(y/.99)),t=x/width;
        float z=sqrt(max(0.,1.-t*t));
        float profile=.28*z;float edgeY=y-profile;
        float shell=max(abs(x)-width,-edgeY);
        float light=.60+.61*max(0.,-.72*t+.58*z);
        float innerW=max(.01,width-.044),ti=x/innerW;
        float inner=.226*sqrt(max(0.,1.-ti*ti));
        float voidEdge=max(abs(x)-innerW,max(-y,y-inner));
        if(y<1.23){
            float front=max(abs(x)-width,max(-y,y-profile));
            vec3 cut=fired(p,seed,.76)+vec3(.048,.008,-.003);
            if(course<.5){
                col=mix(col,cut,mask(front,aa));
                vec3 inShade=fired(p,seed,.24+.24*sq(sat((x/innerW+1.)*.5)));
                col=mix(col,inShade,mask(voidEdge,aa));
            }else{
                float annulus=mask(front,aa)*(1.-mask(voidEdge,aa));
                col*=1.-.29*exp(-sq((y-inner+.015)/.055))*mask(abs(x)-innerW,aa);
                col=mix(col,cut,annulus);
            }
            vec3 cap=fired(p,seed,light);
            cap+=vec3(.084,.057,.033)*exp(-abs(edgeY-.017)*65.);
            cap*=.83+.17*smoothstep(.01,.08,abs(abs(t)-1.));
            col=mix(col,cap,mask(shell,aa));
        }
    }
    fragColor=vec4(finish(col,v),1);
}

Mathematical models & shader specifications

Identifierterracotta-clay-roof-tiles
CategoryStone & Masonry Shaders · Architectural Masonry
Upstream studyconstruction/lib/13_clay_roof_tiles.glsl (commit 1fbd084)
Animation cycleStatic analytical PBR surface
Declared uniformsuResolution
Source size95 lines · 4.2 KB standalone GLSL ES 3.00
PNG baker outputs512px · 1024px · 2048px RGBA8 (4-tap seamless + alpha key)
Companion pixel VFXFree MIT nature 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