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会影响合批处理

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值