Creating eclipsing fog for valleys?

seth

aa
May 31, 2013
1,019
851
I'm finally planning a map and want the playing area set on top of a bluff overlooking some valley. I'd like to make it as if the cliff is punching through the clouds so the valley below gets eclipsed more and more by clouds (or a fog). However, I don't want there to be much fog throughout the map, so an env_fog_controller is out. Any ideas?

EDIT: I suppose I could just use an env_fog_controller and make the whole valley into a 3D skybox?
 

A Boojum Snark

Toraipoddodezain Mazahabado
aa
Nov 2, 2007
4,775
7,669
Using several massive layers of translucent materials puts a heavy drain on the engine, I do not recommend it. What you see in that screenshot was a single translucent layer and a single solid "floor" layer, and a gradient overlay on the rocks to fake a thick fog... something that was only doable because of the simplistic nature of it. Wouldn't work for fully developed natural looking valley space.
 

xzzy

aa
Jan 30, 2010
815
531
Upward might also be good inspiration, they use just a fog controller which you can't do a lot of tricks with, but with careful arrangement of terrain features you might be able to fudge something.
 

Limeaide

L2: Junior Member
Jul 26, 2009
98
9
What about the volumetric fog that's used in water? Would that be usable in this situation, or are there some restrictive qualities that keep that from being viable?
 

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
Rexy did something weird for one map, he modified all the material mipmaps so that they'd fade into a fog colour. It was ridiculous, and not a good solution, but it wasn't particularly resource heavy.
 

henke37

aa
Sep 23, 2011
2,075
515
Uhm, use a material proxy to change the alpha depending on the viewer distance?
 

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
Which is why Rexy used mipmaps, they're all automatically done at set distances. Buuuut if anyone has texture resolution at anything other than max, it's all screwy
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,694
2,579
Which is why Rexy used mipmaps, they're all automatically done at set distances. Buuuut if anyone has texture resolution at anything other than max, it's all screwy
Can't you also manipulate that using the texture's internal LOD value or whatever it's called?
 

xzzy

aa
Jan 30, 2010
815
531
Source doesn't make it easy to make it look good, but I think if you took the advice of other people in the thread and play around with the fog settings on a sky_camera entity you can maybe fudge it enough to get by.

Use the fog blend settings to do full white when looking down, and match the skybox blue when looking up. Adjust the fog start/end distance to taste. Use a transparent texture for a cloud layer to improve the illusion.. framerate permitting, use more layers. If you need more of a 3d effect maybe you can use a particle system.

30 minutes got me this, it has a number of problems but it sort of pulls it off and it might work as a place to start. A proper cloud texture would probably help a lot, I just used a bullet decal because it's the best texture available without making my own.

850286A3BE05C6B230460D3AB8D0755F69A80FD5


http://xzzy.org/files/games/tf2/test_fog.vmf.gz
 

seth

aa
May 31, 2013
1,019
851
Thanks for everyone's responses so far!

xzzy, I really appreciate the test! The beginning of the fog is a very harsh transition, but I'm sure a more graded texture (and time!) would help alleviate that.

So huge "cloud" textures across the entire bottom of the map would be a bit framerate intensive, I gather. I would of course still want the map to be playable for everyone, so that option doesn't fit. Would big particle systems be more practical? I feel like that would be a lot simpler and more efficient, in addition to some 3D skybox env_fog_controller'ing. Actually making the particle system would be quite a challenge, though.
 

xzzy

aa
Jan 30, 2010
815
531
You could probably do a single cloud texture without too many issues. Maybe even two. Every single overlay you use in the map is basically doing exactly that if that gives you a sense of scale.

It's just when you start stacking many of them on top of each other it gets expensive, the game has to do a lot of computation to get each pixel correct.


A particle system wouldn't be any better, it has to calculate the alpha for every single particle there as well.
 

A Boojum Snark

Toraipoddodezain Mazahabado
aa
Nov 2, 2007
4,775
7,669
So huge "cloud" textures across the entire bottom of the map would be a bit framerate intensive, I gather. I would of course still want the map to be playable for everyone, so that option doesn't fit. Would big particle systems be more practical? I feel like that would be a lot simpler and more efficient, in addition to some 3D skybox env_fog_controller'ing. Actually making the particle system would be quite a challenge, though.
The problem is, as xzzy mentioned, translucent materials in general. Whether it be single large faces or lots of particles. An opaque pixel only needs to be handled "once" (lets ignore shaders and yadda yadda here), and will simply render instead of whatever is behind it. If you have a translucent pixel, it has to be added to whatever is behind it, meaning two things to handle. So on and so forth. If you used 10 cloud sheets to gradually make it foggier, each pixel would have get 11 things blended together.

A particle system with large overlapping sprites would suffer the same way. That's the reason you could make an extremely crazy sparking sprite (like a saw cutting metal) and it wouldn't hurt the framerate at all because the sprites are tiny and will rarely overlap each other. Whereas if something like the payload explosion smoke starts to fill too much screenspace it can cause a slowdown because the sprites are huge.

On top of all this... if it gets put in the 3D skybox it will be rendered at all times, because that's just how skybox is.


Now for an actual idea I just had... you might be able to get something that looks pretty good if you hand-draw the clouds to match your map. That is, make one single large (2048^2 or more) non-tiling texture that you would scale up huge and the clouds would "fit" in your valley, and fade out before they reach the hillsides so you don't see a line where the face cuts through.
 

henke37

aa
Sep 23, 2011
2,075
515
I think the engine has a limit on how many transparent layers are considered for each point. But yeah, it's fairly high and the overdraw is going to be expensive. I wonder if the real problem there isn't the drawing itself, but the sorting before. The engine sorts all transparent faces before rendering to get the correct result. Sorting isn't known to be fast, but eleven items? That should be trivial. If the sort criteria is trivial. But it's the view distance, or something. I don't know how much that costs to compute.
 

Tumby

aa
May 12, 2013
1,084
1,192
Now for an actual idea I just had... you might be able to get something that looks pretty good if you hand-draw the clouds to match your map. That is, make one single large (2048^2 or more) non-tiling texture that you would scale up huge and the clouds would "fit" in your valley, and fade out before they reach the hillsides so you don't see a line where the face cuts through.

A Displacement with a white and a transparent material, as well as a cloud-ish blend modulate might help.