Showing posts with label Game Development. Show all posts
Showing posts with label Game Development. Show all posts

Sunday, March 1, 2009

Real-Time Terrain with Geo-Mipmapping

This terrain rendering engine with Geo-Mipmapping is one of my research project. Terrain is an outdoor area, which means not much occlusion-based culling can be done to reduce the total amount of polygon being rendered.


To workaround this issue, we need a method to perfrom terrain rendering with CLOD. The concept of CLOD (Continuous Level of Detail) is not too difficult to understand, basically more details are preserved in the areas closer to the camera view than the farther ones. The key is to maintain real-time rendering performance while not sacrificing too much graphic quality.


Algorithms such as ROAM (Real-time Optimal Adapting Mesh) and Chunked Terrain were developed to compute the CLOD at run-time. I chose to implement the Geo-Mipmapping method utilizes the GPU to do the computational load instead of mainly relying on the CPU.


Essentially the whole terrain area is splitted into many smaller terrain blocks. Each block stores a vertex buffer and multiple levels of index buffers, which represent the terrain block at different resotluion. These computations are done at load-time, and during run-time, based on value of pixel-error / distance factor, a suitable LOD is selected to render the terrain block.



One of the major issue with this approach is the gap formed when blocks of different LODs are adjacent, because the shared edges are represented by different numbers of vertices belonging to each block. To seal these gaps, the index buffer of the higher LOD block is re-computed at run-time to reduce the resolution to match that of the lower LOD block, thus effectively sealing up the gaps.

The end result is the capabilty to render an area made of 2M triangles at full resolution with roughly 20k triangles made of various LOD blocks.

Highlights:
  • OpenGL API.
  • Geo-Mipmapped Terrain.
  • Vertex and Index Buffer.
  • Gap-filling between terrain blocks.

Game Engine Development

Several techniques I implemented during my 3D engine development class:


  • Terrain Following: With several vector cross product computations, the dune buggy can be positioned and oriented to follow the terrain realistically.

  • Maya Export Plug-in: By using the Maya Plug-in SDK, I wrote several plug-ins for Maya which can be used to export model and custom attributes into both XML and binary format.

  • Collision Detect: AABB, Sphere, and K-DOP collision detecting techniques.

  • Camera Views: Mouse-look, Look-At, Turn-to, Hard-attach, Soft-attach camera views with matrix computation.

  • Hierarchy Transformation: Establish and compute 3D object heirarchy to reposition parts from their local space to world space.




Friday, February 27, 2009

Real-Time 3D Animation Technology



















  • I've learned and implement several different kinds of real-time 3D animation techniques. Here is the gist of it:
    Vertex Morphing - Stores key frames and use interpolation to animate the vertexes. Memory intensive but light on the CPU.
  • Articulated - Individual animated parts are modeled as individual meshes, and bones and joints are used to animate the meshes. Less memory needed, but the joints are blocky because the joints don't share vertexes.
  • Skinning (Rigid) - Similar to articulated, but each vertex is associated instead of at per-mesh level. Needs minimal memory, but requires more CPU power. The major draw back is that deformities can happen at the joints when animating.

  • Skinning (Smooth) - A vertex can be associated with multiple bones with different weight values, this reduces the deformities at the joints but at the cost of more CPU computations.

Saturday, December 20, 2008

A.I. - Autonomous Agent - Ants Simulation

This is my research project for my A.I. class. The program simulates a colony of ants attempting to find a food source via collective intelligence.

These ants emit trace signals that other ants will follow. Once the ants find the food source, the ants follows the trails back to the nest. As the number of ants traveling along the same trail increases, so does the amount of signals, which in term causes more ants to go along the same path.

In essense, these autonomous agents follow 3 simple rules for their actions:

  1. Follow trace signal attempting to find food sources.
  2. Return to nest when food is found.
  3. Tell other lost ants the general directions of either "food" or "nest."

These "antbots" can only perform simple actions based limited environmental factors, but together as a colony they are able to find food sources quite efficiently.

