PBR StudyDeep pile velvet fabric with strong grazing retro-reflective rim sheen and brushed nap swirls.
Fabrics & Organic
woven-selvedge-denim.glsl · 88 lines · GLSL ES 3.00 · MIT
#version 300 es
// Woven Selvedge Fabric (woven-selvedge-denim.glsl)
// Upstream study: https://github.com/gokayfem/glsl-studies/blob/main/textiles/lib/10_woven_selvedge.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-textiles-lib-10-woven-selvedge
// Shuttle-woven selvedge | doubled-back ecru picks enclose a vermilion tracer.
// WebGL2: draw a fullscreen triangle with uResolution set to the framebuffer size.
precision highp float;
uniform vec2 uResolution;
out vec4 fragColor;
const float PI=3.14159265359;
const float TAU=6.28318530718;
float sq(float x) { return x*x; }
float hash(vec2 p) {
vec3 v=fract(p.xyx*vec3(.1031,.11369,.13787));
v+=dot(v,v.yzx+19.19);
return fract((v.x+v.y)*v.z);
}
float noise(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 pixel() { return 2./max(1.,min(uResolution.x,uResolution.y)); }
vec2 field() { return (gl_FragCoord.xy-.5*uResolution)*pixel(); }
mat2 turn(float a) { return mat2(cos(a),sin(a),-sin(a),cos(a)); }
float aa(float d,float footprint) { return 1.-smoothstep(-footprint*.55,footprint*.55,d); }
float band(float phase,float footprint) { return cos(phase)*exp(-.11*sq(min(footprint,12.))); }
vec3 backdrop(vec2 p,vec3 tint) {
return tint*(.86+.20*noise(p*3.)+.07*noise(p*32.)+.045*noise(p*130.));
}
vec3 spun(vec3 dye,float side,float phase,float fp) {
side=clamp(side,-1.,1.);
float crown=sqrt(max(0.,1.-side*side));
float helix=phase+2.5*asin(side);
float plies=band(helix,fp*10.);
float lint=band(3.*helix+side,fp*30.);
return dye*(.56+.39*crown-.19*side+.073*plies+.037*lint);
}
void main() {
vec2 p=turn(.27)*field();
float edge=.38+.098*sin(2.3*p.y)+.021*sin(7.*p.y);
vec2 g=vec2((p.x-edge)*17.,p.y*20.);
float fp=pixel()*20.;
vec3 c=backdrop(p,vec3(.45,.375,.30));
c*=1.-.45*exp(-max(g.x-.95,0.)*.98);
// A separate tightly set group of undyed warp ends closes the blue cloth.
float ix=floor(g.x+.5),iy=floor(g.y+.5);
float wobble=.055*sin(2.1*g.y+ix)+.032*sin(.72*g.y+ix*3.);
float x=g.x-ix-wobble;
float drift=.044*sin(1.5*g.x+iy*2.)*(1.-smoothstep(-4.,-.5,g.x));
float y=g.y-iy-drift;
float parity=1.-2.*mod(ix+iy,2.);
float zw=.29*parity*cos(PI*y);
float zf=-.29*parity*cos(PI*x);
float width=mix(.43,.38,hash(vec2(ix,5.)));
float warpMask=aa(abs(x)-width,fp)*step(ix,.1);
float weftMask=aa(abs(y)-.389,fp);
vec3 indigo=mix(vec3(.138,.228,.283),vec3(.29,.40,.43),hash(vec2(ix,3.))*.75);
vec3 dye=ix< -6.5?indigo:vec3(.83,.79,.64);
if(ix==-3. || ix==-4.) dye=vec3(.66,.204,.154);
vec3 warp=spun(dye,x/width,g.y*9.+ix,fp);
vec3 pick=mix(vec3(.40,.48,.48),vec3(.76,.73,.61),smoothstep(-7.,-5.5,g.x));
vec3 weft=spun(pick,y/.389,g.x*9.+iy,fp);
// The outer bend joins two successive picks and turns over the last end.
if(g.x>0.) {
float v=mod(g.y+.5,2.)-1.;
vec2 e=vec2(g.x/.65,v/.5);
float radius=length(e);
float signedDist=(radius-1.)*.55;
float theta=atan(e.y,max(e.x,.0001));
weftMask=aa(abs(signedDist)-.36,fp);
weft=spun(vec3(.78,.75,.63),signedDist/.36,theta*5.+floor(g.y*.5)*2.,fp);
zf=.29*sin(theta);
}
if(g.x<0.) c=vec3(.095,.105,.097);
warp*=.72+.28*smoothstep(-.22,.22,zw);
weft*=.73+.27*smoothstep(-.22,.22,zf);
float warpFront=smoothstep(-.09,.09,zw-zf);
// Contact shade follows the upper yarn across each change of shed.
warp*=1.-.21*(1.-warpFront)*exp(-sq((abs(y-.055)-.38)/.135));
weft*=1.-.23*warpFront*exp(-sq((abs(x-.06)-width)/.15));
c=mix(c,warp,warpMask);
c=mix(c,weft,weftMask);
c=mix(c,warp,warpFront*warpMask);
fragColor=vec4(c*(.96+.065*noise(p*2.)),1.);
}
shader_type canvas_item;
// Attach to a ColorRect, Sprite2D, or SubViewport texture baker in Godot 4.2+.
// Woven Selvedge Fabric — Godot 4 (canvas_item) wrapper
// Source: https://github.com/gokayfem/glsl-studies/blob/main/textiles/lib/10_woven_selvedge.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-textiles-lib-10-woven-selvedge
// Shuttle-woven selvedge | doubled-back ecru picks enclose a vermilion tracer.
// WebGL2: draw a fullscreen triangle with uResolution set to the framebuffer size.
const float PI=3.14159265359;
const float TAU=6.28318530718;
float sq(float x) { return x*x; }
float hash(vec2 p) {
vec3 v=fract(p.xyx*vec3(.1031,.11369,.13787));
v+=dot(v,v.yzx+19.19);
return fract((v.x+v.y)*v.z);
}
float noise(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 pixel() { return 2./max(1.,min(uResolution.x,uResolution.y)); }
vec2 field() { return (pfx_frag_xy-.5*uResolution)*pixel(); }
mat2 turn(float a) { return mat2(cos(a),sin(a),-sin(a),cos(a)); }
float aa(float d,float footprint) { return 1.-smoothstep(-footprint*.55,footprint*.55,d); }
float band(float phase,float footprint) { return cos(phase)*exp(-.11*sq(min(footprint,12.))); }
vec3 backdrop(vec2 p,vec3 tint) {
return tint*(.86+.20*noise(p*3.)+.07*noise(p*32.)+.045*noise(p*130.));
}
vec3 spun(vec3 dye,float side,float phase,float fp) {
side=clamp(side,-1.,1.);
float crown=sqrt(max(0.,1.-side*side));
float helix=phase+2.5*asin(side);
float plies=band(helix,fp*10.);
float lint=band(3.*helix+side,fp*30.);
return dye*(.56+.39*crown-.19*side+.073*plies+.037*lint);
}
void pixelfx_study_eval(vec2 pfx_frag_xy, out vec4 fragColor) {
vec2 p=turn(.27)*field();
float edge=.38+.098*sin(2.3*p.y)+.021*sin(7.*p.y);
vec2 g=vec2((p.x-edge)*17.,p.y*20.);
float fp=pixel()*20.;
vec3 c=backdrop(p,vec3(.45,.375,.30));
c*=1.-.45*exp(-max(g.x-.95,0.)*.98);
// A separate tightly set group of undyed warp ends closes the blue cloth.
float ix=floor(g.x+.5),iy=floor(g.y+.5);
float wobble=.055*sin(2.1*g.y+ix)+.032*sin(.72*g.y+ix*3.);
float x=g.x-ix-wobble;
float drift=.044*sin(1.5*g.x+iy*2.)*(1.-smoothstep(-4.,-.5,g.x));
float y=g.y-iy-drift;
float parity=1.-2.*mod(ix+iy,2.);
float zw=.29*parity*cos(PI*y);
float zf=-.29*parity*cos(PI*x);
float width=mix(.43,.38,hash(vec2(ix,5.)));
float warpMask=aa(abs(x)-width,fp)*step(ix,.1);
float weftMask=aa(abs(y)-.389,fp);
vec3 indigo=mix(vec3(.138,.228,.283),vec3(.29,.40,.43),hash(vec2(ix,3.))*.75);
vec3 dye=ix< -6.5?indigo:vec3(.83,.79,.64);
if(ix==-3. || ix==-4.) dye=vec3(.66,.204,.154);
vec3 warp=spun(dye,x/width,g.y*9.+ix,fp);
vec3 pick=mix(vec3(.40,.48,.48),vec3(.76,.73,.61),smoothstep(-7.,-5.5,g.x));
vec3 weft=spun(pick,y/.389,g.x*9.+iy,fp);
// The outer bend joins two successive picks and turns over the last end.
if(g.x>0.) {
float v=mod(g.y+.5,2.)-1.;
vec2 e=vec2(g.x/.65,v/.5);
float radius=length(e);
float signedDist=(radius-1.)*.55;
float theta=atan(e.y,max(e.x,.0001));
weftMask=aa(abs(signedDist)-.36,fp);
weft=spun(vec3(.78,.75,.63),signedDist/.36,theta*5.+floor(g.y*.5)*2.,fp);
zf=.29*sin(theta);
}
if(g.x<0.) c=vec3(.095,.105,.097);
warp*=.72+.28*smoothstep(-.22,.22,zw);
weft*=.73+.27*smoothstep(-.22,.22,zf);
float warpFront=smoothstep(-.09,.09,zw-zf);
// Contact shade follows the upper yarn across each change of shed.
warp*=1.-.21*(1.-warpFront)*exp(-sq((abs(y-.055)-.38)/.135));
weft*=1.-.23*warpFront*exp(-sq((abs(x-.06)-width)/.15));
c=mix(c,warp,warpMask);
c=mix(c,weft,weftMask);
c=mix(c,warp,warpFront*warpMask);
fragColor=vec4(c*(.96+.065*noise(p*2.)),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;
// Woven Selvedge Fabric — Godot 4 (spatial) wrapper
// Source: https://github.com/gokayfem/glsl-studies/blob/main/textiles/lib/10_woven_selvedge.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-textiles-lib-10-woven-selvedge
// Shuttle-woven selvedge | doubled-back ecru picks enclose a vermilion tracer.
// WebGL2: draw a fullscreen triangle with uResolution set to the framebuffer size.
const float PI=3.14159265359;
const float TAU=6.28318530718;
float sq(float x) { return x*x; }
float hash(vec2 p) {
vec3 v=fract(p.xyx*vec3(.1031,.11369,.13787));
v+=dot(v,v.yzx+19.19);
return fract((v.x+v.y)*v.z);
}
float noise(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 pixel() { return 2./max(1.,min(uResolution.x,uResolution.y)); }
vec2 field() { return (pfx_frag_xy-.5*uResolution)*pixel(); }
mat2 turn(float a) { return mat2(cos(a),sin(a),-sin(a),cos(a)); }
float aa(float d,float footprint) { return 1.-smoothstep(-footprint*.55,footprint*.55,d); }
float band(float phase,float footprint) { return cos(phase)*exp(-.11*sq(min(footprint,12.))); }
vec3 backdrop(vec2 p,vec3 tint) {
return tint*(.86+.20*noise(p*3.)+.07*noise(p*32.)+.045*noise(p*130.));
}
vec3 spun(vec3 dye,float side,float phase,float fp) {
side=clamp(side,-1.,1.);
float crown=sqrt(max(0.,1.-side*side));
float helix=phase+2.5*asin(side);
float plies=band(helix,fp*10.);
float lint=band(3.*helix+side,fp*30.);
return dye*(.56+.39*crown-.19*side+.073*plies+.037*lint);
}
void pixelfx_study_eval(vec2 pfx_frag_xy, out vec4 fragColor) {
vec2 p=turn(.27)*field();
float edge=.38+.098*sin(2.3*p.y)+.021*sin(7.*p.y);
vec2 g=vec2((p.x-edge)*17.,p.y*20.);
float fp=pixel()*20.;
vec3 c=backdrop(p,vec3(.45,.375,.30));
c*=1.-.45*exp(-max(g.x-.95,0.)*.98);
// A separate tightly set group of undyed warp ends closes the blue cloth.
float ix=floor(g.x+.5),iy=floor(g.y+.5);
float wobble=.055*sin(2.1*g.y+ix)+.032*sin(.72*g.y+ix*3.);
float x=g.x-ix-wobble;
float drift=.044*sin(1.5*g.x+iy*2.)*(1.-smoothstep(-4.,-.5,g.x));
float y=g.y-iy-drift;
float parity=1.-2.*mod(ix+iy,2.);
float zw=.29*parity*cos(PI*y);
float zf=-.29*parity*cos(PI*x);
float width=mix(.43,.38,hash(vec2(ix,5.)));
float warpMask=aa(abs(x)-width,fp)*step(ix,.1);
float weftMask=aa(abs(y)-.389,fp);
vec3 indigo=mix(vec3(.138,.228,.283),vec3(.29,.40,.43),hash(vec2(ix,3.))*.75);
vec3 dye=ix< -6.5?indigo:vec3(.83,.79,.64);
if(ix==-3. || ix==-4.) dye=vec3(.66,.204,.154);
vec3 warp=spun(dye,x/width,g.y*9.+ix,fp);
vec3 pick=mix(vec3(.40,.48,.48),vec3(.76,.73,.61),smoothstep(-7.,-5.5,g.x));
vec3 weft=spun(pick,y/.389,g.x*9.+iy,fp);
// The outer bend joins two successive picks and turns over the last end.
if(g.x>0.) {
float v=mod(g.y+.5,2.)-1.;
vec2 e=vec2(g.x/.65,v/.5);
float radius=length(e);
float signedDist=(radius-1.)*.55;
float theta=atan(e.y,max(e.x,.0001));
weftMask=aa(abs(signedDist)-.36,fp);
weft=spun(vec3(.78,.75,.63),signedDist/.36,theta*5.+floor(g.y*.5)*2.,fp);
zf=.29*sin(theta);
}
if(g.x<0.) c=vec3(.095,.105,.097);
warp*=.72+.28*smoothstep(-.22,.22,zw);
weft*=.73+.27*smoothstep(-.22,.22,zf);
float warpFront=smoothstep(-.09,.09,zw-zf);
// Contact shade follows the upper yarn across each change of shed.
warp*=1.-.21*(1.-warpFront)*exp(-sq((abs(y-.055)-.38)/.135));
weft*=1.-.23*warpFront*exp(-sq((abs(x-.06)-width)/.15));
c=mix(c,warp,warpMask);
c=mix(c,weft,weftMask);
c=mix(c,warp,warpFront*warpMask);
fragColor=vec4(c*(.96+.065*noise(p*2.)),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;
}
// Woven Selvedge Fabric — Three.js WebGL2 ShaderMaterial (GLSL3)
// Upstream study: https://github.com/gokayfem/glsl-studies/blob/main/textiles/lib/10_woven_selvedge.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-textiles-lib-10-woven-selvedge
// Shuttle-woven selvedge | doubled-back ecru picks enclose a vermilion tracer.
// WebGL2: draw a fullscreen triangle with uResolution set to the framebuffer size.
precision highp float;
uniform vec2 uResolution;
out vec4 fragColor;
const float PI=3.14159265359;
const float TAU=6.28318530718;
float sq(float x) { return x*x; }
float hash(vec2 p) {
vec3 v=fract(p.xyx*vec3(.1031,.11369,.13787));
v+=dot(v,v.yzx+19.19);
return fract((v.x+v.y)*v.z);
}
float noise(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 pixel() { return 2./max(1.,min(uResolution.x,uResolution.y)); }
vec2 field() { return (gl_FragCoord.xy-.5*uResolution)*pixel(); }
mat2 turn(float a) { return mat2(cos(a),sin(a),-sin(a),cos(a)); }
float aa(float d,float footprint) { return 1.-smoothstep(-footprint*.55,footprint*.55,d); }
float band(float phase,float footprint) { return cos(phase)*exp(-.11*sq(min(footprint,12.))); }
vec3 backdrop(vec2 p,vec3 tint) {
return tint*(.86+.20*noise(p*3.)+.07*noise(p*32.)+.045*noise(p*130.));
}
vec3 spun(vec3 dye,float side,float phase,float fp) {
side=clamp(side,-1.,1.);
float crown=sqrt(max(0.,1.-side*side));
float helix=phase+2.5*asin(side);
float plies=band(helix,fp*10.);
float lint=band(3.*helix+side,fp*30.);
return dye*(.56+.39*crown-.19*side+.073*plies+.037*lint);
}
void main() {
vec2 p=turn(.27)*field();
float edge=.38+.098*sin(2.3*p.y)+.021*sin(7.*p.y);
vec2 g=vec2((p.x-edge)*17.,p.y*20.);
float fp=pixel()*20.;
vec3 c=backdrop(p,vec3(.45,.375,.30));
c*=1.-.45*exp(-max(g.x-.95,0.)*.98);
// A separate tightly set group of undyed warp ends closes the blue cloth.
float ix=floor(g.x+.5),iy=floor(g.y+.5);
float wobble=.055*sin(2.1*g.y+ix)+.032*sin(.72*g.y+ix*3.);
float x=g.x-ix-wobble;
float drift=.044*sin(1.5*g.x+iy*2.)*(1.-smoothstep(-4.,-.5,g.x));
float y=g.y-iy-drift;
float parity=1.-2.*mod(ix+iy,2.);
float zw=.29*parity*cos(PI*y);
float zf=-.29*parity*cos(PI*x);
float width=mix(.43,.38,hash(vec2(ix,5.)));
float warpMask=aa(abs(x)-width,fp)*step(ix,.1);
float weftMask=aa(abs(y)-.389,fp);
vec3 indigo=mix(vec3(.138,.228,.283),vec3(.29,.40,.43),hash(vec2(ix,3.))*.75);
vec3 dye=ix< -6.5?indigo:vec3(.83,.79,.64);
if(ix==-3. || ix==-4.) dye=vec3(.66,.204,.154);
vec3 warp=spun(dye,x/width,g.y*9.+ix,fp);
vec3 pick=mix(vec3(.40,.48,.48),vec3(.76,.73,.61),smoothstep(-7.,-5.5,g.x));
vec3 weft=spun(pick,y/.389,g.x*9.+iy,fp);
// The outer bend joins two successive picks and turns over the last end.
if(g.x>0.) {
float v=mod(g.y+.5,2.)-1.;
vec2 e=vec2(g.x/.65,v/.5);
float radius=length(e);
float signedDist=(radius-1.)*.55;
float theta=atan(e.y,max(e.x,.0001));
weftMask=aa(abs(signedDist)-.36,fp);
weft=spun(vec3(.78,.75,.63),signedDist/.36,theta*5.+floor(g.y*.5)*2.,fp);
zf=.29*sin(theta);
}
if(g.x<0.) c=vec3(.095,.105,.097);
warp*=.72+.28*smoothstep(-.22,.22,zw);
weft*=.73+.27*smoothstep(-.22,.22,zf);
float warpFront=smoothstep(-.09,.09,zw-zf);
// Contact shade follows the upper yarn across each change of shed.
warp*=1.-.21*(1.-warpFront)*exp(-sq((abs(y-.055)-.38)/.135));
weft*=1.-.23*warpFront*exp(-sq((abs(x-.06)-width)/.15));
c=mix(c,warp,warpMask);
c=mix(c,weft,weftMask);
c=mix(c,warp,warpFront*warpMask);
fragColor=vec4(c*(.96+.065*noise(p*2.)),1.);
}
`;
export function createWovenSelvedgeDenimMaterial(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 | woven-selvedge-denim |
|---|---|
| Category | Fabrics & Organic Shaders · Woven & Knit Fabrics |
| Upstream study | textiles/lib/10_woven_selvedge.glsl (commit 1fbd084) |
| Animation cycle | Static analytical PBR surface |
| Declared uniforms | uResolution |
| Source size | 88 lines · 3.7 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 StudyDeep pile velvet fabric with strong grazing retro-reflective rim sheen and brushed nap swirls.
PBR StudyParallel tufted velveteen wales separated by crisp base-weave channels with fibrous sheen.
PBR StudyShingled metallic mylar discs tilting individually to throw glittering specular flashes.
PBR StudySmooth cherry and alder tree bark stretched horizontally by corky breathing lenticels.
PBR StudyChalk-white papery birch periderm curling back to expose warm cinnamon inner bark.
PBR StudyJigsaw puzzle plates of mature ponderosa pine bark terraced over dark resinous fissures.