<bdo id='8pDsA'></bdo><ul id='8pDsA'></ul>

      <i id='8pDsA'><tr id='8pDsA'><dt id='8pDsA'><q id='8pDsA'><span id='8pDsA'><b id='8pDsA'><form id='8pDsA'><ins id='8pDsA'></ins><ul id='8pDsA'></ul><sub id='8pDsA'></sub></form><legend id='8pDsA'></legend><bdo id='8pDsA'><pre id='8pDsA'><center id='8pDsA'></center></pre></bdo></b><th id='8pDsA'></th></span></q></dt></tr></i><div id='8pDsA'><tfoot id='8pDsA'></tfoot><dl id='8pDsA'><fieldset id='8pDsA'></fieldset></dl></div>
      <legend id='8pDsA'><style id='8pDsA'><dir id='8pDsA'><q id='8pDsA'></q></dir></style></legend>
      <tfoot id='8pDsA'></tfoot>

      1. <small id='8pDsA'></small><noframes id='8pDsA'>

        Cocos2d - iPhone 上的月食效果

        Cocos2d - lunar eclipse effect on iPhone(Cocos2d - iPhone 上的月食效果)

          <tfoot id='rCAdu'></tfoot>

              <i id='rCAdu'><tr id='rCAdu'><dt id='rCAdu'><q id='rCAdu'><span id='rCAdu'><b id='rCAdu'><form id='rCAdu'><ins id='rCAdu'></ins><ul id='rCAdu'></ul><sub id='rCAdu'></sub></form><legend id='rCAdu'></legend><bdo id='rCAdu'><pre id='rCAdu'><center id='rCAdu'></center></pre></bdo></b><th id='rCAdu'></th></span></q></dt></tr></i><div id='rCAdu'><tfoot id='rCAdu'></tfoot><dl id='rCAdu'><fieldset id='rCAdu'></fieldset></dl></div>
                <tbody id='rCAdu'></tbody>
              1. <legend id='rCAdu'><style id='rCAdu'><dir id='rCAdu'><q id='rCAdu'></q></dir></style></legend>

                <small id='rCAdu'></small><noframes id='rCAdu'>

                  <bdo id='rCAdu'></bdo><ul id='rCAdu'></ul>
                  本文介绍了Cocos2d - iPhone 上的月食效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个关于实现像月食这样的效果的问题.效果应该看起来像这个 gif 的前几秒.所以就像一个黑色的阴影越过圆圈.理想的情况是一个函数,我可以传递一个百分比参数来获得这个数量作为圆圈上的阴影:

                  我面临的问题是我的背景是渐变的.所以不可能有一个在月球上移动的黑色圆圈来获得效果.

                  我用 CCClippingNode 尝试了一些东西,但它看起来不太好.此外,边缘的剪辑总是有点像素化.

                  我曾想过使用 GLSL Shader 之类的东西来实现效果,但我对 GLSL 不太熟悉,也找不到示例.

                  效果适用于为 iphone 开发的应用游戏.我使用的是版本3(当前版本)的cocos2d框架.

                  有人知道如何获得这种效果吗?我可以从哪里开始搜索?

                  提前谢谢你

                  解决方案

                • 计算月亮的每个渲染像素

                  你显然有月亮的 2D 纹理.因此,您现在需要获取 1D 光照纹理内每个像素的位置.因此,如果月亮完全可见,那么您就处于阳光下.当部分黯然失色时,您处于本影区域.最后,当日全食时,你在半影区.所以只需计算月球位置的中点.其余的使用卫星运动方向的相对位置.

                  所以现在只需将月球表面与光照纹理相乘并渲染输出.

                • 工作时可以添加曲率校正

                  现在您得到了线性切割的月相,但实际月相是弯曲的,因为照明条件也随着与运动方向和卫星中心的径向距离而异.要解决此问题,您可以这样做

                  • 将光照转换为 2D 纹理
                  • 或根据径向距离将纹理坐标移动一些曲率
                • i have a question about achieving an effect like on a lunar eclipse. The effect should look like in the first seconds of this gif. So just like a black shadow which goes over the circle. The ideal situation would be a function where i can passed a parameter in percentage to get this amount as a shadow on the circle:

                  The problem which i am facing is that my background is an gradient. So it's not possible to have a black circle which moves over the moon to get the effect.

                  I tried something with CCClippingNode but it looks not nice. Furthermore the clip on the edges was always a bit pixelated.

                  I thought about using something like a GLSL Shader to achieve the effect but i am not so familiar with GLSL and i can't find an example.

                  The effect is for an app game developed for an iphone. I use the cocos2d framework in version 3 (the current one).

                  Has somebody an idea how to get this effect? An idea where i can start to search?

                  Thank you in advance

                  解决方案

                  The physics behind is simple you change the light shining on the moon. So

                  1. I would create a 1D gradient texture representing the lighting conditions

                  2. compute each rendered pixel of moon

                    you obviously have the 2D texture of moon. So you now need to obtain the position of each pixel inside the 1D lighting texture. So if moon is fully visible you are in sunlight. When partially eclipsed then you are in the umbra region. And finaly while total eclipse you are in penumbra region. so just compute the middle point's of the moon position. And for the rest use relative position in the moons motion direction.

                    So now just multiply the Moon surface with the lighting texture and render the output.

                  3. when working you can add the curvature correction

                    Now you got linerly cutted Moon phases but the real phases are curved as the lighting conditions differs also with radial distance from motion direction and moons center. To fix this you can do

                    • convert the lighting to 2D texture
                    • or shift the texture coordinate by some curvature dependent on the radial distance

                  这篇关于Cocos2d - iPhone 上的月食效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                  Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)
                  Resume game cocos2d(恢复游戏 cocos2d)
                  Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))
                  Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
                  How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)

                    • <bdo id='6ESA1'></bdo><ul id='6ESA1'></ul>

                      1. <legend id='6ESA1'><style id='6ESA1'><dir id='6ESA1'><q id='6ESA1'></q></dir></style></legend>
                      2. <small id='6ESA1'></small><noframes id='6ESA1'>

                        <i id='6ESA1'><tr id='6ESA1'><dt id='6ESA1'><q id='6ESA1'><span id='6ESA1'><b id='6ESA1'><form id='6ESA1'><ins id='6ESA1'></ins><ul id='6ESA1'></ul><sub id='6ESA1'></sub></form><legend id='6ESA1'></legend><bdo id='6ESA1'><pre id='6ESA1'><center id='6ESA1'></center></pre></bdo></b><th id='6ESA1'></th></span></q></dt></tr></i><div id='6ESA1'><tfoot id='6ESA1'></tfoot><dl id='6ESA1'><fieldset id='6ESA1'></fieldset></dl></div>
                          <tfoot id='6ESA1'></tfoot>
                            <tbody id='6ESA1'></tbody>