Gorgon
Show / Hide Table of Contents

Class Gorgon2DChromaticAberrationEffect

An effect that simulates lens imperfection.

Inheritance
object
GorgonNamedObject
Gorgon2DEffect
Gorgon2DChromaticAberrationEffect
Implements
IGorgonNamedObject
IDisposable
IGorgonGraphicsObject
IGorgon2DCompositorEffect
Inherited Members
Gorgon2DEffect.BatchStateAllocator
Gorgon2DEffect.PixelShaderAllocator
Gorgon2DEffect.VertexShaderAllocator
Gorgon2DEffect.Macros
Gorgon2DEffect.Renderer
Gorgon2DEffect.Graphics
Gorgon2DEffect.PassCount
Gorgon2DEffect.Description
Gorgon2DEffect.CompileShader<T>(string, string)
Gorgon2DEffect.OnBeforeRender(GorgonRenderTargetView, bool)
Gorgon2DEffect.OnAfterRender(GorgonRenderTargetView)
Gorgon2DEffect.OnAfterRenderPass(int, GorgonRenderTargetView)
Gorgon2DEffect.BeginRender(GorgonRenderTargetView, GorgonBlendState, GorgonDepthStencilState, GorgonRasterState)
Gorgon2DEffect.BeginPass(int, GorgonRenderTargetView, GorgonCameraCommon)
Gorgon2DEffect.EndPass(int, GorgonRenderTargetView)
Gorgon2DEffect.EndRender(GorgonRenderTargetView)
Gorgon2DEffect.Precache()
Gorgon2DEffect.Dispose()
GorgonNamedObject.GetHashCode()
GorgonNamedObject.ToString()
GorgonNamedObject.Name
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetType()
object.MemberwiseClone()
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 Source

Gorgon2DChromaticAberrationEffect(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
GorgonTexture1DView
LookupTexture
FullScreen

Properties

| Edit this page View Source

FullScreen

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
GorgonTexture1DView
LookupTexture
FullScreen
| Edit this page View Source

Intensity

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
GorgonTexture1DView
LookupTexture
FullScreen
| Edit this page View Source

LookupTexture

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
GorgonTexture1DView
LookupTexture
FullScreen

Methods

| Edit this page View Source

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

true to release both managed and unmanaged resources; false to release only unmanaged resources.

Overrides
Gorgon2DEffect.Dispose(bool)
See Also
GorgonTexture1DView
LookupTexture
FullScreen
| Edit this page View Source

OnBeforeRenderPass(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
Gorgon2DEffect.OnBeforeRenderPass(int, GorgonRenderTargetView, GorgonCameraCommon)
Remarks

Applications can use this to set up per-pass states and other configuration settings prior to executing a single render pass.

See Also
PassContinuationState
| Edit this page View Source

OnGetBatchState(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
Gorgon2DEffect.OnGetBatchState(int, IGorgon2DEffectBuilders, bool)
See Also
GorgonTexture1DView
LookupTexture
FullScreen
| Edit this page View Source

OnInitialize()

Function called to initialize the effect.

Declaration
protected override void OnInitialize()
Overrides
Gorgon2DEffect.OnInitialize()
Remarks

Applications must implement this method to ensure that any required resources are created, and configured for the effect.

See Also
GorgonTexture1DView
LookupTexture
FullScreen
| Edit this page View Source

Render(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 texture, or the output parameter is null.

See Also
GorgonTexture1DView
LookupTexture
FullScreen

Implements

IGorgonNamedObject
IDisposable
IGorgonGraphicsObject
IGorgon2DCompositorEffect

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)

See Also

GorgonTexture1DView
LookupTexture
FullScreen
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author