January 6, 2015

//status update 05 & a sneak peek in 2015!

My previous post was a bit more than a year ago... well the good thing is that since then I have a collected pile of projects and other stuff to share.
None of them are finished though, maybe that`s why I felt they are not shareworthy..

Anyway, I have moved from France back to Latvia and settled down for a while. I am still working full time with Blender & also Blender Game Engine on supersecret projects of which I can`t show anything yet. So I can only share with you things I am working on my spare time.

So, here is a list of projects I am planning to work on and hopefully finish this year. For each of these projects I will write a separate article explaining the details:

RGP (racing game project):

almost all of the effects, shaders and new stuff is related to RGP. I am now building up sort of a base to build the game on. The lighting and shading system is almost done, what yet needs to be finished is the physics, handling and collision system. After that I can finally focus on the content, story and gameplay.

PBR (physically based rendering):

RGP will be rendered using new lighting system. I am now in research and prototyping stage. Basics are functional and it looks really nice already.
- new sky model
- image based lighting (IBL) using environment map
- real time environment map based on sky model or surrounding scene.
- some advanced BRDF functions

Terrain system to render vast landscapes (also needed for RGP).

- uses adaptive LoD
- infinite procedurally generated landscapes

Continue the work on my water shader. I am still planning to implement it in Unity. 

- combined with the new terrain system
- combined with physically based rendering system

Advanced buoyancy system for water shader.

- calculate buoyancy forces for each object submerged in water

Tron lightcycle game, yep still in progress.. I am doing a full re-write of the scripts.

- port all of the code from old Blender versions to Blender 2.7

And some screenshots of the work in progress from each project:

PBR and real time environment map
real time environment map with glossiness
final composite


quadtree LOD terrain

ocean rendering and buoyancy

Tron lightcycle game

November 24, 2013

water/underwater & sky shader update #03

Yep, I haven`t been very active blogger lately.
I am very glad that company I am working for brought me to Amsterdam to Blender Conference this year. I even did a presentation there together with my colleague Michael Otto about GLSL shaders in Blender Game Engine. And for the presentation purposes I decided to demo my water/underwater shader there.
Just before the presentation I managed to tune up the shader and the scenery a bit.

so the changes since last update are:
- projected grid approach for the water surface (lousy implementation)
- per-vertex displacement mapping for waves
- basic but effective shoreline detection for water surface and ground
- added some subtle cloud layer and stars in the skies

yet to be done:
- fixes on inconsistencies
- better and procedural wave propagation model
- focus to underwater visuals
- better camera transition from water/underwater
- better coastline behaviors
- buoyancy (partly done)
- heavy optimization
- when it`s done, as many have requested - implement in Unity

trees are generated with tree[d] by frecle

blend file to be uploaded (have to clean and optimize the code a bit)

September 13, 2013

water/underwater & sky shader update #02

I published this quite a while ago, but found some time to post it here just now.

This is an update video to one of my oldest projects in the making.
nothing much has changed since the last video, I just have a better computer now and I recorded it in a higher quality and framerate.

The water shader is based on my own observations.
it features:
- reflection with accurate fresnel refectance model
- refraction with chromatic aberration
- projected caustics on geometry from the water surface based on normals
- seamless transition to underwater (no fake fog added)
- accurate water volume with light scattering
- view and light ray color extinction based on water color and sunlight
- simple coastline detection based on terrain`s height-map

does not yet feature:
- displaced water geometry
- underwater particles
- underwater light rays from caustics
- shoreline behaviors

Sky model is based on Preetham, but implementation is from Simon Wallner, with a significant (artistic) changes done by myself.

I have also included an overly exaggerated experimental glitter shader and a completely procedural "water droplets on lens" shader.

YES the underwater distortion is completely unrealistic and will be removed once I add underwater particles that will wobble similarly.

download blend:

sound files from

May 15, 2013

image imperfections and Film Grain post process FX

It`s been a while already since game studios try to replicate lens and film camera effects to enhance the visual fidelity for their games. Most of the time it does not make much sense to see them from the perspective of the player, but nonetheless it does look nice if done right.
I am talking about lens flares, vignetting and chromatic aberration, depth of field, bloom effects and film noise/grain. In photography or film they are considered as visual artifacts caused by imperfections and properties of film and lenses and mainly - the physics behind optics. Most of photo/cinemato-graphers do their best to avoid them by using better lenses and lens hoods to reduce vignetting, lens flares and chromatic aberration and use different sensitivity films for appropriate scenes to reduce image noisiness so in the end they get as clear image as possible that is usable for editing - tracking, compositing or whatever they do..  In the gaming industry it is pretty opposite - renderer outputs a perfectly clear image and artists do whatever they can to make it imperfect.

