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會影響合批處理

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章