Unity Shader 数据精度使用情况 float half fixed

Unity Shader 数据精度使用情况 float half fixed

Most mobile GPUs support both precision types, half being more efficient. So if you’re optimizing for mobiles it makes sense to use half as much as possible. The rule of thumb is to use float for positions and texture coordinates only and half for everything else, provided that the results are good enough.

When not targeting mobile platforms, precision isn’t an issue because the GPU always uses float, even if we write half. I’ll consistently use float in this tutorial series.

There’s also the fixed type, but it’s only really supported by old hardware that you wouldn’t target for modern apps. It’s usually equivalent to half.

来源:https://catlikecoding.com/unity/tutorials/custom-srp/draw-calls/

翻译:
大多数移动GPU都支持这两种精度类型,half类型效率要高。所以,如果你在优化移动设备,那么尽可能多地使用half是有意义的。根据使用经验,只在位置(Positions)和纹理坐标(Texture Coordinates)上使用float,其他的在结果足够好的情况下使用half。

当不针对移动平台时,精度不是问题,因为GPU总是使用浮点数,即使我们写了half。

也有fixed类型,但它只主要支持旧设备,现代应用程序不用考虑它。fixed通常就相当于half。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值