Few years ago these effects were done with some moving view-aligned textures, but now with clever shader tricks we can fairly accurate simulate them as an image post-process effects.

I have re-created most of these effects already and posted results in my blog. Links:
lens distortion
lens blur with bokeh v1
dof with bokeh v2.1
lens flare

And here are very nice results from other guys

Lens Flare by Max Planck Institut Informatik
Lens Flare by John Chapman
DoF with bokeh by Epic Games
DoF with bokeh by Matt Pettineo (MJP)

Film Grain.. the reason why I am writing this post here right now.

Film grain is a texture on the photographic film caused by an emulsion containing photon sensitive silver halide salt crystals. They are sort of pixels of the photographic film. Depending of the size of the crystals varies the resolution and sensitivity of the film. Bigger the particle (higher ISO number), higher the light sensitivity, but the image is less detailed. Unlike the digital image sensor where light sensing pixels are arranged in a regular grid, film crystals are jittered randomly over the film which gives an image more pleasing for the human eye. The possible reason for that might be the fact that the film grain does resemble the pattern how the photoreceptors are arranged in the retina of the human eye. Awesome, right?

photoreceptors in human eye (source

an extreme case of color film grain (source

Now in the digital era of cinematography most movies are shot digitally, that`s why often the film grain effect is artificially added on digital image. Many of the Blu-ray movies have a very distinct graininess, which actually gives a nice high-def cinematic feeling.
So exactly the same should apply to computer games.

Film Grain does seem to be the least difficult to simulate compared to other lens effects, but surprisingly I have not yet seen any convincing real-time implementation that does resemble, for example, the nice granularity look of 35mm film. Well the best examples of film grain effect I found used in games are by Crytek and Valve software - Crysis Warhead/Crysis2 and L4D series to be specific. Unfortunately the effect can hardly be called "film grain", it is rather an overlay noise that makes the appearance of slight jitter. What they did right is the elusiveness of the effect. Increase the grain amount a little bit more and it gets annoying.  For many game titles film grain effect bothered me so much I disabled it completely (if there was an option at all). Mass Effect was one of them, in fact in darker scenes it looked nice, but in highlights made the image look dull and dirty. It did a good job covering up some less detailed textures and models though.

The possible reason why film grain does not seem to have advanced over the years like other effects might be that the grain filter is so subtle the developers do not bring much attention to it. And why waste time, money and precious milliseconds of computing time to create an effect most gamers would never notice. Well, here exactly lies the problem - overdone effects. Most notorious are BloomSSAO, DoF and yeah.. Film Grain and they are certainly very easy to overdo.
Personally I love subtle details. For me the best effects are the ones that enhances the visual quality while not bothering me with its presence during gameplay.
And there is another point - high ISO film photograph can get very grainy but the image looks nice and natural, while a bit overdone film grain effect in game ruins any viewing pleasure.. So the problem lies in the technique which generates the grain pattern and mixes it with the scene image.


The common methods of simulating it in games are either using a real grain texture or computing a noise pattern procedurally in runtime and then mixing them with the rendered image.

Pre-computed texture approach might make the best results as you can use actual grain texture taken on real film (filming against a grey background) and then overlaying this image to game scene. the downside is that it needs to be different in every frame. You can offset it a little and tile it, but a trained eye will always notice the tiling and this can make the effect very annoying. The approach does work best for still shots.

Procedural approach will ensure the grain will never tile, but the result is actually a noise and does not resemble the granularity of film grain at all. It does look more like a digital sensor noise. One might actually misinterpret it for an interference of the video signal to the monitor.

My take on Film Grain effect

All the time I have been using the procedural noise approach which is fast and gives nice results if the noise amount is very little, but as I mentioned it looks more like an interference in video signal.
After doing some research in this matter I collected bunch of reference images taken with film camera. I extracted the noise pattern from them and compared it to the noise shader I have been using. As you see it is lacking the graininess of the real thing.

I opened the image of my noise shader in Photoshop and tried to replicate the real grain texture. Blurring a little and adding 3 passes of sharpening did actually the trick. Unfortunately doing that for full-screen texture in shader would significantly slow the process and make it unusable in real-time.

So now I had to find a procedural or semi-procedural approach to simulate the same pattern in the shader without having to blur or rendering it in multiple passes.
Few years ago I did a vertex displacement mapping experiments with a procedural Simplex noise algorithm which created a nice grainy pattern. I resurrected the shader and applied it to a grey color and here is the result:

That is a really pleasant uniform grain. It is lacking a bit of the randomness but otherwise I call this a success!

Comparison shots of noise and grain applied to a gradient.


simplex grain:


There is yet long way to go for more accurate results. It could be extended to include the real science behind it like varying graininess based on camera`s relative aperture. But I am only an artist so I go by whatever looks the best :)
This whole thing is a work in process, but I feel that even at this stage it looks already better than many other real-time film grain shaders. As you see the grain is not making the image look dull. It is less visible at bright areas of the image, but more noticeable in darker shades. An option to change the grain size is yet to be done.

Perlin noise grain applied in CryEngine (big images):
screenshot 1
screenshot 2
screenshot 3

100% crops from the shots above:


today during further grain shader development I tried to replicate the grain in the image with the rally car. I had to de-noise the original image with resulted in some loss of detail. Then I applied the new grain shader on it. Here is the result:


de-noised and artificially added film grain shader:

real film grain compared to new film grain shader:

There are some significant changes from the original shader:

- user variable grain size
- added varying coordinate orientation for noise pass to eliminate any directional artifacts
- option to reduce grain based on luminance value
- added more tweakables for color noise


v1.0 (old one):
HERE you can find the GLSL shader file.


- noise algorithm I copied from HERE by toneburst, but original implementation comes from Stefan Gustavson found HERE

February 25, 2013

RGP day 15 - AI and a download link

So, as promised, I am finally giving you something to play with.

I have added a very basic AI steering system and obstacle avoidance behaviors. I will write a more detailed article about it soon.

physics and handling
I completely rewrote handling and physics system using real world laws of aerodynamics. It was a really nice exercise and gave me the basic understanding of movement, drag, acceleration, etc.
The movement is now much smoother and the vehicle is very stable.
all math came from here: & HERE
I will write a more artist-friendly overview of the physics behind the game.

added subtle motion to the UI while steering

camera movement
The camera is now more dynamic. FOV, height and distance from vehicle increases with the velocity.

post-process filters
added a simple lens filter that distorts, blurs, creates vignette and adds some chromatic aberration near the edges of the viewport. I might make it react to the velocity as well.

a video:

and a download link to blend:

Now I have to finish few projects, so this is probably last (RGP related) blog post in next few months.

January 22, 2013

RGP day 10 - a bit of everything

First post in 2013, and I feel it is going to be a great year :]
I know it`s been a while, but I am working on the game again!

It is actually day 10 - 14 of the RGP. I worked on the project quite a lot, mostly tweaking the code to make it work just right. And finally here is also some visual stuff, while only sketchy, but something! So here is the stuff I`ve been busy these last 5 days.

