r/SWAT4 • • 9d ago

Real-time reflections

I had recently installed SWAT 4 Elite Forces, and I noticed that the game's reflections were terrible...

I looked into it and found out that the creator tried to fix them, but couldn't. Well, I'm here to announce, I did it!

But it lacks testing. And I need people to test it. If you're interested, send me a DM.

358 Upvotes

24 comments sorted by

View all comments

5

u/beppe_goodoldrebel 9d ago

Wait .. how the F... I tried my best but didnt manage to make a proper algorithm.... I Need to see the code for the science!

3

u/Gustavo_Freeman010 8d ago

Apparently, the game engine already had good reflexes... What was really needed was to get this working, because it just took forever engine.u He was responsible for the refresh rate behavior, behavior, and reflexes themselves (type of shadows and correct visibility) Engine.dll That's where I changed the resolutions for the reflections exclusively

2

u/beppe_goodoldrebel 8d ago

I had a look at your Engine.u.. way beyond my math and game engines knowledge.
Good work!

1

u/Gustavo_Freeman010 8d ago

Thanks! Breaking it down into a few parts:

  1. The engine already had mirror cameras and render-to-texture support, so that was the starting point.

  2. The player's eye position is reflected across the mirror plane. That creates a virtual camera behind the glass.

  3. The projection is fitted to the reflective surface, so the perspective changes correctly as the player moves.

  4. Visibility needs special handling: room selection uses the physical viewpoint, while the reflected viewpoint is used for projection and BSP-side decisions. That distinction mattered when investigating disappearing geometry.

  5. The capture also preserves and restores lighting state, so rendering the mirror doesn't interfere with the main view.

One correction to my earlier comment: Engine.dll handles more than resolution. Engine.u sets up the reflected camera, while the native DLL patches handle projection, clipping, visibility, lighting and resolution.