Route Building Tutorial 11: Finishing Construction of the Tunnel & Introducing the Brightness Command

In the previous tutorial, we constructed a tunnel entrance using a photorealistic texture for the portal and then constructed the walls using measurements taken from the portal image. Not 100% successful in my case as part of the tunnel wall looks distorted. This could have been overcome by adjusting the positions of the offending vertices – the principle of the method is sound even if I appear to have been a bit careless with my measurements.

In this tutorial, we will see how to alter the wall texture to obtain more realistic lighting as we enter the tunnel. The tunnel will also be lengthened and the exit constructed. Finally, we will modify the track in the tunnel so that this too is illuminated correctly and then apply the necessary cab brightness commands.

It is worth pointing out that an alternative means of varying the brightness in tunnels is through the use of black fog. This is certainly something I have used before myself and although effective if applied correctly, it is very difficult to get just right.

Time to get to work…

Firstly, we will concentrate on modifying the brick1 texture applied to the tunnel wall so that it looks as if the light fades out when looking into the tunnel. To do this, a reasonably advanced image editor is a useful tool – personally, I use Photoshop.

Before making any modifications to the brick1 texture, make a backup copy – to properly assess the changes being made to the image, it must be saved and the tunnel viewed in BVE or structure viewer. With Photoshop (and possibly other image editors), once an image is saved, there is no going back on the changes made.

The first modification I made to the brick1 texture (after changing it to an RGB image) was to graduate a black fill horizontally from the centre of the bitmap. This will represent years worth of soot accumulation on the roof and also make a start darkening the tunnel walls. The next modification made used the lighting effects available in Photoshop. A wide focus spotlight was shone from the left hand side of the image with the centre point of the beam situated the mid-way up the left hand edge of the texture. The resulting image was then converted back to an eight bit indexed colour image, and now looks like this:

The modified brick texture

The modified brick texture

This texture, which is included in the objects download, may then be used in the tunnel entrance object (tunnel entrance.CSV) in place of the original brick1 texture by changing the original


Compared with what we had previously, the tunnel walls are now generally darker than before and with the brightness fading along the length of the wall.

The next job is to lengthen the tunnel by 75 metres. To do this, we will need two 25metre lengths of dark wall for the central 50metres and then a 25metre length where the walls become brighter as the tunnel exit is approached.

To create the central (dark) lengths we need to create a new object. Rather than rebuild the walls, we can simply make a copy of the tunnel entrance object, remove the portal and use a suitably darkened brick1 image for our texture.

So, make a copy of tunnel entrance.CSV and rename to tunnel_mid.CSV. This object should be indexed in the route file as free object 51 in the route file. It object should then be placed on the route at 275 and 300metres.

To remove the portal from this object, remove the following code from the object file:

If the route is now viewed, the need for a modified wall texture becomes immediately apparent. A uniformly darkened brick1 image is required – the brightness of this must match that of the end of the tunnel entrance section to ensure a seamless transition. Such an image has been supplied with the objects download, brick2.BMP, and this can replace the current texture by changing the line:


If the modified object file is now saved and the route viewed, the middle 50m of the tunnel appear to be of uniform darkness and we could continue extending the tunnel further using these objects.

All we need to do now is to increase the brightness of the tunnel walls as the exit is approached. If the tunnel entrance object is rotated by 180° , the effect could be achieved with no further objects required. However, our tunnel walls are not completely symmetrical and if the object is rotated in this way, gaps in the walls will result.

What we can do is create a new object which uses a mirror image of the tunnel entrance texture but with the same wall construction as used for the other sections. So, create a copy of tunnel_mid.CSV and rename it tunnel_end.CSV. In this object file, then alter the wall texture by changing the line:


It is worth noting that if we want the tunnel walls to be of less uniform appearance, there is no reason why other modifications cannot be made to this or the texture used in the middle section of the tunnel providing the overall brightness effects are not altered – such a modification has been included in the tunnel exit texture (where bits of the wall have been marked out for repair and instructions not to machine tamp included).

Now that the tunnel walls are constructed, we need to turn our attention to the track and fade the brightness of this in and out. One possible way of achieving this is to overlay on the track a semi-transparent black texture, as seen in bridge shadows on Birmingham Cross City and other routes. The difficulty we would have with this approach is producing a uniform graduation of the darkening effect without introducing obvious ‘banding’.

To overcome this, we can again use modified image textures, in this case incorporating them into rail objects. Our first task is therefore to create a new straight rail object by making a copy of DL_STRAIGHT.B3D and renaming it DL_STRAIGHT_TUNNEL_ENTRANCE.B3D. This file needs to be defined as a rail object in the route file by including the code:

To position the rail at the tunnel entrance we also need to add this:

