A quick retrospective into last year2017 was an amazing year for SuperTuxKart, we had tremendous support from our community to Greenlight us in five days and our lead artist released the 0.9.3 version live at the Blender conference. You can watch the event here. 0.9.3 also brought SuperTuxKart to Android.
Behind the doors we are busy and ready to take the game to the next level. On the rendering side we have a couple of exciting things to share with you. We are going to take a journey into the wonderful world of light and shadow.
Improved Rendering EngineSome solutions that worked in the past are slowing becoming a burden going forward. Over the past few months, a lot of work has been ongoing on Antarctica, SuperTuxKart's graphical engine, in particular thanks to our developer Benau.
This work will be released in a future version of the game, though we do not yet know which version or when the release will occur.
Better performanceLet's put it straight, performance is important for us. And while it is hard for our small team to rival the powerful engines used by AAA games, we are working hard to make things as good as we can with the resources at our disposal. The new engine is more optimized and in most scenarios will see slightly improved performance.
Physically Based RenderingOne of the highlights of the new version is an improved materials system. This new system should make it easier for artists to create good-looking tracks, by allowing them to easily use content creation software and tweak materials properties such as roughness, glow or metallic look.
The version of Antarctica that will power the upcoming version of SuperTuxKart will use a PBR renderer. It will become very easy to setup complex materials. Instead of learning a brand new system you just have to answer these questions:
- What is the color of the surface (without any shadows, just the pure color)?
- Is the surface polished?
- Is the surface a metal?
- Is the surface glowing?
Custom shadersWhile we expect the majority of content creators to use the default shaders that are provided with the game, we also want to empower advanced creators by allowing them to create their own custom shaders. It will be possible to easily add shaders, each object can have up to 6 textures in slots and "unlimited shared textures".
|An example of a road shader with procedural texture blending|
New file formatWhile this was already introduced in the last version of SuperTuxKart we extended the format to include high quality bitangent which removed a couple of bugs regarding normal map shading. We now use the same technique that is used by any modern game engine (Blender, Unreal, Unity, etc) so the shading will look perfect.
Everything is shiny, what does it mean?Now let's go in-depth and see how rendering works and how we came here.
A brief history of lightOur epic journey starts 8 minutes ago in the core of a giant plasma ball tirelessly emitting light particles.
|Source: NASA Solar Dynamics Observatory|
When the photons are bouncing around, they will react differently depending on the surface, sometimes they are absorbed, sometimes they are scattered around or they can even go through a material like glass.
Those slight differences are causing the whole diversity of colors and materials in our world. If something appear red it's only because the surface of the object absorb most of the incoming light except red.
Why does it matter for SuperTuxKart?Well, in video games we are trying to simulate this phenomenon to provide a believable environment to the player. When you drive in SuperTuxKart and explore our tracks, the computer has to somehow emulate this, to be able to show you a picture.
The first approach would be to simply cast billions of light rays just like in reality.
While this approach works (it's called ray tracing) and can provide amazing results it has a huge drawback. It's costly in term of performance. It's mostly used in movies and one frame can take up to 5 hours to be computed, not really compatible with an interactive game. People already complain about performance in our game, imagine if now you should wait 2 hours after pressing the start button just to see the first picture.
In our video game if we want to reproduce the world we need to think outside of the box.
In 1975 Bui Tuong Phong revolutionized the world by publishing "Illumination for computer generated pictures", a paper describing how it was possible to compute an approximation of lighting fast enough to be carried in real time. It became known as the Phong Shading.
While the algorithm wasn't physically accurate, it could approximate with a reasonable degree of accuracy how light behaves in the real world.
This model (or usually a variant of it called Blinn Phong) is what 99.9% of 3D games are using to render pictures. While it has several advantages it also introduce some inconveniences. This was the technique used by SuperTuxKart up until version 0.8.2.
- Phong works only for local pixel (objects won't cast shadows)
- It doesn't take into account advanced things like the influence of other objects in the scene.
- Ability for objects to cast shadow on themselves and others
- The sky will light the scene and influence the overall hue
- Light will scatter with fog producing halos
However, there were still some issues. This model separate materials by two categories, the ones that reflect light, like plastic and metal and the ones that are matte, like fabric, however in nature this distinction doesn't exist.
|Previous light model in Antarctica|
This previous implementation is still powering the last version released to date. However aware of the limitation we went back to the drawing board and started to plan improving our rendering technology.
Going PBRIn the new version of Antarctica the artist can easily emulate the whole range of materials by simply defining how the surface looks. Just like in reality if you polish a surface enough it will eventually become a mirror and it will start to reflect the surrounding environment.
Even bricks are a bit shiny, yes they have a rough surface but nonetheless the model will accurately emulate the physical property of any materials.
Metals are a special case, since their color will influence the reflection color, hence the metal map. Parts that are metallic will use the color of the object as one of the components of their reflection.
The emit map is the same as before (if the surface is emitting light). There are no changes.
|Light model in the new Antarctica|
Empowering the artist beyond textures and geometryWe now have a model which is accurate, reflects the real physical world and how it behaves. One last remaining part was allowing an artist to create specialized shaders. While generic shaders are okay in 90% of cases, there can be specific situations where you want to have a custom shader like a lava flow.
Currently it's still a bit difficult to write shaders but we plan to offer a bunch of predefined components to allow you to quickly set up your own shaders.
Why is it worth it?Since the PBR model is more or less a standard you can create an asset in Blender, paint it in Substance Painter, try it in Blender's Eevee and then load it in SuperTuxKart and it will have the same look. You can follow a tutorial about texturing for PBR shaders in Unity and apply the same concepts in SuperTuxKart.
Basically the whole library of tutorials, online courses on real time PBR can be applied to SuperTuxKart. It sounds way better than learning a custom system that is only used in a specific game.
We want to allow people from other backgrounds to quickly contribute and create art for our beloved game.
We will show you more in the coming months and we hope you are as excited as we are for 0.9.4!