physics and handling

I`ve been collecting some useful resources regarding physics, acceleration & springs`n`dampers aswell as browsing through YouTube videos of Wipeout, F-Zero and other futuristic racing games. I believe now that a nice vehicle handling system will be actually much bigger challenge than I initially thought. I hoped I could stay with Blender`s built in Bullet physics & material properties in UI, but I just could not get the feel and handling right as well as it caused stability issues at high speeds. So I created my own system. Basically it consists of spring-damper system for vehicle suspension, engine system for thrust and turning and a very basic inertia and gravity system.

race track & vehicle

I made a race track to push my physics system to the limits. Basically it is an oval loop with a twist - literally :).  I created a race track based on Möbius strip - "A model can easily be created by taking a paper strip and giving it a half-twist, and then joining the ends of the strip together to form a loop". So you are actually racing on the both sides of the race track. Also the oval in the middle is bent around 90degrees up which at high velocity, will create very high negative or positive centrifugal forces, so that the race car will be either pressed against racetrack surface or pulled off it. In the game speedways will have a gravitational force field which will keep the race cars from falling off the track either at high centrifugal forces or regardless if the track is upside down, so I think that this kind of racetrack configuration is perfect for testing and tweaking purposes.

overview of the "Möbius race circuit"

clearer view of the configuration

