Compressing loads of content into only 20mb A case study through - - PowerPoint PPT Presentation

compressing loads of content into only 20mb
SMART_READER_LITE
LIVE PREVIEW

Compressing loads of content into only 20mb A case study through - - PowerPoint PPT Presentation

Compressing loads of content into only 20mb A case study through Swords & Soldiers for WiiWare TM Joost van Dongen What's to come Introduction Texture compression Text compression Audio Executable size Sprite animation


slide-1
SLIDE 1

Compressing loads of content into only 20mb

A case study through Swords & Soldiers for WiiWareTM

Joost van Dongen

slide-2
SLIDE 2

What's to come

  • Introduction
  • Texture compression
  • Text compression
  • Audio
  • Executable size
  • Sprite animation
  • Level format
slide-3
SLIDE 3

Introduction

slide-4
SLIDE 4

Who am I?

  • Joost van Dongen
  • Ronimo Games
  • Lead programmer / co-founder
slide-5
SLIDE 5

What is Ronimo?

  • Independent game developer
  • Utrecht, Netherlands
  • De Blob (PC), Swords & Soldiers (WiiWare)
slide-6
SLIDE 6

Why compression?

slide-7
SLIDE 7

Download size

  • Size often irrelevant for console games: DVD /

Blu-ray

  • Fast internet
  • Large hard-discs (including 360 / PS3)
slide-8
SLIDE 8

Not so on WiiTM!

  • Small internal Wii system memory
  • Low max size per WiiWare game
  • Wii busy during download
slide-9
SLIDE 9

Stop buying?

  • Gamers reluctant to remove games from Wii

system memory

  • Some stop buying when disc full
  • 20mb target for Swords & Soldiers
slide-10
SLIDE 10

SD card update

  • But...
  • SD card as extra harddisc
  • Works nicely
  • Update released just before Swords & Soldiers
  • Hardly any reason to not do some more MBs
  • Still ain't much!
slide-11
SLIDE 11

Mobile platforms

  • Size also important for mobile platforms

– iPhone – PSN on Playstation Portable

slide-12
SLIDE 12

Swords & Soldiers

slide-13
SLIDE 13

Swords & Soldiers

  • WiiWare
  • Side-scrolling real-time strategy
  • Lots of features and assets for a WiiWare game
slide-14
SLIDE 14

Swords & Soldiers

slide-15
SLIDE 15

Swords & Sizes

  • Total size: 17.4mb
  • Executable: 2.6mb
  • Textures: 8.2mb
  • Music: 2.6mb
  • Sound: 1.8mb
  • Text files (XML, dialogue): 0.5mb
  • Becomes 21.2mb with shared files
slide-16
SLIDE 16

Total team

  • 1 programmer + 1 intern
  • 4 artists + 1 intern
  • 2 designers + 1 intern
  • 11 months
slide-17
SLIDE 17

Coding team

  • 1 programmer + 1 intern
  • 11 months
  • Only quickly implementable techniques
slide-18
SLIDE 18

Wii || !Wii

  • Most techniques not Wii-specific
  • Some extra work might be needed elsewhere
slide-19
SLIDE 19

Texture palettes

slide-20
SLIDE 20

Textures

  • 2D game
  • Lots of animations
  • Textures are about half the download
slide-21
SLIDE 21

Textures

  • 587 textures
  • 141mb without compression
  • Went to 8.2mb with no visible loss
slide-22
SLIDE 22

Palette textures

  • Store colour palette
  • Only indices in texture
  • Max 256 colours per texture
  • Each colour is 16 bit
slide-23
SLIDE 23

Palette textures

slide-24
SLIDE 24

Cartoony style

  • Large colour areas
  • Perfect for palette textures
slide-25
SLIDE 25
slide-26
SLIDE 26

Not for everything

  • Coloured gradients problematic
  • Fix banding when it occurs
  • Swords & Soldiers:

– 400 palette textures (8 bit) – 100 greyscale textures (4 bit) – 100 uncompressed textures (16-32 bit)

slide-27
SLIDE 27

Realistic styles

  • Palette not always good option
  • Causes banding
  • Can probably still be used in many textures
slide-28
SLIDE 28

Results

  • Uncompressed textures: 141mb
  • Hardware formats: 36.8mb
  • For both download and in memory
slide-29
SLIDE 29

DXT

slide-30
SLIDE 30

Wii

  • Individual palette per texture (re-use optional)
  • 16 or 256 colours
  • Colours can have alpha
  • Full shading, only palette in storage
  • Supported in hardware
  • Nice!
slide-31
SLIDE 31

OpenGL palettes

  • Same palette for everything
  • Only 256 colours overall
  • Shading impossible
  • Useless
slide-32
SLIDE 32

Shaders

  • Can emulate palette in pixel shader
  • Read greyscale index from texture
  • Use greyscale to look-up colour in 1D texture
  • Filtering problematic without hardware support
slide-33
SLIDE 33

Shader performance

  • Slower than direct texture read
  • Lots of cache misses in palette?
  • Or not: palette is very small
  • Reduces cache misses in texture itself
  • Not actually tested...
  • ...but seems quite feasible
slide-34
SLIDE 34

Texture compression

slide-35
SLIDE 35

Texture size

  • 36.8mb: still too much for WiiWare
  • Need to drop further
slide-36
SLIDE 36

lz77

  • Compression algorithm
  • Uses dictionary
  • Store recurring pieces once and reference them
slide-37
SLIDE 37

Runlength

  • Replace repeating value
  • Set how often the value occurs
  • Example: 1111111 becomes 71
slide-38
SLIDE 38

