Techniques
From Multiverse
Contents |
Overview
A technique section in a material script defines a single
method of rendering an object. The simplest of material definitions
contains only a single technique, however since PC hardware varies
quite greatly in capabilities, you can only do this if you are
sure that every card for which you intend to target your application
will support the capabilities which your technique requires. In
addition, it can be useful to define simpler ways to render a material
if you wish to use material LOD, such that more distant objects use a
simpler, less performance-hungry technique.
In a material script, list techniques in order of preference, that is, list the technique you want to try first, then the one you want to try second, and so on. This normally means listing the most advanced, most demanding, techniques first in the script, and listing "fallback" techniques afterwards.
Techniques also contain at least one and possibly more passes. See Passes.
Compilation
When a material is used for the first time, it is compiled. Compiling involves scanning the techniques which have been defined, and marking which of them are supportable using the current rendering API and graphics card. If no techniques are supportable, the material will render as blank white.
Compilation examines a number of things, including:
- The number of texture_unit entries in each pass. If the number of texture_unit entries exceeds the number of texture units in the current graphics card, the technique may still be supportable so long as a fragment program is not being used. In this case, the Client will split the pass which has too many entries into multiple passes for the less capable card, and the multi-texture blend will turn into a multi-pass blend. See colour_op_multipass_fallback.
- Whether vertex or pixel shader programs are used, and if so which syntax they use (for example, vs_1_1, ps_2_x, arbfp1 and so on).
- Other effects like cube mapping and dot3 blending
Naming
Optionally provide a name to identify a technique. Techniques not named within the script will be named as the technique index number. For example, the first technique in a material is index 0, so its default name is "0". A technique's name must be unique within the material or the final technique will be the resulting merge of all techniques with the same name in the material. The Client issues a a warning message in the log file if this occurs.
Named techniques can help when copying a material and modifying an existing technique: (See Copying Materials).
Format:
technique name {
scheme value
lod_index value
...
}
Attributes
The technique section has two attributes:
Also, see lod_distances which is directly related to the lod_index attribute.
scheme
The scheme attribute specifies a technique's scheme that controls top-level switching from one set of techniques to another. For example, you might use this to define high, medium and low complexity levels on materials to allow a user to pick a performance / quality ratio. You can also uses schemese to specify a fully HDR-enabled pipeline for top machines, rendering all objects using unclamped shaders, and a simpler pipeline for others.
The active scheme is typically controlled at a viewport level, and the active one defaults to "Default".
Format:
scheme name
Default:
scheme Default
Example:
scheme hdr
lod_index
Sets the level-of-detail (LOD) index for the technique.
All techniques must belong to a LOD index. By default they all belong to index 0, the highest LOD. Increasing indexes denote lower levels of detail. You can (and often will) assign more than one technique to the same LOD index, which means the Multiverse Client will pick the best technique of the ones listed at the same LOD index. For readability, list techniques in order of LOD, then in order of preference, although the latter is the only prerequisite (the Client determines which one is 'best' by which one is listed first). You must always have at least one technique at lod_index 0.
The distance at which a LOD level is applied is determined by the lod_distances attribute of the containing material, See lod_distances for details.
Format:
lod_index number
Where number is any interger from 0 (highest level of detail) to 65535 (lowest level of detail), although such a high value is unlikely. Do not leave gaps between techniques LOD index values.
Example:
lod_index 1
Default:
lod_index 0
lod_distances
This attribute must be specified in the outer material section (the parent of all the techniques), but it's specified here since it is most relevant to this section. By setting this attribute, you indicate that you want this material to alter the technique that it uses based on distance from the camera. Specify a list of distances, in ascending order, each one indicating the distance at which the material will switch to the next LOD. Implicitly, all materials activate LOD index 0 for distances less than the smallest of these. You must ensure that there is at least one technique with an lod_index value for each distance in the list. So, for example, if you specify three distances, you must have techniques for indexes 1, 2 and 3.
There must always be at least one technique at lod_index 0.
Format:
lod_distances distance_1 [distance_2 ... distance_n]
Example:
lod_distances 300.0 600.5 1200
The above example would cause the material to use the best technique at lod_index 0 up to a distance of 300 world units, the best from lod_index 1 from 300 up to 600, lod_index 2 from 600 to 1200, and lod_index 3 from 1200 upwards.
This document is based on the OGRE Manual and is licensed under the Creative Commons Attribution-ShareAlike 2.5 License.
