Showing posts with label OpenTTD. Show all posts
Showing posts with label OpenTTD. Show all posts

Sunday, 8 June 2014

PixelTool

Many classic games like Transport TycoonRollercoaster Tycoon and Theme Hospital have pixel art graphics using a limited number of colours. These graphics are tricky to draw and take a lot of skill, especially when trying to draw accurate 3D shapes from different angles and getting the perspective and shading right.

So I made PixelTool to help out!



What is PixelTool?

PixelTool is an online voxel-based tool for drawing isometric pixel art graphics. To use it you modify a 3D volume of voxels; picking 8-bit colours for each of the voxels and leaving the background as the 'magic blue' which is transparent.

It takes the voxel data and does a pixel-perfect rendering of it into 3D and adding lighting and shadowing, but still sticking to the starting 8-bit colour palette.

Slices through the voxel data of a piece of heavy hauling equipment for OpenTTD

The corresponding rendered image of the voxel block.

Blowing up the voxels in the rendered image by 4 times lets you see what is going on in a bit more detail:


PixelTool isn't just a cheap imitation of 3D rendering software, it is a dedicated tool streamlined to making isometric sprites for classic 8-bit games.

Want to play some more?
Test PixelTool out online here: http://www.richardwheeler.net/interactive/pixeltool.html
Grab the source HTML/javascript code here: http://dev.openttdcoop.org/projects/pixeltool
Download this example of voxel data here: www.richardwheeler.net/hosting/voxeldata.txt
Join the discussion here: http://www.tt-forums.net/viewtopic.php?f=26&t=69974&start=60

Monday, 7 January 2013

OpenTTD 32bpp Part 4 - The Finished Product

By using 3D graphics and automation I was able to make a complete complete, high resolution, graphics replacement for OpenTTD almost completely on my own...


Making this graphics set was still a hell of a job though:

The total time I spent in Blender to make the graphics was 135 hours to make 391 blender files.
To render all these Blender files into sprites took 14.16 processor hours to produce 69931 images.
The final downloadable graphics files are 273 Mb and have been downloaded 24123 times.
The total size of all 146280 source files is 2349 Mb.

You can find out more about OpenTTD at http://www.openttd.org/ and more about this high resolution base graphics set (called zBase) here and here.


Software used:
Blender: 3D modelling and rendering.
ImageJ: Sprite post-processing and managing.
Python: Computer usage tracking.
OpenTTD: The game!

OpenTTD 32bpp Part 3 - Automation

3D software makes it quick and easy to make high quality textured and shaded sprites, but it is not just limited to still images; 3D software is normally designed for animation. Using the animation tools in Blender I could massively simplify producing sprites for OpenTTD.

The graphics for different trucks are a great example.


There are 3 different generations of truck graphics (old, current and futuristic), 16 different cargo types and loaded and unloaded graphics; that's 96 different combinations! Designing the graphics in 3D allows the truck to be broken into chunks; the truck body, the trailer and the cargo.


A screenshot of the 3D source for the truck graphics.

With this setup making the various combinations of truck body and cargo is simple; different animation frames just have different trucks and cargoes positioned in front of the camera. It does need a bit of geometry to get all the angles perfect though:
OpenTTD's sprites have the front left and front right sides at 26.56805 degrees from horizontal.

In 3D it is simpler, the camera is at an elevation of 30 degrees.


Each truck has 8 sprites for the 8 different directions it can drive in. Creating these 8 different images using the animation tools in 3D software is also easy, just rotate the truck 360 degrees in front of the camera over 8 frames.

Finally a few extra images are needed to complete the set of sprites required. One of these is the mask sprite to show which bits of the truck should be coloured using the company colour:


Other ones are the different sprite sizes for different zoom levels (256px, 128px and 64px).

Handily these types of outputs are also useful for animators. This tangle of image processing nodes in blender automatically generates and saves these different images:




This level of automation generates all the sprites OpenTTD needs with the minimum of effort. With a little bit of coding these sprites are now recognised by OpenTTD and can be used.

