Firebirds: Motion Blur in War Thunder
Author: Blitzkrieg Wulf,
published 1 day ago,
Today, we’re taking a look at motion blur in War Thunder — what it is, how it’s implemented in the game, and what challenges we were facing. War Thunder goes to the movies!
[h2]What Is Motion Blur?[/h2]
In a video game, images are created from scratch, each frame displays a single point in time.
Real cameras or even our eyes don’t work like this. Taking a picture takes time, and over this time the world doesn’t always stand still. If an object moves while we’re taking the picture, it will appear in all those places at the same time on the final image. This is what we call motion blur.
[img]https://clan.cloudflare.steamstatic.com/images//4649813/bd7bbc8489daedaa5881117d173a19b1c42b6cb8.jpg[/img]
[i]Actual screenshot from War Thunder (Seek & Destroy trailer)[/i]
[h2]Explanation Of The Basics[/h2]
To simulate the effect of motion blur, we need to know how every pixel has moved since the last frame. This requires all animations and moving effects to report their current and old positions. It can be one of the hardest parts of making this feature work. But thankfully we already had this working for anti-aliasing techniques. The few animations that didn’t support this became very easy to spot because motion blur turned them into a big blurry smudge. So we fixed them quickly!
For a starting point, we used a proven technique for implementing the effect, you can read more about that here. Basically we check where a pixel was in the last frame and where it is now, then we blur this pixel along the line in between.
[img]https://clan.cloudflare.steamstatic.com/images//4649813/efb9693faf1fd2d6f228fd9054a2d3897df98d4f.jpg[/img]
[i]Clean separation of foreground and background[/i]
To make calculations more efficient and smooth out some edges, the line is also blurred in the forward direction extending the line past the current pixel position. To speed things up further we make some decisions together for bigger blocks of pixels based on their general direction.
Each pixel’s distance from the camera also needs to be considered to let us blur the background and the foreground separately. The blurred line of a background pixel can sometimes pass behind a still standing, sharp object in the foreground. Other times we need to keep the background sharp while a foreground pixel is blurred on top. When two objects blur together in a single pixel, their individual speed is also important because sometimes neither must stay sharp.
[h2]Technical Challenges In War Thunder[/h2]
Of course we needed to make some tweaks to shape it to our needs. To decide how to blur a pixel we need to know its speed. But what if there’s no single answer because there is more than one thing visible in the same point? Without special care, transparency is invisible to the algorithm.
In War Thunder, we have glass cockpits and colored light bulbs attached to planes flying over trees while breaking the sound barrier. So we needed to treat glass surfaces somehow. Here, we have completely different speeds all on the same pixel. The glass is steady but the forest behind it is very fast.
We ended up using a similar trick as with the background-foreground separation. If we see something through glass, we treat that as one category, while directly visible objects are another. We don’t blur one category on top of another but we allow mixing within categories.
This way we achieve images where the background is blurred through the glass but the glass itself can maintain its sharp silhouette.
Note: at the time of writing this post, special treatment of transparency is only enabled if Motion Blur is maxed out.
[img]https://clan.cloudflare.steamstatic.com/images//4649813/1b54d88f34ba1a6819e9358c2582d683aaab5123.jpg[/img]
[i]Blurred background through sharp glass[/i]
[img]https://clan.cloudflare.steamstatic.com/images//4649813/30e3003a215de92645d8a47fdaecb922d412c9ba.jpg[/img]
[i]Blurred background through sharp glass[/i]
[h2]Limitations[/h2]
Since we only have a single known speed for each pixel, fast moving transparent objects won’t be blurred, only the background objects you can see through them. This also means that reflections on such surfaces can only be blurred based on the background.
To create a perfect effect we would need perfect information. Even if we know a pixel’s screen position in both the past and the current frame, we don’t know what path it took between the two. We just blur it in a line, as if it was moving straight, which is almost always good enough. One important exception is the wheels of vehicles. Here, one point on the wheel can move to the opposite side in a single frame’s time. Assuming straight movement here is far from reality.
For the time being this issue is not solved, wheels will need a custom method for correct motion blur that works on different principles.
[img]https://clan.cloudflare.steamstatic.com/images//4649813/d98c2e03d3fb22ea5ed49739338cd6c1f1da3dce.jpg[/img]
[i]Foreground motion blur with overblurred wheels[/i]
[h2]Is It Realistic?[/h2]
Motion blur is visible not only for fast moving objects, but also if the camera itself moves. On film this is a very common effect, but in our natural vision the eye usually locks onto objects keeping the world more steady for us. Video game motion blur is cinematic — it looks like a real movie made with real cameras. But it’s not like seeing the world with your own eyes.
To better simulate human vision, we added an option to disable motion blur caused by the movement of the camera. This will still blur fast moving objects like planes flying by, or exploding debris, but will keep the image sharp when you’re just looking around.
[img]https://clan.cloudflare.steamstatic.com/images//4649813/7e063ab8eea60a04d5c715a705cec3f2ea920df6.jpg[/img]
[i]Camera blur off, only the turret is moving[/i]
[img]https://clan.cloudflare.steamstatic.com/images//4649813/a2c2475a0895afae89fb809bc8d591229f0ee2b8.jpg[/img]
[i]Turning the turret with full motion blur [/i]
[h2]Is Motion Blur Good For Our Games?[/h2]
We hear this question a lot and internally had conversations about this as well. Some say it gives the feeling of motion and makes the experience more immersive. While others say it makes it harder to aim for moving targets, it removes clarity that’s important for competitive play. Well, they are both right. It’s a matter of taste and what you want from the game. If you’re most interested in winning and climbing the ladder, it may not be for you — feel free to turn it off. We’re completely fine with that. But if you’ve already won and you’re making a highlight reel from your replays, or just want to feel the speed as you’re flying, you can max it out and use it for a movie quality effect.
Comparisons
[expand type=details]
Before
[img]https://clan.cloudflare.steamstatic.com/images//4649813/c17459b1bb7d6595c8fcf720273a2c378d287567.jpg[/img]
After
[img]https://clan.cloudflare.steamstatic.com/images//4649813/b1ebd114b0b2b88a7dda53822fde360e91192008.jpg[/img]
Before
[img]https://clan.cloudflare.steamstatic.com/images//4649813/75fc5e83dc8a9e2983c4381a0442acc45e5373e2.jpg[/img]
After
[img]https://clan.cloudflare.steamstatic.com/images//4649813/7c607ffa3331408163502a6ebbbb2f36ff662876.jpg[/img]
Before
[img]https://clan.cloudflare.steamstatic.com/images//4649813/284da948edac68e51075f41173e8df46a2aa1df3.jpg[/img]
After
[img]https://clan.cloudflare.steamstatic.com/images//4649813/54074a14692f068f854e06c2b49f25c9e75e293c.jpg[/img]
[/expand]