VQ Texture

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
User avatar
Newbie
Insane DCEmu
Insane DCEmu
Posts: 171
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sat Jul 27, 2013 1:16 pm
Has thanked: 0
Been thanked: 0

VQ Texture

Post by Newbie »

Hi everybody,

I want to reduce the size of my textures in VRam.

I have read VQ compression is managed by Dreamcast hardware .
It seems to use 2^n squared 16 bits bitmap texture as source.
Some people said it could raise 8 :1 ratio.
I want to know if KOS 2.x could manage those textures using Dreamcast hardware.
I have seen that a tool exist in KOS 2.x distribution to encode bitmap source to generate VQ textures.

By the way is it possible to specify a transparent or alpha translucency color in VQ textures like in 1555 or 4444 16 bits texture formats ?

Thanks.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: VQ Texture

Post by BlueCrab »

Yes to pretty much everything you've asked (although, 8:1 is probably not completely realistic, especially for smaller textures). Look at the tool in utils/vqenc. There's at least one example of how to use it in the examples tree.
User avatar
Newbie
Insane DCEmu
Insane DCEmu
Posts: 171
Joined: Sat Jul 27, 2013 1:16 pm
Has thanked: 0
Been thanked: 0

Re: VQ Texture

Post by Newbie »

OK.

In examples tree there are 19 examples.

I didn't know where VQ is used so i have make a search using VQ keyword.

I found a file named vq-example.c but it's all GL code sample and i hardly figure out how KOS use VQ in this case.

Could someone provide me a KOS sample code to load and display .vq files (generated by the vqenc utility) please ?

Thanks.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: VQ Texture

Post by BlueCrab »

Look at the examples/pvr/modifier_volume_tex example. It shows how to encode your textures at compile time (in the Makefile, probably using the kmgenc program instead of vqenc, but that's for convenience since KMG files also give you useful information like the width and height of the image). Also, it shows you how to load them with the kmg_to_img() function and put them in the PVR's memory with pvr_txr_load_kmg().

From there, the only difference between displaying a VQ encoded texture versus a normal texture is to include the PVR_TXRFMT_VQ_ENABLE and PVR_TXRFMT_TWIDDLED flags with the rest of the texture format options (like the color format).
User avatar
Newbie
Insane DCEmu
Insane DCEmu
Posts: 171
Joined: Sat Jul 27, 2013 1:16 pm
Has thanked: 0
Been thanked: 0

Re: VQ Texture

Post by Newbie »

I started compile the vqenc utility by launching make.

But it does not compile because GCC claim no jpeglib.h.
I make a search in KOS 2.x source file and it does not find any jpeglib.h.

the error is :

Code: Select all

get_image_jpg.c:6:21: fatal error: jpeglib.h: No such file or directory
How it works ?
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: VQ Texture

Post by BlueCrab »

You need to have the JPEG decoding library (and its development components) installed for your host operating system in order to compile it. Also, you'll probably want libpng (and its development components and dependencies) as well.
User avatar
Newbie
Insane DCEmu
Insane DCEmu
Posts: 171
Joined: Sat Jul 27, 2013 1:16 pm
Has thanked: 0
Been thanked: 0

Re: VQ Texture

Post by Newbie »

Ok!

I have a Debian system with synaptic, what keyword must i use to find the needed component ?

I am a complete newbie in Linux system and i switch to Debian to compile KOS 2.x without cygwin in Windows system.

Thanks.

Below the result for my synaptic search
Attachments
I found that for PNG ...
I found that for PNG ...
I found that for JPG ...
I found that for JPG ...
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: VQ Texture

Post by BlueCrab »

You probably want libpng12-dev and libjpeg8-dev in addition to what you already have installed (libpng12-0 and libjpeg8).
User avatar
Newbie
Insane DCEmu
Insane DCEmu
Posts: 171
Joined: Sat Jul 27, 2013 1:16 pm
Has thanked: 0
Been thanked: 0

Re: VQ Texture

Post by Newbie »

That's fine it works.

I have not 8:1 ratio for my textures but 7.93:1 and 7.64:1 according to the ratio between jpg input file weight and the .kmg files output weight.

I do not understand what is the -t arg in the vqenc, it says "twiddled" is this important ?

I have test with and without -t arg and there is no space difference in the output.

I'm on the way to test the display with a little sample code.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5666
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: VQ Texture

Post by BlueCrab »

Twiddling a texture makes it faster for the hardware to perform certain tasks, such as bilinear or trilinear filtering on the textured polygons. It basically stores the texture in a different pattern than would normally be used to aid the hardware in doing its task. It doesn't affect the size as it does not actually change the content of the texture -- just the order that the content is stored in. Twiddling is also required for some types of textures, like textures that utilize a palette.

Thus, it makes sense that if you're going to preprocess your textures anyway, you might as well twiddle them while you're at it.
User avatar
Newbie
Insane DCEmu
Insane DCEmu
Posts: 171
Joined: Sat Jul 27, 2013 1:16 pm
Has thanked: 0
Been thanked: 0

Re: VQ Texture

Post by Newbie »

I have two reference problems trying to compile my code to test VQ texture display ...

First, i need the file kmg.h to define the file i load after using the encoder.
I noticed that's this file is available only in the vqenc and kmgenc folders.
So i make a copy of it in my app.
But it is strange for me because as KMG is a part of KOS it should be in KOS, so included in Kos.h isn't it ?

Second, to load the KMG file in the sample i need the kmg_to_img() function.
But i could not locate it in KOS.
I search in KOS and found two declarations without implementation in kmg.h file in the encoders folders :

Code: Select all

	/* Call to load a KMG file from the VFS. */
	int kmg_to_img(const char * fn, kos_img_t * rv);
So when i compile the linker complain about it saying "undefined reference" ...

Please help ... thanks
User avatar
RyoDC
Mental DCEmu
Mental DCEmu
Posts: 366
Joined: Wed Mar 30, 2011 12:13 pm
Has thanked: 2 times
Been thanked: 0

Re: VQ Texture

Post by RyoDC »

Try to search in all kos files for an implementation.
If there's no, then no chance. Maybe KMG goes as separate library?
How do I try to build a Dreamcast toolchain:
Image
User avatar
Newbie
Insane DCEmu
Insane DCEmu
Posts: 171
Joined: Sat Jul 27, 2013 1:16 pm
Has thanked: 0
Been thanked: 0

Re: VQ Texture

Post by Newbie »

I understand ! KMG is not KOS but a Kos port library ...
Attachments
KMG.jpg
User avatar
Newbie
Insane DCEmu
Insane DCEmu
Posts: 171
Joined: Sat Jul 27, 2013 1:16 pm
Has thanked: 0
Been thanked: 0

Re: VQ Texture

Post by Newbie »

Ok it works perfectly .. .amazing :)

Thanks all for help !
Post Reply