Texture Formats: Difference between revisions

From dreamcast.wiki
Jump to navigation Jump to search
(Created page with "This tutorial will explain how you can store image data on the Dreamcast's PVR graphics chip for efficient drawing and compact storage. [https://kos-docs.dreamcast.wiki/group...")
 
No edit summary
Line 75: Line 75:
The VQ compressed RGB565 texture takes 344 kilobytes in video memory. No decompression is required, it is quicker to upload to the PVR graphics chip and requires 6 times less video memory.
The VQ compressed RGB565 texture takes 344 kilobytes in video memory. No decompression is required, it is quicker to upload to the PVR graphics chip and requires 6 times less video memory.
Depending on the amount of colors in the original image the quality loss may not be noticeable.
Depending on the amount of colors in the original image the quality loss may not be noticeable.
[[File:Texture dreamcast.png|frame|750px]]

Revision as of 14:13, 26 November 2024

This tutorial will explain how you can store image data on the Dreamcast's PVR graphics chip for efficient drawing and compact storage.

List of texture formats

Color formats

Truecolor

This table describes the color information that can be stored in textures.

ARGB1555 each color channel has 5 bits, transparency is on or off
ARGB4444 each channel has 4 bits, use if you need a transparent gradient
BUMP bumpmap format (stores angles for vertex displacement effects in lighting calculations), similar to a normal map
YUV422 mostly used for video decoding, uncommonly used

Paletted

There are also paletted texture formats which can be combined with the above color formats as well as ARGB8888.

4BPP_PAL (or 8BPP_PAL)

  1. Define an array of 2^4 = 16 (or 2^8 = 256) color values.
  2. Copy the array to the graphics chip, then send textures that use 4-bit (or 8-bit) indices into that array instead of 16 bit argb as pixel values.

ARGB8888 is slow when used with filtering.

You can set multiple palettes on the graphics chip at the same time (1024 bytes total), so they're not per-texture at all, but global.

Paletted textures are always twiddled and never strided.


Additional attributes

Textures can be twiddled, VQ compressed, strided or mipmapped.

Twiddled

Pixels aren't stored row-by-row, but in a z-shape arrangement which puts neighboring pixels closer together. This makes texture filtering cheaper and you definitely want to use it. Twiddled textures must have power-of-two dimensions (e.g. 512x512, 256x1024).

VQ compressed

Vector Quantization is a lossy texture compression. The Dreamcast graphics chip has special hardware to decode it, so you suffer no performance loss for the decoding step when texture data is read by it for drawing. Textures will use less video memory.

Strided

A way to draw non-power-of-two textures by defining gaps.

Mipmapped

Each texture stores smaller versions of itself (512x256 -> 256x128 -> 128x64..). Makes textures 1/3 bigger, texture filtering cheaper and improves rendering performance when textures are displayed at a smaller than original size.


Converting art assets to Dreamcast texture formats

It is more efficient to convert your PNG/TGA/etc. art assets during the build process of your game instead of during runtime.

There are tools for conversion in the KOS utils folder. Be aware that the KOS conversion tool does not support non-square VQ textures, although it should. This conversion tool by tvspelsfreak offers support for that in addition to a handy preview feature [[1]]


Comparison between uncompressed and compressed

To see how useful applying the proper texture format is, check out this thread

Consider face.png, 1024x1024, RGB888 for example.

  • 304K face.png
  • 3.1M face.tga
  • 516K face.dds
  • 344K face.kmg
  • 108K face.kmg.gz

If you store this texture on the CD as PNG, it will will take 304 kilobytes.

After unpacking it and storing it in video memory it will take 3 megabytes (1024*1024 * 3 bytes = 3 MB).

If you convert it from RGB888 to RGB565 it will still take 2 megabytes.

The VQ compressed RGB565 texture takes 344 kilobytes in video memory. No decompression is required, it is quicker to upload to the PVR graphics chip and requires 6 times less video memory. Depending on the amount of colors in the original image the quality loss may not be noticeable.

Texture dreamcast.png