报错解决 unable to unroll loop, loop does not appear to terminate in a timely manner (994 iterations) or unrolled loop is too large, use the [unroll(n)] attribute to force an exact higher number
在 Unity 写 Shader 的时候,在一个循环里面使用了 tex2D 函数,类似与下面这样:
fixed2 center = fixed2(0.5,0.5);
fixed2 uv = i.uv - center;
for (fixed j = 0; j < _Strength; j++) {
c1 += tex2D(_MainTex,uv*(1 - 0.01*j) + center).rgb;
}
打apk没什么问题,但是打win版本的时候有个报错
unable to unroll loop, loop does not appear to terminate in a timely manner (994 iterations) or unrolled loop is too large, use the [unroll(n)] attribute to force an exact higher number
can't use gradient instructions in loops with break
解决方案1.
错误提示上说了,没有办法对循环进行展开,因为展开的迭代次数太多了,快到一千次了,请使用 [unroll(n)] 特性来指定一个可能的最大值。
[unroll(88)]
fixed2 center = fixed2(0.5,0.5);
fixed2 uv = i.uv - center;
for (fixed j = 0; j < _Strength; j++) {
c1 += tex2D(_MainTex,uv*(1 - 0.01*j) + center).rgb;
}
解决方案2.
由于 tex2D 函数需要确定 LOD ,即所使用的纹理层,这才必须 unroll,如果直接使用能够指定 LOD 的 tex2Dlod,那么就可以避免了。
函数签名:
- tex2D( Sampler, IN.Texture );
- tex2Dlod( Sampler, float4( IN.Texture, 0.0f, 0.0f ) );
fixed4 center = fixed4(.5,.5,0,0);
fixed4 uv = fixed4(i.uv,0,0) - center;
for (fixed j = 0; j < _Strength; j++) {
c1 += tex2Dlod(_MainTex,uv*(1 - 0.01*j) + center).rgb;
}
解决方案3.
既然提示说不支持迭代,那么直接避免迭代就好了嘛。
参考链接
Issues with shaderProperty and for-loop[via Unity Forum]:见4楼 Dolkar 的回答,很详细了。
报错解决 unable to unroll loop, loop does not appear to terminate in a timely manner (994 iterations) or unrolled loop is too large, use the [unroll(n)] attribute to force an exact higher number的更多相关文章
- Android 工程报错解决 Unable to resolve target 'android-17'
转自:http://www.cnblogs.com/csulennon/p/3705177.html 换了系统后,重新安装了Android SDK和ADT插件,导入之前的工作空间.居然发现所有的And ...
- 修改ubuntu DNS的步骤/wget url报错: unable to resolve host address的解决方法
wget url 报错:unable to resolve host address ‘url’,显然是无法解析主机地址,这就能看出是DNS解析的问题.解决办法就是配置可用的dns 一般是修改成为谷歌 ...
- 解决报错:Unable to process Jar entry [org/springframework/jmx/export/annotation/*****]
情况说明:从gitub上clone的maven项目,pox.xml配置中的依赖,自己的repository都有,所以正常update project ,正常clean,install,整个过程无报错 ...
- npm总是报错:unable to verify the first certificate
今天npm install总是报错:unable to verify the first certificate(无法验证第一证书),查了一下发现 As of February 27, 2014, n ...
- 【Devops】【docker】【CI/CD】Jenkins自动安装JDK需要提供Oracle的账号密码,否则报错:Unable ro auto-install JDK until the license is accepted
Jenkins自动安装JDK需要提供Oracle的账号密码,否则报错:Unable ro auto-install JDK until the license is accepted 解决方法: ...
- git同步遇到报错“fatal: unable to access 'https://github.com/lizhong24/mysite2.git/': Peer reports incompatible or unsupported protocol version.”
git同步遇到报错“fatal: unable to access 'https://github.com/lizhong24/mysite2.git/': Peer reports incompat ...
- k8s集群node节点一直NotReady, 且node节点(并非master)的kubelet报错:Unable to update cni config: No networks found in /etc/cni/net.d
若要转载本文,请务必声明出处:https://www.cnblogs.com/zhongyuanzhao000/p/11401031.html 问题: 集群搭建的过程中,master节点初始化成功,但 ...
- 报错:Unable to read additional data from client sessionid 0x36ab52d38c20b20, likely client has closed socket
报错背景: CDH集群中,将kafka和Flume整合,将kafka的数据发送给Flume消费. 启动kafka的时候正常,但是启动Flume的时候出现了报错现象. 但是我检查了Flume,Flume ...
- 安装visual stdio 2017后依然报错:Unable to find vcvarsall.bat
安装visual stdio 2017后依然报错:Unable to find vcvarsall.bat 解决办法:更新setuptools 原文章:https://blog.csdn.net/wl ...
随机推荐
- Android PhotoView基本功能实现
Android开发过程中,想必都使用过PhotoView来实现图片展示的功能.在最新版的sdk(android-23)有了一个原生的photoView,并且代码实现也很简单,逻辑也很清晰.我们在实际的 ...
- HTML 创建按钮实现跳转链接
1.使用 form<form method="get" action="/page2"> <button type="submit& ...
- MySQL详解
MySQL详解 什么是数据库 # 用来存储数据的仓库 # 数据库可以在硬盘及内存中存储数据 # 数据库与文件存储数据区别 # 数据库本质也是通过文件来存储数据, 数据库的概念就是系统的管理存储数据的文 ...
- flex布局实现瀑布流排版
网上有很多有关js(jq)实现瀑布流和有关瀑布流的插件很多,例如:插件(Masonry,Wookmark等等).按照正常的逻辑思维,瀑布流的排版(item列表)一般都是 由左到右,上而下排序的结果,单 ...
- mac安装numpy,scipy,matplotlib
SaintKings-Mac-mini:~ saintking$ python Python ( , ::) [GCC Compatible Apple LLVM (clang-)] on dar ...
- OC中ARC forbids explicit message send of release错误
在ios编程中,如果成员变量为对象,我们需要对成员变量内存管理,否则,会造成内存泄露.即我们要对成员变量进行手动的内存释放. 很显然,是ARC的问题. 错误原因:在创建工程的时候点选了“Use Aut ...
- docker镜像、docker容器导入导出命令
一.docker镜像导入导出命令 导出命令: docker save -o <保存路径> <镜像名称:标签> docker save -o ./test.tar test:la ...
- Oracle基本的增删改查语句--本人使用scott用户中的表
--感觉有用点个赞^v^ 1 --创建表空间 create tablespace mykebai datafile 'c:\mykebai.dbf' --数据问价存放位置 size 100m --数据 ...
- zuul+security跨域Cors问题解决
zuul+security跨域Cors问题解决 简介 场景 在服务后台都会出现跨域cors问题,不过一般spring解决起来比较方便,在框架+框架的基础上,问题就显得特别明显了,各种冲突,不了解源码的 ...
- (全国多校重现赛一)F-Senior Pan
Senior Pan fails in his discrete math exam again. So he asks Master ZKC to give him graph theory pro ...