Interior imitation: why buildings in Spider-Man look residential


New York, finally, does not consist of cardboard boxes.

In Marvel’s Spider-Man in many windows you can see the full interior. This is done with a single trick – everything is recreated using a special shader.

Co-founder of the studio Ronimo Games (Awesomenauts) Jost van Dongen on the site Gamasutra published the text, which dismantled the principle of creating realistic interiors in Marvel’s Spider-Man. The author himself dealt with this issue in the framework of his graduate research in 2007. We chose from the main material

The work of this effect is clearly demonstrated in the video Kotaku

At 0:40 this video shows that the rooms actually ignore the geometry of the building: the door is where the window should be. If you look into the same room, but from another window, you will notice that there is already a completely different interior. All this suggests that the rooms are fake, but, nevertheless, they are absolutely correct from the point of view of perspective and have real depth.

This is not to say that this is a big disadvantage, since users pay less attention to such details. Such interiors are simply a backdrop that contributes to giving depth to a city without much impact on performance

To preserve the performance of the room in games often do not have interiors. 
For example, this can be seen in GTA V

So, this whole effect is based on the interior mapping technique. The principle of its work is that the building itself does not contain any additional geometry. Interiors exist only in the shader. He rayskates with walls, ceiling and floor to indicate what the player should see in the interior

From left to right: windows with reflections only; 
windows with interior mapping; 
frame model, which shows that interior mapping does not add polygons

A ray used for raycasting is simply a ray from camera to pixel. The rendered pixel is on the outside of the building, so only part of the beam behind the pixel is used. This is due to the fact that this part is located inside the building.

Reykasting may seem complicated and costly, but in fact it is very useful in this case. The trick is one limitation: when planning the interior, the ceilings and walls are at a constant distance. Knowing this, you can easily calculate the location of the player, the ceiling and the walls of the room.

The ceilings and walls themselves are infinite geometric planes. The calculation of the intersection between the infinite plane and the beam takes only a few steps and reduces the load on the system

The idea behind interior mapping is that when rendering a window pixel, the beam is sent from this point to the building. 
The beam crosses the ceiling to calculate which pixel will be visible.

There are six planes in total: the ceiling, the floor and the four walls. However, only three are enough, since the direction of the user’s gaze is known. For example, if you look at the ceiling, you do not need to check the floor. Similarly, of the four walls, only two need to be considered, which are in the direction in which the player is looking.

To find out exactly what the user sees, you need to calculate the intersection of the beam with each of these three planes. The intersection that is closest to the camera makes it clear which plane is displayed in this pixel.

Then the intersection point is used as the coordinate of the texture to match the color of the pixel. For example, if the beam reaches the ceiling at position (x, y, z), then (x, y) is used as the coordinate of the texture, ignoring z.

At the same time, the intersection calculations for each of the three planes, due to the intelligent packing of variables, can be performed simultaneously

Interior mapping without windows textures shows that rooms are rendered with the correct perspective and textures even without additional polygons.

Also with the help of interior mapping you can, for example, change the lighting in different rooms to simulate the alternation of day and night. For this, a noise texture is applied, from which the index of the room is calculated as the coordinates of the texture

Imitation of different lighting

Since there is only a propagation of rays in the plane, all rooms are simple rectangles with textures. All the furniture in the room is on the texture, which means that it remains flat. In Marvel’s Spider-Man, this is noticeable when approaching: tables in the rooms are in fact flat textures on the walls.

As you can see in the image below, you can supplement this technique with one or more additional texture layers. But it gives an additional load on performance

By tracing the rays of another plane parallel to the outer part of the building, you can add furniture and people to the premises. 
However, they will still remain flat.

Interior mapping was also used in Simcity (2013). The developers improved the original idea and combined several textures into one to create the depth of the rooms. The video below (starting at 1:00) explains how the technology works

The author of the original text attached a link to his interior mappingdemonstration . Also in Unreal Engine 4 you can find this technique as a function of InteriorCubeMap


Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button