可交互水面涟漪


可交互水面涟漪

实现难点:

  1. 多点水面检测,如何传递

    1. 个人想法:通过射线检测,配合差值器的数组类型进行实现,间隔检测时间比如0.1秒,避免数据过大
  2. 水纹相互扩散的实现

    1. 个人想法:

      1. 使用一个圆形 SDF 距离扩散,设定一个最大值,达到后消失
      2. 使用粒子系统,由粒子系统进行接管水纹扩散的大小曲线控制
    2. 调研的方法:

      1. 方法一:使用有限分差波模拟。 通过一张buffer,使用纹素移动,分别采样上下左右四次,然后进行相加并与上次结果相减,乘以阻尼后写回buffer https://www.shadertoy.com/view/4sd3WB https://rice.moonedit.com/edit/?h=W2L7zN

        image-20211222160251599

      2. 方法二:使用波动方程进行计算模拟

        1. https://zhuanlan.zhihu.com/p/108845039

          https://github.com/dreamfairy/interactivity-waterplane

        image-20211222160337232

      3. 方法三:使用RT进行渲染

        1. Water Simulation using CustomRenderTexture from Unity 2017.1
        2. https://github.com/hecomi/UnityWaterSurface
        3. https://youtu.be/jclxfdS3a3w
          1. image-20211222160448854
      4. 方法四:使用粒子系统,分层渲染

        1. https://www.patreon.com/posts/24192529

          image-20211222160646357

        2. https://www.artstation.com/blogs/mattmurch/np4y/code-free-interactive-water

          image-20211222160743974

      1. 方法五:使用粒子系统加网格变形

        1. https://www.reddit.com/r/Unity3D/comments/d8yeoa/interactive_water_using_shader_graph_and_mesh/?utm_medium=android_app&utm_source=share

        2. https://catlikecoding.com/unity/tutorials/mesh-deformation/

          image-20211222160846029

      1. 方法六:使用 sin 波叠加

        ​ [Ripple Water Shader - Unity CG/C# Tutorial [Part 1/3]

        https://youtu.be/UfX9dzhBhg0

        image-20211222160933237

        image-20211222161043227

  3. 水纹扩散相交处的融合处理

    1. 个人想法:直接结果相加
    2. 调研的方法:直接相加
  4. 旧水纹与刚检测到的新水纹的叠加融合处理

    1. 个人想法:直接结果相加
    2. 调研的方法:直接相加

水纹

https://www.shadertoy.com/view/Xsd3DB

https://github.com/ya7gisa0/Unity-Wave-Propagation-Water-Ripple

image-20211222161218788

上述效果的原始版本

https://www.shadertoy.com/view/4sd3WB

https://rice.moonedit.com/edit/?h=W2L7zN

image-20211222161252398

源码

https://rice.moonedit.com/edit/?h=W2L7zN

image-20211222161318948

2D波动方程

Solving the 2D Wave Equation


文章作者: 血魂S
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 血魂S !
  目录