Yansen Sheng

PrimeEngine Development

Introduction

PrimeEngine is a preliminary game engine written in C++ with Python and Lua scripts, developed by Artom Kovalovs, and is used as a tool for the course Game Engine Development.

The following are features developed by me, some with my teammate Bochang Wu, during the course, and the corresponding video demos. Due to confidentiality, I cannot share the source code. If you have any question, please feel free to contact me with the links at the end of the page.

I and Bochang made a game demo upon these features. Please check it out here.

I and other four teammates are also making a networked multiplayer FPS. Please check it out here.

Camera Culling

The camera culling feature culls out every object that is not inside the final render image. This feature optimizes performance, especially when there are a lot of objects need to be rendered.

I maintained a bounding box for each object to detect its collision with the camera frustum. The camera frustum is a frustum in world space for perspective cameras, and it is hard to test collision against due to its shape. However, if the frustum is projected into camera space, the frustum turns into a box, which is easier to test collision against. Thus I projected the bounding box of every object into camera space to check if this object enters the camera frustum and decide if this object needs to go through the render pipeline.

The video demo shows that camera culling can increase the performance up to 50 %.

Please turn subtitle on when watching.

Physics

Physics enables objects to collide with each other. I maintained oriented bounding box for each static object and bounding sphere for each dynamic object (such player and enemies) and implemented methods for testing collision among them. The collision test is similar to camera culling, as I project the bounding box/bounding sphere of one object into another object's model space to check intersection.

Please turn subtitle on when watching.

Particle System (with Bochang)

Particle system consists with an emitter and a bunch of particles. An emitter is a translation in world space, and a particle is a mesh which is spawned by the emitter with a velocity and a lifetime.

Since particles will die and disappear at the end of its lifetime, we managed memory by implementing an array to store all the particles. When an emitter is initialized, we append an array of deactivated particles to it. Deactivated particles do not update there positions over time and are not processed through the rendering pipeline. When the emitter needs to emit a particle, it activates the first deactivated particle in the array, assigning it a velocity and a lifetime. Then the activated particle moves with the velocity, and deactivates itself at the end of its lifetime, exchanging its position in the array with the last activated particle. With this memory management, we don't need to care about releasing memory for dead particles and thus can avoid memory overflow. We only need to calculate the maximum number of active particles at any time, which is the size of the array.

In the game demo, we enabled the glowing texture for the particle mesh. Please check it out at the game demo page.

Please turn subtitle on when watching.

Wind Effect

Wind effect is a modification in the shader program. I created a second UV coordinate for each vertex proportional to its height in model space. This second UV coordinate determines how much displacement the wind will affect on this vertex. I generated three wind effects as constant attribute in the shader program, one in the direction of the camera's front and the other two in the direction of the soldiers' front. The displacement on each pixel of the object is calculated in the GPU shader program.

Please turn subtitle on when watching.

NavMesh (with Bochang)

We implemented a navigation grid mesh with A* pathfinding algorithm. We first baked the navmesh when loading all the objects. The ground mesh is divided into grids, and every grid that is inside an obstacle's bounding box is marked as obstacle. The grid with the player will be marked as player grid, and the ones with the enemy will be marked as enemy grids. A navmesh agent is attached to the enemy character, which will calculate the shortest path from its current position to the player grid with A* algorithm, and will leads the enemy character to move along the shortest path to approach the player.

We are working on generating the navmesh by triangulation with Voronoi Diagram, which will provide a more fluent navigation than navmesh grid.

Please turn subtitle on when watching.

There is a game demo made upon these features. Please check it out here.

There is also a networked multiplayer game demo (under construction). Please check it out here.

Due to confidentiality, I cannot share the source code. If you have any question, please feel free to contact me with the links below.