Alun Evans Ph.D


iOS 3D Engine

In 2013, curious as to the 3D potential of iOS devices, I developed a basic 3D engine for iOS, using OpenGL ES 2.0. While the OpenGL ES specification is less complete than the full OpenGL spec, ES version 2.0 adds support for shaders, and with that opens up the possibilities for all sorts of interesting effects.

My engine features:

  • A full scenegraph: There are a million ways of writing a scenegraph; I use 'Node' parent class and extend it using several subclasses (Mesh, Light, Camera etc) which inherit its basic properties.
  • Wavefront OBJ loader: This was interesting to implement because using Cocoa Touch libraries to process the mapping required when loading a .obj file took forever - it seems NSMutableArray is not really designed to used as a map. Fortunately it is possible to compile standard C++ along with Objective-C, so I was able to speed things up using STL.
  • Shadowmaps, normal maps, specular maps: The shader supports multiple lights and several effects
  • External scene description: It is possible to save a scene description (including URLs to remote assets) as a JSON file, and pass this directly to the app to load the scene.

Below is a screenshot using a famous open source 3D asset, with a normal map and specular map enabled. I also provide a link to the code on GitHub - the code is not particularly stable or well commented yet, but it's there if anybody wants it :)