Shader Optimization Tips
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的更多相关文章
- 10 Python Optimization Tips and Issues
转自: http://www.algorithm.co.il/blogs/computer-science/10-python-optimization-tips-and-issues/
- Unity 5 Game Optimization (Chris Dickinson 著)
1. Detecting Performance Issues 2. Scripting Strategies 3. The Benefits of Batching 4. Kickstart You ...
- u3d 性能优化
http://blog.csdn.net/candycat1992/article/details/42127811 写在前面 这一篇是在Digital Tutors的一个系列教程的基础上总结扩展而得 ...
- 【Unity技巧】Unity中的优化技术
http://blog.csdn.net/candycat1992/article/details/42127811 写在前面 这一篇是在Digital Tutors的一个系列教程的基础上总结扩展而得 ...
- Unity中的优化技术
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/candycat1992/article/ ...
- WWDC 2016 盛宴
转自:http://www.jianshu.com/p/72dd8306c817 整理和维护人:pmstGitHub 链接:WWDC-2016-Feast目前只是整理官方给出的 WWDC 2016 视 ...
- Unity性能优化(2)-官方教程Diagnosing performance problems using the Profiler window翻译
本文是Unity官方教程,性能优化系列的第二篇<Diagnosing performance problems using the Profiler window>的简单翻译. 相关文章: ...
- [译]使用AES 256以达到SSL/TLS安全最大化
原文链接:https://luxsci.com/blog/256-bit-aes-encryption-for-ssl-and-tls-maximal-security.html 原文发表时间:201 ...
- HHVM 是如何提升 PHP 性能的?
背景 HHVM 是 Facebook 开发的高性能 PHP 虚拟机,宣称比官方的快9倍,我很好奇,于是抽空简单了解了一下,并整理出这篇文章,希望能回答清楚两方面的问题: HHVM 到底靠谱么?是否可以 ...
随机推荐
- Python入门-深浅拷贝
首先我们在这里先补充一下基础数据类型的一些知识: 一.循环删除 1.前面我们学了列表,字典和集合的一些操作方法:增删改查,现在我们来看一下这个问题: 有这样一个列表: lst = ['周杰伦','周润 ...
- js中常见面试问题-笔记
原文参考https://mp.weixin.qq.com/s/mCVL6qI33XeTg4YGIKt-JQ 1.事件代理给父元素添加事件,利用事件冒泡原理,在根据e.target来获取子元素<u ...
- html中块级元素和行内元素
块级元素和行内元素的三个区别 1.行内元素与块级元素直观上的区别: 行内元素会在一条直线上排列,都是同一行,水平方向排列 块级元素独占一行,垂直方向排列.块级元素从新行开始结束接着一个断行 2.块级元 ...
- C# Winform窗体和控件自适应大小
1.在项目中创建类AutoSizeForm AutoSizeForm.cs文件代码: using System; using System.Collections.Generic; using Sys ...
- 【网络编程】TCP网络编程
TCP网络程序设计 一.模型函数化 图片:TCP编程模型 1.1 创建套接字Socket #include <sys/types.h> /* See NOTES */ #include & ...
- java中复制数组的5种方法
“=”,相当于将一个数组变量的引用传递给另一个数组;如果一个数组发生改变,那么引用同一数组的变量也要发生改变.,这一种勉强算是吧 使用FOR循环,将数组的每个元素复制或者复制指定元素,不过效率差一点 ...
- Linux ->> UBuntu 14.04 LTE下主机名称和IP地址解析
UBuntu 14.04 LTE下主机名称和IP地址解析一些相关的配置文件: /etc/hosts: 主机文件.手工配置IP地址和主机名称间的映射.格式为每行一条映射条项: <machine_n ...
- Linux ->> Chmod命令改变文件/文件夹属性
简介 chmod命令用于改变linux系统文件或目录的访问权限,控制用户/用户组对文件或目录的访问权限. 用法: 两种用法:1)用字母r(读).w(写).x(执行)表示权限类型:2)用数字表示,4代表 ...
- 双十一问题:kafka消费能力低下原因思考
抛去cpu.内存等机器原因,在每个分区皆分配一个进程消费的情况下,利用扩机器来提高kafka消费速率已无能为力 此时发现,在实际洪峰时段的消费速率元达不到先前压测时的消费速率 原因思考: 1.洪峰时段 ...
- 一个SAP开发人员的2018年终总结
我是SAP成都研究院的Jerry Wang,我喂自己袋盐. 时间过得真快,2017年发生的事情还历历在目,一转眼,2018年又马上要结束了. Jerry惊恐地发现,随着年龄的增长,时光流逝的速度仿佛有 ...