Continued here: OpenTTD 32bpp Part 4 - The Finished Product


Software used:
Blender: 3D modelling and rendering.
OpenTTD: The game!

OpenTTD 32bpp Part 2 - Moving to 3D

The original OpenTTD graphics were 8-bit. This means that all the images were made up only of colours taken from a palette of 256 different colours. This image:
Is only made up from colours from this palette:


 For example you can take all the pixels from the building which are the grey shade indicated in the palette:

An 8-bit image format was used because it was much faster for older computers to display. While the images are simpler it actually makes the graphics harder to draw for a person; every single pixel has to be picked carefully. It isn't possible to use normal photoshop techniques like altering brightness or contrast or reshading the graphics which makes things difficult. Imagine having carefully drawn a brick wall. To use it on the shadowed side of the building you are forced to completely redraw it.

In contrast 32bpp images are easy to make, especially using 3D modeling and rendering. The fact that OpenTTD can now use 32bpp graphics is therefore a big advantage! Once a building is designed in 3D (modelled) the rendering process (converting it into an image) calculates all lighting, shadows, shading etc. This makes it very quick to generate a realistic looking building because the computer does a lot of the work for you.
 
The building as modelled in Blender, the lamps for lighting are the dotted sun-shaped objects on the right.

The rendered image with accurate shadows and shading.


In the same way that 3D modelling and rendering make lighting and shading simple they also make texturing simple.

In the old 8-bit graphics textures like brick walls had to be hand-drawn, brick by brick. With some smart texture design and 3D rendering even hard-to-draw materials can be rendered quickly and accurately. Like with lighting and shading this is far quicker than drawing the texture by hand.
Brick texture on some simple objects

Brick texture on a really complicated object!

With lighting, shading, and texturing simplified by 3D modelling and rendering this actually makes the new, high resolution graphics easier and quicker to make than the old ones. The modelling is still a bit tedious though...

Continued here: OpenTTD 32bpp Part 3 - Automation

Software used:
Blender: 3D modelling and rendering.
OpenTTD: The game!

OpenTTD 32bpp Part 1 - Making a Massive Graphics Update

If you didn't know OpenTTD is an open source remake of the classic "Transport Tycoon Deluxe" by Chris Sawer, the maker of Rollercoaster Tycoon. It still has a huge cult following! Unfortunately the original Transport Tycoon graphics, which can be used in OpenTTD, look slightly dated (1994/5)...

 The original graphics

Originally OpenTTD relied on the graphics from the original game. In an effort to make the game fully free to play the graphics were redrawn from scratch, a massive project that took nearly 3 years to finish. Unfortunately these were subject to the same technical limitations as the original Transport Tycoon graphics:
 The free graphics replacement

The biggest problem with these graphics is their size. The game was originally designed to be played on a screen only 640x480 pixels in size. Modern screens (like an HD display) are nearly 3 times wider/taller with 9 times the area. In an effort to make the game more playable extra zoom levels were added: now the view can be zoomed in 4x further, but the result is not pretty:
 I can see pixels!

The solution? Redraw all the graphics. Again. The result is totally worth it though:
One retina display-safe set of graphics.

OpenTTD uses a (now quite outdated) method for displaying game graphics in which every in-game object is a single image called a sprite, like this:
 
One construction stage of one building.

In some ways this makes a complete, high resolution, graphics replacement is simple; all you have to do is draw the big brother of each sprite:
The same sprite, 4 times larger and with better colour depth and full transparency.

While this this sounds simple it is still a mammoth task. There are currently 11949 sprites (11949 separate images) required for OpenTTD. These cover all the objects, buildings, vehicles, industries, etc. to cover all the four different world environments you can play in... Some of these don't need to be replaced (like the sprites used for the fonts) but it is still a huge number of images.

So could I possibly go about doing this? In short, automation and 3D rendering.

Continued here: OpenTTD 32bpp Part 2 - Moving to 3D

Software featured:
OpenTTD: The game!