The graphics device.
Whether the SSAO effect is blurred. Defaults to true.
The camera frame the effect is registered with, or null.
The graphics device.
Whether the effect is enabled. An effect can additionally disable itself from its own parameters, see CameraFrameEffect#active.
The intensity of the SSAO effect, 0-1 range. Defaults to 0.5.
The minimum angle of the SSAO effect, 1-90 range. Defaults to 10.
The power of the SSAO effect, 0.1-10 range. Defaults to 6.
The radius of the SSAO effect, 0-100 range. Defaults to 30.
Whether the SSAO sampling is randomized. Useful when used instead of blur effect together with TAA. Defaults to false.
The number of samples of the SSAO effect, 1-64 range. Defaults to 12.
The scale of the SSAO effect, 0.5-1 range. Defaults to 1.
The type of the SSAO, which determines how it is applied in the rendering process. Defaults to SSAOTYPE_NONE, making it disabled. Can be:
Gets whether the effect contributes to the frame. SSAOTYPE_NONE disables it, the type being the effect's on/off control.
Gets the scale the effect applies to the exposure of the camera this frame, multiplying the exposure of the scene, or of the physical camera with physical units - for effects adapting the exposure to what the camera sees. Read every frame while the effect takes part, after CameraFrameEffect#frameUpdate; the camera frame applies the product of the scales of the effects taking part, and the camera renders with its own exposure again once none does. Defaults to 1.
// an effect brightening the image by one stop
get cameraExposureScale() {
return 2;
}
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 GLSL source of the compose chunk, or null when the effect has none.
Gets the identifier of the effect.
Gets the frame resources the effect needs: the scene depth, rendered by a prepass when the type is SSAOTYPE_LIGHTING, as the occlusion is then generated before the scene renders.
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.
Called every frame while the effect takes part in the frame, while the frame is being
prepared and before any pass renders, with the values of that frame. Most effects do not
need it: their configuration belongs in CameraFrameEffect#update, which runs only
when the camera frame is updated. Values derived from the resolution, which can change
without an update, are computed here from the sizes in the frame, or in the shader from
sceneTextureSize. Anything which changes over time advances here by the time of the frame,
its dt.
The values of this frame. Read them during this call only.
Returns the compose chunk source for a shader language.
SHADERLANGUAGE_GLSL or SHADERLANGUAGE_WGSL.
The source, or null when the effect has no chunk.
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 Screen Space Ambient Occlusion (SSAO) effect, a postprocessing technique that approximates ambient occlusion by calculating how exposed each point in the screen space is to ambient light, enhancing depth perception and adding subtle shadowing in crevices and between objects.
The occlusion is generated from the scene depth by a pass the effect owns. With SSAOTYPE_LIGHTING it is applied by the lit materials as the scene renders, and with SSAOTYPE_COMBINE it is applied to the rendered scene in linear HDR space, before tone mapping.
Every CameraFrame constructs and registers one, available as CameraFrame#ssao.