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中减少Draw Calls的方法,包括使用Unity Instancing.hlsl进行GPU实例化,以及动态合批技术。GPU实例化通过访问实例数据数组来提高渲染效率,而动态合批则将多个小网格组合为一个大网格进行绘制,但这些方法不适用于使用每对象材质属性的情况。

8604

被折叠的 条评论
为什么被折叠?