This is a generic racecar you would find in similar racing games. As the rest of the game this is only a placeholder. More race car concept-art is on the way :)


This is the first time I am working with Moguri`s BGUI - a graphical user interface (GUI) library for BGE. I have just started to mess around with it, so nothing much to see yet, but I intend to keep it simple and minimal, close to what you can see in the screenshots below.

Camera movement

I worked also on the camera movement a little. A good setup can add a great amount of immersion into the game. Just parenting it to the race car`s chassis does not look good. I will do a deeper look at it sometime later.

Graphics & FX

Nothing fancy yet - a simple skylight setup like THIS, completely texture baked terrain, simple fogging that gives an atmospheric feel. Exhaust trails are cross shaped , textured planes spawned each frame - I should find some more efficient way of doing them.

screenshots showing all of this together which starts to form up the feel of an actual game:

(I am having some difficulties with screen capture software working on Windows 8 so perhaps I will switch back to win7 to be able to make some videos)

Back to Win7 and video is here.

blend file is on the way.

November 26, 2012

Sager NP9150 / Clevo P150EM laptop review

Here is something quite different this time - a notebook review.
Choosing the right one is a time consuming process, at least for a person like me, but as a real tech-freak-geek I love it! hehe :) I hope this review will help someone in a need for a powerful system to choose the right laptop and configuration.

It took me somewhere around a year to finally place my order for this computer as I am very careful choosing right hardware and components (reading tons of expert reviews and user feedback) before buying something. So here are my experiences throughout the whole process.

choosing the right one

As a freelancer I needed a desktop replacement laptop PC, so I can easily bring my work wherever I need. I work with real-time graphics, shaders, simulator and game development so a powerful GPU was the main concern when choosing the right laptop.

Here are the main characteristics I was after when looking for this computer:

- has to be compact, so 15.6"
- has to pack powerful components, especially hold most powerful GPU
- ..while run reasonably cool and quiet
- quality chassis and assembly
- low profile looks
- a good matte display

I decided to get a custom gaming laptop as most ready-made laptops does not really provide the best components I am after. From here it gets quite simple - choose either Alienware, Asus, MSI or Sager. And then I realized that another very important aspect for me is the looks. Immediately I discarded Alienware and MSI because their design, in my opinion, is awful. What I need is a powerful laptop that I am not ashamed to bring to conferences, presentations and workshops. I was down to Asus and Sager. ASUS has max only GTX 670M so my only real choice was Sager/Clevo. Sager laptops especially NP9150 looks tough and solid almost like a business laptop, but in contrast the multi-color backlit keyboard looks badass - adds a premium gaming laptop character to it.

