Skip to content
LX862 edited this page Jan 23, 2024 · 3 revisions

Dynamic Lighting

OpenBVE now supports a basic dynamic lighting model, depending on the time of day. This requires one new command, Route.DynamicLight() , which should point to a DynamicLighting XML file, such as the example below:

<?xml version="1.0" encoding="utf-8"?>
<openBVE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Brightness>
        <Time>00.00</Time>
        <AmbientLight>0,0,0</AmbientLight>
        <DirectionalLight>0,0,0</DirectionalLight>
        <LightDirection>0.223606797749979, 0.86602540378444, -0.447213595499958</LightDirection>
        <CabLighting>80</CabLighting>
  </Brightness>
  <Brightness>
        <Time>12.00</Time>
        <AmbientLight>160,160,160</AmbientLight>
        <DirectionalLight>160,160,160</DirectionalLight>
        <LightDirection>0.223606797749979, 0.86602540378444, -0.447213595499958</LightDirection>
        <CabLighting>255</CabLighting>
  </Brightness>
</openBVE>

As you can hopefully see, the XML file consists of a series of sections. Each of these defines the world lighting conditions at a specified point in time:

  • Time : The 24-hour based time for which this lighting definition refers.
  • AmbientLight : The ambient lighting you wish to use at this point.
  • DirectionalLight : The directional lighting you wish to use at this point.
  • LightDirection : The direction of the directional light at this point.
  • CabLighting : The MAXIMUM cab brightness value at this point.

In-Game

A simple cosine based interpolation curve is used to interpolate the current lighting values from the current time. The cab brightness is the MINIMUM of the interpolated cab brightness value, and that set by the routefile.