Last updated: 2026-11-26
5. Air: fog, mist and mirages
For new readers
So far a ray travels through nothing. Here the air itself takes part: fog and mist dim and tint what is seen through them by the optical depth along the ray, and a mirage bends the ray through layers of air of different temperature, so that it is no longer a straight line. The meadow of the film is seen through a light haze; both effects sit on top of the world's colour for a ray.
Fog and Mist
Distance has been invisible so far: a sphere a hundred units away is as sharp and as bright as one at ten. Air is not clear. A ray that crosses it is dimmed and tinted, and the further it goes the more. This page gives a picture an atmosphere.
The model
Air has a density ฯ(y), which may depend on height. Light that travels a distance through it keeps a fraction
T = e^(โฯ), where ฯ, the optical depth, is the density added up along the path, and what is lost is replaced by the colour of the air itself:optical depth is just integrated density
colour seen = colour ร T + fog colour ร (1 โ T)
so a ray that goes a long way sees mostly fog, and a ray that goes nowhere sees what is there. This is Beer's law. Two things follow that make it cheap and make it right:
- Depths add. The first 4 units and the next 6 have the depth of the 10, so
Tmultiplies: that is why a blend per ray is enough and the air does not have to be walked. - A mirror's reflection is fogged too. Each ray, the one that meets the mirror and the one it reflects, is dimmed for its own length, because
color_atapplies the blend to every ray it follows. A reflected ray that goes off into the sky sees fog colour, and that is added to what the mirror shows.
The density is ฯ(y) = dโ e^(โk y). With k = 0 it is uniform fog; with k > 0 it is mist, thick at the ground and thin high up. Along a ray that starts at height o and rises m
per unit of length, the depth over length L has a closed form,
ฯ = dโ e^(โk o) (1 โ e^(โk m L)) / (k m)
with the limits dโ L when k = 0, and dโ e^(โk o) L when m = 0 (a level ray stays at one density). For a ray that never ends (a miss: the sky) the depth is dโ e^(โk o) / (k m) if the ray is rising, and infinite if it is level or falling:
a ray that goes down into mist would have to end, but it does not, and so sees only fog; a ray that rises out of it sees a little of the sky.
Light is not dimmed on its way to a surface (shadows are as before), and the air does not glow: it only veils. The atmosphere is a part of the world (set_world_atmosphere(w, [d0, k, colour]),
read back by world_atmosphere), so a picture with none, the default, is exactly what it was: the benchmark pictures of the performance page have the same checksums.
# fog or mist [d0, k, fog colour], or false for clear air
make a function called world_atmosphere takes w returns atm
if w.length > 4 then
return w[4]
end
return false
end
make a function called set_world_atmosphere takes w, atm returns w2
return list_set(world_full(w), 4, atm)
end
# the integral of d0 exp(-k y) along a ray that starts at height oy and rises dy per unit length, over
# the length len (which may be infinity): d0 e^(-k oy) (1 - e^(-k dy len)) / (k dy)
make a function called atmosphere_depth takes d0, k, oy, dy, len returns tau
let inf = infinity()
if d0 == 0 then
return 0
end
if k == 0 then
if len == inf then
return inf
end
return d0 * len
end
let base = d0 * exp(0 - k * oy)
let x = k * dy
if len == inf then
if x > 0 then
return base / x
end
return inf
end
let e = x * len
if abs(e) < 0.00000001 then
return base * len * (1 - e / 2 + e * e / 6)
end
return base * (1 - exp(0 - e)) / x
end
# the colour c seen along the ray r to a hit at parameter t, in the atmosphere atm = [d0, k, fog]
# the colour c seen through an optical depth tau of the atmosphere atm
make a function called atmosphere_veil takes atm, c, tau returns out
let through = exp(0 - tau)
return color_add(color_scale(c, through), color_scale(atm[2], 1 - through))
end
make a function called atmosphere_blend takes atm, c, r, t returns out
let mag = sqrt(get_x(r[1]) * get_x(r[1]) + get_y(r[1]) * get_y(r[1]) + get_z(r[1]) * get_z(r[1]))
let tau = atmosphere_depth(atm[0], atm[1], get_y(r[0]), get_y(r[1]) / mag, t * mag)
return atmosphere_veil(atm, c, tau)
end
In the scene language
fog density 0.05 falloff 0.45 color 0.84 0.89 0.95
density is dโ at height 0, falloff is k (0 if left out: fog; more than 0: mist), and color is the colour of the air (a pale grey-blue if left out).
It goes with antialias among the settings of the picture, and a scene has at most one.
Scenarios and oracles
- The optical depth against a numerical integral. 60 random rays, in uniform fog and in two mists, going up, down and level, over lengths from 1 to 30, against Simpson's rule on the density with 4000 steps: no code in common with the closed form.
Level rays; the limits for tiny
kand tinym; a ray that never ends, rising, against an integral to length 400; level and falling rays and uniform fog having infinite depth; depths adding along a ray. - The blend.
colour ร T + fog ร (1 โ T)at a distance of 8 in fog of density 0.1; a distance of 0 changes nothing and one of infinity is the fog; density 0 changes no colour at any distance; the distance isttimes the length of the ray's direction. - In a world. An ambient-only sphere 9 away in fog of 0.05 against the formula; a ray that misses in uniform fog is the fog colour; a ray rising in mist misses and has the fog's share of its finite depth; density 0 gives exactly the plain colour; with no atmosphere a miss is black; density 0.2 is not 0.05.
- A mirror in fog: the first ray is dimmed for
2โ2, and the ray it reflects (which misses) adds the fog. - The language:
fogsets the atmosphere with its values; a default colour and falloff; none when not written; it coexists withantialias; a missing density and an unknown word are reported.
Everything before still passes, and fog off changes no picture:
> tools/bench.sh | grep -c CHANGED
0
A scene in mist
Seven red spheres receding into the distance, a mirror, a glass ball, and mist (density 0.09, falloff 0.5). The far spheres are lost in it, the mirror shows the mist behind the viewer, and the glass ball's refracted view is fogged for its own length.
# a small scene in mist, for the check against the independent tracer
param w = 200
param h = 120
size w h
camera from 0 1.2 -9 to 0 1.4 0 fov 60
light point at -8 12 -8
fog density 0.09 falloff 0.5 color 0.78 0.84 0.92
material grass
color 0.45 0.65 0.3
ambient 0.2 diffuse 0.8 specular 0
end
material mirror
color 0.2 0.2 0.25
ambient 0.05 diffuse 0.3 specular 0.9 shininess 200
reflective 0.7
end
material red
color 0.85 0.2 0.2
ambient 0.15 diffuse 0.7 specular 0.4 shininess 100
end
material glass
color 0.9 0.95 1
ambient 0.05 diffuse 0.1 specular 0.9 shininess 300
reflective 0.4 transparency 0.7 ior 1.5
end
plane material grass
for i in 0 to 6
sphere at (i * 3 - 9) 1 (i * 2.5) material red
end
sphere scale 1.2 at -1.6 1.2 -1 material mirror
sphere scale 1.1 at 1.8 1.1 -2 material glass
> tools/render_scene.sh scenes/fog_test.scene out/fog_test.png 20
progress: the port is written to D:/Projects_Organized/raytrace/out/fog_test.png.progress; ask with v2_interp.exe tools/render_status.patlang --file D:/Projects_Organized/raytrace/out/fog_test.png.progress
rendered 200x120 in 20 bands by threads in 180658 ms
rendered by 18 threads in 196 s wall clock
Checking it independently
Fog changes how every ray is coloured, an engine feature, so this one is checked by the independent tracer. The exporter writes an A line (density, falloff, colour of the air); the checker
blends every ray it follows, including the reflected and refracted ones, by the same law, but finds the depth by numerical integration (Simpson's rule, 400 intervals, and for a ray that never ends as far as the density is worth counting) and not by the closed form.
> v2_interp.exe tools/export_scene.patlang --scene file --file scenes/fog_test.scene --out out/fog_test.txt
wrote out/fog_test.txt (10 shapes)
> powershell.exe -NoProfile -File tools/verify_recursive.ps1 out/fog_test.png -SceneFile out/fog_test.txt -Stride 4
decoded by .NET: 200x120; pixels differing from the independent recursive tracer by more than 1 level: 0 (max difference 0); stride 4 in each direction, 1500 pixels checked
Negative controls: the same scene without its A line (clear air), and with the density 0.07 for 0.09:
grep -v "^A " out/fog_test.txt > out/fog_test_nofog.txt
sed 's/^A 0.09 /A 0.07 /' out/fog_test.txt > out/fog_test_wrong.txt
> powershell.exe -NoProfile -File tools/verify_recursive.ps1 out/fog_test.png -SceneFile out/fog_test_nofog.txt -Stride 4
decoded by .NET: 200x120; pixels differing from the independent recursive tracer by more than 1 level: 1500 (max difference 234); stride 4 in each direction, 1500 pixels checked
> powershell.exe -NoProfile -File tools/verify_recursive.ps1 out/fog_test.png -SceneFile out/fog_test_wrong.txt -Stride 4
decoded by .NET: 200x120; pixels differing from the independent recursive tracer by more than 1 level: 1489 (max difference 22); stride 4 in each direction, 1500 pixels checked
The garden, in the morning
The pond garden of Trees, plants and a garden with one statement more, --set mist=0.07, which turns on fog density mist falloff 0.45 color 0.84 0.89 0.95:
> tools/render_scene.sh scenes/pond_garden.scene out/pond_mist.png 60 --set mist=0.07
progress: the port is written to D:/Projects_Organized/raytrace/out/pond_mist.png.progress; ask with v2_interp.exe tools/render_status.patlang --file D:/Projects_Organized/raytrace/out/pond_mist.png.progress
rendered 400x240 in 60 bands by threads in 4465740 ms
rendered by 18 threads in 4738 s wall clock
Mirage
On a hot road the air next to the ground is thinner than the air above it, and light, which bends toward thicker air, curves back up before it reaches the surface. A ray that travels down at a shallow angle never arrives: it is turned upward, and far-off ground is replaced by sky, with the things standing on it, upside down.the bend is gradual, not a sharp kink
This is the first chapter since Mirrors and glass in which a ray is not a straight line, and everything built on rays has to be asked what it means: what a hit is, where a reflection starts, how far a ray has gone through fog.
The air
The refractive index of the air at height y is n(y) = 1 + g y up to the height top of the hot layer, and
1 + g top above it. A ray is a curve r(s) of arc length s with direction d = dr/ds, and Fermat's principle gives its
equation: d(n d)/ds = grad n. With the gradient in y alone,
dd/ds = (grad n - (d . grad n) d) / n, grad n = (0, g, 0) in the layer and 0 outside it
so a ray turns toward +y at a rate proportional to g cos(theta) / n, where theta is its angle above the horizontal.
In this air the ray has a closed form, and the closed form is what the tests are written against. Along any ray
n cos(theta) is the same number C (Snell's law, for a medium that changes only with y). With Y = y + 1/g the index is
n = g Y, and the ray is a catenary in its vertical plane:
Y(u) = (C / g) cosh(g (u - u_m) / C)
with u the distance along the ray's horizontal direction and u_m where it is lowest. The lowest it gets is where n = C, so
a ray that leaves height y0 at angle alpha below the horizontal reaches the ground exactly when n(y0) cos(alpha) <= 1.
A ray that does not is turned back; the pictures below are made of the rays on either side of that angle.
How the library follows a ray
The library does not use the closed form. It integrates the equation with the classical fourth-order Runge-Kutta step on the
state [x, y, z, dx, dy, dz], so that any profile n(y) could be used later, and cuts the ray into stretches. A stretch is the
chord from where the ray is to where it will be after step of arc length, and that chord, a straight segment, is the ray that
is intersected with the world. The first segment that meets something gives the hit; shading continues from there with the
segment as the ray, so a reflected or refracted ray starts from the hit and bends in its turn. (Shadow rays go straight to the light.)
Three details were needed for it to be right, each found by a test:
- Outside the layer a ray is straight. A Runge-Kutta step that starts above the layer samples the gradient at points inside it and bends the ray, so outside the layer a step is a plain move, to the layer, or for ever. (In the first version, which stepped through the still air as it stepped through the layer, a ray that came down at 0.08 radian into a layer 0.8 meters deep left it 3.3 meters early, at 0.0668 radian, not 0.08.)
- A stretch that crosses the top of the layer is cut where it reaches it. The gradient changes from
gto 0 there, and a step taken across the change bends the ray by the wrong amount (by as much asgtimes the step). Cut at the boundary (by bisection on the length of the step) a ray comes down into the layer, bounces and leaves it at the exact place to 2e-9 and at the exact angle. - Fog adds up along the path. The optical depth of Air: fog, mist and mirages is summed over the segments, which is exact for a uniform fog (the sum of the lengths) and checked against the closed form of the catenary's arc length.
make a function called mirage_index takes m, y returns n
let h = y
if h < 0 then
let h = 0
end
if h > m[1] then
let h = m[1]
end
return 1 + m[0] * h
end
make a function called mirage_gradient takes m, y returns gy
if y >= 0 and y < m[1] then
return m[0]
end
return 0
end
# d/ds of the state s = [x, y, z, dx, dy, dz]
make a function called mirage_derivative takes m, s returns ds
let gy = mirage_gradient(m, s[1])
let n = mirage_index(m, s[1])
let dg = s[4] * gy
return [s[3], s[4], s[5], (0 - dg * s[3]) / n, (gy - dg * s[4]) / n, (0 - dg * s[5]) / n]
end
make a function called mirage_axpy takes s, k, a returns s2
return [s[0] + a * k[0], s[1] + a * k[1], s[2] + a * k[2], s[3] + a * k[3], s[4] + a * k[4], s[5] + a * k[5]]
end
# the state after following the ray for length h: one Runge-Kutta step, the direction made a unit vector again
make a function called mirage_step takes m, s, h returns s2
let k1 = mirage_derivative(m, s)
let k2 = mirage_derivative(m, mirage_axpy(s, k1, h / 2))
let k3 = mirage_derivative(m, mirage_axpy(s, k2, h / 2))
let k4 = mirage_derivative(m, mirage_axpy(s, k3, h))
let out = []
let i = 0
while i < 6 do
let out = list_push(out, s[i] + h / 6 * (k1[i] + 2 * k2[i] + 2 * k3[i] + k4[i]))
let i = i + 1
end
let len = sqrt(out[3] * out[3] + out[4] * out[4] + out[5] * out[5])
return [out[0], out[1], out[2], out[3] / len, out[4] / len, out[5] / len]
end
# how long a stretch of the ray from the state s is taken as straight: `step` inside the layer, and outside it (where the air is
# the same everywhere and the ray is straight) all the way to the layer, or for ever
make a function called mirage_stretch takes m, s returns len
let eps = 0.000000001
let inf = infinity()
if s[1] >= m[1] - eps and s[4] > 0 then
return inf
end
if s[1] > m[1] + eps then
if s[4] >= 0 then
return inf
end
return (s[1] - m[1]) / (0 - s[4]) + eps
end
if s[1] < 0 - eps then
if s[4] <= 0 then
return inf
end
return (0 - s[1]) / s[4] + eps
end
return m[2]
end
# the next stretch of a ray from the state s: [the straight segment to use, its length, the state at its end (false if it never ends)]. Inside the
# layer the segment is the chord from where the ray is to where it will be after `step` of its length, which is nearer the path than
# the tangent would be
make a function called mirage_segment takes m, s returns seg
let len = mirage_stretch(m, s)
if len == infinity() then
return [ray(point(s[0], s[1], s[2]), vector(s[3], s[4], s[5])), len, false]
end
let t = mirage_step(m, s, len)
# outside the layer the air is the same everywhere and the ray is straight: the step is a plain move (a Runge-Kutta step would
# sample the gradient at points inside the layer and bend it)
if s[1] > m[1] + 0.000000001 or s[1] < 0 - 0.000000001 then
let t = [s[0] + len * s[3], s[1] + len * s[4], s[2] + len * s[5], s[3], s[4], s[5]]
end
# a stretch that crosses the top of the layer is cut where it reaches it (the gradient changes there, from g to 0, and a
# step taken across the change would bend the ray by about g times the step too much or too little)
if (s[1] < m[1]) != (t[1] < m[1]) and s[1] <= m[1] + 0.000000001 and s[1] >= 0 - 0.000000001 and abs(s[1] - m[1]) > 0.000000001 then
let lo = 0
let hi = len
let k = 0
while k < 60 do
let mid = (lo + hi) / 2
if (mirage_step(m, s, mid)[1] < m[1]) == (s[1] < m[1]) then
let lo = mid
else
let hi = mid
end
let k = k + 1
end
let len = hi
let t = mirage_step(m, s, len)
end
let dx = t[0] - s[0]
let dy = t[1] - s[1]
let dz = t[2] - s[2]
let chord = sqrt(dx * dx + dy * dy + dz * dz)
return [ray(point(s[0], s[1], s[2]), vector(dx / chord, dy / chord, dz / chord)), chord, t]
end
# the first thing a ray meets as it curves: [the straight segment that meets it, the intersections of that segment, the hit,
# the path length from the start to the hit], or false if it meets nothing within the range
make a function called mirage_first_hit takes w, r, m returns found
let v = r[1]
let mag = sqrt(get_x(v) * get_x(v) + get_y(v) * get_y(v) + get_z(v) * get_z(v))
let s = [get_x(r[0]), get_y(r[0]), get_z(r[0]), get_x(v) / mag, get_y(v) / mag, get_z(v) / mag]
let travelled = 0
let inf = infinity()
while travelled < m[3] do
let piece = mirage_segment(m, s)
let seg = piece[0]
let xs = intersect_world(w, seg)
let h = hit(xs)
if h.length > 0 and h[0] <= piece[1] then
return [seg, xs, h, travelled + h[0]]
end
if piece[1] == inf then
return false
end
let s = piece[2]
let travelled = travelled + piece[1]
end
return false
end
make a function called mirage_hit_point takes f returns p
return position(f[0], f[2][0])
end
# the colour seen along a ray that curves (fog, if there is any, is the sum of the optical depths of the segments)
make a function called mirage_color_at takes w, r, remaining, m returns c
let atm = world_atmosphere(w)
let v = r[1]
let mag = sqrt(get_x(v) * get_x(v) + get_y(v) * get_y(v) + get_z(v) * get_z(v))
let s = [get_x(r[0]), get_y(r[0]), get_z(r[0]), get_x(v) / mag, get_y(v) / mag, get_z(v) / mag]
let travelled = 0
let tau = 0
let inf = infinity()
while travelled < m[3] do
let piece = mirage_segment(m, s)
let len = piece[1]
let seg = piece[0]
let xs = intersect_world(w, seg)
let h = hit(xs)
if h.length > 0 and h[0] <= len then
let seen = shade_hit(w, prepare_computations(h, seg, xs), remaining)
if atm != false then
let tau = tau + atmosphere_depth(atm[0], atm[1], s[1], s[4], h[0])
return atmosphere_veil(atm, seen, tau)
end
return seen
end
if len == inf then
let travelled = m[3]
else
if atm != false then
let tau = tau + atmosphere_depth(atm[0], atm[1], s[1], s[4], len)
end
let s = piece[2]
let travelled = travelled + len
end
end
if atm != false then
return atmosphere_veil(atm, color(0, 0, 0), inf)
end
return color(0, 0, 0)
end
In a scene, a statement sets it:
mirage gradient 0.008 height 0.8 step 0.2 range 300
gradient is g; height, step and range are the height of the layer (default 50), the length of a stretch (default 1/2) and how far a
ray is followed (default 200). Without the statement the air is clear and every picture is as it was.
Scenarios and oracles
All of these are against the closed form of the ray, or the formula written out, and none of them uses code from the library:
- The air. The index is 1 at the ground and
1 + g yin the layer, constant above; the gradient isginside the layer and 0 outside it. - The path. A ray followed for 100 units in steps of 1/4 stays on the catenary: the worst distance from it over 400 steps is 1.5e-11. Its lowest
point is at
y = (n0 cos(alpha) - 1) / g, and its direction stays a unit vector. - Where it meets the ground. A ray from height 1.5 meets the ground exactly when
n0 cos(alpha) <= 1, for eight angles on both sides of the threshold (0.1721 radian), and meets it where the catenary hasY = 1/g, to 0.001. A gradient 5% stronger meets it somewhere else. - A thin layer. A ray that comes down through still air into a layer and leaves it again leaves at the exact place (2e-9) and at the same angle upward.
- No gradient, no change. With
g = 0four rays see what they saw in clear air. - Fog along a curved ray, and the statement: its defaults and its refusals.
The picture
A desert road, with pillars along it and palms further out, and a layer of hot air 0.8 meters deep (g = 0.008: the index is
1.0064 at the top of the layer, far stronger than real air, whose index changes by a few ten-thousandths over such a layer, so that the effect shows in a small picture). The camera is 1.6 meters up, and the picture covers 16 degrees
down from the horizon.
# A desert road in the heat: air that is thin at the bottom and thick above, so that a ray that travels down at a
# shallow angle bends up before it reaches the ground. Beyond about 15 meters the ground cannot be seen: where it should
# be there is sky, with the palms and pillars standing in it upside down.
param w = 320
param h = 160
param g = 0.008
param layer = 0.8
param aa = 1
param fov = 55
param ty = 1.45
size w h
camera from 0 1.6 0 to 0 ty 30 fov fov
light point at -60 120 -30
antialias aa
mirage gradient g height layer step 0.2 range 500
include "parts/species.scene"
material sand
color 1 1 1
ambient 0.35 diffuse 0.75 specular 0
pattern checkers 0.86 0.74 0.5 0.8 0.66 0.44 scale 2.5 at 0 1 0
end
material sky
color 1 1 1
ambient 1 diffuse 0 specular 0
pattern gradient 0.82 0.88 0.95 0.2 0.42 0.82 rotate z 90 scale 300
end
material stone
color 0.85 0.8 0.7
ambient 0.25 diffuse 0.8 specular 0.05
end
material road
color 0.18 0.18 0.2
ambient 0.25 diffuse 0.8 specular 0.1 shininess 20
end
plane material sand
# the sky: a sphere seen from the inside
sphere scale 500 material sky
# a road running away
cube scale 1.6 0.01 400 at 0 0.005 200 material road
# pillars along the road, and palms further out
for i in 1 to 6
cylinder 0 3 closed scale 0.4 1 0.4 at (-4) 0 (i * 14) material stone
cylinder 0 3 closed scale 0.4 1 0.4 at 4 0 (i * 14 + 7) material stone
end
use palm(5, 0.2, 6, 4) at -12 0 60
use palm(6, 0.22, 6, 9) at 14 0 90
use palm(5.5, 0.2, 6, 2) at 3 0 140
The ground beyond a distance of about 14 meters cannot be seen: the rays that would reach it are turned up into the sky. What is seen where it should be is the sky, with the pillars and the palm upside down, their tops lowest. A ray that is only a little shallower than the critical one leaves the layer climbing steeply, a shallower one less, so the order of the image is turned over.
Checking it independently
The independent tracer of the the pages it builds on follows the same rays, but not with the library's method. It reads the air from an M line, and does not integrate:
it follows the exact catenary (the formulas above, with cosh and its inverse), in stretches of the same arc length, ending a stretch where the
ray leaves the layer, and intersects each chord with its own shape intersections.
> v2_interp.exe tools/export_scene.patlang --scene file --file scenes/mirage_check.scene --out out/mirage_check.txt
wrote out/mirage_check.txt (6 shapes)
> powershell.exe -NoProfile -File tools/verify_recursive.ps1 out/mirage_check.png -SceneFile out/mirage_check.txt -Stride 1
decoded by .NET: 80x40; pixels differing from the independent recursive tracer by more than 1 level: 0 (max difference 0); stride 1 in each direction, 3200 pixels checked
Negative controls: the gradient changed from 0.008 to 0.0084 in the text the checker reads, and the M line removed (straight rays):
sed 's/^M 0.008 /M 0.0084 /' out/mirage_check.txt > out/mirage_check_wrong.txt
sed '/^M /d' out/mirage_check.txt > out/mirage_check_straight.txt
> powershell.exe -NoProfile -File tools/verify_recursive.ps1 out/mirage_check.png -SceneFile out/mirage_check_wrong.txt -Stride 1
decoded by .NET: 80x40; pixels differing from the independent recursive tracer by more than 1 level: 101 (max difference 160); stride 1 in each direction, 3200 pixels checked
> powershell.exe -NoProfile -File tools/verify_recursive.ps1 out/mirage_check.png -SceneFile out/mirage_check_straight.txt -Stride 1
decoded by .NET: 80x40; pixels differing from the independent recursive tracer by more than 1 level: 2013 (max difference 203); stride 1 in each direction, 3200 pixels checked
Two things the first comparison found, which the closed-form tests of the path did not: a three-dimensional checker pattern on the floor changes
colour at the floor's own height y = 0, where the two tracers' hit points differ by 1e-16 and fall on different sides, so the floor's pattern is
shifted a little (at 0 1 0); and the library's step across the top of the layer, above.
What it does not do
Shadow rays are straight. A light is not seen to move in a mirage, and a shadow on the ground is cast along a straight line to the light, which for a
light far above the layer is right to within the thickness of the layer. The air is the same everywhere along the ground: its profile depends on the
height alone, so there is no shimmer, and a ray is followed in stretches and not integrated to a hit, so a very thin object at a
great distance can fall between the stretches. A ray is followed as far as range.
How it is checked
> v2_interp.exe tests/run.patlang --node picture/air --depth 2
[ ok ] Fog and mist
[ ok ] Optical depth
[ ok ] The optical depth of 60 finite rays (uniform fog and two mists, up, down and level) ...
[ ok ] The blend
[ ok ] Atmosphere_blend: colour * T + fog * (1 - T), T = e^-0.8 at a distance of 8
[ ok ] A ray at a sphere 9 away in fog of density 0.05: colour * e^-0.45 + fog * (1 - e^-0.45)
[ ok ] A mirror: the reflected ray is dimmed for its own length as well
[ ok ] The scene language
[ ok ] Fog density 0.05 falloff 0.3 color 0.6 0.7 0.8 is the atmosphere [0.05, 0.3, the colour]
[ ok ] Mirages
[ ok ] The air
[ ok ] The path of a ray
[ ok ] Where a ray meets the ground
[ ok ] A thin layer
[ ok ] No gradient, no change
[ ok ] Fog along a curved ray, and the statement
checks: 11 passed, 0 failed, 0 blocked, 0 skipped, 0 not run
ALL PASSED
Graduate Attributes
Modelled on this page
- Researcher: Independent tracers verify results using different numerical methods to confirm the correctness of the primary implementation.
- Critical Thinker: Limitations such as straight shadow rays and missing shimmer effects are stated explicitly alongside the model's capabilities.
- Digitally Fluent: Digital tools are configured with specific parameters to simulate physical phenomena like optical depth and refractive index gradients.
University of Reading Graduate Attributes framework.