I tried to find a good Sager/Clevo reseller in europe, but I did not have much luck. Well I did register for which are the only distributor for Clevo notebooks, but at that moment they were out of P150EM chassis. So my only option was getting mine from US. I chose, the customer service is great and if I ever gonna buy a new laptop, I will buy from gentechpc. From order completion to shipment it took exactly a month, so I guess there were some delays with assembly or parts. Shipping from US to France was not very expensive and shipping itself took around a week to get the package at my doorstep.
Oh, and I had to pay an extra 160-ish euros for the customs tax.


Not much people are interested what parts they have in their laptops, not me hehe. Each component was carefully selected and are there with a reason.

here are the specs of my configuration, I will briefly review each one of them later:

CPU: Intel i7-3840QM 2.80-3.80 GHz, 8MB Cache
RAM: 16GB 1600/PC3 12800 (2x8GB)
HDD: Western Digital Scorpio Blue 1TB 
SSD: Intel SSD 520 Series 240GB
          Mushkin Atlas mSATA SSD 240GB

Display: 1920x1080 Full HD, LED backlit, 95% NTSC Color Gamut, Matte
Wireless: Killer Wireless-N 1103, 802.11a/b/g/n, 450Mbps
Thermal Compound: IC Diamond 24 Carat

Intel i7-3840QM 2.80-3.80 GHz, 8MB Cache

Second  (or maybe third?) fastest mobile CPU out there. 4 cores and 8 threads. Has integrated Intel HD Graphics 4000 GPU. Nvidia Optimus switches to HD 4000 for easier tasks and therefore drastically saves battery life. My decision was between 3740QM and 3840QM, the only real differences are increased clock speed by 100MHz and 8MB L3 cache (over 6MB).

Compared to desktop CPUs based on the chart HERE, it sits somewhere between i7-2700K, i7-3820 and i7-3770.

I opted for IC Diamond 24 Carat thermal compound for cooler operation and longer lifetime.


onboard Intel HD 4000 vs GTX 680M

GTX 680M is currently arguably the most powerful notebook GPU. The performance is almost identical to Radeon HD 7970M. This was a quite hard decision, because 680M was $200 more than 7970M. Here are the reasons why in the end I chose Nvidia over ATI:
- better driver support
- Optimus technology for switchable graphics
- runs cooler thus might last longer

When compared to desktop GPUs, based on the chart HERE the GTX 680M lies between desktop GTX 570 and GTX 580. Or compared to desktop AMD Radeon cards, it sits between HD7850 and HD7870.

Runs most of the games at highest settings fluent on Full HD with anti-aliasing enabled.
I opted for IC Diamond 24 Carat thermal compound also for GPU for cooler operation and longer lifetime.

16GB 1600/PC3 12800 (2x8GB)
Got the model number in CPUID - SuperTalent W1600SB8Gx

Well RAM is quite cheap nowadays, so I got it more than I really needed, although video editing software like After FX and Premiere can squeeze every megabyte of your RAM. When rendering in After Effects (64bit) I noticed 95% usage of all 16GB, nice!

Western Digital Scorpio Blue 1TB
I recently realized that I do not use CDs or DVDs anymore so I opted for an optical drive bay caddy where to put a HDD. But I bought an external BluRay drive in case I need to install stuff, write stuff or want to watch a movie. So anyways there are not much 1TB 2.5'' drives to choose from here so I got the WD Scorpio Blue. It t is not yet installed though :D, so benchmarks later.

