PBR StudyParallel tufted velveteen wales separated by crisp base-weave channels with fibrous sheen.
Fabrics & Organic
crushed-grazing-velvet.glsl · 91 lines · GLSL ES 3.00 · MIT
#version 300 es
// Crushed Grazing Velvet (crushed-grazing-velvet.glsl)
// Upstream study: https://github.com/gokayfem/glsl-studies/blob/main/textiles/lib/12_velvet.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-12-velvet
// Cut velvet | light grazes a folded and brushed garnet pile.
// 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 sat(float x) { return clamp(x,0.,1.); }
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.))); }
float drape(vec2 p) {
float tuck=2.4*p.x+.95*p.y+.38*sin(2.2*p.y);
return .17*sin(tuck)-.115*exp(-sq((tuck-.18)*1.9))
+.075*sin(4.9*p.y-1.9*p.x+.62*sin(2.*p.x));
}
vec3 pile(vec2 p,float face,float fp) {
float e=.003;
vec2 deriv=vec2(drape(p+vec2(e,0))-drape(p-vec2(e,0)),drape(p+vec2(0,e))-drape(p-vec2(0,e)))/(2.*e);
vec3 n=normalize(vec3(-deriv,1.));
// A dragged hand bends adjacent fibres along a broad curved path.
float trail=p.y+.36*sin(2.1*p.x)-.17*p.x;
float brush=exp(-sq((trail-.09)*3.9))*(.79+.21*noise(p*4.));
float lay=1.03+face*1.82+2.05*brush+.58*deriv.x+.32*(noise(p*6.)-.5);
vec2 axis=vec2(cos(lay),sin(lay));
float nap=dot(axis,normalize(vec2(-.75,.53)));
vec3 light=normalize(vec3(-.77,.48,.39));
float rake=sat(.45+.80*dot(n,light));
float sheen=pow(rake,1.9)*(.49+.49*nap);
vec3 c=vec3(.255,.051,.108)*(.63+.53*rake)+vec3(.57,.188,.263)*sheen;
vec2 g=p*117., cell=floor(g);
float footprint=fp*117.;
float radiance=0.;
// Resolve directional shafts at gallery resolution, then average the
// unresolved material response at a lower sampling density.
for(int j=-1;j<=1;j++) for(int i=-1;i<=1;i++) {
vec2 id=cell+vec2(i,j);
float seed=hash(id);
vec2 start=id+vec2(hash(id+7.),seed);
vec2 direction=turn((seed-.5)*.88)*axis;
float len=.62+.70*hash(id+13.);
vec2 rel=g-start;
float t=sat(dot(rel,direction)/len);
float dist=length(rel-direction*len*t);
float fibre=aa(dist-(.067+.044*(1.-t)),max(.025,footprint));
radiance+=fibre*mix(-.21,.64,t)*(.55+.45*seed);
}
vec2 perp=vec2(-axis.y,axis.x);
float fluff=.56*noise(p*80.)+.44*noise(p*36.+axis*.7);
// Evaluate the fine sheen in the tuft's local frame to keep it aligned
// with the shafts even where the brushed direction turns sharply.
float fibrePhase=dot(fract(g)-.5,perp)*TAU+TAU*hash(cell);
float fly=.5+.5*band(fibrePhase,fp*735.);
c*=.79+.26*fluff+.065*fly+radiance*(1.-smoothstep(.64,1.7,footprint));
return c;
}
void main() {
vec2 p=turn(-.18)*field();
float fp=pixel();
float crest=p.y+.61+.22*p.x-.12*sin(2.1*p.x);
vec3 c=pile(p,0.,fp)*(1.-.64*exp(-max(crest,0.)*13.));
// Velvet turned back onto itself exposes the cut tips in profile at the lip.
float nap=.009*noise(vec2(p.x*278.,3.))+.006*noise(vec2(p.x*88.,6.));
vec2 folded=vec2(p.x+.18,crest*.82-.32);
vec3 face=pile(folded,1.,fp);
face+=vec3(.18,.076,.11)*exp(-sq((crest+.055)*11.));
face*=.86+.14*smoothstep(-.12,0.,crest);
c=mix(c,face,aa(crest-nap,fp));
float tips=exp(-sq((crest-nap)*170.));
c+=vec3(.077,.035,.044)*tips*(.4+.6*noise(vec2(p.x*172.,1.)));
fragColor=vec4(c,1.);
}
shader_type canvas_item;
// Attach to a ColorRect, Sprite2D, or SubViewport texture baker in Godot 4.2+.
// Crushed Grazing Velvet — Godot 4 (canvas_item) wrapper
// Source: https://github.com/gokayfem/glsl-studies/blob/main/textiles/lib/12_velvet.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-12-velvet
// Cut velvet | light grazes a folded and brushed garnet pile.
// WebGL2: draw a fullscreen triangle with uResolution set to the framebuffer size.
const float PI=3.14159265359;
const float TAU=6.28318530718;
float sat(float x) { return clamp(x,0.,1.); }
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.))); }
float drape(vec2 p) {
float tuck=2.4*p.x+.95*p.y+.38*sin(2.2*p.y);
return .17*sin(tuck)-.115*exp(-sq((tuck-.18)*1.9))
+.075*sin(4.9*p.y-1.9*p.x+.62*sin(2.*p.x));
}
vec3 pile(vec2 p,float face,float fp) {
float e=.003;
vec2 deriv=vec2(drape(p+vec2(e,0))-drape(p-vec2(e,0)),drape(p+vec2(0,e))-drape(p-vec2(0,e)))/(2.*e);
vec3 n=normalize(vec3(-deriv,1.));
// A dragged hand bends adjacent fibres along a broad curved path.
float trail=p.y+.36*sin(2.1*p.x)-.17*p.x;
float brush=exp(-sq((trail-.09)*3.9))*(.79+.21*noise(p*4.));
float lay=1.03+face*1.82+2.05*brush+.58*deriv.x+.32*(noise(p*6.)-.5);
vec2 axis=vec2(cos(lay),sin(lay));
float nap=dot(axis,normalize(vec2(-.75,.53)));
vec3 light=normalize(vec3(-.77,.48,.39));
float rake=sat(.45+.80*dot(n,light));
float sheen=pow(rake,1.9)*(.49+.49*nap);
vec3 c=vec3(.255,.051,.108)*(.63+.53*rake)+vec3(.57,.188,.263)*sheen;
vec2 g=p*117., cell=floor(g);
float footprint=fp*117.;
float radiance=0.;
// Resolve directional shafts at gallery resolution, then average the
// unresolved material response at a lower sampling density.
for(int j=-1;j<=1;j++) for(int i=-1;i<=1;i++) {
vec2 id=cell+vec2(i,j);
float seed=hash(id);
vec2 start=id+vec2(hash(id+7.),seed);
vec2 direction=turn((seed-.5)*.88)*axis;
float len=.62+.70*hash(id+13.);
vec2 rel=g-start;
float t=sat(dot(rel,direction)/len);
float dist=length(rel-direction*len*t);
float fibre=aa(dist-(.067+.044*(1.-t)),max(.025,footprint));
radiance+=fibre*mix(-.21,.64,t)*(.55+.45*seed);
}
vec2 perp=vec2(-axis.y,axis.x);
float fluff=.56*noise(p*80.)+.44*noise(p*36.+axis*.7);
// Evaluate the fine sheen in the tuft's local frame to keep it aligned
// with the shafts even where the brushed direction turns sharply.
float fibrePhase=dot(fract(g)-.5,perp)*TAU+TAU*hash(cell);
float fly=.5+.5*band(fibrePhase,fp*735.);
c*=.79+.26*fluff+.065*fly+radiance*(1.-smoothstep(.64,1.7,footprint));
return c;
}
void pixelfx_study_eval(vec2 pfx_frag_xy, out vec4 fragColor) {
vec2 p=turn(-.18)*field();
float fp=pixel();
float crest=p.y+.61+.22*p.x-.12*sin(2.1*p.x);
vec3 c=pile(p,0.,fp)*(1.-.64*exp(-max(crest,0.)*13.));
// Velvet turned back onto itself exposes the cut tips in profile at the lip.
float nap=.009*noise(vec2(p.x*278.,3.))+.006*noise(vec2(p.x*88.,6.));
vec2 folded=vec2(p.x+.18,crest*.82-.32);
vec3 face=pile(folded,1.,fp);
face+=vec3(.18,.076,.11)*exp(-sq((crest+.055)*11.));
face*=.86+.14*smoothstep(-.12,0.,crest);
c=mix(c,face,aa(crest-nap,fp));
float tips=exp(-sq((crest-nap)*170.));
c+=vec3(.077,.035,.044)*tips*(.4+.6*noise(vec2(p.x*172.,1.)));
fragColor=vec4(c,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;
// Crushed Grazing Velvet — Godot 4 (spatial) wrapper
// Source: https://github.com/gokayfem/glsl-studies/blob/main/textiles/lib/12_velvet.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-12-velvet
// Cut velvet | light grazes a folded and brushed garnet pile.
// WebGL2: draw a fullscreen triangle with uResolution set to the framebuffer size.
const float PI=3.14159265359;
const float TAU=6.28318530718;
float sat(float x) { return clamp(x,0.,1.); }
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.))); }
float drape(vec2 p) {
float tuck=2.4*p.x+.95*p.y+.38*sin(2.2*p.y);
return .17*sin(tuck)-.115*exp(-sq((tuck-.18)*1.9))
+.075*sin(4.9*p.y-1.9*p.x+.62*sin(2.*p.x));
}
vec3 pile(vec2 p,float face,float fp) {
float e=.003;
vec2 deriv=vec2(drape(p+vec2(e,0))-drape(p-vec2(e,0)),drape(p+vec2(0,e))-drape(p-vec2(0,e)))/(2.*e);
vec3 n=normalize(vec3(-deriv,1.));
// A dragged hand bends adjacent fibres along a broad curved path.
float trail=p.y+.36*sin(2.1*p.x)-.17*p.x;
float brush=exp(-sq((trail-.09)*3.9))*(.79+.21*noise(p*4.));
float lay=1.03+face*1.82+2.05*brush+.58*deriv.x+.32*(noise(p*6.)-.5);
vec2 axis=vec2(cos(lay),sin(lay));
float nap=dot(axis,normalize(vec2(-.75,.53)));
vec3 light=normalize(vec3(-.77,.48,.39));
float rake=sat(.45+.80*dot(n,light));
float sheen=pow(rake,1.9)*(.49+.49*nap);
vec3 c=vec3(.255,.051,.108)*(.63+.53*rake)+vec3(.57,.188,.263)*sheen;
vec2 g=p*117., cell=floor(g);
float footprint=fp*117.;
float radiance=0.;
// Resolve directional shafts at gallery resolution, then average the
// unresolved material response at a lower sampling density.
for(int j=-1;j<=1;j++) for(int i=-1;i<=1;i++) {
vec2 id=cell+vec2(i,j);
float seed=hash(id);
vec2 start=id+vec2(hash(id+7.),seed);
vec2 direction=turn((seed-.5)*.88)*axis;
float len=.62+.70*hash(id+13.);
vec2 rel=g-start;
float t=sat(dot(rel,direction)/len);
float dist=length(rel-direction*len*t);
float fibre=aa(dist-(.067+.044*(1.-t)),max(.025,footprint));
radiance+=fibre*mix(-.21,.64,t)*(.55+.45*seed);
}
vec2 perp=vec2(-axis.y,axis.x);
float fluff=.56*noise(p*80.)+.44*noise(p*36.+axis*.7);
// Evaluate the fine sheen in the tuft's local frame to keep it aligned
// with the shafts even where the brushed direction turns sharply.
float fibrePhase=dot(fract(g)-.5,perp)*TAU+TAU*hash(cell);
float fly=.5+.5*band(fibrePhase,fp*735.);
c*=.79+.26*fluff+.065*fly+radiance*(1.-smoothstep(.64,1.7,footprint));
return c;
}
void pixelfx_study_eval(vec2 pfx_frag_xy, out vec4 fragColor) {
vec2 p=turn(-.18)*field();
float fp=pixel();
float crest=p.y+.61+.22*p.x-.12*sin(2.1*p.x);
vec3 c=pile(p,0.,fp)*(1.-.64*exp(-max(crest,0.)*13.));
// Velvet turned back onto itself exposes the cut tips in profile at the lip.
float nap=.009*noise(vec2(p.x*278.,3.))+.006*noise(vec2(p.x*88.,6.));
vec2 folded=vec2(p.x+.18,crest*.82-.32);
vec3 face=pile(folded,1.,fp);
face+=vec3(.18,.076,.11)*exp(-sq((crest+.055)*11.));
face*=.86+.14*smoothstep(-.12,0.,crest);
c=mix(c,face,aa(crest-nap,fp));
float tips=exp(-sq((crest-nap)*170.));
c+=vec3(.077,.035,.044)*tips*(.4+.6*noise(vec2(p.x*172.,1.)));
fragColor=vec4(c,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;
}
// Crushed Grazing Velvet — Three.js WebGL2 ShaderMaterial (GLSL3)
// Upstream study: https://github.com/gokayfem/glsl-studies/blob/main/textiles/lib/12_velvet.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-12-velvet
// Cut velvet | light grazes a folded and brushed garnet pile.
// 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 sat(float x) { return clamp(x,0.,1.); }
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.))); }
float drape(vec2 p) {
float tuck=2.4*p.x+.95*p.y+.38*sin(2.2*p.y);
return .17*sin(tuck)-.115*exp(-sq((tuck-.18)*1.9))
+.075*sin(4.9*p.y-1.9*p.x+.62*sin(2.*p.x));
}
vec3 pile(vec2 p,float face,float fp) {
float e=.003;
vec2 deriv=vec2(drape(p+vec2(e,0))-drape(p-vec2(e,0)),drape(p+vec2(0,e))-drape(p-vec2(0,e)))/(2.*e);
vec3 n=normalize(vec3(-deriv,1.));
// A dragged hand bends adjacent fibres along a broad curved path.
float trail=p.y+.36*sin(2.1*p.x)-.17*p.x;
float brush=exp(-sq((trail-.09)*3.9))*(.79+.21*noise(p*4.));
float lay=1.03+face*1.82+2.05*brush+.58*deriv.x+.32*(noise(p*6.)-.5);
vec2 axis=vec2(cos(lay),sin(lay));
float nap=dot(axis,normalize(vec2(-.75,.53)));
vec3 light=normalize(vec3(-.77,.48,.39));
float rake=sat(.45+.80*dot(n,light));
float sheen=pow(rake,1.9)*(.49+.49*nap);
vec3 c=vec3(.255,.051,.108)*(.63+.53*rake)+vec3(.57,.188,.263)*sheen;
vec2 g=p*117., cell=floor(g);
float footprint=fp*117.;
float radiance=0.;
// Resolve directional shafts at gallery resolution, then average the
// unresolved material response at a lower sampling density.
for(int j=-1;j<=1;j++) for(int i=-1;i<=1;i++) {
vec2 id=cell+vec2(i,j);
float seed=hash(id);
vec2 start=id+vec2(hash(id+7.),seed);
vec2 direction=turn((seed-.5)*.88)*axis;
float len=.62+.70*hash(id+13.);
vec2 rel=g-start;
float t=sat(dot(rel,direction)/len);
float dist=length(rel-direction*len*t);
float fibre=aa(dist-(.067+.044*(1.-t)),max(.025,footprint));
radiance+=fibre*mix(-.21,.64,t)*(.55+.45*seed);
}
vec2 perp=vec2(-axis.y,axis.x);
float fluff=.56*noise(p*80.)+.44*noise(p*36.+axis*.7);
// Evaluate the fine sheen in the tuft's local frame to keep it aligned
// with the shafts even where the brushed direction turns sharply.
float fibrePhase=dot(fract(g)-.5,perp)*TAU+TAU*hash(cell);
float fly=.5+.5*band(fibrePhase,fp*735.);
c*=.79+.26*fluff+.065*fly+radiance*(1.-smoothstep(.64,1.7,footprint));
return c;
}
void main() {
vec2 p=turn(-.18)*field();
float fp=pixel();
float crest=p.y+.61+.22*p.x-.12*sin(2.1*p.x);
vec3 c=pile(p,0.,fp)*(1.-.64*exp(-max(crest,0.)*13.));
// Velvet turned back onto itself exposes the cut tips in profile at the lip.
float nap=.009*noise(vec2(p.x*278.,3.))+.006*noise(vec2(p.x*88.,6.));
vec2 folded=vec2(p.x+.18,crest*.82-.32);
vec3 face=pile(folded,1.,fp);
face+=vec3(.18,.076,.11)*exp(-sq((crest+.055)*11.));
face*=.86+.14*smoothstep(-.12,0.,crest);
c=mix(c,face,aa(crest-nap,fp));
float tips=exp(-sq((crest-nap)*170.));
c+=vec3(.077,.035,.044)*tips*(.4+.6*noise(vec2(p.x*172.,1.)));
fragColor=vec4(c,1.);
}
`;
export function createCrushedGrazingVelvetMaterial(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 | crushed-grazing-velvet |
|---|---|
| Category | Fabrics & Organic Shaders · Woven & Knit Fabrics |
| Upstream study | textiles/lib/12_velvet.glsl (commit 1fbd084) |
| Animation cycle | Static analytical PBR surface |
| Declared uniforms | uResolution |
| Source size | 91 lines · 4.0 KB standalone GLSL ES 3.00 |
| PNG baker outputs | 512px · 1024px · 2048px RGBA8 (4-tap seamless + alpha key) |
| Companion pixel VFX | Free MIT holy sprite sheets |
| License | MIT License + CC0 / MIT Helpers |
Procedural signed-distance and analytic surface shading
David Hoskins, hash
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.
PBR StudyKeeled diamond dragon and serpent scales imbricated over flexible interstitial skin.