Gorgon
Show / Hide Table of Contents

Class Gorgon2DBloomEffect

An effect that renders a bloom (glow) effect for a scene.

Inheritance
object
GorgonNamedObject
Gorgon2DEffect
Gorgon2DBloomEffect
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.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 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:

  1. Copy pass - This copies the data into an internal render target for processing.
  2. 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.
  3. Combine pass - Combines the resulting blurred image with the original source image using an additive function.
  4. [Optional] Dirt - Applies a lens dirt texture.
  5. 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 Source

Gorgon2DBloomEffect(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
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold

Properties

| Edit this page View Source

BloomIntensity

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
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold
| Edit this page View Source

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
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold
| Edit this page View Source

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
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold
| Edit this page View Source

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
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold
| Edit this page View Source

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
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold
| Edit this page View Source

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
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold
| Edit this page View Source

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
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold
| Edit this page View Source

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
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold
| Edit this page View Source

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
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold

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
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold
| Edit this page View Source

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
Gorgon2DEffect.OnBeforeRender(GorgonRenderTargetView, bool)
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
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold
| 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
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold
| 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
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold
| 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
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold
| Edit this page View Source

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.

See Also
DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold

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

DrawFilledRectangle(RectangleF, GorgonColor, GorgonTexture2DView, RectangleF?, int, GorgonSamplerState, float)
DrawSprite(GorgonSprite)
BufferFormat
Threshold
  • 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