Repository navigation
Rain implementation - dry track until 50% rain, then flooded quickly #162
Description
Activity
Repository -
Changes make for a gradually wetting and drying track, with realistic levels of wetness and puddles that hang around a while after it stops raining. calcWater() in rainHelper has been rewritten basically. I encourage you to implement these changes or similar as your current model holds off wetting the track until over 50% rain intenisity then suddenly floods it.This project is now finished from my side, I hope you will take on the changes I have implemented as they are a huge improvement on your weather implementation and the random weather plugin. Repo is here - and my app is here - I did not "fork" the repo, but I'm sure I can do that and apply my changes again if you want to include them. Please check them out first, you have to try them to appreciate the difference. Here is a summary of the changes I made:-
Sum-up:-
I have written a new Assetto Corsa app to generate random weather systems for tracks in their different climates. It is a two-stage process, stage 1 generates random weather “forecasts” for practice, quali & race and stage 2 creates the random weather systems. The weather systems are either Pure Plans for offline use or weighted weather yaml files for the Assettoserver online solution. The latter of these solutions has required a lot of changes to get the weather systems acting naturally like they do offline with Pure and in the end I decided to hook into the existing random weather plugin – again with some more enhancements to get everything automated.
Link to app:-Key objectives of this project:-
- To create a single tool to generate realistic online & offline event weather systems.
- Make the weather more interesting – wall-to-wall blanket cloud is not absolutely necessary in order to have rain.
- To smooth out the transition lags as the track gets wetter or dryer. Puddles, for example hang around for a good 10 minutes after the rain has stopped now.
- To automate the loading of weather yamls for each session.
- To create a wide, realistic spread of wetness that covers everything from a damp, moist track to a completely rain-sodden one.
- Actually, to bring together the amazing work of Ilja (CSP), Peter (Pure) and Compu (Assettoserver)
Details of the Assettoserver changes are below:-
RainHelper.cs
Calcwater has been revamped to behave in a more natural manner. There is no longer a war between wetting and drying forces, just an equilibrium level of saturation and puddles associated with any given rain intensity and then exponential curves to control how gently or abruptly the levels approach the equilibrium over time. The result is that even with light drizzle, the track is now slightly moist and light rain will give you a track that is wet enough for slicks to be totally useless. Heavy rain, on the other hand will be very similar to before. A lot of fine-tuning went into these exponentials to make it feel as natural as possible. In fact, I’d say that the Assettoserver solution is now superior to Pure Plans in terms of behaviour.
I did add one other tiny bit of extra code as well - when you go from quali to race, for example, and it was a wet quali but a dry race start, I interrupt the natural wetness/puddle evolution and dry everything out instantaneously.
RandomWeather.cs
- Now checks for session yamls being present, these are effectively weather forecasts for each session. If present, it loads them instead of using the standard weightings yaml.
- It now uses /setcspweather exclusively.
- The weather kickstart procedure for each session is a bit odd as there is delay logic in there:-
a. It clears the air (and track) with an immediate /setcspweather to Clear skies - I say “immediate”, there is actually a 1 second delay as the session Id doesn’t actually change the instant an onSessionChanged event has been detected, so I set this with a delay of 1 second to ensure the weather is applied inside the correct session.
b. I then have a 2 second delay to apply the first random weather and this in-turn seems to take about 10 seconds to fully transition.
c. Note that this first random weather is simply the last one of a fast-forwarding sequence of 250 random weathers from a “Clear” weather start point. It ensures the opening weather is natural.
d. I then get straight into the normal cycle of random transitions, but I apply a 150 second lag to each one. This ensures that the 1st weather stays constant for 150 seconds, so you don’t get the weather changing whilst you’re still on the start grid.
e. They all share the same “token” so that new sessions can clear any outstanding ones instantly. - Restarting a session doesn’t reset the weather at all, in weather cycle terms it is ignored.
- I have created what I’d call “momentum” to the weather changes in respect to drying/wetting. If the track is drying I make it more likely that the next weather carries on drying and vice-versa, rather than what it does now which is hunt up and down randomly. This is all in pickRandom() and using exponentials to influence the random choices to either pick further up or down the weighted lists. It can still hunt up and down, of course, but a bit more naturally now – as if you reach the edge of a cloud and it reduces, for example.
WeatherManager.cs
I mapped my new weathers onto the CSP weathers here so that they would work. The visual weather is the one CSP gets, but with the physical characteristics of my new weathers. /setcspweather now works with the new ones as if they were genuinely new weathers.
DefaultWeatherTypeProvider.cs
- I have added my new weathers into here. When these weathers are sent to CSP, RainBrokenClouds (for example) gets set back to BrokenClouds but with rain levels > 0. The new weathers are 33 LightDrizzleFewClouds, 34 LightDrizzleScatteredClouds, 35 LightDrizzleBrokenClouds, 36 LightRainScatteredClouds, 37 LightRainBrokenClouds, 38 RainBrokenClouds.
- Light drizzle is adjusted from 5% to 6%. This just gets the track slightly damp rather than driving as if bone dry and helps smooth out the transition to a dry track in general.
- Light rain has been reduced from 30% to 25% (Assettoserver internal values again), widening the wet tyre window.
- Thunder is increased to 10%, 30%, 70%. As it stood, a heavy thunderstorm was less rainy than normal rain.
- I believe I adjusted the temperature coefficients slightly, these aren’t really used though.
I literally cannot design an F1 car where two wet compounds (ie: inters and wets) are viable. The track holds off getting wet far too long then suddenly floods, so effective water levels are extremely narrow (rain to heavy rain, basically). Solution is in the rainhelper function. The logic there is very much a "wetting versus drying competition" which is always going to end up with one of them winning. Better to have the rain levels heading towards an equilibrium and using wetting/drying to resist getting there rather than stopping it - so hot weather encourages drying, for example, but the track will still dry out eventually in the cold. The source for a simple, neat solution is attached and I also have a working server here - https://drive.google.com/file/d/1VTZzvadL_3xX49JCquYuCJpFEzGpxApG/view?usp=sharing
Rainhelper source.txt