Friday, November 23, 2012

Pre-calculated graphics

ASA is a "slideshow" adventure game : it means it doesn't use realtime 3D. Using pre-calculated graphics was a choice to make the development easier, depending on both my skills and the fact that I work on my own.

Pre-calculated 3D is a powerful way to make beautiful graphics in a game. Remember the Final Fantasy series on psx (7 to 9) ? The backgrounds were made of static pictures, and I believe that most people found this stunning. That was the same with most slideshow adventure games, including Myst and its sequel.

When you make a game in realtime, you spend a lot of time on adjusting and optimizing the number of polygons displayed, the quality of textures and shaders, the lighting... You really depend on technical restrictions, that is to say the power of the processor, the amount of memory, etc... For example, most "gamers" are familiar with terms like anti-aliasing, which is a technique to make the realtime 3D look smoother, but is also asking a lot of hardware resources.

If you make pre-calculated graphics, you don't really have this problem. You don't need to care about the amount of polygons in your scene, you can use more realistic lightings with better shadows, etc... That makes things much easier for me, of course, because I can concentrate on making the game, not on technical restrictions... but there's a downside ! All these parameters have to be calculated at a given time, and that's a step called "rendering".

Rendering is somehow "going from the 3D software to the final picture". You can see it as a "compilation" of the "settings" of your 3D scenes, and these "settings" are what I talked about earlier : the polygons, the textures, etc.... And when you want to obtain this final picture, the computer has a lot of calculations to do, so you'd better optimize your 3D scenes a little, in the end ;)

The problem of these calculations is that they require a huge amount of time. Of course, that depends on your work. For a single picture, it's quite fast, but for a video, it's something you have to take in account in your production process. A video is composed of a succession of single pictures, you know it. In ASA, you have 25 pictures per second in the videos.

Now, imagine that "rendering" a single picture can take from 1 to 15 minutes for me (15 is a maximum that I try not to reach). In average, it was something like 3 minutes per picture. Maybe you think it's not an enormous amount of time ? Then you should try to report these 3 min of rendering per picture to the total number of pictures in the game :

ASA counts approximately 20 minutes of video. We said there was 25 pictures per second. That makes us 1200 seconds for 25 pictures/s = 30 000 pictures to calculate !
Still not convinced it's a lot ? Remember, the computer needs an average of 3 minutes to calculate one single picture.. and it had 30k ones to render. That means my poor laptop PC of 5-years old worked on calculating the ASA movies during 30 000 x 3 = 90 000 minutes, or 1 500 hours, or 62 days ! (In fact, it's more 50 days, because I used some tricks to make things shorter)

This is enormous : it's almost 2 months, that is to say almost half of the time I spent on developing ASA (5 months). And the worst is that, when the computer is calculating the final renderings, you can't do anything else !  You can't work ! Because all the resources (processor, ram, graphic card) are required by the calculation !
So, this rendering step always happens in the night. And every night since I started the 3D production, my poor pc is heating up :) Not surprising the hard drive died recently, when you know it has been making all sorts of renderings since the beginning of 2008 !

Note that the rendering times can be reduced significantly if you have a very strong computer. Most societies working with pre-calculated 3D (games, cinema, advertising...) are using "render farms", which are like a network of powerful computers dedicated to the rendering step !