April 19, 2018

Everything is shiny!

Hi

A quick retrospective into last year

2017 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 Engine

Some 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 performance

Let'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 Rendering

One 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?
To illustrate here is a screenshot taken in Substance Painter and one in SuperTuxKart's new renderering engine.

You will be able to create your assets in another PBR engine/renderer like Blender's Eevee or Substance Painter and directly import your assets in SuperTuxkart.

Custom shaders

While 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
We plan to provide a set of preset shaders in addition to the generic one, to allow quickly creating a nice looking road with skidmarks etc. We'll share more in the coming months.

New file format

While 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 light

Our epic journey starts 8 minutes ago in the core of a giant plasma ball tirelessly emitting light particles.
Source: NASA Solar Dynamics Observatory
Roughly 10⁴⁵ photons are leaving the sun every second. A "tiny" portion of those particles reach our beloved planet, bounce all around the place billions of times and finally reach our eyes where they trigger a reaction which is what we "see".

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.
In order to address those limitations we started to implement our own engine and in 2015 after two years of development we were ready to show to the world the first version of Antarctica. Using a modern approach with Bidirectional Reflectance Distribution Function (BRDF) and Image Based Lighting (IBL).
  • 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
It's already an improvement over the previous version. Artists could use textures to influence the specularity (how much an object reflect light) and the glossiness (how much "spread out" it is).

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
It was impossible to properly emulate how metal reacts to light and it forces artists to learn an unique way custom to our game in order to create materials. It requires a lot of iterations and it was impossible to preview in Blender or other software what you were doing.

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 PBR

In 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 geometry

We 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!

9 comments:

  1. Glad to read it!
    Is there any news about network multiplayer?

    ReplyDelete
    Replies
    1. There is progress, but it's not quite playable yet. We'll probably do a post about it sometime later this year, maybe in a month or two.

      Delete
  2. Hi. You should enable donations via Liberapay. There is already some pledged against your twitter handle https://liberapay.com/on/twitter/supertuxkart

    ReplyDelete
    Replies
    1. Good idea. This way people can give something back for the considerable effort made to make SuperTuxKart. This would enable people to donate even without a credit card.

      Delete
  3. OK, I hate to be "that commenter", but why put so much of your resources into reinventing the wheel, instead of using one of the many fine FOSS game engines out there, such as Godot, and then focus on the parts of the code unique to SuperTuxCart?

    ReplyDelete
    Replies
    1. Because Godot was not an option some years ago, and we already had spent the effort to rewrite to Irrlicht, which took us years.

      Later we wanted to have more advanced graphical features, and got someone willing to work on modifying Irrlicht to that purpose, and we called the resulting fork Antarctica.

      If we were to use Godot that would mean another large rewrite, and a considerably more comprehensive one at that because at the time we switched to Irrlicht, we did so because our needs were small and Irrlicht was a small and simple library. Now STK is considerably more advanced, and Godot also seems to be quite large, leaving us with a big cost of switching.

      It might still happen, but not for the foreseeable future.

      Delete
  4. Nice, can barely wait to see it! Hopefully I'll have a better computer by then so I can play with a higher graphics level than 2.

    Also, I have had STK no output frames for a few seconds, but never fully freeze or be slow/lag.

    ReplyDelete
  5. Any updates on multiplayer?

    ReplyDelete
  6. Inglish::::

    Hello, very good, I love that game. The game since 2013, the truth was the best I played in my whole life. I wonder when there will be a game mode of "pick up nitros". Because it appears in story mode only, and it would be good if it is played as a game mode. The other thing that in crash combat is felt to modify the amount of lives of all players. Another of the best things that the way to look for easter eggs is multiplayer. In other words, all game modes that are played with a single player and multiplayer. And if it is possible that it is believed to use old STK tracks like 0.7, 0.8 and more.

    By the way if it were possible to use but karts in ghost mode.

    And you want to customize the time as remaining to make play a track. Bone in leading mode that edit edit time at a time.


    Spanish:::: Hola, muy buenas, amo ese juego. El juego desde 2013, la verdad fue lo mejor que jugué en toda mi vida. Me pregunto cuando habra modo de juego de "recoger nitros". Porque aparece en modo historia nomas, y estaría bueno que se juegue como modo de juego. Lo otro que en combate de choques se siente modificar la cantidad de vidas de todos los jugadores. Otra de las mejores cosas que el modo de buscar los huevos de pascua se juega multijugador. Osea todos los modos de juegos que se juega con un solo jugador y multijugador. Y si es posible que se cree usar pistas de viejas viejas de STK como 0.7, 0.8 y mas.

    Por cierto si fuera posible que se use pero karts en modo fantasma.

    Y que se desee personalizar el tiempo como restante para hacer jugar una pista. Osea en modo líder que editar editar el tiempo a la vez.

    ReplyDelete