Intel SSD 520 Series 240GB
I am an SSD fan throughout since I got my old Intel X-25 80GB few years ago. Why Intel 520? It is fast and Intel is known for very reliable SSDs. Win7 boots up fast - without even finishing the welcome logo. Software opens almost instantly, Photoshop in around 2 seconds, Lightroom and Blender in less than 1 second. Photo directories reload thumbnails instantly. Totally worth it!
If you get a SSD, get a reliable one. Speed does not matter anymore, you just will not feel the real world difference between most of the SSD drives. The only difference is in the benchmarks, hehe.

Mushkin Atlas mSATA SSD 240GB
It is a miracle - in a size half of a credit card it packs a performance similar to top-end SSDs. Unfortunately the mSATA port in Sagers are 3Gb/s instead of 6Gb/s so it does not utilize full potential of its capabilities, but nonetheless it is awesome. I am storing my frequently played games there.

AUO B156HW01 V4
I chose a matte display just because reflections of surroundings or myself are very distracting while I work. Especially for graphic design and digital painting the reflections might render the colors inaccurate. And matte display is usable in outdoors while for glare type screen you have to look for a shade. And I go outside to paint stuff digitally.
The display itself is one of the best I have seen in laptops. It is bright, vivid with a great contrast. One thing that surprised me a bit - the pixels are very tiny because of the Full HD resolution packed in 15.6''. It might be difficult for other to get used to it as text appears very crisp and thin, but for me - it is now hard to get back to a normal display :)
Viewing angles are great for TN panel, could not expect more.
There is a slight back-light bleed (as expected), but not distracting at all.
One tiny fault in otherwise perfect display is a small stuck pixel in left middle side of the screen. I would not notice it if it would not have a bright halo around it, it is really annoying one. A proper idiom (in my country) for it would be "a drop of tar in a barrel of honey".

Killer Wireless-N 1103, 802.11a/b/g/n, 450Mbps
Well I am not sure how much difference this will make from a standard wireless cards, but if I have a top-end components why not have a top-end gaming wireless card :)
Reviews praise this network card so I will give it a shot.

This laptop comes with Onkyo stereo speakers and a "subwoofer" on the other side of the chassis. Onkyo is a known brand making a quality sound systems and the laptop is Dolby THX certified. I do not expect much from tiny laptop speakers, and that exactly is what it delivers. I am using an external speaker setup or headphones anyway.

Temperature and fan noise
This laptop packs top-end components which, of course produce a whole lot of heat and it is all squeezed tightly in 15.6" chassis. To keep a system like this cool Sager uses separate heatsinks and dual fans for CPU and GPU. Behind laptop there are two exhaust vents much like in ASUS ROG laptops. This highly effective cooling system not only keeps the laptop cool but also adds some room for overclocking.

In my room where ambient temperature is around 23-24°C
CPU idles at 50°C
GPU at 38°C (because of Nvidia Optimus, GPU only kicks in when needed for some serious action)
Full load (with prime95) the CPU temps reach up to 83°C
Full load (with FurMark) the GPU temps reach maximum of 84

While gaming the keyboard surface remains comfortaby warm. On my older Acer laptop the keyboard got quite hot and my palm started to sweat making gaming experience quite unpleasant.

I bought this laptop knowing that is not meant to be silent, but for my surprise it is idling very silently. Sometimes a CPU fan becomes more noticeable when onboard GPU has more load. At nights when ambient noise from street or apartment is gone the laptop seems a bit more audible, but still it is a soft hissing sound.
When on partial load and gaming the GPU fan kicks in only then the laptop gets fairly noisy. On more demanding games with both fans throttling the noise can get quite distracting, but I, honestly, respect that - fan noise is the sacrifice to get that much performance in a laptop of this size. When I have headphones on I do not notice the noise at all anyway.

Battery life
I will be working at my desk for the most of the time with AC power adapter plugged in, so battery life is not an important issue to me. In balanced performance mode with internet browsing etc. I was able to use the laptop for around 3 hours which is not bad at all.


Some brief benchmarking with most common bench tools. If you have any requests of testing I can post them here.

