Weaving data

A loom. The tool used to create weaved fabrics!

An important feature of our shader will be the ability to read the same input data as an industrial loom uses to weave fabrics. The industry standard file format for weaving patterns is .WIF, a simple ascii format resembling windows .ini files.

While reading the file format is straight forward, since the data is intended for looms, interpreting it is a bit involved. This youtube video helped us understand how to read weaving drafts.

We started by writing a small utility that reads a .WIF file and prints the pattern to the console using ascii, here’s an example of the output for this pattern:

X   X     X X   X     X X   X     X X   X     X 
 X X     X   X X     X   X X     X   X X     X  
  X     X     X     X     X     X     X     X   
   X   X X     X   X X     X   X X     X   X X  
    X X   X     X X   X     X X   X     X X   X 
     X     X     X     X     X     X     X     X
X   X X     X   X X     X   X X     X   X X     
 X X   X     X X   X     X X   X     X X   X    
  X     X     X     X     X     X     X     X   
 X     X X   X     X X   X     X X   X     X X  
X     X   X X     X   X X     X   X X     X   X 
     X     X     X     X     X     X     X     X
X   X     X X   X     X X   X     X X   X     X 
 X X     X   X X     X   X X     X   X X     X  
  X     X     X     X     X     X     X     X   
   X   X X     X   X X     X   X X     X   X X  
    X X   X     X X   X     X X   X     X X   X 
     X     X     X     X     X     X     X     X
X   X X     X   X X     X   X X     X   X X     
 X X   X     X X   X     X X   X     X X   X    
  X     X     X     X     X     X     X     X   
 X     X X   X     X X   X     X X   X     X X  
X     X   X X     X   X X     X   X X     X   X 
     X     X     X     X     X     X     X     X
X   X     X X   X     X X   X     X X   X     X 
 X X     X   X X     X   X X     X   X X     X  
  X     X     X     X     X     X     X     X   
   X   X X     X   X X     X   X X     X   X X  
    X X   X     X X   X     X X   X     X X   X 
     X     X     X     X     X     X     X     X

Our next step was to use this data in a Mitsuba shader to get the correct pattern on a surface. We felt that this would be a good first step towards implementing the complete cloth shader. We based our shader on the default SmoothDiffuse BRDF in Mitsuba and using the data from the WIF file and matching it with UV coordinates we were able to get the correct pattern of colors.

The suzanne monkey from blender with a piece of cloth on its head.

We still have a lot to do when it comes to actually shading the cloth in a realistic way, but this felt like a nice start to our project.