A Depth of Field effect. More...
Static Public Member Functions | |
static nkMemory::UniquePtr< DofComplexEffect > | create (System *system=nullptr) |
A Depth of Field effect.
This effect will mimick the depth of field of a camera, and blur everything that is not in the focal plane. It is typically used to give a good sense of depth to an image, and can sometimes fool perception. For instance, a very narrow focal area (near and far close to each other) will make everything feel small, like small toys. It can also make obvious the parts that should attract attention, by focusing on the important objects in a given scene and blurring all its surrounding.
This effect works in a very straightforward way, by mapping world unit distances to the various planes defined. The near and far blur define zones where the pixels are fully blurred, respectively when too close or too far from the camera. The focal plane defines pixels that are in focus and thus, sharp, at the ideal distance from the camera. Anything in between will be interpolated between the blurry and sharp versions, depending on their distance from the focal plane boundaries.
|
noexcept |
Default constructor. Alternatively, see DofComplexEffect::create(), or ComplexEffectManager::createOrRetrieve().
system | The system the resource should live in. |
|
virtual |
Default destructor.
nkGraphics::Texture* nkAstraeus::DofComplexEffect::getSourceTexture | ( | ) | const |
nkGraphics::Texture* nkAstraeus::DofComplexEffect::getSourceDepth | ( | ) | const |
nkGraphics::Texture* nkAstraeus::DofComplexEffect::getOutputTexture | ( | ) | const |
nkGraphics::Camera* nkAstraeus::DofComplexEffect::getCamera | ( | ) | const |
float nkAstraeus::DofComplexEffect::getNearPlaneDistance | ( | ) | const |
float nkAstraeus::DofComplexEffect::getFocalPlaneDistance | ( | ) | const |
float nkAstraeus::DofComplexEffect::getFocalPlaneThickness | ( | ) | const |
float nkAstraeus::DofComplexEffect::getFarPlaneDistance | ( | ) | const |
unsigned int nkAstraeus::DofComplexEffect::getBlurStrength | ( | ) | const |
bool nkAstraeus::DofComplexEffect::getLinearDepth | ( | ) | const |
void nkAstraeus::DofComplexEffect::setSourceTexture | ( | nkGraphics::Texture * | value | ) |
Sets the texture to use as input to the effect.
value | The texture to use as input. |
void nkAstraeus::DofComplexEffect::setSourceDepth | ( | nkGraphics::Texture * | value | ) |
Sets the depth texture to use as input to the effect.
value | The depth texture to use as input. |
void nkAstraeus::DofComplexEffect::setCamera | ( | nkGraphics::Camera * | value | ) |
Sets the camera used to retrieve the projection parameters from. Defaults to nullptr, retrieving the camera information from the active context's camera.
value | The camera to use to get the projection information. |
void nkAstraeus::DofComplexEffect::setNearPlaneDistance | ( | float | value | ) |
Sets the near plane distane, in world units, from the camera. All pixels closer than this distance will get fully blurred. Between the focal plane and the near plane, pixels will gradually get blurrier as they approach the near plane.
value | The near distance, in world units. |
void nkAstraeus::DofComplexEffect::setFocalPlaneDistance | ( | float | value | ) |
Sets the focal plane distane, in world units, from the camera. This distance is the one for which the pixels will be in focus and thus sharp. As pixels get closer to the near or far plane, they will get blurrier.
value | The focal distance, in world units. |
void nkAstraeus::DofComplexEffect::setFocalPlaneThickness | ( | float | value | ) |
Sets the focal plane thickness, in world units. The focal plane defines pixels that are in focus. The plane thickness defines how tolerant the focal plane is, allowing pixels found at a distance from the focal plane smaller than half its thickness to be in focus.
value | The plane thickness, in world units. |
void nkAstraeus::DofComplexEffect::setFarPlaneDistance | ( | float | value | ) |
Sets the far plane distane, in world unit, from the camera. All pixels further away than this distance will get fully blurred. Between the focal plane and the far plane, pixels will gradually get blurrier as they approach the far plane.
value | The far distance, in world unit. |
void nkAstraeus::DofComplexEffect::setBlurStrength | ( | unsigned int | value | ) |
Sets the blurring strength when reaching either the near or far plane. This can be interpreted as the the final blurring radius. Defaults to 3.
value | The blurring strength to apply. |
void nkAstraeus::DofComplexEffect::setLinearDepth | ( | bool | value | ) |
Sets whether the depth information texture should be considered linear, or not. Linear depth information will be between [0, 1] and simply be mapped to the camera's settings (near + depth * (far - near)). If not linear, then the camera's projection parameter will be used to reconstruct linear depth before deducing the depth in world units. Defaults to false.
value | Whether depth data should be considered as already linear (true) or not (false). |
|
overridevirtual |
Loads the effect and make it ready for rendering. After a successful call, this means the compositor node will be populated with the relevant data.
Implements nkAstraeus::ComplexEffect.
|
overridevirtual |
Unloads the effect and its internal memory. After that, the effect is unusable for rendering. The compositor node specified will be cleaned from all linked operations.
Implements nkAstraeus::ComplexEffect.
|
static |
Creates an instance of the class, and returns ownership over it.
system | The system the resource should live in. If left to nullptr, will seek the singleton instance of the system. |