anybody still remembers me?;-)
For Linux users, custom auto-tiling of a given texture is really simple and
does not require any extra software. Today I have quickly hacked a
most convenient shell-script that does the job transparently and flexible:
It uses the two command-line utilities of the ImageMagick package,
convert and identify. Since some arithmetics is done in the
script, it has to be written for execution with the much more powerful
'/usr/bin/zsh' (z-shell) rather than the simple '/bin/sh'.
The main advantage of doing the job via a shell script is clearly that it
may be written/debugged very fast and be easily modified without any
compilation...
Here are the instructions:
1) calling my script, 'virtualtex', with less than the required 3
arguments or '--help' gives a 'usage' printout:
> virtualtex
Usage: virtualtex [--help| <texture name> <tile size> <tile format>]
2) let the original texture 'foo.tga' be of any size that is a power of two and
with aspect ratio 2:1. I have supposed here that it is in *.tga
format, but most other formats are equally supported. Let the
tilesize be e.g. 512 and the desired output tile format e.g. *.tga (such
that it may be easily converted into DXT later with nvdxt, for
example)
Then all you got to do in the appropriate level directory is to copy
foo.tga into it and call
> virtualtex foo.tga 512 tga
a typical output would then be
Texture size = 8192 x 4096 tilesize = 512
Number of tiles = 128
Image format of tiles: tga
along with the desired 128 tile files tx_i_j.tga, i=0..15, j=0..7
Note that the original texture size is automatically determined by the
ImageMagick programm 'identify' within the script!
Under windows, the result may then easily be converted into
(e.g. uncompressed!) DXT including mipmaps like so:
nvdxt -file *.tga -24 u888
3) Here is the script: You may just copy it into a file named
'virtualtex' that you must make executable with 'chmod +x
virtualtex', of course! Then place it somewhere into your execution
PATH, e.g. /usr/local/bin or ~/bin,....
-----------------virtualtex-------------------------
Code: Select all
#! /usr/bin/zsh
if [ $# -ne 3 -o "$1" = "--help" ]; then
echo
echo 'Usage: virtualtex [--help| <texture name> <tile size> <tile format>]'
echo
else
texturewidth=`/usr/bin/identify $1|cut -d " " -f 3|cut -d x -f 1`
((textureheight = texturewidth/2))
tilesize=$2
tileformat="$3"
echo
echo "Texture size = " $texturewidth "x" $textureheight "tilesize = " $tilesize
echo "Number of tiles =" $(( texturewidth/tilesize * textureheight/tilesize ))
echo "Image format of tiles:" $tileformat
echo
echo "Tile: "
echo
j=0
while (( j * tilesize < textureheight )); do
((offy = j * tilesize))
i=0
while (( i * tilesize < texturewidth )); do
((offx = i * tilesize))
echo "tx_"${i}"_"${j}": x-offset:" $offx "y-offset:" $offy
/usr/bin/convert -crop ${tilesize}x${tilesize}+${offx}+${offy} $1 tx_${i}_${j}.$tileformat
((i++))
done
((j++))
done
fi
-----------------------------------------------
4) The safest bet is, however, to download 'virtualtex' from here
http://www.shatters.net/~t00fri/virtualtex
NOTE: It must be (made) executable!
5) By means of 'virtualtex' I made a full set of level0, level1,
level2 tiles /both/ for my 16k earth texture and the associated 16k
earth-normal texture, using a rather large tilesize of 2048 (to
start;-)). While the script was working, I went out for dinner with
my wife....
Bye Fridger