之前一直在用 cocos2dx 的 cocosStudio 自带的骨骼动画
但是为了由于Spine支持网格动画,于是手头的项目都转到支持Spine的骨骼的说。

最近想做一个动画倒播的功能,在之前的 cocosStudio 中,可以通过 API, gotoAndStop(frame) 来实现倒播
到了 Spine 里,貌似就没有这个功能啦

嘛~研究了一下,貌似改起来难度不高。。 自己的本本没装各种编程软件。。。(游戏本嘛) 只有Flash Profession CC, 于是就拿 AS3版本来改改先啦。

话说Spine也是蛮搞的,C++ 版本要合并 Spine C 和 Spine cocos2dx. 而 Flash版本要合并 Spine flash 和 Spine Starling. 而且还没有完整API,丰富的范例(就2个。。还没体现所有功能)

就拿AS3的版本举例好了,最后说下C++中对应的关系就行了
Continue reading

很久没有发全技术文章了。。。
今天折腾了几个小时,终于编译成功一个复杂的cocos2d-x-2.x 项目了。。其中遇到的坑数都数不过来。

1.资源目录中不能包含中文路径,否则打包失败

2.XML配置表中不能包含全角符号,否则加载失败

3.在部分低端手机上,SpriteSheet 的大小达不到 2048 * 2048 会导致闪退

由于项目使用了rapidxml, 而 rapidxml 又调用了 Boost 所以这里要编译boost的相关库
boost_system 和 boost_iostreams

Boost相关问题

4.Boost的HPP文件,不需要加入 Android.mk 中,这是一个类似于.h文件一样的东西,不需要填

5.Boost的库需要用NDK打包成库
1)下载最新的Boost 1.55 http://iweb.dl.sourceforge.net/project/boost/boost/1.55.0/boost_1_55_0.zip
2)使用cygwin 编译 bootstrap.sh 生成 b2.exe, bjam.exe
3)修改 /tools/build/v2/user-config.jam 内容如下

Continue reading

终于把闪之轨迹通关了~

话说闪轨的梗真的好多。

比如校舍第七层的最终BOSS场景,就是Fate Stay Night 中 Archer的无限剑制呀

kiseiki1

最终BOSS的高达战,又满满的 异度装甲 的即视感。。。十几年前的游戏了。。

闪轨

kiseiki2

异度装甲

最后的最后,今天想把 CCSpriteWithFilter 放到手机上测试的时候,发现不设置滤镜的话,默认根本不显示。。 然后是 GodRay滤镜会直接把程序弄崩溃了。。

GodRay的问题我在PC上测试本来是木有问题的,看来手机上的OpenglES 更加严格的说。。。 抱歉之前一直都没有真机测试的说了。

在实际过程中发现
手机上的OpenglES 是强类型的, 不同类型运算比如int / float 会崩溃。
uniform 设置初始值会崩溃
给float 赋值时末尾带f会崩溃
等等。。。
看来以后要多注意这方面的差别了。

好了,今天给修复了。
https://github.com/dreamfairy/cocos2dx-2.x-filters/
GodRay 在我的小霸王手机上测试大概20帧的样子,实际上可以通过修改采样数来提高帧数的说

真机截屏,华为荣耀3(前几天差点给摔碎了 :p )
godrayhw

GodRay APK (小米手机勿下,会闪退)
http://pan.baidu.com/s/1CPmuq

周末去看了韩寒的 《后会无期》。。真TM文艺。。。 我心目中的大仁哥的形象完全毁了,变成蠢萌了。。。 不过还好票价靠谱,只有40元,不像邓超的《分手大师》那么坑爹的要80.
电影给我的感觉是 人们生活中的每一个过客,有一天也许就那么突然消失了,确实有许多伤感呀。。、
不过电影的结局也给人一样的感觉。。突然的结束了。

这周无所事事,顺便把之前捕鱼达人的扭曲shader移植到我的扩展类里了叫 CCWaveFilter.

之前的索引地址:
http://www.dreamfairy.cn/blog/index.php/2013/08/26/migration-apply-wave-filter-in-cocos2d-x-from-agal.html

git地址 : https://github.com/dreamfairy/cocos2dx-2.x-filters/tree/master/class

再丢个预览图吧~
jdfw

每周都想喷一次触控。 shader 的 uniform 拜托您别一直该了行吗。。。当年2.1.3您改了一次,现在2.2.4 您又改。。
顺便吐槽下。做 CCS版的大爷,劳烦您提前退休吧,别做死了。

