Class Gorgon2DChromaticAberrationEffect
An effect that simulates lens imperfection.
Inherited Members
Namespace: Gorgon.Renderers
Assembly: Gorgon.Renderers.Gorgon2D.dll
Syntax
public class Gorgon2DChromaticAberrationEffect : Gorgon2DEffect, IGorgonNamedObject, IDisposable, IGorgonGraphicsObject, IGorgon2DCompositorEffect
Remarks
A chromatic aberration is the failure of a lens to focus all wavelengths of light to the same point. This results in a prism-like effect around the edges of an image.
This implementation of chromatic aberration simulates the effect around the corners of the screen to give the appearance of an actual lens, but when setting its FullScreen property to true, the effect is applied evenly across the screen (and is also cheaper for performance).
If you wish to modify the color spectrum used, setting a new GorgonTexture1DView on the LookupTexture property will let the effect use your custom texture when processing the image.
This effect is based on the presentation by Mikkel Gjoel (https://github.com/playdeadgames/publications/tree/master/INSIDE) and the code of Erik Faye Lund (@kusma) (https://github.com/kusma/vlee/blob/master/data/postprocess.fx).
Constructors
| Edit this page View SourceGorgon2DChromaticAberrationEffect(Gorgon2D)
Initializes a new instance of the Gorgon2DChromaticAberrationEffect class.
Declaration
public Gorgon2DChromaticAberrationEffect(Gorgon2D renderer)
Parameters
Type | Name | Description |
---|---|---|
Gorgon2D | renderer | The 2D renderer used to render the effect. |
See Also
Properties
| Edit this page View SourceFullScreen
Property to return whether or not the effect should cover the render target, or only be used around the corners.
Declaration
public bool FullScreen { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
Setting this value to true will utilize the entire render target when applying the effect, not just the corners. This will increase the performance of the effect because this method is
much more simple than the corner aberration state (FullScreen=
false).
See Also
| Edit this page View SourceIntensity
Property to set or return the intensity of the effect.
Declaration
public float Intensity { get; set; }
Property Value
Type | Description |
---|---|
float |
Remarks
For best results, set this to a value between 0 and 1. Larger values give more exaggerated effects, which may or may not be desirable depending on your needs.
See Also
| Edit this page View SourceLookupTexture
Property to set or return the texture for look up.
Declaration
public GorgonTexture1DView LookupTexture { get; set; }
Property Value
Type | Description |
---|---|
GorgonTexture1DView |
Remarks
If this property is set to null, then an internal default look up will be used.
See Also
Methods
| Edit this page View SourceDispose(bool)
Releases unmanaged and - optionally - managed resources.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing |
|
Overrides
See Also
| Edit this page View SourceOnBeforeRenderPass(int, GorgonRenderTargetView, GorgonCameraCommon)
Function called prior to rendering a pass.
Declaration
protected override PassContinuationState OnBeforeRenderPass(int passIndex, GorgonRenderTargetView output, GorgonCameraCommon camera)
Parameters
Type | Name | Description |
---|---|---|
int | passIndex | The index of the pass to render. |
GorgonRenderTargetView | output | The final render target that will receive the rendering from the effect. |
GorgonCameraCommon | camera | The currently active camera. |
Returns
Type | Description |
---|---|
PassContinuationState | A PassContinuationState to instruct the effect on how to proceed. |
Overrides
Remarks
Applications can use this to set up per-pass states and other configuration settings prior to executing a single render pass.
See Also
| Edit this page View SourceOnGetBatchState(int, IGorgon2DEffectBuilders, bool)
Function called to build a new (or return an existing) 2D batch state.
Declaration
protected override Gorgon2DBatchState OnGetBatchState(int passIndex, IGorgon2DEffectBuilders builders, bool statesChanged)
Parameters
Type | Name | Description |
---|---|---|
int | passIndex | The index of the current rendering pass. |
IGorgon2DEffectBuilders | builders | The builder types that will manage the state of the effect. |
bool | statesChanged | true if the blend, raster, or depth/stencil state was changed. false if not. |
Returns
Type | Description |
---|---|
Gorgon2DBatchState | The 2D batch state. |
Overrides
See Also
| Edit this page View SourceOnInitialize()
Function called to initialize the effect.
Declaration
protected override void OnInitialize()
Overrides
Remarks
Applications must implement this method to ensure that any required resources are created, and configured for the effect.
See Also
| Edit this page View SourceRender(GorgonTexture2DView, GorgonRenderTargetView)
Function to render the specified texture with chromatic aberration into the specified output.
Declaration
public void Render(GorgonTexture2DView texture, GorgonRenderTargetView output)
Parameters
Type | Name | Description |
---|---|---|
GorgonTexture2DView | texture | The texture to apply the effect to. |
GorgonRenderTargetView | output | The render target that will received the result of the effect. |
Remarks
important
For performance reasons, any exceptions thrown by this method will only be thrown when Gorgon is compiled as DEBUG.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |