Guide: How to make Dashboard Backlights switch on & off in night like real life street car

Discussion in 'Car Modding' started by svictor, Apr 14, 2020.

  1. svictor

    svictor Registered

    Joined:
    Jan 20, 2019
    Messages:
    924
    Likes Received:
    6,275
    In some of the other sim-racing title, they usually allow player to turn on & off dashboard backlights during night or day. This feature is not supported in RF2 by default (or in a normal way). But there is a workaround to make it possible in RF2.

    The Problem:
    Normally, RF2 doesn't support switchable/togglable lights in "Cockpit" instance. Using "DashboardElementShader" will only make all dash elements visible in all condition.

    One idea is to put the dash elements into headlights instance such as "HLIGHTDS" or "HLIGHTPS", so when you switched on headlights, dashboard will also light up. However, while it works from outside view (such as swingman), this method will not work for "Cockpit" instance (which has been discussed in this post), this is probably a limitation in RF2 code.


    The Solution:
    Thanks to Chris's idea from this post, it's possible to make switchable lights working in "Cockpit" instance with a bit workaround. (And there are a few mods already using this method, just probably not well known.)

    The solution is to put one of the headlights instance code into the "Cockpit" instance, and use this headlights instance for your dashboard, it will light up in cockpit when you switch on headlights.

    However there are a few problems or limitation with this method, which requires some specific setup to make it working properly:

    1. You create this dashboard the same way as you create headlights, which requires at least 2 textures and set their animation frame to (0, 1).
    For example, the first texture will be named "dashlights00.dds" and should be totally transparent, and second texture should be named "dashlights01.dds" which contains the dash image. (dashlights.dds can be omitted)

    2. All "dashboard" materials used in "headlights" instance must have _HLGLO suffix, same as how you make headlights.

    3. All "dashboard" materials used in "headlights" instance MUST use "High luminance sun" shader, and MUST set "Blending" to either "Alpha Blending Transparent" or "Alpha Chroma".

    The reason for not using "DashboardElementShader":
    If use "DashboardElementShader" and "Replace" blending mode for "headlights" instance, the dashboard will become black when headlights switched off (since dashlights00.dds is transparent but blending mode is Replace, everything behind it is blocked).
    If use "DashboardElementShader" and "Alpha Chroma/Alpha Blending Transparent" blending mode for "headlights" instance, the dashboard either not light up in night, or having inverted luminance (dashboard becomes darker when you switch on headlights), the reason is unknown.

    4. All "dashboard" materials used in "headlights" instance should not contain more than 3 or 4 separated materials. If you have more than 3-4 separated materials, some of the materials will fail to light up, despite having all the material names/values correctly setup, the reason is unknown.


    Example:
    1. Assume you have hlglo_DS.gmt as right-side headlight, and hlglo_PS.gmt as left-side headlight.
    Copy all the mesh from hlglo_DS.gmt into hlglo_PS.gmt, then save hlglo_PS.gmt

    2. Open your dashboard GMT, copy the background mesh and paste into a new GMT file, add a little offset to the mesh so it won't clip with other mesh, then save this file as hlglo_DS.gmt.

    3. Prepare 2 textures for your dashboard background lights, assume the main texture is called dashlights.dds. Then the first texture will be named "dashlights00.dds" and should be totally transparent, and second texture should be named "dashlights01.dds" which contains the dash image.

    Note: Since we are using "High luminance sun" shader, it will be too bright by default. To fix brightness, you will need to adjust texture opacity for "dashlights01.dds", usually change the opacity to 25% is good enough (remember to merge visible layer after changing layer opacity).

    4. Open hlglo_DS.gmt that we just saved, do the following:

    a. Change its "material name" to dashboardlights_HLGLO
    b. Set "texture map" to "dashlights.dds". Then set "Blending" to "Alpha Chroma".
    c. Change "Animation Type" to "Event", set "Frames" to "0, 1"
    d. Save hlglo_DS.gmt

    5. Open your GEN file, find the line with "HLIGHTDS", cut this "HLIGHTDS" instance and paste it into "COCKPIT" instance, such as below:
    Code:
    Instance=COCKPIT
    {
       Moveable=True
       MeshFile=your_gauge.gmt CollTarget=False HATTarget=False LODIn=(0.0) LODOut=(10.0)
    
       Instance=HLIGHTDS // Used for dash lights
       {
       Moveable=True
       MeshFile=hlglo_DS.gmt CollTarget=False HATTarget=False LODIn=(0.0) LODOut=(10.0)
       }
    }
    
    6. Save GEN, and open RF2 to test result, you may need to adjust opacity for "dashlights01.dds" to have proper brightness in night.

    7. Limitation: This switchable dashboard lights will only be visible in cockpit. And since all headlights moved into one .GMT, when hit a wall, left&right headlights probably come off the same time.

    Good luck!
     
    Last edited: Sep 29, 2020
  2. Brent

    Brent Registered

    Joined:
    Nov 5, 2015
    Messages:
    236
    Likes Received:
    111
    svictor likes this.
  3. Arnaud Plume

    Arnaud Plume Registered

    Joined:
    Jul 5, 2019
    Messages:
    178
    Likes Received:
    1,099
    Is your needles also light up?
     
  4. Brent

    Brent Registered

    Joined:
    Nov 5, 2015
    Messages:
    236
    Likes Received:
    111
    @svictor I'm trying to get this to work.

    I got the lighted dash to work but when I turn the headlights on, the gauge needles disappear. I seem to have the same issue no matter if I use alpha chroma or alpha transparency

    I'm also having issues using dds files instead of tgas. If I use dds's when I load RF2 it gives me errors saying the texture format cannot be dxt.

    When you say you adjust opacity are you adjusting the alpha layer?

    Are you doing anything special with the Alpha sort offsets? It seems because the lighted dash meshes are just above the dash that when the lights are on those textures cover the needles.
     
    Last edited: Apr 19, 2020
  5. svictor

    svictor Registered

    Joined:
    Jan 20, 2019
    Messages:
    924
    Likes Received:
    6,275
    Hi, the dashlight background is a separated GMT used for headlight instance. Gauge needles is another GMT file, and should be place slight in front of the dashlight background GMT (and of course there is a base dash background/cockpit GMT placed slightly behind dashlight GMT).

    ps: all material has default alpha sort offset at 0. Opacity is when you adjust texture layer opacity (not channel) in photoshop or GIMP (which I used), then merge visible layers and save.

    As for lighting up needles, I haven't tried, and it will probably require even more workaround (such as make 2 needles gmt, one without lights, and one with lights and placed ontop of the other, just a thought).
     
    Last edited: Apr 19, 2020
  6. Brent

    Brent Registered

    Joined:
    Nov 5, 2015
    Messages:
    236
    Likes Received:
    111
    Ok I got it to work. It seems for the dash I was working on (Reliant Robin) the needles are getting some light but I'm not sure how I did that. I think it's because the needles are on a mesh that is just below the mesh of the lights.

    I agree you should be able to get away with an alpha sort offset at 0. However, I was able to use it to get the dash to render the layers I wanted it to render. I have a mesh that is above and covers most of the needle for the temp and fuel gauges. The sorting seemed to work for that and a digital speedometer that I wanted to render above everything else.

    Thank you again for this guide!
     
    svictor likes this.

Share This Page