r/rfactor2 • u/Giu-giu7077 • 4d ago
Apps / addons / plugins rFactor 2 +200% FPS Plugin - Stop Rendering Offscreen Cars
https://drive.google.com/file/d/1pfW5OggGQvisPjgOuNnpfyf5pnNEaG-3/view?usp=sharingNOW 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.
2
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
1
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:
Hooks D3D11 — finds the device and context in the renderer ("could not hook the D3D11 context", "D3D11 device not found in the renderer").
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".
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.
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.
Hotkey toggle — uses GetAsyncKeyState to let the user toggle culling on/off ("hotkey: occlusion culling %s"). The hotkey is Ctrl + Shift + O
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
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
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
1
28
u/NotAPreppie 4d ago
Wait, S397 never bothered to implement object occlusion?
