A Fast Approximate Anti-Aliasing effect. More...
Public Member Functions | |
FxaaEffect (System *system) noexcept | |
virtual | ~FxaaEffect () |
nkGraphics::Texture * | getSourceTexture () const |
float | getMinContrast () const |
float | getMinLuminance () const |
float | getSmoothingStrength () const |
FXAA_PRESET | getPreset () const |
bool | getLuminanceAsGreenChannelOnly () const |
void | setSourceTexture (nkGraphics::Texture *value) |
void | setMinContrast (float value) |
void | setMinLuminance (float value) |
void | setSmoothingStrength (float value) |
void | setPreset (FXAA_PRESET value) |
void | setLuminanceAsGreenChannelOnly (bool value) |
virtual bool | load () override |
virtual void | unload () override |
Public Member Functions inherited from nkAstraeus::Effect | |
Effect (EFFECT_TYPE type) noexcept | |
virtual | ~Effect () |
nkMemory::StringView | getName () const |
nkGraphics::Shader * | getShader () const |
EFFECT_TYPE | getType () const |
void | setName (nkMemory::StringView value) |
Static Public Member Functions | |
static nkMemory::UniquePtr< FxaaEffect > | create (System *system=nullptr) |
A Fast Approximate Anti-Aliasing effect.
This effect offers anti-aliasing capabilities using the fast approximate algorithm. It works on the final image to detect edges and smooth them up if they are too harsh. It is a good anti-aliasing solution in general cases thanks to its limited impact on performances. However, as it works on the final image rather than geometry information, it can also smooth up textures, sometimes making blurrier images or losing details. To search for a balance between quality and performances, some parameters are offered within the API.
|
noexcept |
Default constructor. Alternatively, see FxaaEffect::create(), or EffectManager::createOrRetrieve().
system | The system the resource should live in. |
|
virtual |
Destructor.
nkGraphics::Texture* nkAstraeus::FxaaEffect::getSourceTexture | ( | ) | const |
float nkAstraeus::FxaaEffect::getMinContrast | ( | ) | const |
float nkAstraeus::FxaaEffect::getMinLuminance | ( | ) | const |
float nkAstraeus::FxaaEffect::getSmoothingStrength | ( | ) | const |
FXAA_PRESET nkAstraeus::FxaaEffect::getPreset | ( | ) | const |
bool nkAstraeus::FxaaEffect::getLuminanceAsGreenChannelOnly | ( | ) | const |
void nkAstraeus::FxaaEffect::setSourceTexture | ( | nkGraphics::Texture * | value | ) |
Sets the texture to use as an input of the effect. For best results, this texture needs to be in non-linear space, meaning that it should be either gamma corrected (see nkGraphics::Texture::setGammaCorrected()) or already corrected upfront. FXAA supposed to work on the final image, it can also be best to apply all tone mapping or post processing operations before applying this effect, depending on the result wanted.
value | The texture to filter. |
void nkAstraeus::FxaaEffect::setMinContrast | ( | float | value | ) |
Sets the minimal contrast required to trigger the filter on a pixel. Contrast corresponds to the difference in intensity of a pixel with its surrounding. Having a higher value for this parameter means that the algorithm will filter less pixels, requiring a bigger local difference before triggering the filtering operation. However, lower values mean the filter will be triggered for less pixels, improving performances. Defaults to 0.57.
value | The wanted value, between [0.f, 1.f]. |
void nkAstraeus::FxaaEffect::setMinLuminance | ( | float | value | ) |
Sets the minimal luminance (how light a pixel is) required before the filter being applied. Typically, darker environments' aliasing is less noticeable. Higher values mean the filter will trigger less often, requiring a lighter environment before triggering. Lower values will make the algorithm trigger more often, as even darker environment will get processed. This parameter can be used to control the impact on performances (lower = more quality, higher = quicker). Defaults to 0.54.
value | The wanted value, between [0.f, 1.f]. |
void nkAstraeus::FxaaEffect::setSmoothingStrength | ( | float | value | ) |
Sets the strength of the smoothing operation. For lower values, the algorithm will output harsher edges. Higher values mean that the algorithm will try to better smooth the end result. Defaults to 0.75.
value | The wanted value, between [0.f, 1.f]. |
void nkAstraeus::FxaaEffect::setPreset | ( | FXAA_PRESET | value | ) |
Sets the preset to use as a basis of the algorithm. Defaults to FXAA_PRESET::DITHER_MEDIUM_RADIUS_5 as a general good compromise between quality and performances.
value | The preset wanted. |
void nkAstraeus::FxaaEffect::setLuminanceAsGreenChannelOnly | ( | bool | value | ) |
Sets whether the luminance computing should only consider the green channel of a color, or not. Enabling it means that computing the luminance required for the algorithm is as simple as returning the green channel. With it off, all three channels of a color will participate in the luminance computing, using a dot product. By default, this parameter is off (use 3 channels).
value | Whether only the green channel (true) or all rgb channels (false) should be used when computing the luminance values. |
|
overridevirtual |
Loads the effect and make it ready for rendering.
Implements nkAstraeus::Effect.
|
overridevirtual |
Unloads the effect and its internal memory. After that, the effect is unusable for rendering.
Implements nkAstraeus::Effect.
|
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. |