PDA

View Full Version : [Tutorial] Env_fog with visible sky



Hezus
29-03-2018, 10:57 AM
I was testing some other stuff and suprisingly I achieved an affect I didn't know was possible, so I thought I'd share it here!

So, this is the level without fog and with fog.
https://i.imgur.com/aUjTFlB.jpg?2https://i.imgur.com/KfnkjId.jpg?1

The env_fog has a certain start and end distance. In this case 512 and 2048. Between those values it will generate a gradient overlay effect from 0 to 100%. However, it doesn't stop after reaching 2048. It will continue rendering that 100% fog thickness from 2048 all the way up to the maximum view distance (which is 160000 in SC). And therefore always completely block out the skybox.

In reality fog is almost never thick enough to block out all of the sky, so here's a trick to get the skybox back: You can cancel out the undesired effect by lowering the view distance. This is done with the cvar "sv_zmax". You can only alter this on load up, so add this line to your CFG: sv_zmax 4096
https://i.imgur.com/baaW6QJ.jpg?2

As you can see, the skybox is starting to become visible again. You can improve the visuals by increasing the end distance for the env_fog. Here is value 3000.
https://i.imgur.com/6QwGKIM.jpg?2

Since this is a bit of an exploit, it has some limitations:
- The lowest sv_zmax value is 4096. For the sky to become slightly visible you'd need at least a difference of 2048 units between the sv_max value and the end value of your env_fog.
- Because of the previous limitation, the end value of the fog can't be lower than 2048. If you're making a small area where you need thick fog, this trick won't work very well.
- sv_zmax will also stop rendering brushes and entities beyond its limit, so make sure you set it high enough, so your entire area is visible.
- It seems sv_zmax overwrites the worldspawns' MaxRange, so you can't use it to work-around this problem.

Hopefully this has been useful to someone! :)

TrEmPlEr
29-03-2018, 05:06 PM
it is!, Good job! :) an example map would be cool.

Silencer
30-03-2018, 06:08 AM
I think the reason the default behavior feels so wrong in the first place is that fog usually only extends up to a couple dozen meters high above the ground, whereas GoldSource simulates it all the way up into space.

Neat trick!

SourceSkyBoxer
30-03-2018, 06:27 AM
Old tutorial - I already made map with fog since before release new version of Sven Coop 5.x - Why do you not read my old example of Vluzacn's Map Compile Tools - You remember -/+16k and -/+32k. Yes I know engine limitation.

Hezus
30-03-2018, 07:17 AM
Old tutorial - I already made map with fog since before release new version of Sven Coop 5.x

I know fog was available before 5.0 but I havn't seen an example with a visible sky. Can you show me how you did that?

SourceSkyBoxer
30-03-2018, 07:40 AM
@Hezus, sorry I loose pictures and files but thread (https://forums.svencoop.com/showthread.php/41255-Incress-max-distance-limit-was-free-because-it-is-not-16384-just-30720)is here. I explain again. I have created map and I add simple hallway -/+30072 and add fog. It looks so close your thread (https://forums.svencoop.com/showthread.php/45183-Tutorial-Env_fog-with-visible-sky?p=529982&viewfull=1#post529982).

Now engine limitation can not make more than -/+16k if you see black hole of distance. I really miss old version of Sven Coop 4.8 with -/+ 30k.

Sorry I have not steam now.

Hezus
31-03-2018, 02:55 AM
Read that thread, but couldn't quite figure out what your example would look like.

Come to think of it, it would be great if someone could redo the env_fog code and add a max transparancy amount to it. Then you could easily adjust the thickness of the fog.