Author : http://www.cnblogs.com/open-coder/p/3982999.html

During the last few months, I have been working on the Graphics and shader optimization work. 
Good FPS is the balance between art and technocal. A good designed level  and game play should take account the potional performance issue. After the optimization work on the high level was done, we could deep into the lower level, and do some invistigation of shader part.
Here are some tips that you could try:
1) Don’t reinvent the wheel, use instrinsic functions; Some one would like to write his own ‘dot’ function, this is not allowed;
2) Use the most appropriate data types in calculations (float, float2, float3 and float4);
3) Get rid of typecasting when it’s not need. Such as convert float3 to float4, float to float4, fixed to half, half to float…
4) Instead of integers rely on floats for math;
5) When indexing into arrays of constants use integers instead of floats;
6) Combine scalar constants into full vectors, pack array elements into full constant vectors;
7) For conditional compilation use boolean constants declared as static;
8) Whennever possible vectorize code by joining similar operations together;
9) Do not use expensive functions, such as  log, exp, pow, sin, cos;
10) Well arrange the variable calculations among application objects, per vertex and per fragment. Per fragment is the most expensive, per vertex is less expensive, and per object is cheap;
11) Get rid of clip as possible, some one will suggest use alpha blend to replace alpah test;
12) Remove branch statements. Some powerful device will support branch well, like K1 device uber-shader;
13) Reduce the bandwith that pass from vertex shader to fragment shader;
14) Use constant variables when you could make sure what those value is:
15) Be careful on the precision such as float, half, fixed. Use theme properly, and get rid of typecast whenever possible.

 

Reference
http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Dark_Secrets_of_shader_Dev-Mojo.pdf
http://blog.hvidtfeldts.net/index.php/2011/07/optimizing-glsl-code/
http://hi.baidu.com/haibo19981984/item/fef0a36de646e508a1cf0f93

Shader Optimization Tips的更多相关文章

  1. 10 Python Optimization Tips and Issues

    转自: http://www.algorithm.co.il/blogs/computer-science/10-python-optimization-tips-and-issues/

  2. Unity 5 Game Optimization (Chris Dickinson 著)

    1. Detecting Performance Issues 2. Scripting Strategies 3. The Benefits of Batching 4. Kickstart You ...

  3. u3d 性能优化

    http://blog.csdn.net/candycat1992/article/details/42127811 写在前面 这一篇是在Digital Tutors的一个系列教程的基础上总结扩展而得 ...

  4. 【Unity技巧】Unity中的优化技术

    http://blog.csdn.net/candycat1992/article/details/42127811 写在前面 这一篇是在Digital Tutors的一个系列教程的基础上总结扩展而得 ...

  5. Unity中的优化技术

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/candycat1992/article/ ...

  6. WWDC 2016 盛宴

    转自:http://www.jianshu.com/p/72dd8306c817 整理和维护人:pmstGitHub 链接:WWDC-2016-Feast目前只是整理官方给出的 WWDC 2016 视 ...

  7. Unity性能优化(2)-官方教程Diagnosing performance problems using the Profiler window翻译

    本文是Unity官方教程,性能优化系列的第二篇<Diagnosing performance problems using the Profiler window>的简单翻译. 相关文章: ...

  8. [译]使用AES 256以达到SSL/TLS安全最大化

    原文链接:https://luxsci.com/blog/256-bit-aes-encryption-for-ssl-and-tls-maximal-security.html 原文发表时间:201 ...

  9. HHVM 是如何提升 PHP 性能的?

    背景 HHVM 是 Facebook 开发的高性能 PHP 虚拟机,宣称比官方的快9倍,我很好奇,于是抽空简单了解了一下,并整理出这篇文章,希望能回答清楚两方面的问题: HHVM 到底靠谱么?是否可以 ...

随机推荐

  1. JavaScript练习笔记整理·4 - 6.26

    基础练习(1): 我的解答为: function getMiddle(s) { if(s.length%2 == 0) { return s.charAt(s.length/2-1)+s.charAt ...

  2. vue的事件

    vue的事件: vue事件简写: vue中事件是 v-on:click=' show()'    但是我嫌弃它写太长每次都要 v-on: 事件 vue中就有事件简写   @click='show()' ...

  3. Linux Centos7安装Oracle12c第二版本

    环境: CentOS7@VMware12,分配资源:CPU:2颗,内存:4GB,硬盘空间:30GB Oracle12C企业版64位 下载地址:http://www.oracle.com/technet ...

  4. Hibernate (ORM)

    1 框架体系结构 2 hibernate入门 2.1 ORM框架 Hibernate是一个数据持久化层的ORM框架. Object:对象,java对象,此处特指JavaBean Relational: ...

  5. How to install the NVIDIA drivers on Ubuntu 18.04 Bionic Beaver Linux

    Objective The objective is to install the NVIDIA drivers on Ubuntu 18.04 Bionic Beaver Linux. This a ...

  6. canvas中的非零环绕原则

    非零环绕原则: 如果需要判断某一个区域是否需要填充颜色. 就从该区域中随机的选取一个点. 从这个点拉一条直线出来, 一定要拉到图形的外面. 此时以该点为圆心.看穿过拉出的直线的线段. 如果是顺时针方向 ...

  7. SQL Server ->> 关于SQL Server Agent Job执行步骤时的用户上下文(User Context)问题

    这是最近项目相关和自己感兴趣的一个问题:SQL Server Agent Job有几种方法可以以特定用户上下文去执行任务步骤的? 这个事情需要分几种情况来说,因为对于不同类型的任务步骤,SQL Ser ...

  8. java操作svn【svnkit】实操

    SVNKit中怎样使用不同的仓库访问协议? 当你下载了最新版的SVNKit二进制文件并且准备使用它时,一个问题出现了,要创建一个库需要做哪些初始化的步骤?直接与Subversion仓库交互已经在低级层 ...

  9. DevExpress控件使用之多重坐标图形的绘制 z

    有时候,基于对一些年份.月份的统计,需要集成多个数值指标进行分析,因此就需要把多种数据放到一个图形里面展现,也成为多重坐标轴,多重坐标轴可以是多个X轴,也可以是Y轴,它们的处理方式类似.本文通过一个例 ...

  10. QT的mouseMoveEvent事件失效

    void TalkWindow::enterEvent(QEvent *event){ grabMouse();}void TalkWindow::leaveEvent(QResizeEvent *e ...