The graphics device.
The camera frame the effect is registered with, or null.
How much the brightness of the center of the screen counts over its edges, 0-1 range. 0 meters the whole screen equally, 1 mostly its center. Defaults to 0.5.
The exposure compensation in EV: how much brighter than middle grey the average of the screen is displayed. Positive values brighten the image, negative values darken it, each step doubling or halving it. Defaults to 0.
The graphics device.
Whether the effect is enabled. An effect can additionally disable itself from its own parameters, see CameraFrameEffect#active.
The fraction of the screen, 0-1, below which the average is taken, the brightest part above it left out, such as the sun and bright highlights. Defaults to 0.9.
The fraction of the screen, 0-1, which is left out of the average as the darkest part of it, such as deep shadows. Higher values meter the brighter parts of the screen, darkening the image. Defaults to 0.1.
The highest exposure the effect adapts to, in EV relative to the exposure of the camera: 2 lets it brighten the image four times, for dark scenes. Defaults to 6.
The lowest exposure the effect adapts to, in EV relative to the exposure of the camera: -2 lets it darken the image to a quarter of its brightness, for bright scenes. Defaults to -6.
How fast the exposure adapts when the scene gets brighter, as from a dark interior into the daylight. Higher values adapt faster - the exposure covers about two thirds of the change in 1 / speedDarkToLight seconds. Defaults to 3.
How fast the exposure adapts when the scene gets darker, as from the daylight into a dark interior. Higher values adapt faster - the exposure covers about two thirds of the change in 1 / speedLightToDark seconds. The eye adapts to the dark more slowly than to the light. Defaults to 1.
Gets whether the effect contributes to the frame: while enabled, and while the composition applies tone mapping, as without it no exposure is applied.
Gets the scale the adaptation applies to the exposure of the camera this frame, 2 raised to the adaptation in EV.
Gets the name the compose chunk can be overridden under in ShaderChunks, the same
way as the built-in chunks. Derived from the id as compose<Id>PS unless given.
Gets the names of the debug views the chunk provides.
Gets the define set on the compose shader while the effect is active: the id in upper snake
case, colorEnhance giving COLOR_ENHANCE.
Gets the name of the function the composition calls at the effect's slot. Derived from the
id as apply<Id> unless given. The signature depends on the slot: colour slots take
(vec3 color, vec2 uv) and return the colour, COMPOSESLOT_SCENE takes and returns a
vec4.
Gets the exposure the camera renders with this frame: the exposure of the scene, or of the physical camera with physical units, scaled by the adaptation.
Gets the GLSL source of the compose chunk, or null when the effect has none.
Gets the latest histogram of the brightness of the screen read back, the weight of each of its 64 bins, from the darkest to the brightest. The bins span the brightness the limits of the exposure display as middle grey, and 4 EV beyond on either side; brightness outside of that counts in the bin at the end. The array is updated in place as histograms arrive.
Gets the identifier of the effect.
Gets the frame resources the effect needs, the FRAMERESOURCE_* constants - for its passes, or for its compose chunk, such as the scene depth. The camera frame provides them while the effect is active. Requirements which depend on the device are computed when constructing the effect; override this as a getter when they depend on a parameter, and the camera frame provides what it returns from the next CameraFrame#update.
Gets the compose slot the entry function is called at, or null for an effect that does not take part in the composition.
Gets the WGSL source of the compose chunk, or null when the effect has none.
Destroys the effect, removing it from its camera frame if it is still registered and
releasing everything it owns, the passes it created included. Subclasses which create
resources in their constructor release them in an override, calling super.destroy(). The
removal takes effect for the frames rendered after the next CameraFrame#update, which
is due before the next frame renders.
The values of this frame.
Returns the compose chunk source for a shader language.
SHADERLANGUAGE_GLSL or SHADERLANGUAGE_WGSL.
The source, or null when the effect has no chunk.
Adapts the exposure to the next measurement at once, rather than gradually - for a cut to a different view, after which a gradual adaptation would look out of place.
Sets a define on the compose shader. The define persists until changed, so fixed defines can be set once in the constructor and those depending on the parameters from CameraFrameEffect#update. A value of false, null or undefined removes it. Changing a define rebuilds the compose shader.
The define name.
The value.
Sets the value of a uniform the effect's shader chunk reads. Like a material parameter, the value is stored by reference, so an array or a texture can be updated in place. Set the values in CameraFrameEffect#update, or in CameraFrameEffect#frameUpdate for a value which changes every frame.
The name of the uniform, as declared in the chunk.
The value.
Applies the effect's parameters. Called by CameraFrame#update while the effect is active: set the uniform values with CameraFrameEffect#setUniform here, and the defines which depend on the parameters. Everything it sets is what the frames rendered until the next update use.
The auto exposure effect, which adapts the exposure of the camera to the brightness of what it sees, like the eye adapting to the dark or to the daylight. Every frame, it measures a histogram of the brightness of the screen and averages the part of it between two fractions of the screen, leaving out the darkest and the brightest parts, such as deep shadows and the sun. It then changes the exposure gradually towards the one which displays that average as middle grey.
The exposure it adapts is the one the camera renders with: the exposure of the scene, or the exposure of the physical camera with physical units, which it scales by up to AutoExposureEffect#minEv and AutoExposureEffect#maxEv stops. Every part of the frame which uses the exposure follows it, the tone mapping of the composition and the anti-aliasing among them. It has no effect without tone mapping, as the composition then applies no exposure.
The histogram is read back to the CPU, so the exposure follows the screen a frame or two late, which the gradual adaptation hides. It is not registered by default - add it to a CameraFrame: