Performance Boost - How To Optimize Routes

Discussion in 'General Discussion' started by torfmeister, Aug 1, 2022.

  1. torfmeister

    torfmeister Guest

    Fellow simmers.

    I've just bought "Zürich - Olten" from Simtrain.ch. This route suffers from a terrible FPS drop in stations, especially at night - going down to 3 FPS on my (fairly old i7) system, which plays a lot of routes at 60 FPS though (capped).

    I looked around and saw the passengers strolling the platforms casting multiple shadows. Then I opened a scenery tile in Notepad and counted about up to 80 shadow casting light sources per tile - and shadow casting requires massive amounts of computing power (unless coded by John Carmack ;)).

    So I tried the following.

    1. Copy the route's "Scenery" folder to a temporary location.
    2. Run SerzMaster.exe, enter the path of the temp folder, select "BIN>XML" to convert the tiles
    3. Start MassSearchAndReplaceTool, enter "1</CastShadow>" in the Search and "0</CastShadow> in the Replace box and proceed (just a few seconds then it's done)
    4. Run SerzMaster again, this time select "XML>BIN"
    5. Copy the Scenery folder to the Route's folder (backing up the old one of course)

    Result was I went from 3 to 24 FPS in the dense areas - quite a boost.

    Note that the visual quality does not suffer from that as you are hardly noticing those shadows. Even the cars in the streets had a shadow under the street lamps - totally unnecessary.

    Also be aware that there is a difference between <CastShadow> and <CastShadows>. The latter is a property of objects to display a shadow when being lit (by the sun for example) - leave these at 1 else you would lose all shadows in the game.

    You could also move the "Shadow Quality" slider in the options - but this only degrades all shadows while not disabling them. The method I used keeps your cab, sunlight and headlight casting shadows but removes the unnecessary scenery lights shadow casting which eats your frames.

    22.png

    33.png

    Before - (No FPS counter because it only goes down to 14 - reality was 2-3 FPS)
    66.png

    After - the missing light source shadows do not really make the scenery lack something but FPS multiply by 10
    11.png

    44.png
     
    Last edited by a moderator: Aug 2, 2022
    • Helpful Helpful x 4
  2. ex_railwayman

    ex_railwayman Active Member

    Joined:
    Dec 12, 2016
    Messages:
    292
    Likes Received:
    225
    I've got this route and thought the drop in fps was because of the station lights, etc, I never thought about passenger shadows at all, well spotted.
    2 thoughts come to mind, for those of us who are not very tech savvy, firstly, could we decrease the number of passengers on the platforms at all for the desired effect, could that help, in which case we might need a tutorial on how to do it?
    Secondly, could this be a general problem across the game for those of us experiencing a drop in frame rates, probably more for the nightime scenarios on any given route?

    Cheerz. Steve.
     
    Last edited: Aug 1, 2022
  3. torfmeister

    torfmeister Guest

    Well it IS the light sources - having the <CastShadow> flag set.

    It's not only the passengers (removing them would not gain much FPS) - check the fences, lamp posts, bushes, trees - everything that is in the lights' path will have shadows computed for each of the great amount of light sources' radius. For a walking sim or shooter that's mandatory, but not for a train sim, and FPS are a big immersion factor. Personally, I like having the passengers walk around because of immersion. You can surely alter the number, but I haven't checked on those blueprint properties yet.

    For nighttime drops - this is definitely the cause. In daylight you normally only have two shadow casting sources (if the scenery light sources are setup correctly to appear only at night) - the sun and your headlights (though I turn them off in daytime because in reality you would not see them casting light beams as the sunlight is brighter. (SearchlightSimulations have implemented a switch on their AC4400 and SD40-2 to toggle the daylight beam).

    Cast shadows are the main FPS eaters on DX9. Even LIRR has scenery lights' shadow casting disabled.
     
    Last edited by a moderator: Aug 2, 2022
  4. torfmeister

    torfmeister Guest

    Btw, just checked for you. This is an excerpt from "Kuju\RailSimulator\Scenery\Procedural\PlatformCharacters 00s DE.xml"

    Code:
               <PopulationDensity>
                   <cPlatformCharactersBlueprint-sPopulationDensity d:id="15331760">
                       <TimebandStart>
                           <cPlatformCharactersBlueprint-sTimeHoursMinutes>
                               <Hours d:type="sInt32">0</Hours>
                               <Minutes d:type="sInt32">0</Minutes>
                           </cPlatformCharactersBlueprint-sTimeHoursMinutes>
                       </TimebandStart>
                       <DensityPercentage d:type="sFloat32" d:alt_encoding="0000000000003440" d:precision="string">20</DensityPercentage>
                   </cPlatformCharactersBlueprint-sPopulationDensity>
               </PopulationDensity>
    
    Change the value "DensityPercentage" to adjust spawning density. Of course you must first locate the according platform asset for your route. But - won't affect FPS. I've had some platform peeps spawn bugs on Riviera Line leading to hundreds of disorientated passengers walking around without any FPS drop.
     
    Last edited by a moderator: Aug 1, 2022
  5. 749006

    749006 Well-Known Member

    Joined:
    Dec 10, 2016
    Messages:
    8,420
    Likes Received:
    2,675
    Last edited: Aug 2, 2022
  6. torfmeister

    torfmeister Guest

    Last edited by a moderator: Aug 4, 2022
  7. 749006

    749006 Well-Known Member

    Joined:
    Dec 10, 2016
    Messages:
    8,420
    Likes Received:
    2,675
    torfmeister
    I think I'm doing something wrong.
    The route I was checking with Search and Replace does not find and with Cast Shadow - only Cast Shadows.
    Is it possible the route does not have any files with Cast Shadow?

    Thanks

    Peter
     
  8. torfmeister

    torfmeister Guest

    Peter,

    Zürich-Olten is admittedly a very rare case. Most routes I've checked have very few to zero shadow casting light sources for good reason.

    And to clarify again: <CastShadow> is the property of a light source, while <CastShadows> is the property of any object (like a tree) to cast a shadow when being lit.
     
    • Helpful Helpful x 1

Share This Page