Overall system bechmarks

Windows 7 Experience Index
So first of all something a real PC enthusiasts does not consider a real benchmark.

not bad, considering my old quad core desktop gaming PC is 5.9

CPU benchmarks

Cinebench R11.5

Geekbench 2.4

GPU benchmarks

3DMark Vantage

3DMark 11

BMW Benchmark scene by Mike Pan in Blender 2.64 - Cycles Render

CPU: 4 minutes 18 seconds

GPU: 1 minute 15 seconds

SSD bechmarks

Note: Mushkin drive is connected through SATA 3Gb/s port, so the scores are lower than they should.

Intel SSD 520 Series 240GB

Mushkin Atlas mSATA SSD 240GB


Intel SSD 520 Series 240GB

Mushkin Atlas mSATA SSD 240GB

And here are screen captures from games played at highest possible settings.

vsync was enabled so it does not show actual frame rate
sound is messed up at 2/3 of the video, sorry.

max settings, no AA, Full HD

Crysis Warhead
max settings, 4x AA, Full HD


Crysis 2
Ultra, DX11 enabled, high res textures on.

NFS Hot Pursuit

Images of the laptop itself are on the way. Till then you can see pics from another user review HERE

edit May 29 2013

So.. after 6 months of intensive use everything is nominal. 2 months ago I noticed some increase of the heat, so I cleaned it from from the dust which fixed the issue, so I suggest a regular maintenance every 3 months.

To get most of the display, I bought Spyder3Pro display color calibration tool. Here is the ICC profile.
drop it in: C/Windows/System32/Spool/Drivers/Color

GTX680M performs really well, it still holds up well against all recent games at FullHD with High graphics settings. Optimus GPU switching works without any issues.

