Realistic Fabric Wrinkles in Real-Time: Building Displacement Maps with Fabric.js
dev.to·1d·
Discuss: DEV
Shaders
Preview
Report Post

How to make designs conform to t-shirt folds without Photoshop or 3D engines

The Challenge

When you upload a design to a t-shirt mockup, it looks flat and fake. Real fabric has wrinkles, folds, and shadows. The design should bend around these contours—but how do you achieve this effect in real-time, entirely in the browser?

The answer: displacement mapping, a computer graphics technique that warps images based on depth information.

What is Displacement Mapping? Displacement mapping uses a grayscale "height map" to determine how pixels should move:

  • White areas (255) = peaks (pixels move outward)
  • Black areas (0) = valleys (pixels move inward)
  • Gray areas (128) = neutral (no movement)

When applied to a design on fabric:

  • Design pixels over wrinkles/f…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help