Class Gorgon2DOldFilmEffect
A post process effect to give an old scratched film effect.
Inherited Members
Namespace: Gorgon.Renderers
Assembly: Gorgon.Renderers.Gorgon2D.dll
Syntax
public class Gorgon2DOldFilmEffect : Gorgon2DEffect, IGorgonNamedObject, IDisposable, IGorgonGraphicsObject, IGorgon2DCompositorEffect
Remarks
This effect animates an image to appear as though it is being displayed on old film.
Constructors
| Edit this page View SourceGorgon2DOldFilmEffect(Gorgon2D, int)
Initializes a new instance of the Gorgon2DOldFilmEffect class.
Declaration
public Gorgon2DOldFilmEffect(Gorgon2D renderer, int noiseTextureSize = 64)
Parameters
Type | Name | Description |
---|---|---|
Gorgon2D | renderer | The renderer used to draw with this effect. |
int | noiseTextureSize | [Optional] The size (width and height) of the texture used for the random noise for scratch line generation |
Remarks
The noiseTextureSize
will determine how often and how many vertical scratch lines appear on the effect. A larger value will yield more scratch lines, while a smaller value
will yield less.
Fields
| Edit this page View SourceGorgon2DFilmGrainIncludeName
The name of the shader include for Gorgon's Gorgon2DOldFilmEffect.
Declaration
public const string Gorgon2DFilmGrainIncludeName = "FilmGrainShaders"
Field Value
Type | Description |
---|---|
string |
Properties
| Edit this page View SourceDesaturationAmount
Property to set or return the amount of desaturation for the current scene.
Declaration
public float DesaturationAmount { get; set; }
Property Value
Type | Description |
---|---|
float |
DirtAmount
Property to set or return the amount of dirt and dust that will appear.
Declaration
public int DirtAmount { get; set; }
Property Value
Type | Description |
---|---|
int |
DirtRegion
Property to set or return the dirt/hair region to draw in on the output render target.
Declaration
public RectangleF? DirtRegion { get; set; }
Property Value
Type | Description |
---|---|
RectangleF? |
Remarks
If this value is null, then the entire output render target region is used to draw the dirt/hair.
HairPercent
Property to set or return the percentage that random hair will appear.
Declaration
public int HairPercent { get; set; }
Property Value
Type | Description |
---|---|
int |
Intensity
Property to set or return the itensity multiplier for scratches.
Declaration
public float Intensity { get; set; }
Property Value
Type | Description |
---|---|
float |
NoiseFrequency
Property to set or return the noise frequency used in generating scratches in the film.
Declaration
public float NoiseFrequency { get; set; }
Property Value
Type | Description |
---|---|
float |
Remarks
It is not recommended to update this value every frame, doing so may have a significant performance hit.
NoiseTextureSize
Property to return the noise texture width and height.
Declaration
public int NoiseTextureSize { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
This determines how often and how many vertical scratch lines appear on the effect. A larger value will yield more scratch lines, while a smaller value will yield less.
ScratchWidth
Property to set or return the width multiplier for scratches.
Declaration
public float ScratchWidth { get; set; }
Property Value
Type | Description |
---|---|
float |
ScrollSpeed
Property to set or return the speed for scratches to move horizontally.
Declaration
public float ScrollSpeed { get; set; }
Property Value
Type | Description |
---|---|
float |
SepiaDarkColor
Property to set or return the darkest color for sepia tone mapping.
Declaration
public GorgonColor SepiaDarkColor { get; set; }
Property Value
Type | Description |
---|---|
GorgonColor |
SepiaLightColor
Property to set or return the lightest color for sepia tone mapping.
Declaration
public GorgonColor SepiaLightColor { get; set; }
Property Value
Type | Description |
---|---|
GorgonColor |
ShakeOffset
Property to set or return the offset that can be used to simulate shaking.
Declaration
public Vector2 ShakeOffset { get; set; }
Property Value
Type | Description |
---|---|
Vector2 |
ToneAmount
Property to set or return the amount of sepia tone for the current scene.
Declaration
public float ToneAmount { get; set; }
Property Value
Type | Description |
---|---|
float |
UpdateSpeed
Property to set or return the speed of updates to the current set of scratches.
Declaration
public float UpdateSpeed { get; set; }
Property Value
Type | Description |
---|---|
float |
Remarks
Smaller values keep the current scratches on the screen longer.
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 | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
Overrides
| Edit this page View SourceOnAfterRender(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
Applications can use this to clean up and/or restore any states when rendering is finished. This is an ideal method to copy any rendering imagery to the final output 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).
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
| 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.
When creating a custom effect, use this method to initialize the effect. Do not put initialization code in the effect constructor.
Render(GorgonTexture2DView, GorgonRenderTargetView)
Function to render the effect.
Declaration
public void Render(GorgonTexture2DView texture, GorgonRenderTargetView output)
Parameters
Type | Name | Description |
---|---|---|
GorgonTexture2DView | texture | The texture to blur and render to the output. |
GorgonRenderTargetView | output | The output render target. |
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 |