Source: http://habrahabr.ru/company/wargaming/blog/249115/ (yes, there’s a download, exclusive for FTR – if you have that device, you might like it) Hello everyone, the following article describes how Wargaming developed a special mod for Occulus Rift from the developer point of view. Enjoy. Roughly a year and a half ago, Wargaming developers got their hands on the DK-1. After some time spent playing Team Fortress and Quake in Full 3D, they decided to do something with it for World of Tanks. You can read below about the results. World of Tanks supports a certain number of game devices (peripheries), which extend the player user experience (various vibrations for example). However, with the appearance of the Occulus rift, we decided not to please only the butt of the player, but to give them some new eye candy as well. To be honest, noone knew what it should look like, the task to create a Rift mod was issued just “for the lulz”. We did not hurry and worked on it only when the brain refused to think of the main tasks, we slowly downloaded the Rift SDK, installed it and started rummaging through the source code examples. The work started using the first devkit, which was somewhat dangerous to the psyche.The problem was that the devkit had relatively low screen resolution. Luckily for us, we got our hands on a HD version soon and working with it was much more fun. Software Development Kit The development started with the 0.2.4 SDK version for DK-1. When the HD Prototype arrived, new SDK version was not required. That’s why we used the old, but satisfactory version of the SDK for 90 percent of the time. After that, when the DK-1 mod was practically finished, DK-2 came and it turned out that the old SDK wouldn’t work with it anymore. But would that pose a problem? Well, we downloaded the new SDK version (0.4.2) only to found out that it was totally rewritten. We had to chance practically the entire device support and to introduce various fixes. But the most interesting thing happened to the render. Earlier, the pixel shader was quite simple, but the new version made it more complex – the reason for all that were the lenses. I don’t remember anymore why the decision to do that was taken – but a nasty side effect were terrible chromatic aberrations, decreasing from the edges of the lenses towards the center. And to reduce this effect, new pixel shader was written. It was a strange solution to put it mildly: it reduced the performance due to an odd developer solution. But! Good old human ingenuity saves the galaxy yet again. It turned out that the DK-1 and HD Prototype lenses work just fine with DK-2 without any side effects. And that was it. Initialization The initialization process was copypasted without any pitfalls. Rendering The device creates stereoscopic image rather classically, using the method of rendering the scene on two separate screens in various angles, introducing one part of the scene to one eye. You can read more about this method here. Accordingly, our original algorithm for creating stereoscopic images was as follows: 1) Matrix creation Since you have to create a render with a slight offset for each eye, you have to as a first step modify the original view-matrix. Occulus Rift SDK provides the required matrices to transform the image for each eye. The modification looks like this: - acquiring the matrix of additional transformation - transforming this matrix (Occulus uses a different system of coordinates) - to multiply the transformed matrix on the original one from the left 2) Rendering two times with the acquired matrix After modifying the view-matrix for the left eye and setting it in render-context, the rendering happens as usual. After that, the view matrix is modified one more time for the right eye, is set in render-context once again and rendered one more time. 3) Lens distortion post-effect In order to fill better the field of view, Occulus uses lenses, that have a side effect of distorting object geometry. In order to suppress this side effect, an additional post effect is applied to the final render, this post-effect distorts the geometry to the opposite side. 4) Release of the final render The final render is formed by combining of the renders for both eyes, which are depicted each on their respective half of the screen and by applying the anti-distortion post-effect to them. Challenges During the development, we quickly discovered that there are no clear, hundred percent working guidelines for making Occulus Rift work in games. If you run several games with OR support, you’ll get several interface versions and several versions of Occulus management. As far as we know, Occulus developers do now issue strict sets of rules and requirements. Their idea is for the game developers to experiment and work with the device themselves. This caused us to rework our Occulus version more than once: when everything seemed to be ready, there suddenly were still some issues here and there and in the result, you had to throw out half of the code. To add to the fun, some of our own special features caused trouble as well. In World of Tanks, the camera is hanging above the tank and turning your head using the Occulus in this mode does not correspond to your experience from real life. You can’t fly in real life above the vehicle you are driving (although sometimes, this might be useful). Add to that that World of Tanks is a PvP game, where you are fighting 29 15 other players. As a result, Occulus strongly messes up with the combat skills of the player. This nuance adds a lot of hassle to the development. If we have a look at the applicability of Occulus Rift to multiplayer games in general, the device is by far not suitable for every game class. In games with the gameplay dynamics of Quake 3 and Team Fortress 2, it will bring more harm than good. In these games, you seem to look at the environmant with the eyes of a person, but the movement in these games is very different than in real life. As I mentioned before, if the game doesn’t use first person camera, what you get are problems with spatial orientation and with the mechanism of turning your viewpoint when you look to the sides. We had the impression that Occulus is primarily applicable to single-player games where the immersion of the player is paramount and control inconveniences can be forgiven. To be continued… ….or wait, the mod, right :) Check this out Continue reading →

More...