Kodi Community Forum

Full Version: XBMC Skin Compressed Textures Tool
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6
i've implemented compressed texture support into the latest build of xbmc. this helps reduce the memory used by skins significantly. it does, however, mean that you will need to mind a few points while creating skins.

all textures used are now power of 2 (i.e 1, 2, 4, 8, 16, 32, etc.) if you supply a non-power of two texture, it will be padded to the next largest power of two. this can result in a large amount of wasted space. for instance a 40x40 texture is padded to 64x64 wasting 2496 pixels - more than half the pixels in the image are wasted. so basically, try to keep your images as close to power of 2 as possible.

png, jpg and gif files are automatically re-compressed on load into an xbox compatible format, this can cause some quality loss, particlarly in the alpha channel. i have added support for dds files to help with this. dds files are loaded without any conversion - whatever you put in the file, you get loaded directly. to create dds files you'll need an app, this util includes a plug-in for photoshop that will let you convert your textures to dds. please note xbmc does not support mipmaps. if you want animation, you'll have to use gifs still.
sounds interesting.
will test it soon.

my results:
i used the 2 different backgrounds from hifi skin.
these are two of the biggest graphics in my skin.
rescaled it to 512x512 and saved it as 32bit argb.
other modes (16bit,..) seemed to be a too high quality loss.

one background is now about 1mb big (150kb as png).
now i renamed these two dds files into .png and overwrite the original png's.
no problem for xbmc, but i only saved about 1-2 mb free memory.
that is not much for the two biggest graphics.
i don't know if i can use a better way to save the dds files, but if this is the only way every skin would be 10-20mb big.

is there a limit for free space ?
you should be mainly using dxt1, dxt3, or dxt5 for graphics - for non-alpha textures, or textures with a single transparent colour use dxt1 as it's half the size of dxt3/dxt5.

if you use 32bit argb you'll not save any memory at all. in fact with the current code a 32-bit argb dds uses more memory than a png as the png will be recompressed to dxt3 by xbmc, while the dds will not.

also a note for skinners:
all current skins will work fine. you don't have to change anything if you don't want to, you can change stuff to dds if you want finer control over which compression method is used. that's the only advantage.
changing things to be power of two is a space saving feature only, they'll work fine if they aren't power of two but you waste some memory.

currently skins are loading very slowly unless you have all the texutres as power of 2 dds, but i'm planning to work on this and sort it so that pngs and jpgs will be just as fast.

speed fix is done, pngs loading nice and fast now.

something to consider if you're finding dxt compression causes quality loss - try using gifs for stuff. you only get 256 colours, but xbmc loads them without recompressing so there's no quality loss and they're the same size (once loaded) as dxt3.
i disabled the compressed textures (for now)
it caused the skins to look very ugly cause of the compression
we'll see if this can be solved, however in the mean time we'll just use uncompressed textures
note for those wanting to keep skin sizes down... easiest way is small textures. size of the file itself is largely irrelevant - you can have a 2k png, but if it's 1000x1000 pixels, it's going to use a lot of memory. also try and use sizes close to but below a power of 2. a 130x100 texture uses twice as much memory as a 128x100 or a 120x100.
ok, new plan - i've made a texture compression tool, it's in cvs (sorry no bin, it needs the xdk). if you run it over your skin's media directory it'll compress the files in it a bit more "intellegently" than the xbox-based compression.

usage is quite simple:
xbmctex [-output outdir] [-input indir] [-quality qual]

-input lets you specify the input directory for the converter. it will search for any files named *.png, *.bmp *.jpg *.tga *.dds in the given directory and convert them. if you don't supply an input directory, it uses the current directory.

-outdir lets you specify an output directory for the converted files. files are saved as filename.xpr (e.g. pic.jpg.xpr) so they won't overwrite your files if you use the same input and output directory. if you don't supply an output directory, it uses the current directory.

-quality sets the quality for conversion. there are 5 levels, default is normal quality:
min this will change all textures to the smallest suitable type, regardless of quality implications. quality will generally be poor, but the size is very small also.
low this will aggressively compress most textures, it will generally give some visible artifacts in textures.
normal this gives a good balance of quality and compression. there may be soime small image artifacts, but much less than the low setting.
high this should give virtually no visible artifacts on textures, some very slight effects are possible though.
max this will only compress textures if the result is completely lossless. it gives little to no compression but you are guaranteed not to lose any quality.

i'd recommend skinners choose either normal or high as a quality setting for their skins.

edit: couple of other things.
256-colour images are never compressed, they are kept as 256-colour. if you want a 256-colour non-animated image a png is better than a gif as pngs are preconverted whereas gifs are not (faster loads for png). quality for both is the same.
images less than 1024 pixels (eg. 32x32, 16x64) are never compressed as it doesn't actually save any memory to do so. so your icons and such will not become distorted.

sounds better and easier.
i will test it soon.

by the way..
i had a look at internal 02-28 and saw that there is more free memory as it was in 02-27.
any optimizations ?
other than compressed textures i don't think so
are all graphics loaded on xbmc startup, or only if they needed ?
as needed, we haven't got the memory to pre-load everything.
new version of the tool does gif processing.
all gif processing is done in lossless mode, so you'll never lose any animation quality.
any duplicate frames in the gif are merged so it's not a problem if you want to repeat frames (a common one is a fully transparent frame to hide the anim). merged frames do not have to be sequential (e.g. if frame number 2 and frame number 10 are identical, they are merged).
1 new bug.
screen calibration is messed up if you use compressed textures

i think it's faulty png's that is the problem here. skins that has replaced these images doesnt show this problem. (atleast not project mayhem)
i found this browsing nvidia's developers website, not sure if it can be used but here you go anyway:

dxtc decompression code
this sample provides code to read and decompress .dds files in the dxt1, dxt3, and dxt5 formats.

dxt compression library with source
includes and image library with dxt compressor with full source written by jason dorie of black box games.

nvidia dxtc texture tools
Pages: 1 2 3 4 5 6