Route Building Tutorial 14: Finishing the Tunnel Entrance and Introducing Lighting (Built-in BVE Lighting & .x Files)

In the previous tutorial, we added a waterfront to the left hand side of the track on the approach to the tunnel. To complete the scene, a rocky outcrop jutting into the water and forming a hill over the tunnel is required. The outcrop and hill will give reason for the tunnel being present although details of it‘s construction will be brief as the construction methods used have already been covered.

Because of the textures used and the orientations they are presented at, consideration will be given to lighting effects, with BVE lighting commands being introduced and an example of the use of .x format given.

Time to get to work…

Starting off with a brief description of construction of the rocky outcrop and hill on top of the tunnel; these have been combined in a single object file, tunnel entrance_2.CSV. This should be indexed as freeobject 53 and positioned at 250m;

This object is made up of 7 separate faces which are (in the order they appear in the object file);

The texture used for the rocks was derived from a photo of part of Langstone rock, near Dawlish, the original image being shown below:

The original image- Langstone Rock

The original image- Langstone Rock


The was cropped as reguired, flipped horizontally and the colour blalance altered so that it integrates better with the scene being created. The texture was then applied as a single face with the left hand side being 70m from the running rail. The bottom edge of the texture is 14m below the height of the running rail; this is necessary as the height above the surface of the water at this point is over 13m. The rock face has been made to slope (rather than being vertical) by offsetting the top left corner back by 35m.

The second face uses a mirror image of the rock face texture which is extended over the top of the tunnel. By using a mirror image, no ‘joint’ is apparent between the main rock face and the extension over the tunnel.

Bushes on the left of the tunnel portal are formed by the third face with care being taken on the position of these (as the rock face is tilted.) Both this face and the bushes over the top of the portal (formed by the fourth face) use the same texture as was used for the bushes on the cutting top on the tunnel approach. This does give a ‘homogenous’ appearance to the scene, possibly to the point of blandness!

The fith face sees the same bush texture being used but this time applied upside down and intentionally distorted (the face not being rectangular). This offers a representation of bushes hanging down from the rock face.

The final two faces add small parts of stonework to the bottom of the tunnel portal to fill in the gaps between this and the ballast. The texture used was sampled from the portal bitmap to maintain a consistent appearance.

Before describing the use of BVE’s ambient and directional lighting commands which control the global illumination, it is worth studying the tunnel entrance scene for a few moments to try and understand the requirements.

The current tunnel entrance in BVE

The current tunnel entrance in BVE


Our route is set on a bright, clear, sunny day so the amount of ambient illumination is high. This can be specified in BVE using the Route.ambientlight command;

Route.ambientlight R;G;B
Where R, G and B are the intensities of the primary lighting colours (red, green and blue) and can have values between 0 – 250.

We should add this command to our route and specify a high level of slightly yellow ambient light (where the values of R, G and B are equal) after the Route.Gauge statement:

Applying this seems to have very little effect on the scene (presumably because the settings chosen are close the the default values). However, if we were to make the ambient light levels much lower (as they would be on a very dull day or in the evening) by using values of 50 for R, G and B:

The whole scene is now much darker, particularly those faces which are aligned vertically – not at all what we want!.

Considering the colour of the light, because of differential scattering of the red, green and blue wavelengths by the atmosphere, around sunrise and sunset, the lighting may have a distinct reddish hue. This can be reproduced by increasing the red component (to an extreme extent in this case, and again, not what we want):

As our route is set on a summer morning (at 9.30), the ambient lighting would be expected to have a slight yellow hue, as originally applied (around midday, the lighting would be white or slightly blue).

Our next consideration is the directional light which is provided by the Sun. For routes set in cloudy or foggy conditions, the use of directional lighting is not really necessary.

On non-fictional routes, the position of the directional lighting will be governed by the time of day and direction of travel. For example, in the UK, when travelling north in the morning, the Sun is on the right hand side, around midday it will be behind you and in the afternoon on the left hand side. The elevation (how high in the sky) will also change throughout the day and will also be dependent on the season, being higher in the summer than in the winter. The colour of the directional light will also change with time in much the same way as was described for the ambient light.

These effects can be modelled in BVE using the Route.directionallight and Route.lightdirection commands:

Route.directionallight R;G;B
Where R, G and B are the intensities of the red, green and blue light components.

Route.lightdirection X;Y
Where X is elevation of the directional light source and Y the rotation (both in degrees).

For our route, which is set in the summer, at the time being modelled the elevation of the sun will be around 35° and it will be shining brightly with only a slight yellow hue. The shading we have applied to the tunnel entrance suggests the directional light is at right angles to the direction of travel (with the shadow on the rock face suggesting it is on the right hand side).

