Class TMaterialRenderer

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TMaterialRenderer = class(TReferenceCounted)

Description

Interface for material rendering.
Can be used to extend the engine with new materials. Refer to TVideoDriver.AddMaterialRenderer for more informations on how to extend the engine with new materials.

Hierarchy

Overview

Methods

Public function Prepare(Services: TMaterialRendererServices; VType: TVertexType): Boolean; inline;
Public procedure SetMaterial(Material, LastMaterial: PMaterial; ResetAllRenderStates: Boolean; Services: TMaterialRendererServices); inline;
Public procedure UnsetMaterial; inline;

Properties

Public property RenderCapability: LongInt read GetRenderCapability;
Public property Transparent: Boolean read IsTransparent;

Description

Methods

Public function Prepare(Services: TMaterialRendererServices; VType: TVertexType): Boolean; inline;

Called every time before a new bunch of geometry is being drawn using this material with for example DrawIndexedTriangleList call.
This function equals irr::IMaterialRenderer::OnRender.
Prepare should normally only be called if the renderer decides that the renderstates should be changed, it won't be called if for example two DrawIndexedTriangleList() will be called with the same material set. This method will be called every time. This is useful for example for materials with shaders, which don't only set new renderstates but also shader constants.

Parameters
Services
Pointer to interface providing methos for setting constants and other things.
VType
Vertex type with which the next rendering will be done. This can be used by the material renderer to set some specific optimized shaders or if this is an incompatible vertex type for this renderer, to refuse rendering for example.
Returns

True if everything is ok, and false if nothing should be rendered. The material renderer can choose to return false for example if he doesn't support the specified vertex type. This is actually done in D3D8 and D3D9 when using a normal mapped material with a vertex type other than vtTangents.

Public procedure SetMaterial(Material, LastMaterial: PMaterial; ResetAllRenderStates: Boolean; Services: TMaterialRendererServices); inline;

Called by the TVideoDriver implementation the let the renderer set its needed render states.
This function equals irr::IMaterialRenderer::OnSetMaterial.
This is called during the TVideoDriver.SetMaterial call. When overriding this, you can set some renderstates or for example a vertex or pixel shader if you like.

Parameters
Material
The new material parameters to be set. The renderer may change the material flags in this material. For example if this material does not accept the zbuffer = true, it can set it to false. This is useful, because in the next lastMaterial will be just the material in this call.
LastMaterial
The material parameters which have been set before this material.
ResetAllRenderStates
True if all renderstates should really be reset. This is usually true if the last rendering mode was not a usual 3d rendering mode, but for example a 2d rendering mode. You should reset really all renderstates if this is true, no matter if the lastMaterial had some similar settings. This is used because in most cases, some common renderstates are not changed if they are already there, for example bilinear filtering, wireframe, gouraudshading, lighting, zbuffer, zwriteenable, backfaceculling and fogenable.
Services
Interface providing some methods for changing advanced, internal states of a TVideoDriver.
Public procedure UnsetMaterial; inline;

Called by the TVideoDriver to unset this material.
Called during the TVideoDriver.SetMaterial() call before the new material will get the TMaterialRenderer.SetMaterial() call.

Properties

Public property RenderCapability: LongInt read GetRenderCapability;

Returns the render capability of the material.
Because some more complex materials are implemented in multiple ways and need special hardware capabilities, it is possible to query how the current material renderer is performing on the current hardware with this function. Equals nil if everything is running fine. Any other value is material renderer specific and means for example that the renderer switched back to a fall back material because it cannot use the latest shaders. More specific examples: Fixed function pipeline materials should return nil in most cases, parallax mapped material will only return 0 when at least pixel shader 1.4 is available on that machine.

Public property Transparent: Boolean read IsTransparent;

Returns if the material is transparent.
The scene managment needs to know this for being able to sort the materials by opaque and transparent.


Generated by PasDoc 0.12.1 on 2012-09-14 17:32:22