| 1 |
#!/usr/bin/perl -w |
| 2 |
# |
| 3 |
# Simple script to generate .dds and low-rez versions of tree textures. |
| 4 |
# |
| 5 |
|
| 6 |
# Clean up temporary file that might have been left around |
| 7 |
system("rm temp.png"); |
| 8 |
|
| 9 |
my @textures = glob("*.png"); |
| 10 |
my $tex; |
| 11 |
|
| 12 |
foreach $tex (@textures) { |
| 13 |
# Get the current size |
| 14 |
my $base = $tex; |
| 15 |
$base =~ s/\.png//i; |
| 16 |
|
| 17 |
my $id = `identify $tex`; |
| 18 |
($id =~ /\w+ PNG (\d+)x(\d+) /) || die ("Unable to parse output from identify: $id"); |
| 19 |
my $x = $1; |
| 20 |
my $y = $2; |
| 21 |
|
| 22 |
# Generate DDS version |
| 23 |
system("convert $tex -flip temp.png") && die ("Unable to flip texture $!"); |
| 24 |
system("nvcompress -bc3 temp.png $base.dds") && die ("Unable to nvcompress texture $tex: $!"); |
| 25 |
system("rm temp.png") && die ("Unable to rm temp.png"); |
| 26 |
|
| 27 |
# Generate lower resolution versions |
| 28 |
system("convert $tex -resize 50% ../../Textures/Trees/$tex") && die ("Unable to resize texture $!"); |
| 29 |
|
| 30 |
# Generate DDS version of low-rez |
| 31 |
system("convert ../../Textures/Trees/$tex -flip temp.png") && die ("Unable to flip texture ../../Textures/Trees/$tex $!"); |
| 32 |
system("nvcompress -bc3 temp.png ../../Textures/Trees/$base.dds") && die ("Unable to nvcompress texture ../../Textures/Trees/$tex: $!"); |
| 33 |
system("rm temp.png") && die ("Unable to rm temp.png"); |
| 34 |
|
| 35 |
} |