PBR StudyRounded granite street setts polished smooth on their crowns with sandy compacted joints.
terracotta-clay-roof-tiles.glsl · 95 lines · GLSL ES 3.00 · MIT
#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);
}
shader_type canvas_item;
// Attach to a ColorRect, Sprite2D, or SubViewport texture baker in Godot 4.2+.
// Terracotta Clay Roof Tiles — Godot 4 (canvas_item) wrapper
// Source: https://github.com/gokayfem/glsl-studies/blob/main/construction/lib/13_clay_roof_tiles.glsl (MIT License)
// Drive uTime from GDScript if animating helper functions: material.set_shader_parameter("uTime", Time.get_ticks_msec() * 0.001 * u_speed)
uniform vec2 uResolution = vec2(1024.0, 1024.0);
uniform float uTime = 1.2;
uniform float u_speed : hint_range(0.0, 3.0, 0.05) = 1.0;
uniform float u_tiling : hint_range(0.25, 8.0, 0.25) = 1.0;
uniform vec4 u_tint : source_color = vec4(1.0, 0.722, 0.42, 1.0);
uniform float u_tint_mix : hint_range(0.0, 1.0, 0.01) = 0.0;
uniform float uOpen : hint_range(0.0, 1.0, 0.01) = 0.0;
uniform int uLightMode : hint_range(0, 3, 1) = 0;
uniform int uCamMode : hint_range(0, 1, 1) = 1;
uniform bool u_luma_alpha_key = false;
// 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.
vec2 screen(){return (pfx_frag_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(pfx_frag_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 pixelfx_study_eval(vec2 pfx_frag_xy, out vec4 fragColor){
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);
}
void fragment() {
vec2 tiled_uv = fract(UV * u_tiling);
vec2 frag_xy = vec2(tiled_uv.x, 1.0 - tiled_uv.y) * uResolution;
vec4 study_col = vec4(0.0, 0.0, 0.0, 1.0);
pixelfx_study_eval(frag_xy, study_col);
vec3 tinted = clamp(mix(study_col.rgb, study_col.rgb * u_tint.rgb * 1.35, u_tint_mix), 0.0, 1.0);
float out_alpha = study_col.a * COLOR.a;
if (u_luma_alpha_key) {
float luma = dot(tinted, vec3(0.2126, 0.7152, 0.0722));
out_alpha *= smoothstep(0.035, 0.22, luma);
}
COLOR = vec4(tinted, out_alpha);
}
shader_type spatial;
render_mode cull_disabled;
// Terracotta Clay Roof Tiles — Godot 4 (spatial) wrapper
// Source: https://github.com/gokayfem/glsl-studies/blob/main/construction/lib/13_clay_roof_tiles.glsl (MIT License)
// Drive uTime from GDScript if animating helper functions: material.set_shader_parameter("uTime", Time.get_ticks_msec() * 0.001 * u_speed)
uniform vec2 uResolution = vec2(1024.0, 1024.0);
uniform float uTime = 1.2;
uniform float u_speed : hint_range(0.0, 3.0, 0.05) = 1.0;
uniform float u_tiling : hint_range(0.25, 8.0, 0.25) = 1.0;
uniform vec4 u_tint : source_color = vec4(1.0, 0.722, 0.42, 1.0);
uniform float u_tint_mix : hint_range(0.0, 1.0, 0.01) = 0.0;
uniform float uOpen : hint_range(0.0, 1.0, 0.01) = 0.0;
uniform int uLightMode : hint_range(0, 3, 1) = 0;
uniform int uCamMode : hint_range(0, 1, 1) = 1;
uniform bool u_luma_alpha_key = false;
// 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.
vec2 screen(){return (pfx_frag_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(pfx_frag_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 pixelfx_study_eval(vec2 pfx_frag_xy, out vec4 fragColor){
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);
}
void fragment() {
vec2 tiled_uv = fract(UV * u_tiling);
vec2 frag_xy = vec2(tiled_uv.x, 1.0 - tiled_uv.y) * uResolution;
vec4 study_col = vec4(0.0, 0.0, 0.0, 1.0);
pixelfx_study_eval(frag_xy, study_col);
vec3 tinted = clamp(mix(study_col.rgb, study_col.rgb * u_tint.rgb * 1.35, u_tint_mix), 0.0, 1.0);
float luma = dot(tinted, vec3(0.2126, 0.7152, 0.0722));
ALBEDO = tinted;
ROUGHNESS = clamp(0.85 - luma * 0.45, 0.08, 0.96);
METALLIC = 0.04;
EMISSION = tinted * 0.0;
}
// Terracotta Clay Roof Tiles — Three.js WebGL2 ShaderMaterial (GLSL3)
// Upstream study: https://github.com/gokayfem/glsl-studies/blob/main/construction/lib/13_clay_roof_tiles.glsl (MIT License)
import * as THREE from 'three';
const vertexShader = /* glsl */ `
out vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`;
const fragmentShader = /* glsl */ `
// 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);
}
`;
export function createTerracottaClayRoofTilesMaterial(width = 1024, height = 1024) {
const material = new THREE.ShaderMaterial({
glslVersion: THREE.GLSL3,
vertexShader,
fragmentShader,
uniforms: {
uResolution: { value: new THREE.Vector2(width, height) },
uTime: { value: 1.2 },
uOpen: { value: 0.0 },
uLightMode: { value: 0 },
uCamMode: { value: 1 },
},
});
return {
material,
update(elapsedSeconds) {
material.uniforms.uTime.value = elapsedSeconds * 1.0;
},
resize(nextW, nextH) {
material.uniforms.uResolution.value.set(nextW, nextH);
},
};
}
| Identifier | terracotta-clay-roof-tiles |
|---|---|
| Category | Stone & Masonry Shaders · Architectural Masonry |
| Upstream study | construction/lib/13_clay_roof_tiles.glsl (commit 1fbd084) |
| Animation cycle | Static analytical PBR surface |
| Declared uniforms | uResolution |
| Source size | 95 lines · 4.2 KB standalone GLSL ES 3.00 |
| PNG baker outputs | 512px · 1024px · 2048px RGBA8 (4-tap seamless + alpha key) |
| Companion pixel VFX | Free MIT nature sprite sheets |
| License | MIT License + CC0 / MIT Helpers |
Procedural signed-distance and analytic surface shading
Standalone GLSL ES 3.00 math primitives
PBR StudyRounded granite street setts polished smooth on their crowns with sandy compacted joints.
AnimatedCrushed basalt road aggregate in dark bitumen binder crossed by glossy poured-tar crack sealant.
AnimatedBrutalist poured concrete imprinted with timber plank grain, form-tie cones, and air bug-holes.
AnimatedRain-soaked street puddle with thin-film rainbow petroleum sheen lapping aggregate stones.
AnimatedTroweled lime-terracotta facade plaster with hairline craze cracks and sun-bleached wash.
AnimatedConcentric chalcedony fortification bands growing inward toward a crystalline quartz cavity.