47 lines
1.9 KiB
Plaintext
47 lines
1.9 KiB
Plaintext
#! Contains exposure: how a camera is set for a scene's light, as an exposure
|
||
#! value at ISO 100, of its settings or of what its meter reads; and what light
|
||
#! is multiplied by, so exposed, as a renderer records it.
|
||
#!
|
||
#! Exposed by a meter, a matte white surface lit as the meter read records as
|
||
#! about two thirds of the most, and an 18% grey card about an eighth, which an
|
||
#! sRGB display shows as middle grey.
|
||
|
||
import std::math;
|
||
module photometry;
|
||
|
||
#! The exposure value at ISO 100 of a camera's settings: its aperture's
|
||
#! f-number, its shutter's time open, in seconds, and its sensitivity, as ISO.
|
||
#! It's log₂(N²/t), a step less each time the ISO doubles past 100, so f/16 at a
|
||
#! hundredth of a second is about 15, a sunny day's, as the sunny 16 rule has
|
||
#! it.
|
||
pub def ev100_of_camera(aperture: f32, shutter: f32, iso: f32 = 100): f32 {
|
||
return math::log2(aperture * aperture / shutter) - math::log2(iso / 100);
|
||
}
|
||
|
||
#! The exposure value at ISO 100 a camera's own meter sets for a scene of an
|
||
#! average luminance, in nits, calibrated as such meters are, by 12.5:
|
||
#! log₂(nits × 100 / 12.5).
|
||
pub def ev100_of_nits(luminance: f32): f32 {
|
||
return math::log2(luminance * 8);
|
||
}
|
||
|
||
#! The exposure value at ISO 100 a meter held where a scene is lit sets for it,
|
||
#! of the lux it reads, calibrated as such meters are, by 250:
|
||
#! log₂(lux × 100 / 250). Direct sunlight's is about 15.3, an office's 7.3.
|
||
pub def ev100_of_lux(illuminance: f32): f32 {
|
||
return math::log2(illuminance * 0.4);
|
||
}
|
||
|
||
#! What light, in nits, is multiplied by, recorded by a camera at an exposure
|
||
#! value at ISO 100: the most it records, 1, over the luminance that fills its
|
||
#! sensor, 1.2 × 2^EV100 nits.
|
||
pub def exposure_of_ev100(ev100: f32): f32 {
|
||
return 1 / (1.2 * math::exp2(ev100));
|
||
}
|
||
|
||
#! The exposure value at ISO 100 at which light is multiplied by so much, as
|
||
#! `exposure_of_ev100` gives it.
|
||
pub def ev100_of_exposure(exposure: f32): f32 {
|
||
return -math::log2(1.2 * exposure);
|
||
}
|