rev: 21c5e6d2f665d0e8b4ff917a51b664c895dab2ed tukan/tukan/fog.sc -rw-r--r-- 503 bytes View raw Log this file
21c5e6d2f665 — Leonard Ritter * renamed project from Liminal to Tukan 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
struct FogSetup
    k : f32

# average 50% visibility range on a clear day: 33871.2 meters

# input: distance at which scene is 50% visible in meters
fn fog_setup (halfdist)
    "FogSetup <- (f32)"
    FogSetup (-1.0 / (halfdist * halfdist))

# input: fog setup, squared distance e.g. (dot viewpos viewpos)
# output: visibility of scene (0 = 100% fog)
fn fogterm (setup distsq)
    "f32 <- (FogSetup f32)"
    exp2 (distsq * setup.k)

#if main-module?
    let s = (fog_setup 0.1)
    dump s.k

locals;