OpenArena Message Boards

OpenArena Contributions => Development => Topic started by: fromhell on May 30, 2008, 01:54:20 PM



Title: OA Tiny-ize batch script
Post by: fromhell on May 30, 2008, 01:54:20 PM
Hi
I'm wanting to do an automated process of:
- Extracts OA pk3s
- Use LordHavoc's tgatools to fix the headers of TGAs with alpha channels but 24bit (there are a lot of them, and imagemagick doesn't recognize them)
- Use Imagemagick to reduce the size of all TGAs by half, retaining alpha channel if any
- Somehow use Imagemagick to JPEG all TGAs that are 24bit, and lack alpha channels
- Use Oggenc to resample all sounds to half their normal sampling rate (22050hz for most), and keep them as ogg
- Use the ogg sound subsitution engine patch to support the load and playback of OGG sound effects if a WAV does not exist.
- Rebuild the pk3s using the same build script you find in the svn (build-pieced)
OA is getting bloaty (250mb+) and I want to experiment on making specialized "tiny" releases again, though doing this manually now is more than a pain. No pure server compatibility unfortunately but there's no way that could work anyway.
The script could also be run again to have even more reduced quality and filesize, and then again until there's just beeps and boops in flatworld. :P
My issue is that Imagemagick is quite bloated, especially in filesize.
Any tips and such on this ?


Title: Re: OA Tiny-ize batch script
Post by: Mr. Oho on May 30, 2008, 06:00:33 PM
Hmm could you provide an example of those 24bit alpha TGAs (i have OA so a pth would be enough)? Im playing with the idea of writing a small coversion/scale tool (like i dont have enough to do :P) but i couldnt find any info on this and im wondering if it might be simply 32bit files with a wrong header or maybe grayscale.

Btw: Pure support would be possibly (at least for official tiny distributions) but it would require a rather nasty engine hack and i have a felling you dont like this :P

Sorry for editing around but i wanted to make sure i wasnt talking total crap ;)


Title: Re: OA Tiny-ize batch script
Post by: andrewj on May 30, 2008, 11:10:23 PM
The file "models/players/hnt/redneko2.tga" in pak2-players-mature.pk3 is an example of the TGA problem.

Byte 16 in the header is the pixel size, value is 32
Byte 17 in the header contains "attribute size", value is 0 but should be 8

Problem is: quake3 allows this to contain alpha, yet most programs (especially GIMP. also all image viewers on Linux I tried) require the attribute size field to be 8 to support the alpha channel.

Some ideas for the script:

You could test if an image has transparency like this:
1. convert original image to A.PNG
2. convert original image to B.PPM then to B.PNG
3. compare the two png files
(since PPM does not support transparency, the second png will be flattened if the image has any).

You could test and fix the broken tgas just with of linux "dd" and "cmp" commands.

Not sure if you know about the linux "find" and "xargs" commands, they can find all files with a certain extension and run a sub-script on them all, e.g.
Code:
find dirname -name "*.wav" | xargs sound_conv.sh


Title: Re: OA Tiny-ize batch script
Post by: fromhell on May 30, 2008, 11:16:02 PM
Not sure if you know about the linux "find" and "xargs" commands, they can find all files with a certain extension and run a sub-script on them all, e.g.
Code:
find dirname -name "*.wav" | xargs sound_conv.sh
That is really cool
unfortunately I have to run Windows for a while to survive heat issues (fglrx fully loads the video card when not really in use causing horrible heat issues)


Title: Re: OA Tiny-ize batch script
Post by: Mr. Oho on May 31, 2008, 02:39:43 AM
Wow thanks andrew :)

Excellent! :P


Title: Re: OA Tiny-ize batch script
Post by: sago007 on May 31, 2008, 03:25:25 PM
- Use Imagemagick to reduce the size of all TGAs by half, retaining alpha channel if any

Be careful, do not change the resolution or it will break. You might want to consider converting larger TGAs with alpha channel to PNGs.


Title: Re: OA Tiny-ize batch script
Post by: Mr. Oho on May 31, 2008, 10:27:54 PM
Nooooo! I just got the resize code working :[ Well... thats life hehe


Title: Re: OA Tiny-ize batch script
Post by: andrewj on June 01, 2008, 12:50:07 AM
Be careful, do not change the resolution or it will break.
Do you mean that wall texture size (in-game) depends on the TGA size?

If so, a workaround would be to add a shader (or modify the existing one) to compensate, However that would greatly complicated the process.

I'm pretty sure that model skins are size-independent.


Title: Re: OA Tiny-ize batch script
Post by: fromhell on June 01, 2008, 01:56:20 AM
Changing resolution of texture TGAs won't break their scale in compiled maps

but who would want to compile a map with a tiny release is beyond me.

Still unsure on how to really make a script that nicely inputs from xargs. :(


Title: Re: OA Tiny-ize batch script
Post by: andrewj on June 01, 2008, 08:26:39 PM
By default xargs will run the command (or script) with every filename.

You probably want only one filename each time, like this:
Code:
find dirname -name '*.tga' | xargs -n1 command