Class Gorgon2DGBuffer
A GBuffer containing targets for rendering effects that have need of multiple render targets.
Inherited Members
Namespace: Gorgon.Renderers
Assembly: Gorgon.Renderers.Gorgon2D.dll
Syntax
public class Gorgon2DGBuffer : Gorgon2DEffect, IGorgonNamedObject, IDisposable, IGorgonGraphicsObject, IGorgonGBuffer
Constructors
| Edit this page View SourceGorgon2DGBuffer(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 |
Properties
| Edit this page View SourceDiffuse
Property to return the diffuse texture for the gbuffer.
Declaration
public GorgonTexture2DView Diffuse { get; }
Property Value
Type | Description |
---|---|
GorgonTexture2DView |
DiffuseTarget
Property to return the diffuse render target for the gbuffer.
Declaration
public GorgonRenderTarget2DView DiffuseTarget { get; }
Property Value
Type | Description |
---|---|
GorgonRenderTarget2DView |
GBufferTexture
Property to return the entire gbuffer texture (all array indices).
Declaration
public GorgonTexture2DView GBufferTexture { get; }
Property Value
Type | Description |
---|---|
GorgonTexture2DView |
Normal
Property to return the normal map texture for the gbuffer.
Declaration
public GorgonTexture2DView Normal { get; }
Property Value
Type | Description |
---|---|
GorgonTexture2DView |
NormalTarget
Property to return the normal map render target for the gbuffer.
Declaration
public GorgonRenderTarget2DView NormalTarget { get; }
Property Value
Type | Description |
---|---|
GorgonRenderTarget2DView |
Position
Property to return the position texture for the gbuffer.
Declaration
public GorgonTexture2DView Position { get; }
Property Value
Type | Description |
---|---|
GorgonTexture2DView |
PositionTarget
Property to return the position render target for the gbuffer.
Declaration
public GorgonRenderTarget2DView PositionTarget { get; }
Property Value
Type | Description |
---|---|
GorgonRenderTarget2DView |
Specular
Property to return the specular texture for the gbuffer.
Declaration
public GorgonTexture2DView Specular { get; }
Property Value
Type | Description |
---|---|
GorgonTexture2DView |
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 SourceBegin(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. |
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.
ClearGBuffer()
Function to clear the GBuffer.
Declaration
public void ClearGBuffer()
Dispose(bool)
Releases unmanaged and - optionally - managed resources.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing |
|
Overrides
| Edit this page View SourceEnd()
Function to end rendering.
Declaration
public void End()
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
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.
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
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.
OnInitialize()
Function called to initialize the effect.
Declaration
protected override void OnInitialize()
Overrides
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.
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. |