Texture compression

  • Hardware formats: 36.8mb
  • Runlength: 13.8mb
  • lz77: 8.19mb
  • lz77: 5 seconds to decompress on Wii
slide-39
SLIDE 39

Why so strong?

  • 78% compression
  • Palettes!
  • Few values repeated often
  • Both lz77 and runtime love that!
slide-40
SLIDE 40

I want strong?

  • Does this work for more realistic styles?
  • Not easily: too many colours and noise
slide-41
SLIDE 41

I like strong!

  • Reduce colour variation
  • Often not noticeable!
  • Also works without explicit palettes
  • Can then do arbitrary colour count
slide-42
SLIDE 42

Might work in things like this (Gears of War)

slide-43
SLIDE 43

Text compression

slide-44
SLIDE 44

Text compression

  • XML common these days
  • Often binary to save space
slide-45
SLIDE 45

Swords & Soldiers

  • 221 text files
  • Mostly XML
  • No compression: 3.65mb
  • LZ77: 0.30mb
slide-46
SLIDE 46

Slow?

  • Often heard:
  • “XML too slow to parse on load”
  • “Should save memory image instead”
  • So people say
slide-47
SLIDE 47

“Mwa”

  • S&S skirmish AI
  • One 227kb XML
  • Decompressed with lx77
  • Parsed with TinyXML
  • Takes Wii less than 1 second
  • Okay by me
slide-48
SLIDE 48

Audio

slide-49
SLIDE 49

Ogg/Vorbis

  • Open source audio format
  • Free to use
  • BSD-like license
  • Okay for closed source commercial software
  • Consult platformholder about this!
slide-50
SLIDE 50

Ogg versus MP3

  • S&S: 10 minutes of stereo music
slide-51
SLIDE 51

Ogg versus MP3

  • S&S: 10 minutes of stereo music

MP3 128kbps 9.0mb MP3 64kbps 4.4mb Ogg 45kbps 2.6mb

slide-52
SLIDE 52

Ogg versus MP3

  • S&S: 10 minutes of stereo music

MP3 128kbps 9.0mb sounds good MP3 64kbps 4.4mb sounds terrible Ogg 45kbps 2.6mb sounds nearly like MP3 128kbps

slide-53
SLIDE 53

Swords & Soldiers

  • All audio in S&S on 45kbps Ogg
  • Music, voices and audio effects
slide-54
SLIDE 54

Good enough

  • Is quality good enough?
  • Reviews very positive about audio in S&S
  • Reviews never mention “bad audio quality”
  • Apparently good enough
slide-55
SLIDE 55

Executable

slide-56
SLIDE 56

Executable

  • Why would you want to compress that?!
slide-57
SLIDE 57

Executable

  • Wii executable: 3.40mb
  • Quite relevant on a whole of 21mb
slide-58
SLIDE 58

Executable

  • S&S Windows exe: 1.15mb
  • Wii executable: 3.40mb
slide-59
SLIDE 59

Executable

  • S&S Windows exe: 1.15mb
  • Wii executable: 3.40mb
  • Cause: Wii executable contains its own OS
slide-60
SLIDE 60

Executable

  • WiiWare loads compressed executables
  • Uncompressed: 3.40mb
  • Compressed: 2.64mb
  • Nice little bonus
slide-61
SLIDE 61

Logging size

  • Certain function calls grow very big
  • Size without logging: 3.40mb
  • Size with logging: 4.13mb
  • Difference: 119 calls to template function
slide-62
SLIDE 62

Logging size

  • Certain function calls grow very big
  • Size without logging: 3.40mb
  • Size with logging: 4.13mb
  • Difference: 119 calls to template function
  • Odd: only from 1.15 to 1.17mb on Windows
slide-63
SLIDE 63

Template function

template <typename T1, typename T2> void Logger::log(const T1& part1, const T2& part2) { std::stringstream output;

  • utput << part1 << " " << part2;

get()->logString(output.str()); }

slide-64
SLIDE 64

Instruction size

  • “Wii development tips”
  • Presentation on warioworld.com
  • Some more tips
  • Authorized Wii developers only
slide-65
SLIDE 65

Sprite animation

slide-66
SLIDE 66

Spacing is problematic

slide-67
SLIDE 67

Simple solution

  • Store center and size of each frame
  • Use space optimally
  • Ignore ordering
slide-68
SLIDE 68
slide-69
SLIDE 69

Building too big to store texture for each state

slide-70
SLIDE 70

Re-used animation system for buildings

slide-71
SLIDE 71

Building as animation

  • Each layer in Photoshop is an animation frame
  • Wrote custom exporter for this
  • Frames are layered in-game
  • Saved texture space on buildings this way
slide-72
SLIDE 72

Level design

slide-73
SLIDE 73

Small team

  • No time to create a custom editor
  • Ended up doing level design in Notepad
  • I don't understand: why don't artists like

Notepad?

  • (Not compression: this is about small-team

development)

slide-74
SLIDE 74

1D

  • Swords & Soldiers is really 1D
slide-75
SLIDE 75

Example level file

slide-76
SLIDE 76

Notepad

  • Not as bad as it looks
  • 1D is quite clear
  • Quickly editable
  • Still, not WYSIWYG, so not cool
  • Very fast solution if you have only one coder!
slide-77
SLIDE 77

Conclusion

slide-78
SLIDE 78

Conclusion

  • Texture palette: good quality for cartoony
  • The less colours, the better lz77 works
  • Ogg beats MP3
  • Executable size is relevant on WiiWare
  • Cutting up buildings saves space
slide-79
SLIDE 79

?

Joost van Dongen joost@ronimo-games.com