unity游戏优化(第2版) 第三章 批处理的优势

主要参考:https://zhuanlan.zhihu.com/p/390456989  

  https://forum.unity.com/threads/confused-on-batching.1115887/    链接中 bgolus 的评论

 

 

几个概念1.DrawCall  2.Batch   3.Static Batch   4.Dynamic Batch

    

    单渲染线程。    

    drawcall:cpu发送指令给gpu的过程

    batch: Batch一般指经过打包之后的 Draw call 。 带有渲染状态的drawcall

    渲染状态:各种渲染模式。。各种test Mode、 shader、 light  ( ID3D11DepthStencilState   ID3D11RasterizerState  FillMode CullMode FrontCounterClockwise DepthClipEnable 。。。。。) 

    更改渲染状态是耗时的过程

注意点: 1.侧重点,static:消耗内存   Dynamic:cpu计算压力

      static是将多个同material的mesh合并成一个大的vertex buff和 indexbuff , 加载并上传这个大的buff 给GPU

           dynamic是cpu把多个同material的mesh 转化成 worldcoord 传给GPU

      

     2. Dynamic 在Cpu传输到GPU前 需要把多个同material的mesh 的顶点数据全部转化到WorldCoord下。 (原因:如果不在一个worldcoord下,每个mesh中shader内的unity_ObjectToWorld是不同的,则在vertexShader内无法单一指令进行转化。 )

 There's only one unity_ObjectToWorld  matrix used on a batched mesh, any batched mesh, and it's an identity matrix: no scale, no rotation, no translation. It assumes the mesh is being rendered placed at the center of the world, because it is.

  

 

posted @   sun_dust_shadow  阅读(109)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示