Highlights:
  • Autonomous agent system.

Sunday, November 16, 2008

Code Optimization Techniques

Several common techniques that I've learned in my Optimization class:
  • Instancing: static (pack geometries into the same vertex buffer), dynamic (similar to static, but transformed per frame), Shader (use vertex constants and GPU transforms the data), Hardware (supported by GPU).
  • Reduce draw calls: Since the process of transferring data to the GPU includes overhead, the concept of instancing is to pack more data into the same buffer to improve the performance.

  • Data Dependencies: How to write the code in special ways for the CPU to trade memory for computational speed.

  • Threading: Avoid deadlocks and other abnormalities.

  • Memory allocation: Avoid "new" memory at all cost.

  • Benchmark, bottleneck, and performance tuning.

  • SIMD: Single Instruction Multiple Data.

Saturday, November 1, 2008

OpenGL Rendering

This is my project written with C++ and OpenGL. The goal of this project is to create a real-time 3D playground scene. 3D models are exported into source code and loaded into vertex buffer. The river is an animated mesh which is able to reflect the bridge above, and pointsprite was used to render the grass on the playground.

Highlights:

  • OpenGL API
  • Vertex animation
  • Reflection with Stencil Buffer
  • Pointsprite Grass




Saturday, October 11, 2008

Game - Super Star

Super Star is my game project which is designed towards casual and female audiences. In SuperStar, the player assumes the role of a record company manager, who has a limited amount of time to recruite new pop stars and make them shine in the entertainment industry.

The player will recruite the stars by playing the puzzle mini-games, where correct answers to the pop-culture trivia will impress them and allow the player to manage them. In addition, to make the stars more popular, the player will train them through singing and dancing mini-games which improve their popularity stats.

As the pop stars gain popularity, the player can then book small concerts for them. The ultimate goal of the player is to have the stars perform at the biggiest event in town - concert at the stadium.

Highlights:

  • DirectX
  • Sprite Animation
  • Music and Rhythm mini-games.
  • Puzzle mini-games.
  • Collision and physics.



Thursday, October 2, 2008

Game - Mystic Kingdom

Mystic Kingdom is a 2D side scrolling action shooter game that I made in 2 weeks for my class project. The player controls a girl who can attack the monsters with projectiles, and level-up items are dropped randomly when the monsters are defeated.

Sprite animation system is used to deliver the graphics for this game. The animation is scripted by XML files. Each level is defined by a XML file which control the appearance and monster spawning, and the monster A.I. is controlled by behavioral scripting to give them more organic look.

Highlights:
  • DirectX API.
  • Sprite Animation.
  • Script-driven level and monster AI.
  • Physics simulation.
  • Collision detection.


Monday, September 22, 2008

Game Tool - Singing Editor (Rock Band/Guitar Hero)

The purpose of this tool is create Rock Band/Guitar Hero-like music charts for the player to perform key presses in-sync with the music track. This tool genereates XML files which stores the timing of the music notes. I created this tool to accelerate the content creation for my "SuperStar" game project.

Because the GUI is running in a thread, and I want to synchronize the state of the WMP control plug-in with the GUI, so I used a C# delegate to poll the WMP control and update the GUI.


  • C# and .Net Framework.
  • Windows Media Player control plug-in.
  • Multi-threading delegates.

Friday, September 19, 2008

Game Tool - Dance Editor (DDR/Dance Dance Revolution)

This is another tool which goes along with my "SuperStar" project. The Dance Editor reco-lrds mouse clicks and generates "foot steps" as the dance moves. These moves are stored in XML which is loaded by the game to display the DDR-like gameplay.

One of the challenge for this tool is to be able to "pick" different oriented "foot steps" in different angles, and I use half-space test to check if the mouse click is within the collision rectangle or not.
Highlights:
  • 2D Picking with half-space test.
  • C# and .NET Framework.
  • Windows Media Player control plug-in.