Gorgon
Show / Hide Table of Contents

Class Gorgon2DGBuffer

A GBuffer containing targets for rendering effects that have need of multiple render targets.

Inheritance
object
GorgonNamedObject
Gorgon2DEffect
Gorgon2DGBuffer
Implements
IGorgonNamedObject
IDisposable
IGorgonGraphicsObject
IGorgonGBuffer
Inherited Members
Gorgon2DEffect.BatchStateAllocator
Gorgon2DEffect.PixelShaderAllocator
Gorgon2DEffect.VertexShaderAllocator
Gorgon2DEffect.Macros
Gorgon2DEffect.Renderer
Gorgon2DEffect.Graphics
Gorgon2DEffect.PassCount
Gorgon2DEffect.Description
Gorgon2DEffect.CompileShader<T>(string, string)
Gorgon2DEffect.OnBeforeRenderPass(int, GorgonRenderTargetView, GorgonCameraCommon)
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 Gorgon2DGBuffer : Gorgon2DEffect, IGorgonNamedObject, IDisposable, IGorgonGraphicsObject, IGorgonGBuffer

Constructors

| Edit this page View Source

Gorgon2DGBuffer(Gorgon2D, int, int)

Initializes a new instance of the Gorgon2DGBuffer class.

Declaration
public Gorgon2DGBuffer(Gorgon2D renderer, int width, int height)
Parameters
Type Name Description
Gorgon2D renderer

The 2D renderer for the application.

int width

The initial width of the gbuffer.

int height

The initial height of the gbuffer.

Exceptions
Type Condition
ArgumentNullException

Thrown when the renderer parameter is null.

Properties

| Edit this page View Source

Diffuse

Property to return the diffuse texture for the gbuffer.

Declaration
public GorgonTexture2DView Diffuse { get; }
Property Value
Type Description
GorgonTexture2DView
| Edit this page View Source

DiffuseTarget

Property to return the diffuse render target for the gbuffer.

Declaration
public GorgonRenderTarget2DView DiffuseTarget { get; }
Property Value
Type Description
GorgonRenderTarget2DView
| Edit this page View Source

GBufferTexture

Property to return the entire gbuffer texture (all array indices).

Declaration
public GorgonTexture2DView GBufferTexture { get; }
Property Value
Type Description
GorgonTexture2DView
| Edit this page View Source

Normal

Property to return the normal map texture for the gbuffer.

Declaration
public GorgonTexture2DView Normal { get; }
Property Value
Type Description
GorgonTexture2DView
| Edit this page View Source

NormalTarget

Property to return the normal map render target for the gbuffer.

Declaration
public GorgonRenderTarget2DView NormalTarget { get; }
Property Value
Type Description
GorgonRenderTarget2DView
| Edit this page View Source

Position

Property to return the position texture for the gbuffer.

Declaration
public GorgonTexture2DView Position { get; }
Property Value
Type Description
GorgonTexture2DView
| Edit this page View Source

PositionTarget

Property to return the position render target for the gbuffer.

Declaration
public GorgonRenderTarget2DView PositionTarget { get; }
Property Value
Type Description
GorgonRenderTarget2DView
| Edit this page View Source

Specular

Property to return the specular texture for the gbuffer.

Declaration
public GorgonTexture2DView Specular { get; }
Property Value
Type Description
GorgonTexture2DView
| Edit this page View Source

SpecularTarget

Property to return the specular render target for the gbuffer.

Declaration
public GorgonRenderTarget2DView SpecularTarget { get; }
Property Value
Type Description
GorgonRenderTarget2DView

Methods

| Edit this page View Source

Begin(GorgonTexture2DView, GorgonTexture2DView, GorgonBlendState, GorgonDepthStencilState, GorgonRasterState, GorgonCameraCommon)

Function to begin rendering using separate texture views for the normal/specular map.

Declaration
public void Begin(GorgonTexture2DView normal = null, GorgonTexture2DView specular = null, GorgonBlendState blendState = null, GorgonDepthStencilState depthStencilState = null, GorgonRasterState rasterState = null, GorgonCameraCommon camera = null)
Parameters
Type Name Description
GorgonTexture2DView normal

[Optional] The normal map texture to render.

GorgonTexture2DView specular

[Optional] The specular map texture to render.

GorgonBlendState blendState

[Optional] A user defined blend state to apply when rendering.

GorgonDepthStencilState depthStencilState

[Optional] A user defined depth/stencil state to apply when rendering.

GorgonRasterState rasterState

[Optional] A user defined rasterizer state to apply when rendering.

GorgonCameraCommon camera

[Optional] The camera to use when rendering.

| Edit this page View Source

Begin(int, int, GorgonBlendState, GorgonDepthStencilState, GorgonRasterState, GorgonCameraCommon)

Function to begin rendering using array indices of the texture being rendered for the normal/specular map.

Declaration
public void Begin(int normalMapIndex, int specularMapIndex, GorgonBlendState blendState = null, GorgonDepthStencilState depthStencilState = null, GorgonRasterState rasterState = null, GorgonCameraCommon camera = null)
Parameters
Type Name Description
int normalMapIndex

The array index of the texture being rendered that contains the normal map.

int specularMapIndex

The array index of the texture being rendered that contains the specular map.

GorgonBlendState blendState

[Optional] A user defined blend state to apply when rendering.

GorgonDepthStencilState depthStencilState

[Optional] A user defined depth/stencil state to apply when rendering.

GorgonRasterState rasterState

[Optional] A user defined rasterizer state to apply when rendering.

GorgonCameraCommon camera

[Optional] The camera to use when rendering.

Remarks

This method takes the texture of whatever is currently being rendered and uses an array index to index into the texture and retrieve the normal and specular map values.

| Edit this page View Source

ClearGBuffer()

Function to clear the GBuffer.

Declaration
public void ClearGBuffer()
| 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)
| Edit this page View Source

End()

Function to end rendering.

Declaration
public void End()
| Edit this page View Source

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
Gorgon2DEffect.OnAfterRender(GorgonRenderTargetView)
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.

| 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

This method is called prior to rendering the effect (before any passes). It allows an effect to do any required effect set up that's not specific to a pass. For example, this method could be used to send a view matrix to a shader via a constant buffer since the view matrix will unlikely change between passes.

Developers should override this method to perform any required setup prior to rendering a pass.

| 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 defaultStatesChanged)
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 defaultStatesChanged

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)
Remarks

This method is responsible for initializing and setting up a rendering state for a pass. State changes (e.g. blend states change, additonal textures needed, etc...) are also handled by this method. Note that the defaultStatesChanged parameter indicates that the user has changed the default effect states when initially rendering (i.e. not per pass).

Developers must take care with this method when creating state objects. Constant discarding and creating of states can get expensive as the garbage collector needs to kick in and release the memory occupied by the states. To help alleviate constant state changes between passes, of the allocator properties in this class may be used to reuse state objects. The rule of thumb however is to create a state once, and then just return that state and only recreate when absolutely necessary. Sometimes that's never, other times it's when the swap chain resizes, and other times it may be on every pass. These conditions depend on the requirements of the effect.

| Edit this page View Source

OnInitialize()

Function called to initialize the effect.

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

This method is called to allow the effect to initialize. Developers must override this method to compile shaders, constant buffers, etc... and set up any initial values for the effect.

| Edit this page View Source

Resize(int, int)

Function to update the gbuffer to a new width and height.

Declaration
public void Resize(int width, int height)
Parameters
Type Name Description
int width

The width of the gbuffer texture.

int height

The height of the gbuffer texture.

Implements

IGorgonNamedObject
IDisposable
IGorgonGraphicsObject
IGorgonGBuffer

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • 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