Class DrawContext
Allows control over how the scene is rendered.
Inherited Members
Namespace: Evergine.Framework.Graphics
Assembly: Evergine.Framework.dll
Syntax
public abstract class DrawContext : DisposableObjectConstructors
DrawContext(RenderPipeline, RenderPath)
Initializes a new instance of the DrawContext class.
Declaration
public DrawContext(RenderPipeline renderPipeline, RenderPath renderPath)Parameters
| Type | Name | Description | 
|---|---|---|
| RenderPipeline | renderPipeline | The rendering pipeline. | 
| RenderPath | renderPath | The rendering path. | 
Fields
CullingResult
The culling results.
Declaration
public readonly CullingResult CullingResultField Value
| Type | Description | 
|---|---|
| CullingResult | 
DrawContextResources
The material collection associated with this draw context.
Declaration
public DrawContextResources DrawContextResourcesField Value
| Type | Description | 
|---|---|
| DrawContextResources | 
EffectAutoParamSource
Instance used to automatically pass parameters to effects.
Declaration
public EngineShaderParameters EffectAutoParamSourceField Value
| Type | Description | 
|---|---|
| EngineShaderParameters | 
ElapsedTime
The elapsed time between the last frame rendered and the current frame.
Declaration
public TimeSpan ElapsedTimeField Value
| Type | Description | 
|---|---|
| TimeSpan | 
ForceBlitAlphaBlending
Indicates that when this camera's intermediate buffer is blitted into the target framebuffer, it will be forced to use alpha blending.
Declaration
public bool ForceBlitAlphaBlendingField Value
| Type | Description | 
|---|---|
| bool | 
FrameCount
The number of frames.
Declaration
public long FrameCountField Value
| Type | Description | 
|---|---|
| long | 
GAMMA_COLORSPACE
Directive that indicates if we need to perform the conversion to gamma in the shader.
Declaration
public const string GAMMA_COLORSPACE = "GAMMA_COLORSPACE"Field Value
| Type | Description | 
|---|---|
| string | 
ID
Gets the identifier.
Declaration
public readonly int IDField Value
| Type | Description | 
|---|---|
| int | 
MultiviewStrategy
The cached multiview strategy for this graphic context device.
Declaration
protected readonly MultiviewStrategy MultiviewStrategyField Value
| Type | Description | 
|---|---|
| MultiviewStrategy | 
RenderPath
The rendering path.
Declaration
public readonly RenderPath RenderPathField Value
| Type | Description | 
|---|---|
| RenderPath | 
RenderPipeline
The render manager.
Declaration
protected readonly RenderPipeline RenderPipelineField Value
| Type | Description | 
|---|---|
| RenderPipeline | 
TotalTime
The total time since this camera started rendering.
Declaration
public TimeSpan TotalTimeField Value
| Type | Description | 
|---|---|
| TimeSpan | 
drawContextGeneration
The drawing context generation number.
Declaration
protected int drawContextGenerationField Value
| Type | Description | 
|---|---|
| int | 
passCount
Passing count.
Declaration
protected int passCountField Value
| Type | Description | 
|---|---|
| int | 
Properties
AdditionalEffectDirectives
Gets the additional effect directives that must be included to compile effect techniques.
Declaration
public string[] AdditionalEffectDirectives { get; }Property Value
| Type | Description | 
|---|---|
| string[] | 
BoundingFrustum
Gets the bounding frustum of this camera.
Declaration
public abstract BoundingFrustum BoundingFrustum { get; }Property Value
| Type | Description | 
|---|---|
| BoundingFrustum | 
ClearFlags
Gets Clear flags used for clearing the FrameBuffer, stencilBuffer, and ZBuffer.
Declaration
public abstract ClearFlags ClearFlags { get; }Property Value
| Type | Description | 
|---|---|
| ClearFlags | 
ClearValue
Gets the clear value for the camera.
Declaration
public abstract ClearValue ClearValue { get; }Property Value
| Type | Description | 
|---|---|
| ClearValue | 
CullingSystem
Gets the culling system used by the Render System. A camera can specify the Culling System that it will use.
Declaration
public virtual CullingSystem CullingSystem { get; }Property Value
| Type | Description | 
|---|---|
| CullingSystem | 
DrawContextGeneration
Gets the additional directives generation ID.
Declaration
public int DrawContextGeneration { get; }Property Value
| Type | Description | 
|---|---|
| int | 
FarPlane
Gets the far plane of the frustum.
Declaration
public abstract float FarPlane { get; }Property Value
| Type | Description | 
|---|---|
| float | 
FieldOfView
Gets the field of view of the camera.
Declaration
public abstract float FieldOfView { get; }Property Value
| Type | Description | 
|---|---|
| float | 
FrameBuffer
Gets or sets the framebuffer.
Declaration
public FrameBuffer FrameBuffer { get; set; }Property Value
| Type | Description | 
|---|---|
| FrameBuffer | 
HighResolutionIntermediateFrameBuffer
Gets or sets the intermediate framebuffer. If the framebuffer comes from the swapchain, the render path will use this intermediate framebuffer to render before transferring it to the final framebuffer.
Declaration
public FrameBuffer HighResolutionIntermediateFrameBuffer { get; protected set; }Property Value
| Type | Description | 
|---|---|
| FrameBuffer | 
IntermediateFrameBuffer
Gets the intermediate framebuffer depending on whether super resolution is enabled or not.
Declaration
public FrameBuffer IntermediateFrameBuffer { get; }Property Value
| Type | Description | 
|---|---|
| FrameBuffer | 
IsMultiview
Gets or sets a value indicating whether this draw context will be rendered in stereo display.
Declaration
public bool IsMultiview { get; protected set; }Property Value
| Type | Description | 
|---|---|
| bool | 
LowResolutionIntermediateFrameBuffer
Gets or sets the low resolution intermediate framebuffer. This buffer is used by the renderer, which will perform upsampling and copy it to the IntermediateFramebuffer before transferring to the FrameBuffer swapchain.
Declaration
public FrameBuffer LowResolutionIntermediateFrameBuffer { get; protected set; }Property Value
| Type | Description | 
|---|---|
| FrameBuffer | 
MultiviewEyeCount
Gets the number of views of this draw context.
Declaration
public abstract int MultiviewEyeCount { get; }Property Value
| Type | Description | 
|---|---|
| int | 
MultiviewInstancingCount
Gets the number of instance count to render all views.
Declaration
public abstract int MultiviewInstancingCount { get; }Property Value
| Type | Description | 
|---|---|
| int | 
Remarks
In a Multiview with RenderTargetIndex strategy, the number is MultiviewEyeCount, but in the ViewIndex strategy, the instance count is 1.
MultiviewPosition
Gets the multi-view position array.
Declaration
public abstract Vector4[] MultiviewPosition { get; }Property Value
| Type | Description | 
|---|---|
| Vector4[] | 
MultiviewProjection
Gets the Multiview projection transformation array.
Declaration
public abstract Matrix4x4[] MultiviewProjection { get; }Property Value
| Type | Description | 
|---|---|
| Matrix4x4[] | 
MultiviewProjectionInverse
Gets the Multiview view projection inverse transform array.
Declaration
public abstract Matrix4x4[] MultiviewProjectionInverse { get; }Property Value
| Type | Description | 
|---|---|
| Matrix4x4[] | 
MultiviewView
Gets the multiview view transform array.
Declaration
public abstract Matrix4x4[] MultiviewView { get; }Property Value
| Type | Description | 
|---|---|
| Matrix4x4[] | 
MultiviewViewProjection
Gets the multiview view projection transform array.
Declaration
public abstract Matrix4x4[] MultiviewViewProjection { get; }Property Value
| Type | Description | 
|---|---|
| Matrix4x4[] | 
NearPlane
Gets the near plane of the frustum.
Declaration
public abstract float NearPlane { get; }Property Value
| Type | Description | 
|---|---|
| float | 
NeedsEncodeGammaInPixelShader
Gets or sets a value indicating whether this draw context will render in a gamma color space framebuffer.
Declaration
public bool NeedsEncodeGammaInPixelShader { get; protected set; }Property Value
| Type | Description | 
|---|---|
| bool | 
Position
Gets the position.
Declaration
public abstract Vector3 Position { get; }Property Value
| Type | Description | 
|---|---|
| Vector3 | 
Projection
Gets the projection transform.
Declaration
public abstract Matrix4x4 Projection { get; }Property Value
| Type | Description | 
|---|---|
| Matrix4x4 | 
ProjectionInverse
Gets the inverse projection matrix.
Declaration
public abstract Matrix4x4 ProjectionInverse { get; }Property Value
| Type | Description | 
|---|---|
| Matrix4x4 | 
RenderFramebuffer
Gets the framebuffer used to render the scene.
Declaration
public FrameBuffer RenderFramebuffer { get; }Property Value
| Type | Description | 
|---|---|
| FrameBuffer | 
Remarks
If the draw context has an intermediate buffer, return the intermediate buffer. If the IntermediateBuffer is disabled, return the default framebuffer.
RenderManager
Gets the render manager.
Declaration
public RenderManager RenderManager { get; }Property Value
| Type | Description | 
|---|---|
| RenderManager | 
RenderProjection
Gets the rendered projection transform.
Declaration
public abstract Matrix4x4 RenderProjection { get; }Property Value
| Type | Description | 
|---|---|
| Matrix4x4 | 
RenderViewProjection
Gets the render view projection transformation.
Declaration
public abstract Matrix4x4 RenderViewProjection { get; }Property Value
| Type | Description | 
|---|---|
| Matrix4x4 | 
SuperResolutionEnabled
Gets or sets a value indicating whether super resolution is enabled.
Declaration
public bool SuperResolutionEnabled { get; set; }Property Value
| Type | Description | 
|---|---|
| bool | 
SuperResolutionScaleFactor
Gets or sets the Scale Factor for FidelityFX 1.0: Performance 2.0, Balance 1.7, Quality 1.5, UltraQuality 1.7.
Declaration
public float SuperResolutionScaleFactor { get; set; }Property Value
| Type | Description | 
|---|---|
| float | 
Transform
Gets the view object's transform.
Declaration
public abstract Transform3D Transform { get; }Property Value
| Type | Description | 
|---|---|
| Transform3D | 
View
Gets the view transform.
Declaration
public abstract Matrix4x4 View { get; }Property Value
| Type | Description | 
|---|---|
| Matrix4x4 | 
ViewCount
Gets the number of views of this draw context.
Declaration
public abstract int ViewCount { get; }Property Value
| Type | Description | 
|---|---|
| int | 
Remarks
A draw context can contain several views (cascade shadows, point light shadows, reflection probe, etc.).
ViewIndex
Gets the View index of this draw context.
Declaration
public abstract int ViewIndex { get; }Property Value
| Type | Description | 
|---|---|
| int | 
Remarks
A draw context can contain several views (cascade shadows, point light shadows, reflection probe, etc.).
ViewInverse
Gets the inverse view matrix.
Declaration
public abstract Matrix4x4 ViewInverse { get; }Property Value
| Type | Description | 
|---|---|
| Matrix4x4 | 
ViewProjection
Gets the view-projection transform.
Declaration
public abstract Matrix4x4 ViewProjection { get; }Property Value
| Type | Description | 
|---|---|
| Matrix4x4 | 
ViewProjectionInverse
Gets the inverse of the view-projection transform.
Declaration
public abstract Matrix4x4 ViewProjectionInverse { get; }Property Value
| Type | Description | 
|---|---|
| Matrix4x4 | 
Methods
BeforeCollect()
Before collect method. Used to process drawables and cull objects.
Declaration
protected virtual void BeforeCollect()BeforeRender()
Executes actions needed before the camera renders.
Declaration
public abstract bool BeforeRender()Returns
| Type | Description | 
|---|---|
| bool | True if the camera should be rendered. | 
Collect()
Collects resources to perform the render.
Declaration
protected virtual void Collect()CollectBatch(ref RenderBatch)
Collects a batch.
Declaration
public virtual void CollectBatch(ref RenderBatch batch)Parameters
| Type | Name | Description | 
|---|---|---|
| RenderBatch | batch | The batch information to be collected. | 
CollectBatches()
Collects render batches from the visible meshes.
Declaration
protected virtual void CollectBatches()CollectMaterials()
Updates all per-view constant buffers.
Declaration
protected virtual void CollectMaterials()CollectMeshSources()
Gets the mesh sources.
Declaration
public virtual void CollectMeshSources()CouldBatch(int, RenderObjectInfo, int, RenderObjectInfo)
Method that indicates if this drawContext can batch these meshes.
Declaration
protected virtual bool CouldBatch(int idxA, RenderObjectInfo meshA, int idxB, RenderObjectInfo meshB)Parameters
| Type | Name | Description | 
|---|---|---|
| int | idxA | Mesh Index A. | 
| RenderObjectInfo | meshA | Mesh A. | 
| int | idxB | Mesh Index B. | 
| RenderObjectInfo | meshB | Mesh B. | 
Returns
| Type | Description | 
|---|---|
| bool | True if everything is OK. | 
CullLights()
Cull non-visible meshes.
Declaration
protected virtual void CullLights()CullObjects()
Cull non-visible meshes.
Declaration
protected virtual void CullObjects()Destroy()
Destroys the resources.
Declaration
protected override void Destroy()Overrides
EmitBatch(ref RenderBatch)
Collects a batch.
Declaration
protected virtual void EmitBatch(ref RenderBatch batch)Parameters
| Type | Name | Description | 
|---|---|---|
| RenderBatch | batch | The batch info to be collected. | 
FilterObjects(RenderObjectInfo)
Indicates whether this object must be filtered.
Declaration
public abstract bool FilterObjects(RenderObjectInfo renderObjectInfo)Parameters
| Type | Name | Description | 
|---|---|---|
| RenderObjectInfo | renderObjectInfo | The object info to filter. | 
Returns
| Type | Description | 
|---|---|
| bool | True if the object must be filtered. | 
FireOnFrameBufferProcessed()
Fires the OnFrameBufferProcessed event.
Declaration
protected void FireOnFrameBufferProcessed()GetAdditionalDirectives()
Refreshes the additional directives.
Declaration
protected virtual List<string> GetAdditionalDirectives()Returns
| Type | Description | 
|---|---|
| List<string> | The additional directives. | 
GetPassFramebuffer(int)
Gets the framebuffer associated with the specified pass.
Declaration
public virtual FrameBuffer GetPassFramebuffer(int passID)Parameters
| Type | Name | Description | 
|---|---|---|
| int | passID | The pass ID. | 
Returns
| Type | Description | 
|---|---|
| FrameBuffer | The framebuffer. | 
GetTexture(TextureSemantic, int)
Gets the texture.
Declaration
public virtual Texture GetTexture(TextureInfo.TextureSemantic textureSemantic, int textureIndex)Parameters
| Type | Name | Description | 
|---|---|---|
| TextureInfo.TextureSemantic | textureSemantic | The texture semantic. | 
| int | textureIndex | The texture index. | 
Returns
| Type | Description | 
|---|---|
| Texture | The found texture. | 
PrepareBatches(CommandBuffer)
Prepares batches to be rendered.
Declaration
public void PrepareBatches(CommandBuffer commandBuffer)Parameters
| Type | Name | Description | 
|---|---|---|
| CommandBuffer | commandBuffer | The command buffer. | 
PrepareBatches(CommandBuffer, int, int)
Prepares batches to be rendered.
Declaration
public virtual void PrepareBatches(CommandBuffer commandBuffer, int count, int offset)Parameters
| Type | Name | Description | 
|---|---|---|
| CommandBuffer | commandBuffer | The command buffer. | 
| int | count | The number of batches to prepare. | 
| int | offset | The offset index of the batch to be drawn. | 
ProcessDrawables()
Executes the Draw() method for each drawable.
Declaration
protected virtual void ProcessDrawables()RefreshAdditionalDirectives()
Refreshes the additional directives.
Declaration
protected bool RefreshAdditionalDirectives()Returns
| Type | Description | 
|---|---|
| bool | True if the directives have changed. | 
Render(CommandBuffer)
Executes the draw action of the draw context.
Declaration
public abstract void Render(CommandBuffer commandBuffer)Parameters
| Type | Name | Description | 
|---|---|---|
| CommandBuffer | commandBuffer | The command buffer used for rendering. | 
RenderBatches(int, CommandBuffer)
Batches the render passes.
Declaration
public void RenderBatches(int passId, CommandBuffer commandBuffer)Parameters
| Type | Name | Description | 
|---|---|---|
| int | passId | Pass ID. | 
| CommandBuffer | commandBuffer | Command buffer. | 
RenderBatches(int, CommandBuffer, int, int)
Batches the render passes.
Declaration
public virtual void RenderBatches(int passId, CommandBuffer commandBuffer, int count, int offset)Parameters
| Type | Name | Description | 
|---|---|---|
| int | passId | Pass ID. | 
| CommandBuffer | commandBuffer | Command buffer. | 
| int | count | Pass count. | 
| int | offset | Pass offset. | 
SetPerViewEngineParameters()
Collects shader resources per view.
Declaration
protected abstract void SetPerViewEngineParameters()SortObjects()
Sorts the meshes.
Declaration
protected virtual void SortObjects()Events
OnCollect
OnCollect is called before a camera starts to collect resources.
Declaration
public event EventHandler OnCollectEvent Type
| Type | Description | 
|---|---|
| EventHandler | 
OnFrameBufferProcessed
OnProcessFrameBuffer is called when the framebuffer is refreshed.
Declaration
public event EventHandler OnFrameBufferProcessedEvent Type
| Type | Description | 
|---|---|
| EventHandler | 
OnPostRender
OnPostRender is called after the camera finishes rendering the scene.
Declaration
public event DrawContext.DrawContextEventHandler OnPostRenderEvent Type
| Type | Description | 
|---|---|
| DrawContext.DrawContextEventHandler | 
OnPreRender
OnPreRender is called before a camera starts rendering the scene.
Declaration
public event DrawContext.DrawContextEventHandler OnPreRenderEvent Type
| Type | Description | 
|---|---|
| DrawContext.DrawContextEventHandler |