原本计划2周的,没想到一周就基本搞定了。
发几张截图的说

全屏转风车
danmu1

黑洞 吸引视界内的弹幕
danmu2

激光
danmu3

可编程的弹幕系统,可以生成各种弹幕花纹图案等….

btw,前几天入了闪轨。。300大洋,又败家了。。。

QQ20140712224340

end
看完邓超的 《分手大师》后我觉得。。画面太美,我根本不敢看,尤其是你洗澡的时候丢肥皂的那个眼神…

cocso2dxgodray

可以通过网盘下载gif看看动态效果
http://pan.baidu.com/s/1jGoRER0

也可以看看移植前的stage3D版本的效果
http://www.dreamfairy.cn/blog/index.php/2014/05/10/create-a-god-ray-effect-in-stage3d.html

又一个月没写博客了,先吐槽下,怎么广告这么多。。。 每天都要删,插件都顶不住了。
然后再吐槽下之前某网友好像是叫as3er的看了我的god ray教程,然后自己在away3d中实现了但是缺少了遮挡这个god ray中最体现效果的功能。 这先不说,这位同学看就看了,理解了就好了嘛,反而不满我不发源码~ 我也不知道该说啥 摊手. 国内的开源社区条件是一直很恶劣的,以前我也完整开源,现在只能有选择的开源了,我还没有那么伟大到不用考虑薪水问题,而无私贡献。之前廖成在 Particle 做的 幻影和热流效果就不开源,我做了详细的讲解但也不开源,没有必要跟他人起矛盾,但我觉得对于有经验的程序员这些讲解已经足够了。

回归正题,cocos2dx纯粹的代码堆积,毫无美感,这是用了一段时间的体会,API的不稳定也是大忌,有点赞同云风大叔的想法了。 最近要在 CCSprite 上做各种效果,以网络上的教程来说,只能创建多个 自定义CCSprite, 每个特定滤镜,最后不断切换。。。 对于从AS毕业的我来说,太坑了。

于是打算实现带滤镜接口的CCSprite,我没有一部分程序员的毛病,比如重复造轮子,触控的程序员估计大部分都有这毛病,看看cocos2dx中大量的重复功能函数库。 于是找到了 zrong 同学写的 CCFilteredSprite github 上在这里
https://github.com/zrong/cocos2d-x-filters 而且这货在 quick 和 cocos2dx 3.x 中貌似继承了。 由于我不想装win8, 所以用不了 3.x , 因为是开发弹幕游戏,担心lua顶不住,不能用quick. 又因为项目是用 cocos2dx 2.2.4 搞的,这个库不完全兼容,所以只能做修改或者重写了。

我试着重现AS3 的 多个滤镜,但是 cocos2dx 在 2.x 版本对于 renderTexture 的封装。。。无力吐槽, 要实现仅能大改了,于是放弃了这个想法,还是单个滤镜吧。

接下来上代码
Continue reading

–Opengl 超级宝典我已经决定放弃不看了,太尼玛坑了,为了运行个Demo,去捣鼓作者的工具类库,但是这本书可是面向小白的,工具类库又是各种恶心的问题不能用,要有一定经验的人才能解决,简直本末倒置~

so~ 我决定看 Opengl 编程指南了, 目前看到第六章感觉良好~
Opengl的配置不打算开新贴了,直接挤在这里~
第六章的Demo blendeqn.c 是Opengl的混合模式,里面用到了glBlendEquation API 这是Opengl的API,因此要么使用 glutext 扩展,要么直接使用 glew 我选择后者。 可是在编译的时候,各种找不到 glew 的相关定义,造成这种问题的一般都是 dll 或者 lib 的位置问题。
于是我按照网上的教程放它们

.h文件放到 VS/VC/include 中
.lib 放到 VS/VC/lib 中
.dll 放到 system32 中

