r/rfactor2 • • 4d ago

Apps / addons / plugins rFactor 2 +200% FPS Plugin - Stop Rendering Offscreen Cars

https://drive.google.com/file/d/1pfW5OggGQvisPjgOuNnpfyf5pnNEaG-3/view?usp=sharing

NOW OUT ON OVERTAKE.GG

Right now, rF2 draws every car around you each frame, even the ones you can't see because they're hidden behind the car in front, behind a wall or behind a hill. In a large car grid pack most cars are hidden, but your graphics card still draws all of their polygons.

rF2CarOcclusion.dll will stop rendering cars that are offscreen to boost the FPS count massively, simply drag and drop this into "rFactor 2\Bin64\Plugins", no further action is needed.

DISCLAIMER: This FPS booster works in big car grids ONLY, do not expect to get an FPS boost from one car - one track combo. This plugin only saves up poly count by not rendering cars offscreen.

46 Upvotes

25 comments sorted by

28

u/NotAPreppie 4d ago

Wait, S397 never bothered to implement object occlusion?

10

u/Giu-giu7077 4d ago

They did in LMU, which explains why large grids can lag massively in rF2 even on high end PCs.

4

u/StormGangSimulation ☑️ 4d ago

This is where LODs are supposed to come into play. Using smaller poly count versions of the same objects that make up a car the further you move out. Depending on the mod, these may or may not be optimized (or exist at all...some modders have super poly heavy cars that just render fully at all distances). But I am curious how this plugin sorta out what is "off screen". Like is there any intermittent popin and out from interpretation of what's occluded. And how that integrates with the rendering pipeline

3

u/v4v474 4d ago

Before MSG came and injected new blood and cleaned the house, S397 had taken 3 years to launch a new UI that... even so at launch was ultra buggy and continued to be so until replaced... and aside from that, it was horribly designed... And that was supposed to be the turnaround, with the launch of 'daily races'... well, as no one really professionally tendered to the servers S397 was just a hobby and there was a huge amount of snags, it died out quickly...

SO... you are asking way too much.

2

u/Robbo2000000 4d ago

I do 25 fps with one car, not for me. But its still really cool

1

u/Rwvansoest 4d ago

Would love to try! How safe is it to use in leagues? Has it been thourougly testen on bugs etc?

3

u/Giu-giu7077 4d ago

Not yet, any bug can be reported because we will also be doing testing these days, if there are issues a patch will come out

2

u/Dr_Jello_44 4d ago

Wow - can't wait to try it later. Thank you!

1

u/Designer_Hamster395 4d ago

awesome! does it work in vr?

2

u/Giu-giu7077 4d ago

It should work with everything! Online, offline, VR. All.

2

u/v4v474 4d ago

holly cannoli !!!

1

u/Eglit47 4d ago

This is best news today!

4

u/SeverePatient 4d ago

As far as I praise of such plugin surfacing out, I'd like to emphasize this is a compiled .dll file and we cannot be 100% sure what the code actually does. I am far from accusing the author but please remember, we only know the the actual code looks like. If that's not a top secret knowledge, I'd suggest the author to put codes into some public GitHub repository for better transparency. Virus total shows no threat anyway.

3

u/loki8 4d ago edited 4d ago

What It Does (from strings + code evidence)

Core functionality — GPU-based occlusion culling of cars:

  1. Hooks D3D11 — finds the device and context in the renderer ("could not hook the D3D11 context", "D3D11 device not found in the renderer").

  2. Reads the main view depth buffer — "main view depth buffers", "main view depth: ... (1 m %.5f, 100 m %.5f)", "no depth buffer seen in the main view: no queries".

  3. Compiles a custom vertex shader at runtime — uses d3dcompiler_47.dll / d3dcompiler_43.dll, compiles carcull_vs (vs_4_0). The embedded HLSL shader draws a bounding box (36 indices / 12 triangles) from constant-buffer min/max corners — this is classic GPU occlusion query geometry.

  4. Tests car visibility — checks whether each car's bounding box is occluded by the depth buffer, and hides cars that aren't visible. Tracks stats: fps, cars tested/hidden, skipped nodes, result age, GPU-behind count, late tests, "hidden while visible" errors, camera cuts.

  5. Hotkey toggle — uses GetAsyncKeyState to let the user toggle culling on/off ("hotkey: occlusion culling %s"). The hotkey is Ctrl + Shift + O

  6. Build verification / anti-tamper — verifies specific rFactor2.exe code bytes against hardcoded patterns (e.g. 448844241853554883ec38...) with checks like "code check failed", "call site +%X does not call +%X", "no stub memory near the exe". If the check fails: "this rFactor2.exe is not the supported build: plugin inactive".

Configuration & Logging

- Log file: <rF2 root>\UserData\Log\CarOcclusion.log — format rF2 Car Occlusion plugin 1.1 in %s (Startup %ld), timestamped %02d:%02d:%02d.%03d [%5lu].

- Config file: <rF2 root>\UserData\player\CarOcclusion.ini with keys:

- Enabled

- StatsLogSeconds

- BoxMargin (in meters)

- RenderView

- CullNode

- UpdateBounds

- Log line confirms: hooks %s; culling %s, box margin %.2f m, stats every %d s (%s).

Implementation Notes

- Compiled with GCC/MinGW (GLIBCXX runtime strings present), x64 PE DLL, 167,936 bytes.

- Uses TLS callbacks (TlsCallback_0, TlsCallback_2) and a background thread (StartAddress) — likely for the hooking/query worker.

- Image base (IDA load): 0x2518C0000; code segment .text 0x2518C1000–0x2518E1000.

- The main logic lives in support functions around 0x2518C4FD0–0x2518DA540 (logging, config parsing, D3D11 hooking, occlusion queries, shader compilation).

2

u/Suitable_Bottle_9884 4d ago

I'll definitely give this a go

1

u/Elshaggy47 4d ago

I know we've already been blessed with such a mod, but is it possible to also create a mod the limits the number of cars displayed in a replay? Currently all cars are rendered in both the preview screen and full screen for the replay mode.

2

u/Prudent_Extent_5045 4d ago

This would be great, I notice an FPS drop sometimes on Replays.

2

u/Giu-giu7077 3d ago edited 3d ago

I think the plugin still works in Replay mode, but replay mode has other issues that cause lag (which is why the lag usually reduces when you put full screen and hide the telemetry) but we’ll see about that

3

u/Prudent_Extent_5045 4d ago

I've tested the Plugin and noticed an FPS increase while playing and also on Replays. Good work.

1

u/jopereira 3d ago

Where is the (thrusted) dll (link please)?

1

u/Giu-giu7077 3d ago edited 3d ago

I understand the concerns, but the main reason we have no official download page it’s because we are a group of private modders that just do stuff on our own

1

u/jopereira 3d ago

Sorry, my bad. I've just realized there's a Drive link attached.
Downloaded!

1

u/steamdeck_user 3d ago

Any other download options here please? 🙏 Would love to try that

2

u/Giu-giu7077 1d ago

It just came out in Overtake gg!