srp——gpu instance

https://catlikecoding.com/unity/tutorials/custom-srp/draw-calls/
what UnityInstancing.hlsl does is redefine thouse macros to access the instanced data arrays instead.
but to make that work it needs to know the index of the object that is currently being rendered. the index is provided via the vertex data, so we have to make it available. UnityInstancing.hlsl defines macros to
make this easy, but they assume that our vertex function has a struct parameter.

when gpu instancing is used the object index is also available as a vertex attribute. we can add it when appropriate by simply putting UNITY_VERTEX_INPUT_INSTANCE_ID inside Attribtues.

struct Attributes {
	float3 positionOS : POSITION;
	UNITY_VERTEX_INPUT_INSTANCE_ID
};

2.5 dynamic batching
there is a third method of reducing draw calls, known as dynamic batching.
this is an old technique that combines multiple small meshes that share the same material into a single larger mesh that gets draw instead.
this also does not work when per-object material properties are used.

关于动态和gpu instance的补充
1、如果两者同时存在,那么gpu instance的优先级高于动态合批
2、如果gi会影响合批处理

你可能感兴趣的:(Unity)