Pages: [1]
  Print  
Author Topic: OA Tiny-ize batch script  (Read 10101 times)
fromhell
Administrator
GET A LIFE!
**********

Cakes 35
Posts: 14520



WWW
« 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. Tongue
My issue is that Imagemagick is quite bloated, especially in filesize.
Any tips and such on this ?
« Last Edit: May 30, 2008, 02:06:51 PM by leilol » Logged

asking when OA3 will be done won't get OA3 done.
Progress of OA3 currently occurs behind closed doors alone

I do not provide technical support either.

new code development on github
Mr. Oho
Half-Nub


Cakes 0
Posts: 55

I will press the button!


« Reply #1 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 Tongue) 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 Tongue

Sorry for editing around but i wanted to make sure i wasnt talking total crap Wink
« Last Edit: May 30, 2008, 06:08:54 PM by Mr. Oho » Logged
andrewj
Member


Cakes 24
Posts: 584



« Reply #2 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
Logged
fromhell
Administrator
GET A LIFE!
**********

Cakes 35
Posts: 14520



WWW
« Reply #3 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)
Logged

asking when OA3 will be done won't get OA3 done.
Progress of OA3 currently occurs behind closed doors alone

I do not provide technical support either.

new code development on github
Mr. Oho
Half-Nub


Cakes 0
Posts: 55

I will press the button!


« Reply #4 on: May 31, 2008, 02:39:43 AM »

Wow thanks andrew Smiley

Excellent! Tongue
Logged
sago007
Posts a lot
*

Cakes 62
Posts: 1664


Open Arena Developer


WWW
« Reply #5 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.
Logged

There are nothing offending in my posts.
Mr. Oho
Half-Nub


Cakes 0
Posts: 55

I will press the button!


« Reply #6 on: May 31, 2008, 10:27:54 PM »

Nooooo! I just got the resize code working :[ Well... thats life hehe
Logged
andrewj
Member


Cakes 24
Posts: 584



« Reply #7 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.
Logged
fromhell
Administrator
GET A LIFE!
**********

Cakes 35
Posts: 14520



WWW
« Reply #8 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. Sad
« Last Edit: June 01, 2008, 02:28:46 AM by leilol » Logged

asking when OA3 will be done won't get OA3 done.
Progress of OA3 currently occurs behind closed doors alone

I do not provide technical support either.

new code development on github
andrewj
Member


Cakes 24
Posts: 584



« Reply #9 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
Logged
Pages: [1]
  Print  
 
Jump to: