July 11, 2012

day5 - race track coordinate concept

Yesterday I had some thoughts on the toughest challenges I will have to overcome during the development.  I think it is wise to reckon them before I start the work on technical aspects of the game.
Here is the first task that got me a little worried.

getting precise player positions in the race track space
This includes for AI and player to know its exact distance from start and finish and distance from both track sides. I want to avoid any ray-checks from car to do that. It is too expensive and not very accurate. One solution is to have loads of colliders (sensors) covering the track, so whenever car touches one of the sensors we know how far the car is from sides and finish then it is possible to compare it with other cars and we know which car is leader and so on. But it is just not very efficient to manually add them for a hundred kilometers long track. 
What I have in mind is to convert world space position to track-relative position. So it would switch from world xyz coordinates to track uv coords. U would correspond to travelled distance and range from 0.0 to 1.0 where 0.0 is start line and 1.0 is finish line (not sure about floating point precision here) and V would be track width ranging from -1.0 to 1.0 where 0.0 is middle of the track. This idea comes from THIS blog post about AI coordinate system used for MotoGP. I think it is very elegant and simplifies a lot of tasks especially AI behavior and keeping them on track without using bunch of waypoints and ray-check system.

How would that work?

Vector power!
Race tracks will be made of segments which I will deform by curve and multiply with array till the end of the length of curve. Lets assume that 1 track segment is a quadrilateral (tetragon) made of 4 points. To switch to track-realtive coordinates we need to know world position for each track segment. This means getting each point of track into an array and sort them to form lines, so each segments start & end line act as sort of check point. Then for each car we can get on which segment the car is on and calculate the fraction of the segment covered with point-quad or point-triangle intersection function.

I already got a chance to implement an efficient ray-quadrilateral intersection test in BGE and it works really nicely, though I have to check performance compared to point-triangle intersection functions.

Here is a simple illustration:

The tracks will have sharp turns, loops, banks, tilts and variety of configurations which makes the work on AI really hard, but converting all to track-relative coordinates "flattens" and "straightens" the track which makes work with AI ridiculously simple.
some examples:

if (player.distance > otherplayer.distance):
    #you are ahead of other player

difference = player.distance - otherplayer.distance
if (difference < treshold):
    #start collision avoidance
    #start the overtake process?

how to check on which side to overtake an opponent:

if(overtake = 1):
    #overtake in progress
    player_ahead.width > 0.0 ? go_left : go_right
    #see on which side is more space and go
    #here we can also override previous statement to check if car width is wide enough to fit in the narrowest side and so on..

this all is just a theory now how I imagine it to work in my game. I think many commercial racing games use similar approach and it works, but they have dedicated professional programmers up to the task. will see how I can handle this when I start the work. I am open for suggestions and perhaps there is even a better solution for this.

Now I take a few day rest from the project as I am moving from France to Belgium and then back to Latvia.

I got working the basic concept of coordinate system:
If this proves to be efficient enough for big tracks then I will use it in the game.

1 -

2 -
3 -
4 -

July 7, 2012

water/undewater shader WIP

This is a water shader I am working on in my spare time. The work is based on my own observations of water characteristics and written from a scratch. It is still a work in progress.
Right now the water surface is a plane, but support for real geometry waves is on its way.

Due to my old computer I am currently on, I am almost unable to capture a video with decent framerate, but the shader uses simple calculations and runs very well on even 6 years old mid-end hardware.

thread on BlenderArtists HERE

blend HERE

known issues and bugs:
- OpenGL clipping plane is not working on some GPUs
- mouselook goes wacko on some BLender versions but works fine in others
- some are reporting that sun-grab is not working
- and for some it does not open blend at all..

July 4, 2012

RGP GDD (work in progress)

As I mentioned before I will post all of the development process online. Today I am making a game design document or GDD. This is the first time I am writing one on my own.
I consider GDD to be one the of most important parts of the game development process, especially if there are more than 1 developer working on the project. Well in my case this document will be a lead that will keep me on track and I do not waste time on details while there is not a solid foundation yet.

all content here is a subject to change and will form up in further development of the game. At one point I will have to make a document file. For now this is more like a verbal sketchbook of ideas and concepts not a proper GDD, so here it goes..


"Racing Game Project¹"

¹I will come up with a proper title in the process


RGP is a fast paced single player¹ racing game where the player is a pilot of ultra fast, hovering race vehicles². Game setting takes place in a distant future or a fictional parallel universe on various distinct planets around the galaxies. The aim of the race is to test the very limits of racers skills, endurance and cutting-edge technology of vehicles in various terrain and weather conditions, much like Rally Racing and Formula One.

¹ multiplayer not planned for now
² will need a name of the vehicle


Player takes a role of a race car driver born on a fictional desert planet¹ where except for racing there is not much else to do. Player has to prove that he is the best racer on the planet in order to qualify for much more prestige races taking place in different locations. Here starts player's journey through galaxies and exotic places and extreme races. As player progresses through the game the vehicles get faster and more responsive, racetracks more dangerous and more challenging.

¹planet not yet named
Edit: darn this sounds like a plot from StarWars Ep1 taking place on Tatooine...


Well racing games is all about being first to the finish line.
The goal of my game is for player to experience the racing itself and have fun, rather than finishing the race always first, and this might not be that easy. To do this I might make different vehicle classes or groups separated by their performance. For example player starts with a lower class race car and competes against better race cars. To qualify further, player needs just finish the race, or during the race player competes in different race groups. Player does not have to finish first, but finishing at higher position in your race group is the aim. Overtaking higher class cars might make finish more rewarding. Well of course eventually the final cup becomes a fight for the first place.

But, while the game is in the development, I will focus on primary goals - having great race mechanics and make a challenging opponents.


Player has a control over a jet engine powered racing vehicles able to reach speeds that exceeds the speed of sound ( in dry air -> 1236 kph / 768 mph). Vehicles are specially designed to be agile and race at extremely high speeds. The overall design is to be aggressive yet sleek, something between jet fighter and Formula-1, the design is very distinct for each class or manufacturer.  Cockpit is completely isolated from outside world as races often take place at poisonous atmospheres, very low atmosphere densities or even vacuum. Race cars are powered by a fictional power source fit in a compact capacitors that can be filled up instantaneously by being near the power source. It also powers the power-ups and onboard weapon system¹.

¹ I am not yet sure if I want add a weapons system in the game.


As races take place in different planets the tracks vary in every possible way -
 track length & width, terrain, weather, hazards, even day/night cycle, etc. As the vehicles are hovering there is no need for a dedicated race track so it can take place at canyons, forests, deserts, rough surfaces and hills and even above water. Off-road racing is much more extreme and adds additional difficulty unlike on specialized racing tracks (from now on called "speedways"). Speedways offer a completely different racing experience - it is more narrow and requires more precision while overtaking and planning turns. 

Length of each racetrack might be around few hundred kilometers. Most of the tracks will be cyclic, but alternate routes will add variation in each lap. Alternate routes are an important part of a race track design. Some of them might be harder to reach, but more rewarding to use, some would shorten the track if used properly, but add risk losing speed otherwise. As I mentioned there are off-road races and speedways. Speedways are powered with a force field that keeps race cars on the track. This allows speedways to be oriented at any angle, and keeps vehicles racing even upside down. When off-road, racers have full freedom. Off road races takes place at canyons, dry lakes, oceans, hills and snow filled landscapes. The only lead that shows you that you are on the course are checkpoint marks, it is up to you how you reach them.


I plan to keep the controls as intuitive and simple as possible, so it has a steep or almost non existent learning curve even for newcomers in the racing genre. The difficulty of game will increase as the player progresses in the story. I want to completely get rid of manual difficulty settings in game options.

I am putting high priority on the vehicle physics. Making a race game for cars without wheels makes the task much easier, but getting the right feel and believability might be a difficult task. The ground friction is non existent (as the vehicle does not have contact with ground) I get to play around more with air friction and physics laws behind it. This involves changes in vehicle control at higher speeds, changes of pressure at different atmosphere densities or behind other vehicles.
Visual feedback as vapor cone at high speeds and humid environments will add more realism in physics presence.


Having a memorable and unique visual style is one of the most important tasks in the development process.
As I have graduated in fine arts, I feel that visual aspect of the work is one of my strongest sides. I am planing to keep the game in somewhat retro futurism style, like seen in 60s - 70s futurist artworks - smooth, bright, shiny and simple, but in the same time functional and realistic.
As a professional shader designer I will focus on creating the game visually stunning and physically plausible using atmospheric effects, smooth lighting, volumetric clouds, smoke and fog, dynamic FX and sophisticated post-processing. As the hardcoded lighting engine in BGE is currently quite limited, I will make a completely custom lighting, shading and effects engine, written from ground up completely in GLSL.
(to be continued)


I am making my game in Blender Game Engine (BGE). I am a long time BGE user and I know what it is capable of as well as its limits.

This is how I plan to split the realization process.

- planning & preparation
- sketching & concepting
- developing game core mechanics
- developing graphics and shaders
- developing game art
- developing sound, graphics & effects
- putting all together
- playable alpha version
- debugging

