Bump Map Surface Lighting
A procedural relief surface shaded live by a light you move with the pointer; depth and grain size are adjustable.
AI prompt
Macro photograph of a coarse sandstone wall surface lit by a low raking light from the upper left, strong relief with deep micro-shadows in every pit and crisp highlights on the ridges, fine mineral grain and subtle pores, warm beige tone, shallow depth of field, tactile and detailed, no objects. Variants: smooth clay with soft shallow relief and large gentle bumps, dark slate with fine sharp grain and a cool tone. Name the light direction (upper left, low angle) and the scale of the texture (coarse, fine). Negative: flat frontal lighting, repeating tile pattern, blur, plastic look, text.About this pattern
Definition
A bump map stores surface height. The renderer turns height differences into slopes and shades each point by how much it faces the light, so a flat image looks carved, rough or embossed.
When to use it
- Raking light (from a low side angle) exaggerates texture, which is why photographers use it for stone, leather and paper.
- Depth sets how strong the relief looks; scale sets how coarse the texture is.
- In prompts, state the light direction and the texture scale: "low raking light across coarse limestone".
What the controls do
- Move the pointer over the surface to change the light; Depth and Scale sliders; three tints (stone, clay, slate).
Motion & timing
- The surface re-renders as the pointer moves.
- Reduced motion: the light stays at the default angle until you choose a new one with the sliders.
Tips & variations
- Fine textures disappear at small sizes; use a coarser scale for icons and thumbnails.
- Light direction matters more than strength for readability.
Code of this live preview
<div class="bx"><canvas id="cv" width="300" height="140" role="img" aria-label="Lit relief surface"></canvas>
<div class="pre" id="pre" role="group" aria-label="Tint"><button data-t="0" aria-pressed="true">Stone</button><button data-t="1" aria-pressed="false">Clay</button><button data-t="2" aria-pressed="false">Slate</button></div>
<div class="two"><label>Depth <input id="dp" type="range" min="1" max="12" value="6"></label><label>Scale <input id="sc" type="range" min="1" max="8" value="4"></label></div></div>:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
.bx{width:min(320px,100%);display:grid;gap:8px}
canvas{display:block;width:100%;height:auto;border-radius:12px;touch-action:none;cursor:crosshair}
.pre{display:flex;gap:5px}.pre button{flex:1;height:28px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11.5px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.two{display:grid;grid-template-columns:1fr 1fr;gap:10px}.two label{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}input[type=range]{width:100%;accent-color:#171717}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}const cv=document.getElementById('cv'),cx=cv.getContext('2d'),W=300,H=140,dp=document.getElementById('dp'),sc=document.getElementById('sc'),bs=[...document.querySelectorAll('#pre button')];
const TINT=[[214,200,176],[196,128,92],[96,106,118]];let tint=0,lx=-.6,ly=-.6,seed=7;const rnd=()=>(seed=(seed*16807)%2147483647)/2147483647;
const G=[];for(let i=0;i<4096;i++)G.push(rnd());function vn(x,y){const xi=Math.floor(x),yi=Math.floor(y),xf=x-xi,yf=y-yi,u=xf*xf*(3-2*xf),v=yf*yf*(3-2*yf),h=(a,b)=>G[((a&63)*64+(b&63))];return h(xi,yi)*(1-u)*(1-v)+h(xi+1,yi)*u*(1-v)+h(xi,yi+1)*(1-u)*v+h(xi+1,yi+1)*u*v;}
function hf(x,y,s){return vn(x/(36/s),y/(36/s))*.6+vn(x/(14/s),y/(14/s))*.3+vn(x/(5/s),y/(5/s))*.1;}
let queued=false;function render(){queued=false;const s=+sc.value,d=+dp.value*1.1,im=cx.createImageData(W,H),L=[lx,ly,.7],ln=Math.hypot(L[0],L[1],L[2]),T=TINT[tint];
for(let y=0;y<H;y++)for(let x=0;x<W;x++){const dx=hf(x+1,y,s)-hf(x-1,y,s),dy=hf(x,y+1,s)-hf(x,y-1,s),nx=-dx*d*8,ny=-dy*d*8,nz=1,nl=Math.hypot(nx,ny,nz),dot=Math.max(0,(nx*L[0]+ny*L[1]+nz*L[2])/(nl*ln)),k=.25+dot*.95,i=(y*W+x)*4;im.data[i]=Math.min(255,T[0]*k);im.data[i+1]=Math.min(255,T[1]*k);im.data[i+2]=Math.min(255,T[2]*k);im.data[i+3]=255;}
cx.putImageData(im,0,0);}
function q(){if(!queued){queued=true;requestAnimationFrame(render);}}
const reduce=matchMedia('(prefers-reduced-motion: reduce)').matches;
cv.addEventListener('pointermove',e=>{if(reduce)return;const r=cv.getBoundingClientRect();lx=((e.clientX-r.left)/r.width-.5)*2;ly=((e.clientY-r.top)/r.height-.5)*2;q();});
cv.addEventListener('pointerdown',e=>{const r=cv.getBoundingClientRect();lx=((e.clientX-r.left)/r.width-.5)*2;ly=((e.clientY-r.top)/r.height-.5)*2;q();});
bs.forEach(b=>b.addEventListener('click',()=>{tint=+b.dataset.t;bs.forEach(x=>x.setAttribute('aria-pressed',String(x===b)));q();}));dp.addEventListener('input',q);sc.addEventListener('input',q);render();One complete HTML file. Save it and open it in a browser.
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Bump Map Surface Lighting — demo</title>
<style>
:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
html,body{height:100%}body{background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Roboto,sans-serif;-webkit-font-smoothing:antialiased}.stage{min-height:100%;display:grid;place-items:center;padding:24px}button,input,select,textarea{font-family:inherit}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
.bx{width:min(320px,100%);display:grid;gap:8px}
canvas{display:block;width:100%;height:auto;border-radius:12px;touch-action:none;cursor:crosshair}
.pre{display:flex;gap:5px}.pre button{flex:1;height:28px;border-radius:99px;border:1px solid var(--line);background:var(--surface);font-size:11.5px;cursor:pointer}
.pre button[aria-pressed=true]{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.two{display:grid;grid-template-columns:1fr 1fr;gap:10px}.two label{display:grid;gap:3px;font-size:11.5px;color:var(--muted)}input[type=range]{width:100%;accent-color:#171717}
button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
</style></head>
<body><div class="stage">
<div class="bx"><canvas id="cv" width="300" height="140" role="img" aria-label="Lit relief surface"></canvas>
<div class="pre" id="pre" role="group" aria-label="Tint"><button data-t="0" aria-pressed="true">Stone</button><button data-t="1" aria-pressed="false">Clay</button><button data-t="2" aria-pressed="false">Slate</button></div>
<div class="two"><label>Depth <input id="dp" type="range" min="1" max="12" value="6"></label><label>Scale <input id="sc" type="range" min="1" max="8" value="4"></label></div></div>
</div>
<script>
const cv=document.getElementById('cv'),cx=cv.getContext('2d'),W=300,H=140,dp=document.getElementById('dp'),sc=document.getElementById('sc'),bs=[...document.querySelectorAll('#pre button')];
const TINT=[[214,200,176],[196,128,92],[96,106,118]];let tint=0,lx=-.6,ly=-.6,seed=7;const rnd=()=>(seed=(seed*16807)%2147483647)/2147483647;
const G=[];for(let i=0;i<4096;i++)G.push(rnd());function vn(x,y){const xi=Math.floor(x),yi=Math.floor(y),xf=x-xi,yf=y-yi,u=xf*xf*(3-2*xf),v=yf*yf*(3-2*yf),h=(a,b)=>G[((a&63)*64+(b&63))];return h(xi,yi)*(1-u)*(1-v)+h(xi+1,yi)*u*(1-v)+h(xi,yi+1)*(1-u)*v+h(xi+1,yi+1)*u*v;}
function hf(x,y,s){return vn(x/(36/s),y/(36/s))*.6+vn(x/(14/s),y/(14/s))*.3+vn(x/(5/s),y/(5/s))*.1;}
let queued=false;function render(){queued=false;const s=+sc.value,d=+dp.value*1.1,im=cx.createImageData(W,H),L=[lx,ly,.7],ln=Math.hypot(L[0],L[1],L[2]),T=TINT[tint];
for(let y=0;y<H;y++)for(let x=0;x<W;x++){const dx=hf(x+1,y,s)-hf(x-1,y,s),dy=hf(x,y+1,s)-hf(x,y-1,s),nx=-dx*d*8,ny=-dy*d*8,nz=1,nl=Math.hypot(nx,ny,nz),dot=Math.max(0,(nx*L[0]+ny*L[1]+nz*L[2])/(nl*ln)),k=.25+dot*.95,i=(y*W+x)*4;im.data[i]=Math.min(255,T[0]*k);im.data[i+1]=Math.min(255,T[1]*k);im.data[i+2]=Math.min(255,T[2]*k);im.data[i+3]=255;}
cx.putImageData(im,0,0);}
function q(){if(!queued){queued=true;requestAnimationFrame(render);}}
const reduce=matchMedia('(prefers-reduced-motion: reduce)').matches;
cv.addEventListener('pointermove',e=>{if(reduce)return;const r=cv.getBoundingClientRect();lx=((e.clientX-r.left)/r.width-.5)*2;ly=((e.clientY-r.top)/r.height-.5)*2;q();});
cv.addEventListener('pointerdown',e=>{const r=cv.getBoundingClientRect();lx=((e.clientX-r.left)/r.width-.5)*2;ly=((e.clientY-r.top)/r.height-.5)*2;q();});
bs.forEach(b=>b.addEventListener('click',()=>{tint=+b.dataset.t;bs.forEach(x=>x.setAttribute('aria-pressed',String(x===b)));q();}));dp.addEventListener('input',q);sc.addEventListener('input',q);render();
</script>
</body></html>