DEV Community


Posted on

Using Custom Binary files for Rendering

When learning computer graphics concepts for the first time it is easy to ignore simple initialization time optimizations like using a custom binary filespec for models, textures or animations, but there are various reasons why you'd want to do custom files. I'll be explaining why I didn't use them initially and why I'm glad I use them now.

I originally started computer graphics using modern OpenGL, this was a good way to get some tutorials down since most computer graphics tutorials use OpenGL. Following all these tutorials I learned quite a bit, but I eventually got to the point where I needed to lead models into my renderer and I did it the standard beginner way of just using obj files and parsing the file on initialize, that worked for a while because I was loading some simple 3d models with limited vertices and I didn't need tangents and bitangents of animation data so I could make due, but once I started doing some fancy features that required some mesh data processing my initialization times became unbearable and it was something I had to worry about inside my rendering project which wasn't ideal.

I eventually started making my own filespecs and only storing the data I needed still as text though. Although this sped up the initialization time greatly it still became a nuisance with projects loading a large number of models. So I finally bit the bullet and implemented some custom binary files for my models and my animations and even the textures, though I don't often use the custom texture tools outside of attracting demos.

Using the custom format game me the freedom to optimize the renderer to work with data streaming for animations so that I could load my files really fast and not choke the main thread with fileio and save some precious ram for more important thing that were actually being used.

It's very freeing to make your own binary filespecs because it gives you quite a bit of confidence when working with buffers and other types of binary data and also gives you some file io skills. Additionally, making your own filespec allows you to name things after yourself. I call all my two custom mesh formats the skinned Whittington Object(.swobj) and the Whittington Object(.wobj) and the animation file is called the Whittington Animation (.wanim).

So in short, make your own filespecs because it saves you time in the long-run, your repo is smaller, you get to name things after yourself and you can potentially discover additional optimizations that are only possible if you make your own file formats. See my other blog post linked below about one texture optimization I made because I was using my own texturing tools.

Reducing Texture Overhead for our PBR Asset Pipeline by 50% using Channel Packing & Emissive Intensity Maps.

By Joseph Whittington

Discussion (0)