Code Monkey home page Code Monkey logo

meshmaterialcombine's Introduction

MeshMaterialCombine

很多时候我们需要把具有相同shader的材质球合并,从而减少drawcall的产生。
比如九龙战里面,一个人物带有10个部位,10个部位各自来自不同的fbx文件,加上身体,就有11个材质球,占上11个drawcall。如果主城里面跑着10个角色,光人物就占了110个drawcall!所以这种时候材质球合并是必须的。

材质球合并,分以下几步走,首先我们讨论普通的MeshRenderer的材质球合并,然后再讨论SkinnedMeshRenderer的材质球合并。 普通的MeshRenderer的材质球合并: 1.合并所有材质球所携带的贴图,新建一个材质球,并把合并好的贴图赋予新的材质球。 2.记录下每个被合并的贴图所处于新贴图的Rect,用一个Rect[]数组存下来。 3.合并网格,并把需要合并的各个网格的uv,根据第2步得到的Rect[]刷一遍。 4.把新的材质球赋予合并好的网格,此时就只占有1个drawcall了。

项目是用 Unity 5.3.4f1 版本创建的,低于此版本有可能运行有问题。

详情请转移到博客:http://blog.csdn.net/dardgen2015/article/details/51517860

meshmaterialcombine's People

Contributors

arbao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.