Adding these parameters to the route file, it now looks like this:

Applying the directional lighting to the route eliminates most of the brightness variations which were visible on the bushes above the tunnel portal. It is worth noting that the light direction we have applied and the time specified means our route is initially heading off in a northerly direction.

The absence of shadows is a clear omission from the scene (the cutting wall on the right hand side should cast shade over the right hand track). Unfortunately, shadows need to be added manually in BVE, either by modifying the textures used (which was done for the tunnel walls and tracks) or by applying semi-transparent dark coloured overlays (as in the bridge shadows on Birmingham Cross City).

Included in the objects download is a modified version of the cutting wall object; this is of reduced brightness to enhance the shaded effect (and also has the top edge of the wall smoothed off by application of another row of bushes) – this can replace the original object if desired for a better appearance.

If we wanted to create a late evening scene, we can change our lighting parameters so that the ambient lighting level is low and has a red hue. The directional light would be relatively bright and also reddish in colour:

Clearly, the background will need to be modified so that this too depicts an evening scene and some modification of the object textures may also be necessary before a satisfactory result is obtained.

Although the BVE lighting commands do provide global control over illumination, there is also the option of controlling the luminosity of individual objects by making use of .X format files. The value of this format is that the emissive (glowing) and specular (reflecting) power and colour of the object faces can be specified.

Objects may be constructed in .X format quite easily although I have always tended to convert them from .CSV format using the converter available on Mackoy’s website. A note of caution; if you are planning on using this to convert objects – copy the object files and textures used by them to a separate directory and convert them from within that directory otherwise you will end up converting all your objects! Also, when converting, specify the output as being text format if you with to modify the object further. Compressed and binary formats, although resulting in smaller files (which will be much quicker loading and displaying) are completely unintelligible. It is also recommended that ;comments, are removed from .CSV object files before conversion.

Included in the objects download is a version of the tunnel wall (entrance section) which has been converted to .X format. It was my intention to use this to apply reflected (specular) lighting on the left had wall to represent the sunlight which would be present near the entrance when used in combination with a modified texture . In practice, I was unable to obtain the required result (this was because the wall was constructed using a single mesh block which allows little control on where the reflectance is applied). Nevertheless, if the .X file is used as a replacement object for the tunnel wall by changing it’s freeobject declaration to this:

We can still examine the lighting effects made possible by using this type of file.
Opening up the object file in Wordpad (or other text editor), the code of interest is

The ‘power’ value has been set close to zero as the amount of reflected light will be low (the sun is not shining directly onto the tunnel wall and stonework is inherently matt and substantially non-reflective in nature).

The specular (reflected) colour is white (the three parameters relating to red, green and blue wavelengths, values between 0 and 1 being required). No emissive colour is required (as the tunnel wall does not glow in the dark!) so the R,G,B values are set to zero.

Although of no practical value, it is worth having a play with these values to see what effect they have on the appearance of the tunnel wall.

Firstly, lets make the tunnel wall glow green by changing the emissive colour settings line to:

Checking the result, we find the right hand side of the tunnel wall (which is not subject to specular reflectance) now has a distinctly green appearance. Because of the high amount of ambient light present in our route and the orientation of the faces, the effect appears quite weak. This can be overcome by modifying the route file’s ambientlight statement to this:

Quite a dramatic effect and a useful technique for night scenes, where orange lighting to reproduce the effects of sodium lamps.

Keeping the ambient light setting low, we can now turn our attention to the specular light. At the moment, the left hand side of the tunnel wall appears quite normal in appearance because of the small amount of white reflected directional light. Changing this to an intense blue clearly shows which faces are capable of reflecting the directional light; do this by changing the specular component to:

And change the power parameter to 1. Although in no way subtle, this clearly shows where the reflected light occurs (remembering that our directional light source is situated on the right hand side)

Use of .X files allows each mesh block to be individually illuminated. Keeping the ambient light level low, we can also illuminate the tunnel portal by further altering the .X file; try changing this block:

To:

This quite clearly demonstrates the way different mesh blocks can be independently illuminated.

A further use of .X files is to create objects of differing appearance without the need for additional textures – examples of this application include different coloured bushes, walls and grounds; differently coloured and shaded objects for a couple of k’s of object file rather than the typical 10-30k+ of texture image.

In this part, we have finished constructing the tunnel entrance and introduced lighting effects. Use of the lighting capabilities of .X format files has also been demonstrated.

In the final tutorial, construction of a station will be started, initially concentrating on the platforms.

Leave a Reply

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