-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFog.ffx
49 lines (41 loc) · 1.09 KB
/
Fog.ffx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
DECLARATIONS fog_global
include global
{{
void CalculateFog( float4 iPosition, float height, float in_fog_length, out float out_fog )
{
float3 to_camera = iPosition.xyz - camera_position;
float fog_depth = iPosition.z - height;
float to_cam_percent = saturate( fog_depth / abs( to_camera.z ) );
float fog_length = length( to_camera ) * to_cam_percent;
out_fog = saturate( fog_length / in_fog_length );
}
}}
DECLARATIONS fog_functions
include fog_global
include screen_space_global_illumination
{{
}}
FRAGMENT fog
include fog_functions
inout SurfaceData surfaceData : surface_data
inout EmissionData emissionData : emission_data
{{
emissionData.pixel_color = ApplyGlobalFog(float4(surfaceData.world_pos, 1.0f), emissionData.pixel_color);
}}
FRAGMENT fog_custom_pos
include fog_functions
inout SurfaceData surfaceData : surface_data
inout EmissionData emissionData : emission_data
{{
emissionData.pixel_color = ApplyGlobalFog(float4(surfaceData.world_pos, 1.0f), emissionData.pixel_color);
}}
// deprecated fragments
FRAGMENT fog_linear
{{
}}
FRAGMENT fog_exp
{{
}}
FRAGMENT end_fog
{{
}}