Class Gorgon2DBloomEffect
An effect that renders a bloom (glow) effect for a scene.
Inherited Members
Namespace: Gorgon.Renderers
Assembly: Gorgon.Renderers.Gorgon2D.dll
Syntax
public class Gorgon2DBloomEffect : Gorgon2DEffect, IGorgonNamedObject, IDisposable, IGorgonGraphicsObject, IGorgon2DCompositorEffect
Remarks
Bloom is an effect that helps make light sources or bright areas look more intense and vibrant by surrounding them in a glow.
It does this by finding the bright areas above a certain threshold in a render target, and then blurring that image while down sampling and up sampling and applying the result to the original scene using an additive blend. Depending on the settings your scene could be given a dream-like hazy look, or an overbright image for very intense light sources (e.g. a star).
To facilitate the quality of the resulting bloom image, rendering will be performed on a mini HDR (High Dynamic Range) pipeline, and all render targets will use a floating point buffer format (R16G16B16A16_Float). This means that this effect will use a lot of memory, and consume a fair bit of bandwidth. This means that developers should take target hardware capabilities into considering before using this effect.
While this effect employs HDR, it does not provide a means of performing Tone Mapping (a means of converting the large range of color values from floating point into LDR values that map from 0..1/0..255 per channel), so the resulting image may not appear as desired. Tone mapping is a very subjective process, and as such, there is no "right" tone mapping.
When using this effect, be aware that all blending is turned off except on the first pass. The best practice in this case would be to render the contents of your original render target (or swap chain) using a call to DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float) or DrawSprite(GorgonSprite).
The rendering is split out over multiple passes:
- Copy pass - This copies the data into an internal render target for processing.
- Filter down/up sample pass - This isolates all bright areas above a certain Threshold and performs the down/up sampling of the image to blur it.
- Combine pass - Combines the resulting blurred image with the original source image using an additive function.
- [Optional] Dirt - Applies a lens dirt texture.
- Tone mapping - Not available as of this writing. May come in a future version.
This effect is based on the work of Jorge Jimenez from his SIGGRAPH 2014 presentation on advances in realtime rendering.
The website for this presentation is located here.
The PowerPoint presentation is here (it's a big'un).
Constructors
| Edit this page View SourceGorgon2DBloomEffect(Gorgon2D)
Initializes a new instance of the Gorgon2DBloomEffect class.
Declaration
public Gorgon2DBloomEffect(Gorgon2D renderer)
Parameters
Type | Name | Description |
---|---|---|
Gorgon2D | renderer | The renderer used to render this effect. |
See Also
Properties
| Edit this page View SourceBloomIntensity
Property to set or return the intensity of the bloom effect.
Declaration
public float BloomIntensity { get; set; }
Property Value
Type | Description |
---|---|
float |
Remarks
An intensity of 0 will disable the effect.
See Also
BlurAmount
Property to set or return the blurring level for the bloom effect.
Declaration
public float BlurAmount { get; set; }
Property Value
Type | Description |
---|---|
float |
Remarks
Higher values generally apply more blurring when down/up sampling, while lower values will lessen the blur. Note that a value of 0 will disable the bloom effect.
See Also
BrightPassCurveKnee
Property to set or return the knee value to apply to the curve when filtering for a bright pass.
Declaration
public float BrightPassCurveKnee { get; set; }
Property Value
Type | Description |
---|---|
float |
See Also
Color
Property to set or return the color to apply to the bloom.
Declaration
public GorgonColor Color { get; set; }
Property Value
Type | Description |
---|---|
GorgonColor |
See Also
ColorIntensity
Property to set or return the intensity of the color.
Declaration
public float ColorIntensity { get; set; }
Property Value
Type | Description |
---|---|
float |
Remarks
This value has a range of -6 to 6.
See Also
DirtIntensity
Property to set or return the intensity for the dirt.
Declaration
public float DirtIntensity { get; set; }
Property Value
Type | Description |
---|---|
float |
Remarks
Setting this value to 0.0f will disable the dirt.
See Also
DirtTexture
Property to set or return the texture used simluate lens dirt.
Declaration
public GorgonTexture2DView DirtTexture { get; set; }
Property Value
Type | Description |
---|---|
GorgonTexture2DView |
Remarks
Setting this value to null will disable the dirt.
See Also
LowQuality
Property to set or return whether to use lower quality rendering to improve performance.
Declaration
public bool LowQuality { get; set; }
Property Value
Type | Description |
---|---|
bool |
See Also
Threshold
Property to set or return the level of color value that will be included in the bright filter pass .
Declaration
public float Threshold { get; set; }
Property Value
Type | Description |
---|---|
float |
Remarks
Values higher than or equal to 1 will only pick up data that has an R, G or B value larger than 1.0 and is only useful for HDR imagery. Values lower than 1 will skip LDR colors.
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
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).
See Also
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
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
See Also
OnInitialize()
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
Render(GorgonTexture2DView, GorgonRenderTargetView)
Function to render the effect to a render target.
Declaration
public void Render(GorgonTexture2DView texture, GorgonRenderTargetView output)
Parameters
Type | Name | Description |
---|---|---|
GorgonTexture2DView | texture | The texture to render. |
GorgonRenderTargetView | output | The final render target output. |