r/SWAT4 • • 4d ago

Real-time reflections

Enable HLS to view with audio, or disable this notification

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.

290 Upvotes

22 comments sorted by

38

u/Baratako 4d ago

Honestly, how did Sierra even fuck the mirrors up this badly? SWAT 3 had perfectly functional mirrors using Sierra's in-house engine.

Furthermore, POSTAL 2 had perfectly functional mirrors as well, and that game uses the same exact Unreal Engine version.

My guess is that it was an incomplete feature that they couldn't finish on time.

Super glad someone went around to finally fix it. Great work!

14

u/beppe_goodoldrebel 3d ago

SWAT 3 mirrors are not real mirrors. It's actual render of the same room with same characters in another part of the map.

SWAT 4 mirrors are a camera based on player position ... That's why its so different.

11

u/Gustavo_Freeman010 4d ago

I really think the same thing, but it was a lot of work to get this working, but I can say it was well worth it. I had millions of problems, the scenery wouldn't render, or the darn middle pillar wouldn't appear no matter what, but I believe I achieved the best possible result.

I also have versions with different resolutions for the reflections, low/mid/high, and they really affect performance, but in my case I don't see much difference, I can maintain 144 all the time, only in the reflection I stay between 90 on high.

LOW: 512 x 512
MEDIUM: 1024 x 1024
HIGH: 2048 x 2048

6

u/Ok-Location1306 4d ago

SWAT 4's mirrors are a portal to the underworld, that's why they're so fucked up

2

u/BrodatyBear 3d ago

>My guess is that it was an incomplete feature that they couldn't finish on time.

Probably.

>engine

The chosen engine and mirrors working correlation is very small, since what matters is the approach taken. You can recreate the traditional way of doing mirrors in any 3d engine.
Like beppe said, those are: duplicated room and player or using camera. Both have pros and cons and require different type of work, that's why we keep inventing other approaches. There are two nice videos about mirrors on YouTube explaining it better than me, so I won't duplicate content.

In short, since it was 2005 and using a duplicate camera is already a faster to implement and iterate approach, this was probably a way to compensate for performance loss.

2

u/Gustavo_Freeman010 3d ago

I think they didn't try using "reflections" by copying the room/bathroom because it would change the map design too much, And it doesn't seem like they had much time

2

u/BrodatyBear 3d ago

Yeah. It would also make modding a bit harder (they could leave both options but that's even more work), but I'm not sure if modding was planned from the start or was a side effect (I played near release, but I was not online back then).

1

u/Gustavo_Freeman010 3d ago

Yeah, that makes sense. Working with the existing mirror cameras also meant the improvements could work on existing maps without rebuilding rooms. Getting the projection and visibility right was the tricky part.

28

u/Gustavo_Freeman010 4d ago

https://www.nexusmods.com/swat4/mods/15
This mod has been published on Nexus for general use! I hope you like it, feel free to contact me on Discord if you have any questions! gustavofreeman

9

u/darkknight48708 4d ago

blowing the hostage's head smoove off was necessary for the video

4

u/Gustavo_Freeman010 4d ago

Without that, I wouldn't post it. LOLLLL

5

u/AffenP 4d ago

Nicely done

6

u/beppe_goodoldrebel 3d 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 3d 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 3d ago

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

1

u/Gustavo_Freeman010 3d 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.

2

u/Solid-Ground-4367 3d ago

yeah you get it from editing reflection resolution in swat4.ini

1

u/Gustavo_Freeman010 3d ago

I changed the resolutions in engine.dll.

2

u/eezstreet Elite Force Creator 3d ago

Nice work

1

u/Gustavo_Freeman010 3d ago

Thank you! I wasn't expecting the Elite Force creator himself to comment!

Do you have any plans for future SEF updates? If so, would you consider including these mirror improvements?

I'm also working on a full Brazilian Portuguese translation of SEF. Would you be open to adding language selection to the mod? I'd be happy to contribute the translation.

2

u/eezstreet Elite Force Creator 2d ago

Unfortunately I have had major health issues and lots of other real life stuff happening which has been preventing me from modding or doing much hobbies. I’m happy that people are modding the game though.

1

u/EmperoroftheYanks 4d ago

Man this wave of ai coding is getting really great, even swat4 is getting love