Mixedrealitytoolkit-unity: "Enable Instancing" in StandardFast doesn't enable GPU Instancing

Created on 15 Jul 2017  路  6Comments  路  Source: microsoft/MixedRealityToolkit-Unity

Hello all-

I'm building a HoloLens app, and GPU instancing would improve performance significantly in some cases. The issue is that checking "Enable Instancing" in a material using HoloToolkit/StandardFast doesn't enable instancing, whereas checking the same box for Unity's Standard does. I really prefer to use HoloToolkit/FastConfigurable, but "Enable Instancing" isn't exposed (enhancement request, please!).

To reproduce, create a new project set up with HoloToolkit. Create 2 materials, one with Standard and one with HoloToolkit/StandardFast, both with "Enable Instancing" checked. Add a GameObject with this script:
```C#
public Material Material;

void Start () {

var gameObj = new GameObject("TRIANGLE");
gameObj.transform.position = new Vector3(-1, 0, 2);

var mesh = new Mesh();
mesh.vertices = new[] { new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(0, 1, 0) };
mesh.triangles = new[] { 2, 1, 0 };
mesh.RecalculateNormals();

gameObj.AddComponent<MeshFilter>().sharedMesh = mesh;
gameObj.AddComponent<MeshRenderer>().sharedMaterial = Material;

Instantiate(gameObj, new Vector3(0, 0, 2), Quaternion.identity);
Instantiate(gameObj, new Vector3(1, 0, 2), Quaternion.identity);

}
```
Drag the Standard material to the script field.

Play. In the Frame Debug window you'll see "Draw Mesh (instanced) TRIANGLE". That's what I'm looking for.

Switch the field to StandardFast and repeat. You'll see "Dynamic Batch".

Unfortunately, most of my instance-able meshes are oversize for dynamic batching. If we disable batching in the player settings we see that this results in more draw call overhead.

Thanks everyone!

Question

All 6 comments

@dbastienMS any idea?

Everything should be migrated to FastConfigurable. I haven't done any testing on the earlier shaders since their release. FastConfigurable is a superset of existing functionality and is faster and easier to use as well.

StandardFast in particular is a dangerous red herring - at the time Unity tied Standard shader perf tradeoffs to the shader model supported and special cases for specific consoles, etc.

This is no longer the case, so StandardFast should be removed. Additionally, it isn't performant enough for full screen rendering - it clocks in somewhere around 70 ALU ops.

We've got an open issue to remove this following shaders if someone can help out:
BlinnPhongConfigurable
BlinnPhongConfigurableTransparent
LambertianConfigurable
LambertianConfigurableTransparent
StandardFast
UnlitConfigurable
UnlitConfigurableTransparent
VertexLitConfigurable
VertexLitConfigurableTransparent

@dbastienMS do you remember which issue we had open for this? I might go ahead and take care of it now.

You are a true hero of the three kingdoms!
It was surprisingly hard to find: https://github.com/Microsoft/HoloToolkit-Unity/issues/628

I guess I'm missing something, but I have the same question about GPU Instancing on the FastConfigurable shader.

@bkfichter the FastConfigurable shader is being replaced by a new shading system which you can find in the Dev_Working_Branch. here is the specific shader and material editor.

Using this new shader may help with your scenario if you are still experiencing issues with the FastConfigurable shader.

Was this page helpful?
0 / 5 - 0 ratings