📜 ⬆️ ⬇️

Fast & Furious: Forza Horizon 4 acceleration due to window shaders

image

Gareth Harwood - Technical Art Director of the Playground Games

The action of Forza Horizon 4 takes place in beautiful Britain, filled with instantly recognizable places and sights, including the model of the city of Edinburgh in the Playground Games version.

In most open world games, particular attention needs to be paid to the speed of data streaming, and Forza Horizon 4 with its detailed and variegated city is no exception. Edinburgh buildings needed new resources for assembling resources, rendering, and engine functionality to load models while driving at 300 miles per hour.

A modular solution that reduces memory load


The buildings were created by reference from the real world. To do this, it was necessary to take a picture and make a lot of houses, but we can create and physically store a limited number of buildings on the disk. To cope with this limitation, while maintaining the variability, we created an interchangeable modular set of objects that are added to buildings ; These include objects such as window frames, entrances, antennas and security alarms. We also provided the ability to change the colors and shades of parts of these objects. Such a system was ideal for creating a series of houses with terraces, each of which has a door of its own color.
')

In Edinburgh, we needed to create a huge number of buildings in a relatively small area. Loading these buildings for a small part of our open world significantly increased the amount of memory required. To cope with this, we built buildings from modules taken from first-floor libraries, upper floors, and roofs, which could be connected in various ways, obtaining variability and an interesting picture with low memory requirements.

In addition, it allowed us to shift the complexity of the models closer to the first floors; The windows next to which the player passes are more detailed than the roofs, which are visible only from a distance. Unique buildings like the Scott Monument and the National Gallery in combination with modular buildings reduce the monotony of the picture, while at the same time maximizing reuse of resources and variability .

Implement parallax textures



Realistic worlds have always been a strong feature of Forza Horizon games, and one of the ways to create them was to add interiors to buildings.

We knew that in Forza Horizon 4, Edinburgh would be so densely built and detailed that physically modeled interiors would create an overload. Therefore, we decided to use another technique called “parallax textures”. They gave us a huge advantage when creating interiors. When baking them in texture, they are not limited by the number of polygons and the complexity of the materials . Rendering such textures is less expensive than creating geometry, so there can be more interiors in the game. Previously, it was necessary to close the windows with curtains or shade them, but now we have completely parallax interiors.


The materials of the parallax interiors consist of three layers, each of which is individually chosen by the artists for each of the windows. Since each layer has several different variations, they create hundreds of possible external views for each window, even if a small amount of texture atlases is used.

The first layer is simple, it contains only the window frame and glass. He adds such nuances as stained glass and lead glass, typical of old British architecture. This layer has diffuse, alpha, roughness, metalness and normal pass. The normal pass contains a variation of each stained glass to add a realistic variation of the angles of reflection of glass, which is particularly noticeable in old stained glass windows.


The second layer is used for curtains or curtains. They have diffuse and alpha, as well as a light-transmitting texture, which is used at night to show the thickness of the curtains. We have thick curtains that do not let in light, translucent curtains, and even curtains with decorations that we created from holes that partially let in light.


In the last layer, all the shader magic is created - it consists of a flat texture imitating a three-dimensional interior. The interiors are first modeled in 3D at the same scale, and then rendered in a unique texture format supported by our shaders of parallax interiors. As in all other layers, we in this layer create atlases containing up to eight different interiors of the same style in order to reduce the number of draw calls.

We have several village atlases that are rendered on village houses, atlases for town houses, as well as several atlases of commercial establishments that are superimposed on shops, restaurants, and classic British pubs. We also have two main depths of interiors. One is for standard rooms, the other is for shallow windows. Artists can choose which part of the atlas they want to use for each window of the building, and then set the materials using the properties of the polygonal model of each window.


The shader calculates the angle at which the player looks into the room, and changes the UV coordinates so that he sees only that part of the interior that would be visible at this angle. This technique has several limitations that we dealt with.

First, the shader trick becomes noticeable at very sharp corners. In such boundary cases, we increased the natural Fresnel effect of glass to show more reflected image than the interior. Second, as the corners increase, the details in the center of the room begin to distort. We reduced this effect by shifting accents to walls and corners, darkening the floor. As in real life, the parallax effect allows you to reduce lines that fall into one focal point. In our images, we took advantage of this by maximizing the use of parallel lines: in tiles, bookshelves, wooden flooring and wallpaper patterns.

Each interior texture also has a lighting texture for evening light. Thanks to the benefits of baking the texture, we could use any number of light sources, because as a result they all turn out to be written into the texture. Each building has variations with lights on and off.


Artists were free to choose any combination of windows, curtains, and interior, but they followed simple rules: bedrooms are usually located on the upper floors, you cannot use the same rooms in each window, and there are no stairs leading up on the upper floors. We also considered how convincing each room is. For example, we could not have a small two-bedroom cottage in which ten or more windows lead to different rooms, so the artists created the windows so that they looked like different parts of the same room.

Finally, to improve performance when the player was removed from the building, we needed to reduce not only the complexity of the mesh, but also the complexity of the shaders and materials. To do this, we turned off the parallax effect and replaced the window with a flat image containing in one layer a window, curtains and an interior. Replacement occurs when the window takes up little space on the screen and is unnoticeable to the player.


Regardless of whether you are traveling leisurely around Edinburgh in your vintage roadster, looking at each storefront, or traveling at a speed of 300 miles per hour on a supercar for one million pounds, Forza Horizon 4 will recreate a beautiful, realistic and interesting environment. Each technology, rendering method, shader and texture work in harmony, creating one of the most technically complex parts of the Forza Horizon 4 card.



From the translator: for greater clarity, I found a video that shows the interiors of the game.

Source: https://habr.com/ru/post/433164/


All Articles