kmg vs dtex vs png

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
splatkillwill
DCEmu Newbie
DCEmu Newbie
Posts: 1
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sat Jul 11, 2020 10:00 pm
Location: Sacramento CA
Has thanked: 0
Been thanked: 0
Contact:

kmg vs dtex vs png

Post by splatkillwill »

Hello I'm new to Dreamcast dev and C / C++ (my background is C# and JS). My goal is to make some 2d game or app with pvr / plx (parallax). So far I'm drawing text with `plx_font` and `plx_fcxt`. I'm overwhelmed with options to dive into for sprite sheets. Form that perspective what are the pros and cons of kmg vs dtex vs png (or some kos port file handler).
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: kmg vs dtex vs png

Post by BlueCrab »

Well, kmg and dtex are just containers for (generally) compressed textures that are built with VQ encoding -- that is to say that the texture data as stored in the file is compressed with the same compression that the PVR actually supports natively. Thus, both of them will result in less texture memory used for the same amount of image data. Either one of them will result in pretty much the same amount of data needing to be in the video memory to use your textures. That said, the texture compression is not lossless -- there is some image degradation in the conversion process (although, honestly it isn't all that bad -- it's certainly better than a low-quality JPG file, for instance). Also, you need to convert your textures using another program in order to have them in either of these formats.

Using a PNG file has the benefit that there is no lossy compression applied to your texture data and that you can obviously easily open and edit the files in just about any image editor without having to go through any extra conversion step. That said, these will take up more space in video memory when you load them (usually more than the file size of the actual file). Basically, each texture will take up width * height * 2 bytes in video memory when loaded from a PNG file (VQ encoded textures take up roughly 1/6th or so of that IIRC, depending on the size of the image).

Basically, for someone just starting out, I'd recommend just sticking with PNG files until/unless you find that you're running out of video memory to store your textures. In the end, it's not particularly that difficult to switch between any of these formats, so it shouldn't be of any huge consequence to change to another format later. I'm sure others have their own opinions, though. ;-)
User avatar
lerabot
Insane DCEmu
Insane DCEmu
Posts: 134
Joined: Sun Nov 01, 2015 8:25 pm
Has thanked: 2 times
Been thanked: 19 times

Re: kmg vs dtex vs png

Post by lerabot »

Like BlueCrab stated, I'd stick to png and the libpng included in kos-port. It works fairly well and will work until you need further compression.

I use a mix of .dtex and .png in my project.

One advantage .dtex has is argb1555 encoding, which can be useful if you prefer to preserve color over alpha accuracy. IIRC libpng will squash your cute png to argb4444, which cause banding in color gradiant and other visual artifacts.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: kmg vs dtex vs png

Post by BlueCrab »

lerabot wrote: Thu Aug 06, 2020 10:21 amOne advantage .dtex has is argb1555 encoding, which can be useful if you prefer to preserve color over alpha accuracy. IIRC libpng will squash your cute png to argb4444, which cause banding in color gradiant and other visual artifacts.
You can specify to libpng to use ARGB1555 as well by using PNG_MASK_ALPHA. You just have to make sure that your pixels are all either fully opaque or fully transparent.
Post Reply