Generating Random UV Maps for Blender 3D

I wanted to test UV mapping personal photos onto cubes rolling down a hill or something. Its probably more interesting the way I actually created the UV maps than anything, using Imagemagick and some command line trickery.

First, make sure you have the uuidgen and imagemagick software installed. Also, you should probably only use a set of images whose total count can be divided by 6, otherwise the automated commands below will have issues when it runs out of images.

cd into the directory containing the images you want to randomize onto cube faces. Then create a temporary directory inside that will contain symlinks back to the original images.

mkdir uv-images && cd uv-images

This generates random image names without the extra space of copying them into random filenames.

for i in ../*.jpg ; do ln -s "$i" $( uuidgen ).jpg ; done

If you don't like the order, you can just remove the links above and run the command again. Thanks to @christianh814 for the idea of using uuidgen. That makes more sense.

Now you need to create a variable that contains instances of the image file names in a certain order so that it creates a 6 sided UV map and leaves the other spaces in the image blank.

p="@ @ @ + @ + + @ + + @ +" ; for i in *.jpg ; do p=$( sed "s/@/$i/"<<<$p ) ;done ; echo ${p//+/null:}

Then make a bunch of cube UV maps from the $p pattern created previously.

montage -adjoin -frame 0 -tile 3x4 -mode concatenate -geometry 1000x1000 $p montage.jpg

--Deltaray

Created: 2014-01-08 (Originally posted in 2011)

Go to climagic homepage

blog comments powered by Disqus