IRenderStage

Description

interface Tinman.Engine.Rendering.Stages.IRenderStage

Derived from

IDisposable
IGraphicsComponent

Extended by

RenderStageBase abstract

Base interface for classes that implement a pipeline for rendering frames.

A render stage implements a frame pipeline that has the following characteristics:

  • Logarithmic Z-buffering is used, in order to allow 3D scenes to span arbitrary depth ranges.

  • Opaque geometry is rendered to a separate render target, using alpha-to-coverage or alpha-cutoff.

  • Transparent geometry is rendered to a separate render target, using order-independent transparency.

  • The sky background is rendered in a separate step.

  • Shadows are generated by using cascaded shadow-mapping.

To render a full frame, the following sequence must be performed:

  1. Call Begin.

  2. Call BeginShadow1 or skip to 5.

  3. Call BeginShadow2 for each shadow cascade, render all shadow geometry or skip, then call End.

  4. Call End.

  5. Call BeginOpaque, render all opaque geometry, then call End.

  6. Call BeginBackground, render the background geometry, then call End.

  7. Call BeginTransparent, render all transparent geometry, then call End.

  8. Call End.

The CallbackAdd method may be used to inject additional render work into an existing render stage.

Public / Methods

Begin


public method Begin → ()

Begins rendering of a new frame.

The color buffer of the render target at index 1 (see RenderTargets.Get) of the current set of render targets (see IGraphicsContext.GetRenderTarget) is used as final output for the pixels of the rendered frame. The depth/stencil buffer at index 0 is used by the steps of the render stage.

GPU resources that are required by the render stage for rendering frames should be created in the IGraphicsComponent.GraphicsAttach method or in this method. If an exception is thrown by this method, the render stage will remain at the state 1 (see remarks).

RenderException

If a graphics subsystem error has occurred.

See also

IRenderStage.End

Begin​Background


public method BeginBackground → ()

Begins to render the frame background.

The frame background will be visible where no opaque geometry is present, i.e. all pixels with a maximum depth value. When this render step starts, the ModelRenderer.FlushState method of Models is called.

See also

IRenderStage.End

Begin​Opaque


public method BeginOpaque → ()

Begins to render opaque geometry.

When this render step starts, the IBeginEnd.Begin method of Models is called and ModelRenderer.Mode is set to ModelRendererMode.OpaqueTransparent or ModelRendererMode.OpaqueTransparentNoOrder. When it ends, the ModelRenderer.FlushQueue method is called (passing 1).

See also

IRenderStage.End

Begin​Shadow

2 overloads


public method BeginShadow1 → (2)

shadowMapping in : ShadowMapping

[not-null]
The shadow mapping object.

parameters opt : ShadowParameters = null

Optional ShadowParameters object to update with ShadowMappingResource.ApplyParameters, in addition to the Models helper.

Begins to render the cascaded shadow maps.

When this render step starts, the IBeginEnd.Begin method of Models is called and ModelRenderer.Mode is set to ModelRendererMode.Shadow. When it ends, the IBeginEnd.End method is called.

See also

IRenderStage.End


public method BeginShadow2 → (1)

shadowCascade in : ShadowCascade

[not-null]
The shadow cascade object.

returns → bool

true if the shadow cascade is not empty and the render step must be performed,
false if the shadow cascade is empty and the render step must be skipped.

Begins to render the given shadow cascade.

When this render step ends, the ModelRenderer.FlushQueue method is called (passing 1). The End method must always be called, regardless of the returned value.

See also

IRenderStage.End

Begin​Transparent


public method BeginTransparent → ()

Begins to render transparent geometry.

When this render step ends, the ModelRenderer.FlushQueue method is called (passing 2).

See also

IRenderStage.End

Callback​Add


public method CallbackAdd → (1)

callback in : IRenderStageCallback

[not-null]
The render stage callback to add.

Adds the given render stage callback.

If a frame is being rendered (i.e., Begin has been called without a matching call to End), callback in will be added as soon as rendering of the current frame has finished.

Callback​Remove


public method CallbackRemove → (1)

callback in : IRenderStageCallback

[not-null]
The render stage callback to remove.

Removes the given render stage callback.

If a frame is being rendered (i.e., Begin has been called without a matching call to End), callback in will be removed as soon as rendering of the current frame has finished.

End


public method End → ()

Ends the current render step.

For each call to one of the Begin* methods, the End method must be called once.

Hint​Ho​Shadow


public method HintHoShadow → ()

Tells the render stage that BeginShadow1 will not be called when rendering subsequent frames.

Implementations may use this hint to release GPU resources, for example.

Public / Attributes

Cache


public attribute Cache → (get)

value : IResourceCache

The IResourceCache object or null iff not attached.

Returns the IResourceCache object of this render stage.

Context


public attribute Context → (get)

value : IGraphicsContext

The IGraphicsContext object or null iff not attached.

Returns the IGraphicsContext object of this render stage.

Flags


public attribute Flags → (get)

value : RenderStageFlags

The supported render stage flags, when attached to a graphics context. Will be RenderStageFlags.None when not attached.

Returns the render stage flags.

See also

RenderStage.For

Geometry


public attribute Geometry → (get)

value : Renderer

The Renderer object or null iff not attached.

Returns the Renderer object of this render stage.

Graphics


public attribute Graphics → (get)

value : Graphics

The Graphics object or null iff not attached.

Returns the Graphics object of this render stage.

Models


public attribute Models → (get)

value : ModelRenderer

The ModelRenderer object or null iff not attached.

Returns the ModelRenderer object of this render stage.