Opening up this object to take a look, we find that the track part of this rail object is made up of 5 ‘segments’ (We know this as it uses 5 face statements):

Although we have not previously edited any .B3D objects, the way in which these are constructed should be familiar even if the commands and syntax are not. What we will do to modify our rail object is firstly create a image composed of tiled track textures and then add lighting effects to this image before incorporating it into the rail object by modifying the coordinates commands. The ballast texture will also need modification in the same way. Suitably modified textures have been included with the objects download (dl_track_3_fade_in.BMP and dl_ballast_fade_in.BMP).

Now we need to modify the object file DL_STRAIGHT_TUNNEL_ENTRANCE.B3D;

Change the texture by modifying this line:


And then modify the texture coordinates by changing the whole section to look like this:

Now if the object is saved and the route viewed, the brightness of the track texture, but not the rails or ballast, is seen to fade as the tunnel is entered (this effect will be repeated every 25m as we have not changed the rail type in the route file after ‘fading out‘).

The next job is to modify the ballast in a similar way, using a modified DL_BALLAST.BMP image as the texture. The ballast on both the left and right of the track will need altering by changing both instances of:


Then modify the texture coordinates by changing each section to this (Ballast on the left and right of the track is identical!):

Darkening the rails is also required. Unfortunately, the Switch generated track does not lend itself well to lighting effects such as we have applied to the ballast and track textures as it is composed of multiple faces which are all of a single colour. We could rebuild the object so that we can apply different colours for each face of the rail, however, in practice, the rails will still appear quite light in comlour because they are inherently bright and shiny and will be illuminated by the train headlights. We will therefore only decrease the brightness of the rails by a relatively small amount, altering the command (Remember to change both rails!):


If we view the route now, the shading effects for the tunnel entrance are now complete. The small amount of grass evident on the right hand side will be covered up when we create the ground which will form the hill through which the tunnel passes.

Now for the mid-section of the tunnel. Firstly, we need to create the rail object by copying DL_STRAIGHT_TUNNEL_ENTRANCE.B3D and renaming it to DL_STRAIGHT_TUNNEL_MID.B3D. This needs to be indexed in the route file as rail 22:

This rail type should then be started at 275m:

Our next job is to create a track and ballast textures which are suitably darkened for use in the middle 50metres of the tunnel. To create these, we can use any suitable image editor to darken tiled images of the track and ballast so that they match the end of the entrance section. Suitable darkened textures have been included in the objects download – DL_STRAIGHT_DARK and DL_BALLAST_DARK. These need to be included in the rail object by changing:


You also need to change both occurrences of this:

To this:

The final task for the middle section of the tunnel track is to reduce the brightness of the rails slightly further by changing for both rails:


That’s the middle section of the tunnel completed. All we need to do now is brighten the track as we approach the tunnel exit. To do this, we firstly need to create a new rail object by copying DL_STRAIGHT_TUNNEL_ENTRANCE.B3D and renaming it to DL_STRAIGHT_TUNNEL_EXIT.B3D before indexing this as rail 23 in the route file;

This rail type will commence at 325metres, like this:

To change the brightness from fading into shadow, we can either use mirror images of the ballast and track textures (as we did for the wall) or display the existing ones as mirror images by altering the coordinates commands in the object file.

Choosing the latter option, change this:

To look like this:

Similarly, both occurances of the ballast co-ordinates must be changed from this:

To look like this:

That’s construction of the tunnel complete although there are a couple modifications still needed to the route file. The first of these is to define the run sounds associated with the rails which are used in the tunnel. This is done by adding these to the route file:

Now the train run sounds reflect the fact that we are passing through a tunnel.

The final job is to change the cab brightness using the brightness command;

Where X may be between 1 (very dark) and 255 (very light).

When using brightness commands, it is important to realise that the cab lighting will follow a static gradient between two brightness commands. In other words, if we set brightness 1 at position 0, and brightness 255 at position 200, then the brightness level will move gradually from dark to light between these two commands.
We therefore need to set the cab brightness at the start of the route, at the start of the tunnel, at the mid-point of the tunnel and at the tunnel exit.

To do this, we need to add the following code to the route file

This defines the brightness at the start of the route.
Secondly, add:

This ensures the cab brightness remains at a constant 240 between the start of the route and the tunnel entrance.
Next add this:

This fades the cab brightness concurrent with the shading of the wall and track textures.
Then this:

This holds the cab brightness at a low level as the middle section of the tunnel is traversed.
This is our final bit of code:

This increases the cab brightness as the tunnel exit is approached.

The tunnel itself is now complete – in the next tutorial, we will make a start creating the hill over the top of the tunnel.

Leave a Reply

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