Menu

#32 Break lights

Unstable_(example)
accepted
nobody
None
1
2024-07-24
2021-03-14
No

This patch adds the functionality for break lights.

In order to test it:

  1. Apply the patch to r1013.
  2. Copy the attached image to data/vehicles/cordo_kitcar/
  3. Add the following line at the end of the file data/vehicles/cordo_kitcar/cordo_kitcar.mtl (without the quotes): "map_Ke cordo_kitcar_emission.png"

The image cordo_kitcar_emission.png is provided for testing purposes and it shouldn't be included in the game as it isn't very polished.

The emission map need to have the same dimensions as the diffuse map (e.g. cordo_kitcar.png). Each pixel that isn't part of the break lights must have an alpha value of 0 (transparent) and the pixels that are part of the break lights an alpha value of 1 (solid). The colors of the pixels could be anything and those that are transparent would be ignored within the game. The displayed colors in the game are calculated using the following formula: diffuse_map * light + emission_map. For example, suppose a certain pixel have a color equals to (0.4, 0.4, 0.4) in the diffuse map, a color equals to (0.3, 0.3, 0.3) in the emission map and lighting reduces the color intensity by half. The final color would be (0.4 / 2, 0.4 / 2, 0.4 / 2) + (0.3, 0.3, 0.3) = (0.5, 0.5, 0.5).

Note that the emission map only works for break lights and not for other types of lights. This could be changed by using separate meshes for different lights.

2 Attachments

Discussion

  • Onsemeliot

    Onsemeliot - 2021-03-14

    Hi kirada,

    thank you very much for sharing your patch. I followed your steps (adding re-building the game as step 1.5) but I can't see any effect. No matter if I use the hand brake or the normal brake. How should I see the effect? Or is it only possible if I have appropriate hardware support – which I most likely don't have on my Technoethical T400s?

    Can you share a screenshot how the result should look like?

     

    Last edit: Onsemeliot 2021-03-14
  • Onsemeliot

    Onsemeliot - 2021-03-14

    No, sorry. It works absolutely fine. I just added the link to the tail light to the .mtl of the wheel instead of the file for the car. I am uncertain if it looks better with more blur. It doesn't really seem to work that way.

    Since the game uses the back arrow as the break it is a little odd because the red lights are active when the car is pulling backwards (instead of white lights). This is just a consequence how it is set up. I like it but people might complain that it isn't very realistic that way.

     

    Last edit: Onsemeliot 2021-03-14
  • Anonymous

    Anonymous - 2021-03-15

    Here's an updated patch. Now the break lights are not displayed while going reverse.

    The glow effect of lights could be done using code. Not sure how hard could it be in the version of OpenGL Trigger Rally uses.

     
  • Onsemeliot

    Onsemeliot - 2021-03-15

    Fantastic. Unfortunate, that glowing isn't easy to do. But why are you then not happy with the break light image? I see no flaw in it other that the border looks unnaturally sharply edged. My adapted version with blurred edges doesn't look any better in the game.

    However, creating an unsharp mask of the original tail lights seems to work best because a plain red looks to flat.

    I noticed that the break lights won't appear during having a look around when pressing "." or ",". The keys seem to cancel the tail lights out if pressed first. It works if you start hitting the breaks and then take a look. But not if you have a look around and then hit the breaks while doing that.

    Maybe it would look a little better if the blend mode was a little weaker. I suspect the tail lights don't need to be that much brighter if switched on.

     

    Last edit: Onsemeliot 2021-03-15
  • Anonymous

    Anonymous - 2021-03-15

    But why are you then not happy with the break light image?

    The only thing I did was to take the original image and paint transparent the pixels that don't belong to the break lights. I suppose a more realistic effect could be achieved by actually painting the break lights in the emission map.

    I noticed that the break lights won't appear during having a look around when pressing "." or ",". The keys seem to cancel the tail lights out if pressed first. It works if you start hitting the breaks and then take a look. But not if you have a look around and then hit the breaks while doing that.

    I'm not able to reproduce that. I tried what you described in the Aegyptian map and I can see the lights until the car starts going reverse.

    Maybe it would look a little better if the blend mode was a little weaker. I suspect the tail lights don't need to be that much brighter if switched on.

    The emission map could be scaled while blending but I don't think that's a good idea as it would alter the lighting equation. A better solution would be to reduce the intensity of the emission map with an image editor. This is somewhat related to what I said about the image I provided not been really good. Since it has the same colors as the original diffuse map the result is that the break lights intensity is roughly doubled.

     
  • Onsemeliot

    Onsemeliot - 2021-03-15

    I'm not able to reproduce that.

    Do you also steer the car using the keyboard?

    A better solution would be to reduce the intensity of the emission map with an image editor.

    This is what I originally did with my version of the Cordo emission image. But I felt in case of the Evo it looked better when I just duplicated the original image. Otherwise it just looked like a undifferentiated flat red surface. Maybe I need to do more experimentation with transparency levels.

     
  • Anonymous

    Anonymous - 2021-03-16

    Do you also steer the car using the keyboard?

    Yes, I'm using the keyboard. Are you using the default configuration file? If not, maybe you can try to delete the config file and let the game create a new one.

     
  • Onsemeliot

    Onsemeliot - 2021-03-26

    I will just include your patch now. We can still improve on the emission files later on if we have any ideas how to make them better.

     
  • Onsemeliot

    Onsemeliot - 2021-03-26
    • status: open --> accepted
     
  • Eugene MC

    Eugene MC - 2024-03-30

    Why no brake lights when braking by handbrake? In real cars handbrake against lights.

     
  • Eugene MC

    Eugene MC - 2024-07-24

    And how to add brakelights to handbrake?

     

Log in to post a comment.