Modify fog and PVS for performance increase

I would like to modify the fog on gm_atomic so that everything becomes obstructed by fog at 680 units away from the camera. Entities beyond 1024 units should not exist on the client, since they are not visible.

This way, when the player ventures out into the desert, and can’t see any other players, the director will spawn NPC zombies just outside the players view and they will converge on the player. Since the player will always be alone when this zombie spawn happens, no other players need to know about it, and therefore the zombies should not appear in other peoples’ PVS.

Should I use gm_cvar2 and gm_pvs to set a fog override and then manually remove zombies from the PVS if they are not within the players’ view?

Can I modify the fog values in env_fog_controller and sky_camera with EntityKeyValue and then will the PVS stuff be setup automatically?

Is there another way? I have never been able to get the fog modification stuff working that was included from the gm_renderx module. If someone could provide an example, that would also be appreciated.

If possible, I also need to be able to change the fog values during the map, on the fly. In some areas of the map, such as inside, I don’t want fog. Inside the base, the fog should start ‘just outside’, and beyond the base it should be very up close.


Yes, you can. But if I remember correctly the far clip plane wasn’t working as I expected.

Does anyone know how the fog functions in the render library work?

cvar2.SetFlags(“fog_override”, flag)
cvar2.SetFlags(“fog_start”, flag)
cvar2.SetFlags(“fog_startskybox”, flag)
cvar2.SetFlags(“fog_end”, flag)
cvar2.SetFlags(“fog_endskybox”, flag)
cvar2.SetFlags(“fog_color_r”, flag)
cvar2.SetFlags(“fog_color_g”, flag)
cvar2.SetFlags(“fog_color_b”, flag)

While this works for my computer, it doesn’t work on players connecting to me.

EDIT: Seems to be a problem with the dll and the new update, it’s missing the ReplicateData function.

I was trying to use the fog functions in the render library to no avail.
The way you’re doing it above (Talking out my ass here could be wrong) is directly modifying the fog_controller in the map. If the map doesn’t have it, nothing happens. Also, for it to work in multiplayer, cheats need to be on.

So we’re back to the render library fog, which has little documentation/might be broken.

Don’t you think that is a little bit overkill? I mean, 1024 units is only around 20 meters. Thats seriously no visibility.

The map I am using, gm_atomic, does have a fog controller. gm_cvar2 fixes the cheat problem, at least it did. Once haza has finished the update I will be able to use cvar2.ReplicateData to make the fog commands available on the client without cheats, currently they need the module for it to work.

I can’t get the keyvalues solution to work either, but that’s okay since it didn’t allow for dynamic fog changes. Using the cvar2 method I will be able to make changes to the fog on the fly.

I agree, it’s barely anything, but that is pretty much the point. Basically, inside the bases you will be able to see the fog that is outside the base, as you approach the exit, the fog seemingly remains where it is, as if it’s a solid wall of fog right in front of you. Once you pass through the fog, your visibility will be reduced to those 1024 units. This is the sort of look inside the fog:

When you are inside the fog, you are vulnerable to the zombie attacks. The director spawns zombies just outside the fog so that no player sees the spawn, and it gives the illusion that zombies are everywhere, when in fact there are only zombies near other players. With the pvs modified, people back at base won’t even know the zombies out there exist. Only zombies near you will be networked, hopefully allowing for a lot more zombies :unsmith:

Reminds me back in the day when developers used fog to increa- oh, that’s what you’re doing.

So does anyone know how the fog functions included in GMod work?

Well what type of fog? Theres bad fog and good fog:
Example of good fog (not really fog, but still fog)

The fog slowly makes it harder to see until you can’t see.

Then there is shitty fog. The bad type is you can only see 10 meters in front of you. Anywhere past that is just a blue screen.

Type sv_cheats 1 into console, then mess around with the Fog stuff in the options menu. That overrides the maps fog, you can make good fog with it, that blends perfectly with the skybox and gradually makes it harder to see. You can also make bad fog that means you can only see 10 meters in front of you. I need to find a way to change this stuff on the fly for every individual client, as well as gain the performance boost that is associated with the PVS updates.

I’m trying to achieve ‘shitty fog’, you can’t see more than 20 meters in front of you and beyond that is just the grey mist. It won’t be shitty in context.

From what I know if you do this and not render the npcs for players not in sight, it is an amazing fps saver. I’ve had 100+ npcs on the map not affect a players fps as they were “out of sight”.

Exactly, this is a massive performance increase! However, env_fog_controller doesn’t like it’s keyvalues being changed. When I do it on map load, it crashes, and when I do it on the fly with SetKeyValue, it does nothing.

I’m just waiting for gm_cvar2 to have its update so that I can use the fog_override functions on the client. Then I’ll just change the PVS manually.

What I really need is for the fog functions included in GMod to be fixed! Or the functions
need to be included from the old renderx module.

It works, I’ve used this exact thing before and had it start on map load. All I remember is you have to have certain values set to make it even work, but I don’t remember which ones sorry. Maybe look at a map that has fog and check what values it has set and replicate those to get the fog working and then adjust them to your liking.

It is very possible, I’ve used this before and on the fly. I can’t seem to find the code now though.