• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Waaayoff

Question about zlib?

3 posts in this topic

I don't have any experience with file compression and i want to use zlib to compress my terrain. I was wondering if zlib can be used to decompress a region of interest, edit the data and compress it back?

The reason i'm asking is because i want to edit my terrain which is drawn using gpu clipmaps. So the heightmap isn't broken down into chunks. I want to be able to apply any changes i make to the terrain to the compressed heightmap. Is that possible?
0

Share this post


Link to post
Share on other sites
[quote name='Waaayoff' timestamp='1340829152' post='4953447']
don't have any experience with file compression and i want to use zlib to compress my terrain. I was wondering if zlib can be used to decompress a region of interest, edit the data and compress it back?
[/quote]
The encoding is a streaming enconding. If you want to use it, you need to compress the whole file again. Either subdivide your file into chunks and collect all chunks in an according file (i.e. zip), using zlib to compress/decompress each chunk. Or take a look at image compression algorithm which are able to work on a subregion only.
1

Share this post


Link to post
Share on other sites
Heightmap chunks are likely to not compress terribly well, unless you take some special measures. Just like a digital photo from your camera does not compress well.

Zlib, like all LZ-based compressors, matches the next substring on a stream with (ideally) all possible substrings that it has seen before. Heightmap data will probably have some repetitions on a binary level, but unless your heightmap is something like a plane or a ramp, it is not likely that there will be many, or long ones. It's just not the nature of a heightmap.

Before compressing, you will definitively want to do a transform on your data to make it more compression-friendly. Some good choices may be:
- quantization
- delta encoding
- wavelets

Quantization simply reduces the number of possible values. This means fewer possible combinations in substrings, and this means a higher likelihood of having many matches. Of course, this reduces the quality of the heightmap.
Choosing 8 or 16 bit integers instead of float values is also a form of "quantization". This makes sense insofar as floating point values are always a bit tricky for being the same on a binary level. Depending on how you generate that data, a rounding error that is not visible in any way may give floating point values that aren't the same (and therefore don't match when the compressor runs over them).

Delta encoding exploits the fact that most terrain data is "kind of flat" or "kind of smoothly continuous". By encoding one vertex as the difference to a preceding neighbour vertex, many numbers will be zero or close to zero. Many similar/identical values yield a higher likelihood of finding many matches. You can additionally quantize, too, if you want. Delta encoding as such [i]does not reduce quality[/i], it is the same data represented differently.

Wavelets can be seen as a more mathematical formulation of delta encoding. They have the additional property of delivering lower levels of detail for free. For a perfect result, you'll need to dig a bit in mathematics, but a simple Haar transform is straighforward (like, 3-5 lines of code) and already provides quite good results. You can imagine a wavelet visually as walking over a texture's mip map levels, starting from the lowest 1x1 pixel mipmap, interpolating when scaling up, and encoding just the error. The interesting property with wavelets is that they also contain many values close to zero, and it does not make a very noticeable difference if you set the close-to-zero values to zero. Also, you kind of get LOD "for free", because the wavelet representation with the tail of the data left out is nothing but a lower level of detail!

With any kind of transform, you must make sure that vertices at the patch border are the same on neighbouring patches, or you run into trouble with cracks/holes (one very simple way of ensuring this is to treat the border pixels separately, but there are probably more space-conserving strategies). Or, you can use techniques such as degenerate triangles (which are no more degenerate when a crack would be visible!) or skirts to hide the cracks. Edited by samoth
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0