Class Gorgon2DDisplacementEffect
An effect that displaces the pixels on an image using the pixels from another image for weighting.
Inherited Members
Namespace: Gorgon.Renderers
Assembly: Gorgon.Renderers.Gorgon2D.dll
Syntax
public class Gorgon2DDisplacementEffect : Gorgon2DEffect, IGorgonNamedObject, IDisposable, IGorgonGraphicsObject
Constructors
| Edit this page View SourceGorgon2DDisplacementEffect(Gorgon2D)
Initializes a new instance of the Gorgon2DDisplacementEffect class.
Declaration
public Gorgon2DDisplacementEffect(Gorgon2D renderer)
Parameters
Type | Name | Description |
---|---|---|
Gorgon2D | renderer | The renderer used to render this effect. |
Properties
| Edit this page View SourceChromaticAberration
Property to turn chromatic aberration on or off.
Declaration
public bool ChromaticAberration { get; set; }
Property Value
Type | Description |
---|---|
bool |
Remarks
Setting this value to false may improve performance.
The default value is true.
ChromaticAberrationScale
Property to set or return the scaling for the color channel separation when chromatic aberration is applied.
Declaration
public Vector2 ChromaticAberrationScale { get; set; }
Property Value
Type | Description |
---|---|
Vector2 |
Remarks
This scales the distance between color channels (along with Strength).
If the ChromaticAberration value is false, the this value is ignored.
The default value is (0.5f, 0.0f)
.
DisplacementSampler
Property to set or return the sampler state to use when displacing texture data.
Declaration
public GorgonSamplerState DisplacementSampler { get; set; }
Property Value
Type | Description |
---|---|
GorgonSamplerState |
Strength
Property to set or return the strength of the displacement map.
Declaration
public float Strength { get; set; }
Property Value
Type | Description |
---|---|
float |
Methods
| Edit this page View SourceBeginDisplacementBatch(GorgonTexture2DView, GorgonRenderTarget2DView, GorgonDepthStencilState, GorgonCameraCommon)
Function to begin a batch for rendering the objects used to displace the target.
Declaration
public bool BeginDisplacementBatch(GorgonTexture2DView backgroundTexture, GorgonRenderTarget2DView output, GorgonDepthStencilState depthStencilState = null, GorgonCameraCommon camera = null)
Parameters
Type | Name | Description |
---|---|---|
GorgonTexture2DView | backgroundTexture | The texture that will be displaced. |
GorgonRenderTarget2DView | output | The output render target that will receive the displaced rendering. |
GorgonDepthStencilState | depthStencilState | [Optional] A user defined depth/stencil state to apply when rendering. |
GorgonCameraCommon | camera | [Optional] The camera to use when rendering. |
Returns
Type | Description |
---|---|
bool | true if the pass can continue, false if not. |
Remarks
This is the first pass in the effect. It will receive rendering using objects like sprites, primitives, etc... that will be used to displace the pixels on an image in the next pass.
When this method is called, the EndDisplacementBatch() method must be called prior to moving to the next pass. If this is not done, an exception will be thrown. If this method returns false, the EndDisplacementBatch() still must be called.
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
| Edit this page View SourceEndDisplacementBatch()
Function to end the batch.
Declaration
public void EndDisplacementBatch()
Remarks
This method must be called after the BeginDisplacementBatch(GorgonTexture2DView, GorgonRenderTarget2DView, GorgonDepthStencilState, GorgonCameraCommon), and any custom rendering is called.
OnAfterRender(GorgonRenderTargetView)
Function called after rendering is complete.
Declaration
protected override void OnAfterRender(GorgonRenderTargetView output)
Parameters
Type | Name | Description |
---|---|---|
GorgonRenderTargetView | output | The final render target that will receive the rendering from the effect. |
Overrides
Remarks
This method is called after all passes are finished and the effect is ready to complete its rendering. Developers should override this method to finalize any custom rendering. For example an effect author can use this method to render the final output of an effect to the final render target.
OnBeforeRender(GorgonRenderTargetView, bool)
Function called prior to rendering.
Declaration
protected override void OnBeforeRender(GorgonRenderTargetView output, bool sizeChanged)
Parameters
Type | Name | Description |
---|---|---|
GorgonRenderTargetView | output | The final render target that will receive the rendering from the effect. |
bool | sizeChanged | true if the output size changed since the last render, or false if it's the same. |
Overrides
Remarks
Applications can use this to set up common states and other configuration settings prior to executing the render passes. This is an ideal method to initialize and resize your internal render targets (if applicable).
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
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
| Edit this page View SourceOnInitialize()
Function called when the effect is being initialized.
Declaration
protected override void OnInitialize()
Overrides
Remarks
Use this method to set up the effect upon its creation. For example, this method could be used to create the required shaders for the effect.