Instancing

Instancing allows draw multiple instances of the
same mesh with a single draw call. Given a scene that contains many objects that
use the same geometry, you can draw many instances of that geometry at different
orientations, sizes, with dramatically better performance by reducing the amount
of data you need to supply to the renderer. This technique is useful for
rendering massive similar objects such as woods, vegetation.
In Awakening, moblie, skinmesh, and cloth supports
instancing; you can first select a mesh, and check it's 'Bump'
style, then do Edit > Copy
, then use
Edit > Instanced Paste to create a
instancing mesh; you can clone the instancing mesh to generate massive objects.
Also, there is a 'cloneInstance()'
function in script api for movable objects. The
Select > Select Objects By Instance ID
command can select all similar instancing meshs.
You need assign material with corresponding shader to instancing mesh for correct instancing rendering. All instancing shader files can be found at the "effects\instancing" folder. You need check 3d object's 'Bump' style to use the shader.
For shader coding, there is a preset variable ' _bInstancing ' to indicates whether instancing rendering is on ( instancing technique needs vs_3_0 device, so the ' _bInstancing ' is false on graphics hardware that does not support vs_3_0 ); and there is a console variable 'r_instancing' for turning on/off instancing.
Shader File |
Applicable Object | Explanation |
| instancing\mobile.fx | mobile, cloth | Two lights vertex lighting |
| instancing\mobile_dot3.fx | mobile, cloth | Two lights pixel lighting (set normal map to the 1st texture of material, and check material's Sepcular Enable style if you want specular lighting.) |
| instancing\mobile_depth.fx | mobile, cloth | for depth rendering, should be used in depth material. |
| instancing\skinmesh.fx | skin mesh | Two lights vertex lighting |
| instancing\skinmesh_dot3.fx | skin mesh | Two lights pixel lighting (set normal map to the 1st texture of material, and check material's Sepcular Enable style if you want specular lighting.) |
| instancing\skinmesh_depth.fx | skin mesh | for depth rendering, should be used in depth material. |
Remark: All shaders list here also applicable to no-instanced mesh.