Urho.Technique Class

Material technique. Consists of several passes.

See Also: Technique

Syntax

public class Technique : Resource

Remarks

A technique definition looks like this:

XML Example

<technique vs="VertexShaderName" ps="PixelShaderName" vsdefines="DEFINE1 DEFINE2" psdefines="DEFINE3 DEFINE4" desktop="false|true" >
    <pass name="base|litbase|light|alpha|litalpha|postopaque|refract|postalpha|prepass|material|deferred|depth|shadow" desktop="false|true" >
        vs="VertexShaderName" ps="PixelShaderName" vsdefines="DEFINE1 DEFINE2" psdefines="DEFINE3 DEFINE4"
        lighting="unlit|pervertex|perpixel"
        blend="replace|add|multiply|alpha|addalpha|premulalpha|invdestalpha|subtract|subtractalpha"
        depthtest="always|equal|less|lessequal|greater|greaterequal"
        depthwrite="true|false" 
        alphamask="true|false" />
    <pass ... />
    <pass ... />
</technique>

The "desktop" attribute in either technique or pass allows to specify it requires desktop graphics hardware (exclude mobile devices.) Omitting it is the same as specifying false.

Shaders are referred to by giving the name of a shader without path and file extension. For example "Basic" or "LitSolid". The engine will add the correct path and file extension (Shaders/HLSL/LitSolid.hlsl for Direct3D, and Shaders/GLSL/LitSolid.glsl for OpenGL) automatically. The same shader source file contains both the vertex and pixel shader. In addition, compilation defines can be specified, which are passed to the shader compiler. For example the define "DIFFMAP" typically enables diffuse mapping in the pixel shader.

Shaders and their compilation defines can be specified on both the technique and pass level. If a pass does not override the default shaders specified on the technique level, it still can specify additional compilation defines to be used. However, if a pass overrides the shaders, then the technique-level defines are not used.

The technique definition does not need to enumerate shaders used for different geometry types (non-skinned, skinned, instanced, billboard) and different per-vertex and per-pixel light combinations. Instead the engine will add certain hardcoded compilation defines for these. See Shader for details.

The purposes of the different passes are:

  • base: Renders ambient light, per-vertex lights and fog for an opaque object.
  • litbase: Renders the first per-pixel light, ambient light and fog for an opaque object. This is an optional pass for optimization.
  • light: Renders one per-pixel light's contribution additively for an opaque object.
  • alpha: Renders ambient light, per-vertex lights and fog for a transparent object.
  • litalpha: Renders one per-pixel light's contribution additively for a transparent object
  • postopaque: Custom rendering pass after opaque geometry. Can be used to render the skybox.
  • refract: Custom rendering pass after postopaque pass. Can sample the viewport texture from the environment texture unit to render refractive objects.
  • postalpha: Custom rendering pass after transparent geometry.
  • prepass: Light pre-pass only - renders normals, specular power and depth to the G-buffer.
  • material: Light pre-pass only - renders opaque geometry final color by combining ambient light, per-vertex lights and per-pixel light accumulation.
  • deferred: Deferred rendering only - renders ambient light and per-vertex lights to the output rendertarget, and diffuse albedo, normals, specular intensity + power and depth to the G-buffer.
  • depth: Renders linear depth to a rendertarget for post-processing effects.
  • shadow: Renders to a hardware shadow map (depth only) for shadow map generation.

More custom passes can be defined and referred to in the render path definition. For the built-in passes listed above, the lighting shader permutations to load (unlit, per-vertex or per-pixel) are recognized automatically, but for custom passes they need to be explicitly specified. The default is unlit.

The optional "litbase" pass reduces draw call count by combining ambient lighting with the first per-pixel light affecting an object. However, it has intentional limitations to not require too many shader permutations: there must be no vertex lights affecting the object, and the ambient lighting can not have a gradient. In case of excessive overdraw, it is possibly better not to define it, but instead allow the base pass (which is computationally very lightweight) to run first, initializing the Z buffer for later passes.

"Alphamask" is not an actual rendering state, but a hint which tells that the pixel shader will use discard based on alpha. Because this may interfere with the early-Z culling, materials without the alpha masking hint will be drawn first.

The refract pass requires pingponging the scene rendertarget to a texture, but this will not be performed if there is no refractive geometry to render, so there is no unnecessary cost to it.

Requirements

Namespace: Urho
Assembly: Urho (in Urho.dll)
Assembly Versions: 1.0.0.0

The members of Urho.Technique are listed below.

See Also: Resource

Public Constructors

Constructs a new instance of Urho.Technique which is tied to the Application.CurrentContext.
Constructs a new instance of Urho.Technique, given a raw pointer to an unmanaged object
Constructs a new instance of Urho.Technique linked to a specific Context.

Protected Constructors

Empty constructor, chain to this constructor when you provide your own constructor that sets the handle field.

Public Properties

[read-only]
DesktopBoolean. Indicates whether requires desktop level hardware.
[read-only]
NumPassesUInt32. Return number of passes.
[read-only]
SupportedBoolean. Indicates whether technique is supported by the current hardware.
[read-only]
override
TypeStringHash. Urho's type system type.
[read-only]
override
TypeNameString. Urho's low-level type name.
[read-only]
static
TypeNameStaticString. Urho's low-level type name, accessible as a static method.
[read-only]
static
TypeStaticStringHash. Urho's low-level type, accessible as a static method.

Public Methods

override
BeginLoad(File) : Boolean
override
BeginLoad(MemoryBuffer) : Boolean
Clone(String) : Technique
CloneWithDefines(String, String) : Technique
CreatePass(String) : Pass
Create a new pass.
GetPass(String) : Pass
Return a pass by name, or null if not found. This overload should not be called in time-critical rendering loops; use a pre-acquired pass index instead.
GetPass(UInt32) : Pass
Return a pass, or null if not found.
static
GetPassIndex(String) : UInt32
Return a pass type index by name. Allocate new if not used yet.
GetSupportedPass(String) : Pass
Return a supported pass by name. This overload should not be called in time-critical rendering loops; use a pre-acquired pass index instead.
GetSupportedPass(UInt32) : Pass
Return a pass that is supported for rendering, or null if not found.
HasPass(String) : Boolean
Return whether has a pass by name. This overload should not be called in time-critical rendering loops; use a pre-acquired pass index instead.
HasPass(UInt32) : Boolean
Return whether has a pass.
static
RegisterObject(Context)
Register object factory.
ReleaseShaders()
Reset shader pointers in all passes.
RemovePass(String)
Remove a pass.
SetIsDesktop(Boolean)
Set whether requires desktop level hardware.