Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
霧著色器
Fog shaders are used to define how fog is added to (or subtracted from) a scene in
a given area. Fog shaders are always used together with
FogVolumes and volumetric fog. Fog shaders only have
one processing function, the fog() function.
霧著色器的解析度取決於體積霧 froxel 網格的解析度。因此,霧著色器所能增加的細節層級會根據 FogVolume 與攝影機的距離而變化。
Fog shaders are a special form of compute shader that is called once for every froxel that is touched by an axis-aligned bounding box of the associated FogVolume. This means that froxels that just barely touch a given FogVolume will still be used.
內建變數
標記為 in 的值為唯讀。標記為 out 的值可寫入,但不一定有合理初始值。取樣器(sampler)無法寫入,因此未標記。
全域內建變數
全域內建變數可於任何地方使用,包括自訂函式中。
內建變數 |
說明 |
|---|---|
in float TIME |
Global time since the engine has started, in seconds. It repeats after every |
in float PI |
A |
in float TAU |
A |
in float E |
An |
霧內建變數
所有霧體積(fog volume)的輸出值會彼此重疊。這使得 FogVolumes 能夠高效繪製,因為它們可以同時處理。
內建變數 |
說明 |
|---|---|
in vec3 WORLD_POSITION |
目前 froxel 單元在世界座標中的位置。 |
in vec3 OBJECT_POSITION |
目前 FogVolume 在世界座標中的中心位置。 |
in vec3 UVW |
三維 UV,將 3D 紋理貼圖映射至目前的 FogVolume。 |
in vec3 SIZE |
|
in vec3 SDF |
到 FogVolume 表面的有號距離場。於體積內為負,反之為正。 |
out vec3 ALBEDO |
輸出基礎色值,會與光源互動產生最終顏色。僅在使用時會寫入至霧體積。 |
out float DENSITY |
輸出密度值。可為負數,允許一個體積從另一個體積中減除。霧著色器必須使用密度,否則不會寫入任何數值。 |
out vec3 EMISSION |
輸出發光色值,於光照階段加到顏色上產生最終顏色。僅在使用時會寫入至霧體積。 |