Height Fog Tutorial(高度雾教程)
Height Fog Tutorial
《魔兽争霸III》Forged(Reforged)模组开发者分享 Height Fog Tutorial,讲解在 Hiveworkshop 发布的线性雾与高度雾实现差异。教程说明高度雾支持地面雾、Z start/end 控制应用范围,编辑器内实时更新,可用 SetTerrainFogExV() 等原生函数与 GUI 触发器控制。
Original tutorial written by a Forsaken Kingdom dev. Permission was granted to post it on Hive.
Height Fog Tutorial
First, let's talk a bit about the existing "normal" linear fog. Normal fog is purely in screen-space, meaning that the fog plane is always parallel to your monitor, and things that are further away (deeper into the screen) get more fog. A simple crappy programmer art explanation:
One limitation of normal linear fog is that if you pull the camera up, things get more foggy. A good example is the very first Reforged campaign mission "Chasing Visions". It's hard to make fog noticeable with gameplay camera views without making it affect the scene at the max zoom-out level.
The first screenshot is zoomed way in and you can see the fog looks nice. The second screenshot is zoomed out far enough that the camera angle is "normal", and you can still see the fog a bit, all good. The third screenshot is zoomed all the way out and everything is fogged, which is not so good.
Note that fixing this isn't the main intent of the height fog, it's more of a side-effect extra. The main point of the height fog is to support ground fog, which we'll get to in a bit.
How height fog works
Here's what is done differently for the linear fog when height is enabled:
- Linear start/end is similar to Z start/end for linear fog, except the fog plane is always vertical in world space (perpendicular to the ground plane). With camera angles that look along into the distance (like the first screenshot above from the campaign), it looks like normal linear fog. If you pull the camera up and look more straight down, like the third campaign screenshot above, the fog does not kick in for the "near" things.
- Z start/end in the height fog are also vertical planes in world space, but instead of defining a wall of fog, they define when to start applying the ground fog (height start/end).
- Height start/end defines where the ground fog is applied.
The linear start/end and the Z start/end are both camera relative -- they are distances from the eye, but only along the ground plane.
The height start/end are absolute world-space, non-camera-relative values.
Linear fog vs. height fog
Here's an example of linear fog vs height fog. Note that the "height" part of the height fog is effectively disabled here (the Z start is 13,000, which means no ground fog is applied until 13,000 units away). They are both using start/end of 1000/2500 for the linear fog. The height version looks a bit different because the math isn't the same for reasons explained above.
Regular linear fog:
Linear fog as implemented in the height fog:
Here is the same 1000-2500 near/far setting with the camera pulled up and looking down. You'll have to take my word for it that the linear fog version is exactly the same camera position as the height fog version.
Regular linear fog:
Linear fog as implemented in the height fog:
Adding ground fog
Now let's throw some "height" in. This shows applying ground fog from 20 to -120. Note that Z start/end are both 0, which means the entire scene has full ground fog. The linear start/end are way in the distance to disable the linear fog (except for where we hit the sky).
This screenshot shows how to mix in some linear fog. We have the full ground fog, plus fading in the distance (2000-4000).
Controlling where ground fog starts (Z start/end)
These screenshots show the effect of Z near/far to control when the ground fog starts getting applied.
Ground fog applied to whole scene (Z start and end are 0):
Z start is partway into the first hole:
Z start is partway into the second hole:
Editor, natives and GUI
All of these settings update live in the editor. Rather than hitting ENTER when you change a value, tab to a different value to see your change get applied. Or use the up/down spinner arrows. Besides enabling "Use Terrain Fog", you have to hit F to view the fog effects.
To control this with natives, use SetTerrainFogExV() ("V" for height fog), or SetTerrainFogExVBJ() for the BJ script version. These functions support all fog modes; the "V" is added to signify that height support is included, not that it's the only mode you can set.
GUI triggers also have new actions to control the fog.
来源:Hiveworkshop · hiveworkshop.com