2,733
edits
m (Add 3rd offset "landing-light3-offset-deg" to ALS secondary lights (landing lights)) |
Red Leader (talk | contribs) m (→Rain: Formatting) |
||
Line 354: | Line 354: | ||
=== Rain === | === Rain === | ||
Rain splashes will render automatically when the weather system reports rain via environment/rain-norm. In addition, the user can set rain splashes to render via <code>environment/aircraft-effects/ground-splash-norm</code> (this is intended to allow splashes to be rendered e.g., for water landings of aircraft equipped with floats). | |||
By default, the rain splashes impact from above (more precisely the +z direction in model coordinates). This may be inadequate if the aircraft is moving. However, the shader can not know what the airstream at the glass will be, so the impact vector of rain splashes has to be modeled aircraft-side and set via <code>environment/aircraft-effects/splash-vector-x</code> (<code>splash-vector-y</code>, <code>splash-vector-z</code>). These are likewise in model coordinates. | |||
As long as the length of the splash vector is less than 1, just the impact angle will change, as the length of the vector increases to 2, droplets will also be visibly moving. This allows fine control of the visuals dependent on any number of factors desired. A simple Nasal snipped varying the splash vector with airspeed for the F-16 is given below (but ''do not mindlessly copy and expect to work for any aircraft — it won't!'') | |||
<syntaxhighlight lang="nasal"> | |||
var splash_vec_loop = func(){ | |||
var airspeed = getprop("/velocities/airspeed-kt"); | |||
# f16 | |||
var | var airspeed_max = 120; | ||
if (airspeed > airspeed_max) { | |||
airspeed = airspeed_max; | |||
} | |||
airspeed = math.sqrt(airspeed / airspeed_max); | |||
var splash_x = -0.1 - 2 * airspeed; | |||
var splash_y = 0.0; | |||
var splash_z = 1.0 - 1.35 * airspeed; | |||
setprop("/environment/aircraft-effects/splash-vector-x", splash_x); | |||
setprop("/environment/aircraft-effects/splash-vector-y", splash_y); | |||
setprop("/environment/aircraft-effects/splash-vector-z", splash_z); | |||
settimer(func(){ | |||
splash_vec_loop(); | |||
}, 1); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Note the timing constant of the loop | Note the timing constant of the loop — running the update per-frame leads to a spurious movement of the coordinate system in which rain is rendered and spoils the effect. | ||
=== Frost and fogging === | === Frost and fogging === |