planning and preparation
Is stuff I am doing here right now - collecting my ideas and putting them on paper. Gathering inspiration - watching videos, images, reading books. Drawing sort of an initial roadmap for the development. Having a good rest before sketching and concepting. Taking a rest nicely fit in this schedule as I am moving back from France to Latvia.

sketching & concepting
Taking a look at collected ideas, then getting rid of complex and stupid ideas and keeping simple and good ones.
Making sketches and concept art of environments, vehicles, characters, menu, HUD, overall style, etc.

Alternately "sketching" the game code, making code snippets and proof of concepts. Visualizing it on paper how all pipeline interacts with idea to have easily upgradeable system. Creating a simple test vehicle. Making of a playground for testing gameplay, car handling and physics, tracks, controls etc.
Making of first track sketches with placeholders. Testing it over and over again till it plays right.

developing game core mechanics
Taking the "sketched" game code and clean, polish, and make it solid till basic gameplay works and I have something to build further features on.

developing game art
Here starts track building from track sketches, car making from concept art, texture painting, menu creation, prop modeling, etc.

developing graphics,  sound & effects
Making of unified shading system as I plan to have every material for the game to be completely hand written. Making particle effects. Recording, mixing, and making of sound effects

putting it all together
as fun this sounds, it is actually a long process of separating directories, optimizing models (LoD), linking them to scenes, optimizing scenes, adding collision meshes, optimizing shaders. Then comes lighting, adding effects and testing & tweaking till it looks and plays right.

playable alpha version
fun part for everyone, game-testing, collecting bugs and stuff.

ensuring that bugs does not distract game experience.


Here is the list of games and artists which I consider my mentors for this project:

1. Wipeout series from developer Psygnosis is first title everyone mentions when seeing concept art. I am a big fan of Wipeout 2097 (1996, 2002 Mac), which I used to play on my old Mac a lot.
2. Sparth (Nicolas Bouvier) is my favorite concept artist since I started game-dev as an artist in 2006. The atmosphere and feel in his works is the main inspiration for environments of my game.
3. Star Wars Episode I: Racer by LucasArts (1999), awesome game. Love the race tracks, feel of speed, sound design, etc.
4. Syd Mead does not need an introduction :) or does it? he is awesome!
5. DethKarz by Melbourne House (1998) - an underrated futuristic racing game with beautiful visuals for the time. basically Wipeout + wheels.
6. John Wallin Liberto
7. Extreme G Racing series from Acclaim -  Extreme G2 (XG2) (1998) finally a game where you can break the sound barrier and it is actually shown and heard
8. Vyle (David Levy)
9. F-ZERO series
10. Goodbrush (Craig Mullins)


just posted first version of GDD. It is awesome how much things get clear while writing a game design document. I did not put even half of my initial ideas, so that is the work for tomorrow. I feel that much of the game will form up while writing more in-depth description for each of the planets, cars and the technical details.

updated some stuff. I had a 3 day holidays, but I am back now. I got prematurely a little worried about technical stuff like getting precise relative position of each race-car on the track. But I consider this as a healthy challenge and extra experience in vector math.

added stuff in "PRESENTATION"

July 3, 2012

RGP day2

After a free screen-cast application roundup for Mac, I came to a conclusion that VLC is by far the best one. Still on this old and slow Mac I found it hard to work in Photoshop while screencasting even at 1fps.

So here is a vehicle concept:

This is done as an exercise and test before I start my work on the game for real. Mostly to test out sketching workflow and screen-casting.

I have not thought of the title of the game yet, but for now I will call it "RGP" - Racing Game Project

Next up - game details and putting all my thoughts and ideas on a paper (in this case - blog)

July 2, 2012

a new game project

while working on "BGE Candy" I realized I need a game I can apply the new features on. The idea of the game has been brewing for a while in my head now and I feel it is mature enough to start developing it further. I have not been sketching for few years already, so my hand needs some training..
Here are three first drawings, you can guess the genre from these already :)

(took me few hours each)

I will try to keep the visual style of the game as clean as possible using mostly gradients, nuanced lighting, atmospheric effects, vertical shapes and simple geometry.
The art of Syd Mead, Sparth (Nicolas Bouvier),  Rainart (Sebastien Larroude), Vyle (David Levy), John Wallin Liberto and other awesome concept artists will keep me inspired :)

I have already done BGE version of Simon Wallner's sky implementation originally from 2002 GDC Presentation by Naty Hoffman and Arcot J. Preetham. HERE is the link to implementation details and even a demo. It will take care of lighting and atmospheric effects:

..maybe I can finally finish a game I have started
I will screen cast the whole developing process from now on.