Layered Pine Bark Plates shader

layered-pine-bark-plates.glsl · 74 lines · GLSL ES 3.00 · MIT

Layered Pine Bark PlatesFabrics & Organic
Layered Pine Bark Plates WebGL2 procedural shader preview
FPS 60BUFFER 960×540SOURCE 74 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

Bark, Scales & Flora
layered-pine-bark-plates.glsl (74 lines)
#version 300 es
// Layered Pine Bark Plates (layered-pine-bark-plates.glsl)
// Upstream study: https://github.com/gokayfem/glsl-studies/blob/main/plants/lib/13_pine_bark_plates.glsl
// License: MIT (Copyright 2026 Gokay Aydogan) + MIT/CC0 helpers — https://pixelfx.io/LICENSE-SHADERS.txt
// Uniforms: uResolution (vec2), uTime (float)
// Hash adapted from David Hoskins, Hash without Sine. See THIRD_PARTY_NOTICES.md.
// Credits: https://github.com/gokayfem/glsl-studies/blob/main/credit.md#shader-plants-lib-13-pine-bark-plates
// Mature ponderosa pine bark with fissured, exfoliating plates. uResolution only.
precision highp float;
uniform vec2 uResolution;
out vec4 fragColor;

float pixel(){ return 2.0 / min(uResolution.x, uResolution.y); }
vec2 screen(){ return (gl_FragCoord.xy - 0.5*uResolution)*pixel(); }
float hash(vec2 p){
    vec3 q=fract(vec3(p.xyx)*vec3(.1031,.1030,.0973));
    q+=dot(q,q.yzx+33.33);
    return fract((q.x+q.y)*q.z);
}
float noise2(vec2 p){
    vec2 i=floor(p), f=fract(p); f=f*f*(3.-2.*f);
    return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),
               mix(hash(i+vec2(0,1)),hash(i+1.),f.x),f.y);
}
float fbm(vec2 p){
    return .56*noise2(p)+.28*noise2(p*2.07+11.)+.16*noise2(p*4.13-5.);
}
vec3 bump(float height){
    return normalize(vec3(-dFdx(height)/pixel(),-dFdy(height)/pixel(),1.));
}

struct Plate{float gap;vec2 local;vec2 id;};
Plate fracture(vec2 g){
    float a=9.,b=9.;vec2 chosen=vec2(0),loc=vec2(0);
    for(int j=-1;j<=1;j++)for(int i=-1;i<=1;i++){
        vec2 id=floor(g)+vec2(i,j);
        vec2 v=g-id-.5-.71*(vec2(hash(id),hash(id+7.))-.5);
        float d=dot(v,v);
        if(d<a){b=a;a=d;chosen=id;loc=v;}else b=min(b,d);
    }
    return Plate((b-a)/max(.35,sqrt(b)+sqrt(a)),loc,chosen);
}
void main(){
    vec2 p=screen();
    vec2 g=p*vec2(3.15,1.63);
    g+=vec2(.35*sin(3.3*p.y)+.78*(fbm(p*vec2(5.,3.))-.5),
            .60*(fbm(p*6.+4.)-.5));
    Plate block=fracture(g);
    vec2 wood=vec2(p.x+.07*sin(5.*p.y+block.id.x),p.y);
    float fibre=fbm(wood*vec2(33.,7.));
    float grain=fbm(p*115.);
    // Nested shear fractures terminate inside the older, larger plate.
    Plate flake=fracture(g*vec2(2.4,2.9)+.30*fibre+block.id*.3);
    float edge=block.gap-.039-.051*(fibre-.5);
    float depth=smoothstep(-.028,.15,edge);
    float stepHeight=smoothstep(.002,.12,flake.gap+.025*(fibre-.5));
    float crown=.036*depth+.011*depth*stepHeight+.007*depth*fibre;
    crown+=.0025*depth*fbm(wood*vec2(53.,9.));
    crown+=.012*depth*clamp(-block.local.x+.4*block.local.y,-1.,1.);
    vec3 n=bump(crown);
    float illumination=max(0.,dot(n,normalize(vec3(-.59,.56,.58))));
    float age=hash(block.id+22.),scaleAge=hash(flake.id+2.);
    vec3 old=mix(vec3(.40,.235,.155),vec3(.70,.434,.246),age);
    vec3 exposed=mix(vec3(.64,.285,.135),vec3(.81,.51,.28),scaleAge);
    vec3 face=mix(old,exposed,(.24+.46*scaleAge)*stepHeight);
    float stria=fbm(wood*vec2(112.,17.)+block.id);
    float fibreSplit=smoothstep(.61,.77,stria)*smoothstep(.12,.32,edge);
    face*=.62+.29*fibre+.27*grain+.18*stria-.23*fibreSplit;
    // Cracks contain warm, rough fibre and a darker occluded core.
    vec3 crevice=mix(vec3(.079,.057,.050),vec3(.30,.168,.103),fibre*grain*1.6);
    face=mix(crevice,face,smoothstep(-.013,.075,edge));
    float slough=fbm(g*vec2(6.,3.)+fibre);
    face=mix(face,vec3(.57,.401,.275)*(.70+.36*stria),.26*smoothstep(.38,.76,slough)*depth);
    face*=.48+.69*illumination+.07*depth;
    face+=vec3(.097,.067,.037)*exp(-34.*abs(flake.gap-.09))*depth*stepHeight;
    fragColor=vec4(face*(.98-.045*dot(p,p)),1);
}

Mathematical models & shader specifications

Identifierlayered-pine-bark-plates
CategoryFabrics & Organic Shaders · Bark, Scales & Flora
Upstream studyplants/lib/13_pine_bark_plates.glsl (commit c3a6f6c)
Animation cycleStatic analytical PBR surface
Declared uniformsuResolution
Source size74 lines · 3.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

David Hoskins, hash

All fabrics & organic shaders
Sphagnum Forest Moss WebGL2 procedural shaderAnimated

Dense cushion of star-shaped emerald sphagnum moss heads glistening with capillary moisture.

Fabrics & Organic
Quilted Padded Fabric WebGL2 procedural shaderPBR Study

Diamond-stitched gambeson / flight-suit padding with pillows puffing between taut thread seams.

Fabrics & Organic