Computer Graphics

Vortex 3D Engine was born as a framework on which I could prototype realtime rendering techniques, but soon evolved into a set of proven, reusable components that enable delivering 3D applications and games on a disparate array of platforms, including desktop and mobile.

Some of the most prominent features of Vortex Engine include:

  • Developed in standard C++, completely object-oriented.
  • Fast and portable.
  • Non-intrusive and flexible.
  • Minimal external dependencies.
  • Dynamic scene management.
  • Automatic resource life-cycle management through reference counting.
  • Rendering through the Fixed and the Programable pipelines.
  • Supports OpenGL, OpenGL ES 1.1 and OpenGL ES 2.0.

This page gathers notes on the development of the Vortex 3D Engine and its features, as well as on other musings on computer graphics. These posts are licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

Table of Contents

  1. Bump Mapping
  2. Light Scattering
  3. Render-to-Texture
  4. Realtime Shadows
  5. Geometry Post-Processing
  6. Multi-pipeline Support for Rendering
  7. Engine Resource Management
  8. Using your own Tools

Bump Mapping


Bump Mapping a Door texture. Diffuse and Normal maps taken from the Duke3D HRP. Rendered using Vortex 3D Engine. (HTML5 video, a compatibility GIF version can be found here.)

In my last post, I started discussing Bump Mapping and showed a mechanism through which we can generate a normal map from any diffuse texture. At the time, I signed off by mentioning next time I would show you how to apply a bump map on a trivial surface. This is what we are going to do today.

Bump mapping is a texture-based technique that allows improving the lighting model of a 3D renderer. Much has been written about this technique, as it’s widely used in lots of popular games. The basic idea is to perturb normals used for lighting at the per-pixel level, in order to provide additional shading cues to the eye.

Light Scattering

Art Gallery scene with Light Scattering. Art Gallery model courtesy of Reality Frontier.

Art Gallery scene with Light Scattering. Art Gallery model courtesy of Reality Frontier.

Light Scattering (also known as “God Rays”) is a prime example of what can be achieved with Shaders and Render-to-Texture capabilities. In the following image, a room consisting of an art gallery with tall pillars is depicted. We want to convey the effect of sun light coming from outside, illuminating the inner nave.

Render-to-Texture

Vortex Framebuffer Object Support: a knight is rendered on a texture that is then mapped on a cube. All rendering is done on the GPU, avoiding expensive copies to RAM.

Vortex Framebuffer Object Support: a knight is rendered on a texture that is then mapped on a cube. All rendering is done on the GPU, avoiding expensive copies to RAM.

Vortex 3D Engine supports render-to-texture capabilities by means of Framebuffer Objects.

Realtime Shadows

Vortex 3D Engine supports both Stencil Shadow Volumes and Shadow Mapping.

A demonstation of Vortex's Stencil Shadow Volumes implementation: A Knight being lit by a green light, casting a shadow on a tiled floor.

A demonstation of Vortex’s Stencil Shadow Volumes implementation: A Knight being lit by a green light, casting a shadow on a tiled floor.

Shadows are a very interesting feature to implement in an renderer, as they provide important visual cues that help depict the relationship between objects in a scene. Notice in the following image how the shadow tells our brains that the Knight is standing on the floor (as opposed to hovering over it).

Shadow mapping is a technique originally proposed in a paper called “Casting Curved Shadows on Curved Surfaces”, and it brought a whole new approach to implementing realtime shadows in 3D Apps.

Geometry Post-Processing

Angel with Generated Normals

Automatic Normal Generation: an Angel Model is lit using normal data generated automatically by the Vortex Engine.

Sometimes the 3D models we have to display provide no information other than vertex data for the triangles they define. To help solve this problem, Vortex now provides a simple Normal generation algorithm that “deduces” smooth per-vertex normals from the geometric configuration of the 3D model. The results are nothing short of astonishing.

Multi-pipeline Support for Rendering

Dual Pipeline support: a Comparison of the Rendering Pipelines available in Vortex Engine. The image on the left represent the Fixed Pipeline. The image on the right represents the Programmable Pipeline.

Dual Pipeline support: a Comparison of the Rendering Pipelines available in Vortex Engine. The image on the left represent the Fixed Pipeline. The image on the right represents the Programmable Pipeline.

Supporting several rendering pipelines enables the developer to use the most appropriate rendering pathway for the target device’s capabilities. Newer video cards for Desktop computers and the latest mobile devices can be programmed for though the programmable pipeline, whereas older devices (such as the original iPhone and the iPhone 3G) can still be supported through the fixed pipeline.

Engine Resource Management

Now that we have advanced support for a dual rendering pipeline in Vortex, we are now shifting our attention into a completely different topic. This time we are looking into overhauling the engine’s inner resource management.

One of the great features of C++ is that the language is super-extensible. You can literally change the way many things work in C++ and, it turns out that after some research and experimentation (and a little C++ magic too), we found a way to implement C# covariance/contravariance for our custom smart pointers.

Using your own Tools

Someone once said there is no building the engine without building a game. There is nothing like actually using your own tools in order to pinpoint the weak spots of the Engine.

A capture of the MD2 Library App runnin on the iPad Simulator in Landscape mode.

A capture of the MD2 Library App runnin on the iPad Simulator in Landscape mode.

MD2 Library 2.0 has been out for a while now (download here), but I haven’t had the time to update this blog! It’s a free download for all iPad users, and, at the time of writing, all iOS versions are supported. The App has been revamped to use the latest version of my custom 3D Renderer: Vortex 3D Engine, bringing new features to the table.

One of the roughest edges in Vortex was Md2 model animation support. Until last week, integrating animated models into a Scene Graph was unnecessarily complicated. Fortunately, this is no longer the case. Adding an animated Md2 model to a Scene Graph is now as easy as adding any other node type.

Md2 models in Vortex can now be “instanced” from the same data at the Engine level (not to be confused with GPU instancing) and different animations can be assigned to each model. The idea for the short-term is to be able to provide entities the ability to create a Md2 model instance and animate it however they like without causing conflicts with other entities that instantiate the same model.

Leave a Reply

Your email address will not be published. Required fields are marked *

*