PBR StudyKeeled diamond dragon and serpent scales imbricated over flexible interstitial skin.
Fabrics & Organic
layered-pine-bark-plates.glsl · 74 lines · GLSL ES 3.00 · MIT
#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);
}
shader_type canvas_item;
// Attach to a ColorRect, Sprite2D, or SubViewport texture baker in Godot 4.2+.
// Layered Pine Bark Plates — Godot 4 (canvas_item) wrapper
// Source: https://github.com/gokayfem/glsl-studies/blob/main/plants/lib/13_pine_bark_plates.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;
// 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.
float pixel(){ return 2.0 / min(uResolution.x, uResolution.y); }
vec2 screen(){ return (pfx_frag_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 pixelfx_study_eval(vec2 pfx_frag_xy, out vec4 fragColor){
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);
}
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;
// Layered Pine Bark Plates — Godot 4 (spatial) wrapper
// Source: https://github.com/gokayfem/glsl-studies/blob/main/plants/lib/13_pine_bark_plates.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;
// 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.
float pixel(){ return 2.0 / min(uResolution.x, uResolution.y); }
vec2 screen(){ return (pfx_frag_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 pixelfx_study_eval(vec2 pfx_frag_xy, out vec4 fragColor){
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);
}
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;
}
// Layered Pine Bark Plates — Three.js WebGL2 ShaderMaterial (GLSL3)
// Upstream study: https://github.com/gokayfem/glsl-studies/blob/main/plants/lib/13_pine_bark_plates.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 */ `
// 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);
}
`;
export function createLayeredPineBarkPlatesMaterial(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 | layered-pine-bark-plates |
|---|---|
| Category | Fabrics & Organic Shaders · Bark, Scales & Flora |
| Upstream study | plants/lib/13_pine_bark_plates.glsl (commit c3a6f6c) |
| Animation cycle | Static analytical PBR surface |
| Declared uniforms | uResolution |
| Source size | 74 lines · 3.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
David Hoskins, hash
PBR StudyKeeled diamond dragon and serpent scales imbricated over flexible interstitial skin.
AnimatedCycloid silver-blue scales with concentric growth circuli and guanine thin-film shimmer.
AnimatedDense cushion of star-shaped emerald sphagnum moss heads glistening with capillary moisture.
AnimatedBranching cyan-green fungal rhizomorph veins pulsing across damp cavern bark.
PBR StudyPlush uncut cotton yarn loops casting soft micro-occlusion across woven backing.
PBR StudyDiamond-stitched gambeson / flight-suit padding with pillows puffing between taut thread seams.