结果编译项目,还是符号错误。 之后我在 glew 的 binary 文件中有看到 x64的版本。 我估计可能我是 win7 x64系统,就必须用x64版本的glew. 于是 .dll 文件就丢到了 SYSWOW64 目录下,结果编译失败。一番寻找,让我在 VS/VC/lib 目录下居然找到了个 amd64 的目录(真坑) 把 .lib 丢到 这个目录下。 终于未知定义的错误没了。 但是给我弹出 找不到符号的错误,在各种系统相关的dll中, 搜索了一番,这个还算好解决 直接 VS菜单 调试 -> 选项和设置 -> 常规 -> 打勾源服务器支持 / 调试 -> 选项和设置 -> 符号 -> Microsoft符号服务器 。 之后编译项目,还是报错 0xc000007b 错误。 最后的最后,我考虑下只有一种可能性了。
glew 的包中提供了 win32 和 win64 的2个版本,之前是 win64 丢到 syswow64 , win32 丢到 system32 目录下。这一次, 我把 glew 的win32中的文件,也丢到 syswowo64 下, 终于编译成功了。。总之,好坑~~

这里是华丽的分割线———————

最近在从stage3D转向到opengl开发,于是入手了 Opengl超级宝典第五版。 结果SB5 工具库各种恶心的环境搭建,耗费了3个多小时,最终放弃。 于是转向用 第四版学习。

进度蛮顺利的,第一天就看到第四章 (跟stage3D大同小异,API的变种版本而已,很多都是跳着看的)

结果编译 transformGl 的时候出错了。

这2个API 报错

gltDrawTorus
m3dRotationMatrix44

error LNK2019: 无法解析的外部符号 “void __cdecl gltDrawTorus(float,float,int,int)” (?gltDrawTorus@@YAXMMHH@Z),该符号在函数 “void __cdecl RenderScene(void)” (?RenderScene@@YAXXZ) 中被引用

看到这个就知道是函数没有具体实现的问题,于是到 shared 里做文档内部搜索
最后发现 gltDrawTorus 的实现在 gltools.cpp 里,m3dRotationMatrix44 的实现在 math3d.cpp 里,果断将这2个cpp引入到项目中,之后继续编译出现新的错误

gltools.obj : error LNK2001: unresolved external symbol _pglCreateShaderObjectARB
gltools.obj : error LNK2001: unresolved external symbol _pglCreateProgramObjectARB
gltools.obj : error LNK2001: unresolved external symbol _pglLinkProgramARB
gltools.obj : error LNK2001: unresolved external symbol _pglShaderSourceARB
gltools.obj : error LNK2001: unresolved external symbol _pglGetObjectParameterivARB
gltools.obj : error LNK2001: unresolved external symbol _pglAttachObjectARB
gltools.obj : error LNK2001: unresolved external symbol _pglDeleteObjectARB
gltools.obj : error LNK2001: unresolved external symbol _pglCompileShaderARB

=。= 真是命运多舛

于是一口气全部在项目中定义掉,终于编译成功