The sad news - no Nvidia 3D Vision on this laptop :(
I was very disappointed that "Optimus" thing is preventing any possibility to enjoy 3D stereoscopic movies and games... and I need this feature for my job. The thing is that due the architecture of GPU switching the video output from GTX680M is routed through integrated HD4000. Nor Sager/Clevo, nor Nvidia advertise this issue, but it would be nice if I knew it before buying Nvidia 3D Vision set and a 120Hz display. I will try to find a workaround or something.

Images of laptop yet to be made

November 16, 2012

BGE Candy - Area lights

I have a new PC computer and this is a milestone for the development for BGE and my racing game. Finally I can to some more quality screen capture, and the first ones to show you are - area lights!

As soon as I saw Arkano22`s implementation of area lights in forums I knew Blender must have it in GE! This is a slightly modified version of Arkano22 technique, the biggest differences are the smoother light falloff and specular reflection glossiness variations based of the reflecting surface properties and distance, and of course - the texture support!

video showing how to set-up them:

win32 build:

October 29, 2012

RGP day 9 - physics

So today I am doing something completely different I've done so far - the physics system. It is the next big challenge aside from the track coordinates and AI.
For collision detection and simpler stuff I will be relying on Blender's Bullet Physics system, but more advanced things - track space constraints, hover spring-damper system, vehicle handling and behaviors I will have to write from a scratch. And as an artist I am very good at it :P. Fortunately we have an Internet and there are a lot of really helpful resources for this.

The first thing I tried to implement was a mass-spring-damper system. I will be using it to make the vehicles levitate above the ground/racetrack surface. The idea is to cast a ray from the vehicle's vertical axis down. If it collides with a surface the spring-damper simulation will run and apply the calculated force to the vehicle.
The most helpful resource I found had an actual Blender Game Engine implementation already :). HERE is the link where I found it. It is done by Sebastian Korczak, same guy who is making the Burster - a web browser plugin to allow publish and play Blender files online. I will be using it at one point of development to show off the progress.
So after some changes I had a nice springy levitating box.

Another thing I managed to create - a force field that will keep the race car close to speedway's surface, thus preventing the vehicle to fall off the track surface even if the speedway is oriented upside down.

For those who have Burster plugin, can play around here in the browser:
(I have no idea if it works or not, I am currently on mac)
controls: arrowkeys Left/Right

or blend file HERE

October 28, 2012

shader based cube environment mapping

I present you a pure shader based cube environment mapping. It might be useful for those who, for whatever reason, does not have "samplerCube" texture type support in their engine or want some more flexibility or customization for envmaps. It is a tiny bit slower than the proper version and mip-mapping is not working well, so it is pretty much useless.
This paper helped me a lot:

Anyways, the input can be 6 separate textures or cube environment map Blender style. A standard OpenGL style alignment is on the way.

shader HERE

screenshots are in previous post :)

October 23, 2012

//status update 04 & RGP day 8

Lots of good stuff has happened recently. I am waiting for my new custom laptop to get shipped from US, so finally I will be able to normally screencast the process of the development of my racing game ..and to actually play my game. As a real tech geek I will also write a short review of it :)
Not much has happened to RGP since the last post and I believe the real process will start whenever I will be on my new rig.

Here is the list of stuff regarding RGP:

- So for the outdoors lighting in the game I will be using a procedural sky model originally presented in 2002 GDC by Naty Hoffman and Arcot J. Preetham. Implementation by Simon Wallner seemed to be the best one I could find and I have already got it working in BGE (see it HERE). I thought I was quite satisfied with the results, but just few days ago some guy asked for an assistance regarding the sky shader as he is implementing it in UDK4 engine. It turns out I had seen his works numerous times and visited his portfolio earlier, be sure to check it out HERE <- awesome stuff! Anyways he also pointed out that it lacks the distinct sunrise feel to it so I took another look at the shader. After few modifications I came up with a nice sunset/sunrise effects.
- I also added a Uncharted2 filmic tone mapping operator from John Hable's GDC presentation and implementation of it from HERE. I really Hope I can add a real HDR support in BGE someday.
- Another feature I have been trying to replicate in BGE is generation of cubemap environment maps in real-time. I did it by simply rendering textures from 6 cameras and then combining them in a shader. It is slow but works! A simplified and optimized version of it I might use for reflection in the game.
- And the last but not least - a pseudo lens flare by John Chapman (implementation from HERE)


both files also feature point light scattering by Miles Macklin.

realtime cubemap:

lens flares:


the upgraded sky model

real time cube environment mapping

lens flares

Battlefield3 style dusty lens

light directly into lens

October 2, 2012

RGP day7

so I've taken enough rest and today I am moving from "planning and preperation" to  "sketching and concepting" phase of the development process.

here is a fast 30 minute draft of shaping up the feel and scale of the desert planet. I will do a series of these.

Aside of the art part, today I tried Moguri's BGUI, which I will use for menu and some of in-game HUD. It looks very promising, but will require some intensive learning for me to get used to it. I am also planning to create a custom lighting engine with atmospheric scattering, aerial perspective, weather system, moon phases, etc. I will then build physics and handling mechanism on it. After I will publish first pre-alpha demo to try out.

September 12, 2012

//status update 03 & RGP day 6

it`s been a while, but no worries - the racing game project and BGE Candy is progressing. Slowly though as the spare time passes with friends and grasping the last summer days before I go back to France next week. After that aside from the job I am fully focusing again on RGP and BGE Candy.

RGP day 6

After a few days of intensive tinkering with vector math, I finally found a perfect solution to get barycentric coordinates of the track (I explained about this coordinate concept in the previous post)

I found rayCast() function in Blender`s Python API which also fetches UV coordinates of the ray intersection point. So now all I need is to UV map the race track, shoot a ray from vehicle down to track`s vertical tangent and voila we get vehicles relative position on the track.

I also made a simple racetrack trajectory recording system that records position and speed of the car at current segment. When it is recorded it saves it to a list and AI linearly interpolates between the points.

That`s it for now.

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 -