Mahjong solitaire

One of my favorite DOS games as a kid was Mahjong solitaire. I remember wondering how it worked underneath and knew I had to implement it using a modern 3D graphics API.

Details

I started simple by first rendering rectangular prisms to represent the tile positions.

Mahjong solitaire

I next added texturing and basic lighting.

Mahjong solitaire

I improved the legibility of the tiles, added a hint mechanism and score counter:

Mahjong solitaire

I created a map editor as well. Each layer can be hidden/shown for easier editing. The counter at the bottom tells you how many tiles have yet to be placed.

Mahjong solitaire

I applied bump mapping to the tiles to give them an engraved look, and then refined the shading of the ink.

Mahjong solitaire

Mahjong solitaire

To polish the look, I applied a wood texture and bump mapping to the tiles. Note how no two tiles look quite the same.

Mahjong solitaire

Mahjong solitaire

I added a fun win effect, complete with fog. The tiles are traveling along a Hermite-interpolated curve. I used transform feedback to perform the computations on the GPU.

Mahjong solitaire

I experimented with other effects too, such as worn tiles and vertex-displaced meshes. In addition, I ported the game to Direct3D.

Mahjong solitaire

Mahjong solitaire

Mahjong solitaire

I implemented a layer separator mechanism in the map editor, for enhanced legibility.

Mahjong solitaire

Like all of my other graphics projects, I support the 3Dconnexion SpaceNavigator mouse to visualize my shaders:

The raw tile bitmaps were generated from GNOME Mahjongg's postmodern SVG tileset.