M$[TT~HOWND`MS]SXJYN~6D

like this

PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;
PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
PFNGLUNIFORM4FARBPROC glUniform4fARB;
PFNGLUNIFORM1IARBPROC glUniform1iARB;

好了,先去爽下 “Watch Dog” !

传说中的上帝之光

实际上 上帝之光有2种实现方式
1.真的光
2.使用阴影体

阴影体的Demo 在前两篇文章里就有了。
本文是使用真实光来做

直接上Demo

具体做法,参考Demo中的左上角两张Debug图。

将所有遮挡物和光圈都渲染到纹理
然后在片段着色器中判断像素的颜色,是光圈则加亮,不是光圈则设置为无像素,有时候某些材质的颜色会近似光圈颜色,因此在渲染遮挡物的时候,直接将它们的Color输出为0即可,只需要它们的轮廓。
将光圈渲染到纹理并混合之前的轮廓纹理图,这样就能制造出被遮挡的光圈(残缺的光圈), 同时根据光圈的位置,对光圈的像素做指向性衰减像素采样。
最后和主场景的RTT混合即可。

ps: 原本想做HDR的, 但是10张的RTT性能实在是坑不起,还是算了。 过几天把这个GodRay 整合到之前的水体反射里看看效果。

childoflight

休刊,休刊!
哈哈~光之子,应该是今年最赞的2D游戏了,音乐也是最高的说~~ 话说最近又是游戏荒啊,蜘蛛侠肯定是个坑就不玩了。 下下周就是独角兽最终话啦。

AGAL2

After a bit of a start and stop first round, the Adobe team recently stated that they were back and working on the AGAL2 specification, a feature that was previously available in an earlier beta version of the Flash player, but later dropped but a feature set that I had been eagerly awaiting.

Anyone who joined us at the last Stage3D online conference will have seen the Adobe Flash team showing off some of the great new player features, which included demonstrations of AGAL2 in action, amongst other features. Today, I’m really excited to see that the new beta player is available for download and the AGAL2 features will be available publicly in the next iteration, which is scheduled for public release next month. Meanwhile, we can download the latest beta player from Adobe labs:

 

What’s new in AGAL2?

AGAL2?offers a set of additional features that can be used to improve the visual fidelity of rendering output in your Stage3D projects. This means that Flash graphics are about to got a lot sexier. Features such as MRT help to increase the speed of rendering by referencing multiple render to target textures from within a single shader pass, we have additional features and memory space.?So what can you expect to be playing with? Here is a quick overview of some of the new features:

  • Multiple Render Texture (MRT)
  • Anisotropic filters
  • Conditional forward jump
  • Increases in register space
  • Floating point textures (RGBA_HALF_FLOAT)
  • Partial derivatives (ddx, ddy)
  • Fragment depth (od)
  • Texture anti-aliasing

 

Multiple Render Targets (MRT)

MRT is a feature that will allow a shader to access a number of addressable render targets. This is useful when considering the concepts used in deferred rendering. Deferred rendering is a technique in which multiple images are rendered sequentially and then those images are composited back into a final result. The memory space used during this process is often referred to as the GBuffer and will contain channels such as; albedo, light, normals, depth etc. There are a number of advantages to this technique, perhaps most notably, the ability to render lights to an independent light map, which is then combined with the scene accordingly.

deferred-shading

 

Anisotropic Filtering

Anisotropic filtering is used to improve the artifacts that are caused by viewing a surface at an oblique angle. The image below illustrates the difference in output quality where the texture on the right is being anisotropically filtered.

anisotropic-compare

To make use of this feature is very simple. A new sampler parameter is now available that can be placed within a tex operation as such:

tex ft0, v0, fs0 <2d,anisotropic8x,miplinear,wrap,dxt1>

The anisotropic sampler parameters can be any of the following:

  • anisotropic2x
  • anisotropic4x
  • anisotropic8x
  • anisotropic16x

 

Conditional Forward Jump

If you are familiar with an?if?statement, you are already well equipped to dealing with conditional jumps on the GPU if you’ve used that with an?else?statement, then you’re really ready to roll. Prior to this, AGAL required various hacks to achieve similar functionality with branching that required checks against register data. The conditional flow controls of AGAL2 allow for execution of shader code upon a particular condition. These operations are:

  • IFE – (if equal)
  • INE – (if not equal)
  • IFG – (if greater than)
  • IFL – (if less than)
  • ELS – (else)
  • EIF – (else if)

Collectively they serve to provide developers with more granular control over the flow of their shader programs but I must add a quick note to say they should be used judiciously. Using conditional statements inherently means that you will be using more operations, which can impact the performance of your shader code. That being said, conditionals are great when used to simplify workflow and their advantages often outweigh the negative performance hit. It’s probably wise to see what works best and monitor execution speed of your shaders. There is always Adobe Scout or Intel GPA etc for such tasks?;)

 

Increased Register Space

In the previous AGAL spec, we had access to the usual set of registers. Vertex and fragment registers were made available, allowing us to intermediately store resources and make them available to the programmable graphic pipeline. Whilst this is exactly the same with AGAL2, the amount of memory that each shader can access has been increased. Here is a chart that shows a comparison between the numbers of available registers.

AGAL Resisters

We can see from the table that we have access to well over double the number of registers on most registers. Possibly the two most notable would be the number of tokens that can be used, which directly translates to the overall size of your shader programs, and the VC register. My guess is that the large increase of the VC register is balanced like this for one important reason, bone animation. Bone animations are used for manipulating vertices, the technique is also known as skinning, and requires that either matrices or quaternions are uploaded to the GPU via the VC register. The original AGAL spec was quite limited in this regard but the increase means that more than double the number of bones can be uploaded, offering the ability to produce more detailed animations.

 

Half Time Conclusion

Well, that’s half way!?We can see that Adobe are really bringing exciting and much awaited set of features and?whilst many of them are nothing new to the 3D community, it’s important to realize that the emphasis for Adobe is on platform reach. Adobe are seemingly striving to provide cross platform GPU support to as many users as possible by offering subsets of features that target as many GPU chipsets as possible. In this regard, it makes complete sense that the Flash Player team are trying to ensure that Stage3D doesn’t need to fall back on its software rendering mode and the result of that is a good overall experience to the end-users.

 

引用:http://plugin.io/agal2-is-here/