『部分工程文件点我下载』
『知乎转载链接』
『有点相关的Unreal Circle演讲』
Summary
因为本文涉及到的内容比较广,关于Niagara最基础的一些部分比如怎么新建、怎样添加使用模块就不详细说明了,没用过的同学可以先看一下Epic官方文档的介绍:
Niagara核心概念
和贾越同学的系列教学直播:
https://www.bilibili.com/video/av73602807
本次工程效果:
为了实现海浪拍到岩石上激起千层浪的感觉,我们可以看到有几个表现上的关键点
- 在岩石附近生成水花
- 水花激起的时机和位置与海水的流动匹配
- 出射速度受到海水运动和石头表面的撞击情况影响
- 激起后水花的体积感
海面的模拟 – Gerstner Waves
游戏里模拟海水的途径是一门艰深的课题,本文就不多涉及了。这里为了制作需要,介绍一下相对直观实用的Gerstner Waves。
在流体动力学中,Gerstner Waves是周期表面重力波的欧拉方程方程的精确解。它计算机图形技术之前很久就出现了,用来描述不可压缩流体的表面波动。
单一Gerstner Wave材质应用在一个平面上的效果如图:
数学时间
我们可以看到每一个点不止有Z轴方向的运动,也有XY轴的运动。并且这不是一个简单的sin波而是带有‘浪尖’的波形,这些都是Gerstner Wave的重要特征。
因为篇幅原因这里就不具体说公式了,本节末尾提供了我做好的材质节点可以直接下载取用。详细算法可以参考:
Chapter 1. Effective Water Simulation from Physical Models
https://developer.download.nvidia.com/books/HTML/gpugems/gpugems_ch01.html
简单说来,定义一个波形的属性有:
[高度, 前进方向, 波长, 陡峭度]
我们定义相位φ
φ = 方向 ⋅ 位置 / 波长 + 频率 * 时间
其中
频率 = sqrt(重力 * 2π / 波长)
那么以
z轴偏移 = 高度 * sin(φ)
xy轴偏移 = 陡峭度 * 高度 * 方向 * cos(φ)
的形式去移动海面的顶点,顶点会沿着椭圆绕圈(左图),一系列的顶点组合在一起就会形成具有浪尖的波形。
引擎内实现
在引擎里的实现可以用HLSL写在Custom节点里,你也可以选择用节点连。执行效率上,节点连出来的公式和HLSL代码没有区别。
材质函数 MF_GerstnerWave
核心部分:
float3 d = float3(sin(DirectionInDegrees * 0.0174533), cos(DirectionInDegrees * 0.0174533), 0); // 为了控制方便,输入并不是一个向量而是角度,这里转换一下
float w = 6.2831854 / L;
float theta = sqrt(6.2831854 * Gravity / L); // 由波长算出频率
float q = Stiffness / (Amplitude * w); // q是控制浪尖陡峭度的系数
float phase = dot((w * d).xy, WorldPosition.xy) – theta * Time; // 喂给cos和sin的相位
float3 offset = float3(q * Amplitude * d.xy * cos(phase), Amplitude * sin(phase)); // 照抄上面公式
这部分我放在了BlueprintUE.com里,点下面链接直接把节点复制粘贴到UE材质编辑器里就可以得到图上的节点:
https://blueprintue.com/blueprint/tt5p124n/
波形叠加
显然,一条波并不能说非常炫酷,Gerstner Wave的典型做法是把多条波叠加在一起。上面提到每条波可以控制的变量有:[高度, 前进方向, 波长, 陡峭度]
要合并多个波形,首先考虑的是波长,因为能组合的波长数量有限(8个已经很多了),我们无法完全参照真实世界的海洋数据,只能尽可能利用能付出的资源。由于波长相似的wave在叠加时看起来更有错综复杂的动态表现,我们可以在输入参数里首先给一个波长的中值LengthMedian,然后让不同wave的波长围绕这个中值变化。这样只要保留所有wave的波长与LenghMedian的比例,就可以通过改变LengthMedian来调整整个海洋的波浪大小:
在定义一组waves的结构FGerstnerWavesParameters中,美术可以在海洋的蓝图Actor上直接填写LengthMedian。
接下来,美术可以手动填写各个wave和LengthMedian的比例,也可以像我一样偷懒,填一个LengthMultiplierRange然后随机选取范围内的比例,在场景里拖动Seed直到随出一个好看的组合。
类似的方法同样适用于高度, 前进方向, 陡峭度。要注意的是,wave的高度和波长存在正相关关系,简单的做法是定义一个常数比例,让每个wave高度和和波长的比例保持一致。而在定义前进方向时会类似的给出一个DirectionRange定义前进方向的范围。
Niagara GPU粒子的生成
匹配水面位移
上面说了这么多,海面Shader内的位移数据其实并不能被外界直接读取,为了让Niagara能获取到海面的位移数据从而实现位置的同步,我们需要额外做一些工作:
方块:Niagara GPU particles
因为Gerstner Wave算法是确定性的,即给定同样的 [ 高度 | 前进方向 | 波长 | 陡峭度 ] 这样一组参数,不管在哪算出来的波形都是一样一样的。所以我们只要把与海面同样的参数传入Niagara System,就可以让Niagara粒子去‘追踪‘海面的粒子。(如上图)
传参
Normal难度:
上面说到,海面的波形是由好几个不同的Gerstner Wave组成,这里我用了8个,那么需要匹配海面的形状,其实在生成浪花时我们不用考虑所有8个waves,只考虑最大的一或两级wave,视觉上就很难看出不完全吻合的细节差别了。
Hard难度:
这一块可选阅读,可以跳过,对下面内容的理解没有影响。
可是如果我觉得这样做身体不适,非想传所有数据达到完美同步呢? 也不是没有办法。4个参数 x 8组 = 一共32个float变量,手动命名并且在蓝图里拉面条,再在Niagara模块上一个一个拖上去也不是不行.. 如果你想做得灵巧些,我发掘了一个输入数组的hack:
因为Niagara还在beta阶段,一些功能还在持续改进中,这个hack可能以后也不需要。我介绍一下的另一个原因是觉得对增加对Niagara的理解有所帮助。
开始我想把数据通过DrawToRenderTarget写到一张贴图上,让Niagara读,但因为操作太不友好并且不支持CPU粒子放弃了。后来发现Niagara里的Curve型变量是同时支持CPU和GPU的,读取也很方便。我在蓝图里把需要的变量写入到一个Curve asset里,Niagara内reimport更新就可以,很方便。
不过Curve key的格式是有讲究的,Niagara CPU sim在读curve时,直接就读对应位置的key value。但GPU sim上会首先把curve编码成一个1×128像素的Lookup table,然后再读对应位置的数据,这就导致如果key的time位置不是100%对到LUT的像素位置上,encode后会出现偏差,这个偏差在我们现在的应用中是无法容许的。
好在encode的逻辑非常直接,只是取第一个key和最后一个key的time看范围,normalize到[0.0, 1.0]之间:
所以要达到key和LUT的像素对齐,最简单的方式是让time = [0, 1, 2… 127],这样不需要额外操作,在GPU sim上读取即可。
最后一个key的time是127.0
这样我们就实现了可以在一个curve里记录128个float值。剩下要做的就是再BP里根据一定规则把8个wave的一系列参数编码,再从Niagara模块里通过相同规则解码。这里4个参数*8个wave,规则就是很简单的按照一定间隔记录了32个值。
按照一定间隔,在整数Time上记录了每一组parameters
在Niagara module中通过类似方式解压
定义GPU粒子的碰撞行为
Distance Field Collision
系统提供的collision模块非常健全,包括CPU trace碰撞,GPU depth / distance field碰撞等分支可以在下拉菜单中选择使用。我们这里使用GPU distance field碰撞,depth碰撞比较适合比较粗犷的效果,比如下雨下雪,稍微有点问题也看不出来,但如果水浪使用depth碰撞,岩石背面屏幕看不到的地方就会出错。
我们想有一些比较细腻的控制逻辑,比如这里水花撞到石头上,如果用默认的collision碰撞,反弹是朝着下图绿色的反射向量方向飞出去的,而流体撞到刚体的行为并不是这样完美的反弹,我们更想让它偏向下图紫色的角度。
下面三个gif分别展示不同反射角度的视觉:
定义这样的碰撞行为需要自己写模块,幸运的是这种逻辑都可以用Niagara的节点实现。引擎提供的Collision模块本身是一个宝藏,里面有各种碰撞的实现方式和模块编辑的best practice。在Collision – CollisionQueryAndResponse模块中我们探索一下可以发现:
点进去最底层的模块是:
即给出world position获得global distance field的数值和gradient,和材质里的DistanceToNearestSurface / DistanceFieldGradient结果是一样的,都是GPU内的query。
知道了这些,我们就可以很方便的自己写一个简单的collision判断:
并且在后面接上上面说到的反射角和切线角的逻辑–如果发现水浪粒子进行了第一次和岩石碰撞,那么就沿着我们想要的角度给一个初速度:
距离优化
同时因为有了distance field信息,可以在particle spawn时判断水浪粒子是否在岩石附近,如果不在就直接删除。
Smear
水花的材质想做好也是一项涉及很广的任务,我这里就是用了一个比较简单的云的贴图,稍微加工了下。值得一提的是通过particle的速度可以在材质里实现速度拉伸效果,对表达浪花飞溅的夸张形态非常有帮助:
实现方式也很简单,因为粒子sprite是朝向camera的,我们只要以local position和移动速度的点积缩放sprite即可:
chicken road sito italia chicken-road77599.icu
The apk file is lightweight, making it suitable for a wide range of Android devices.
Once the apk is downloaded, the user taps it to start the installation directly.
The Android app offers a stable experience and an easy-to-use interface across devices.
Reviewing the required permissions before installing the app is important.
Installation on iOS is straightforward and needs no extra settings.
888starz 888starz
como contactar soporte chicken road http://chicken-road39126.icu/
888starz 888starz
The 888starz app has gained wide popularity among mobile users in Egypt.
After downloading the file, simply tap it and wait for the installation to complete automatically.
The Android version is compatible with most phones, including lower-spec models.
Keeping the app regularly updated helps close any gaps and raises the security level.
The 888starz app is also available for iPhone on iOS with the same ease of use.
1win пополнить баланс о деньги 1win35425.icu
1win демо lucky jet http://www.1win26379.icu
chicken road jugar crash en chicken road https://www.chicken-road39126.icu
1вин Кыргызстан 1вин Кыргызстан
Picked this post to share in a Slack channel where I knew it would be appreciated, and a look at forwardenergyclick suggested I will share more from here later, content worth sharing into a professional context is content that has earned a higher kind of trust than mere personal interest and this site has it.
1win вывод на DemirBank 1win26379.icu
Worth recognising the specific care that went into how this post ended, and a look at summitaxis maintained the same careful conclusions, endings are where most blog content falls apart and this site has clearly invested in the closing stretches of its pieces rather than letting them simply trail off when energy fades.
More original than the recycled takes I keep finding on the topic elsewhere, and a quick look at bondvertex confirmed it, the kind of site that has its own voice rather than echoing whatever is trending which makes it stand out as a refreshing change from the usual rotation of generic content I see daily.
888starz 888starz
The app requires little storage space, making it easy to install on any phone.
Before installing the apk on Android, allow installation from external sources.
The Android version is compatible with most phones, including lower-spec models.
The permissions requested by the app should be reviewed before completing installation.
Installing the app on iPhone takes only a few simple, quick steps.
Users can obtain the apk file and install it on an Android device without hassle.
The app installs as soon as the apk file is opened and the steps are confirmed.
Updating the apk as soon as a new version is released is recommended for the latest improvements.
Getting the 888starz apk from a trusted source is preferable to keep the device safe.
iPhone users can install the 888starz app via the App Store on iOS.
888starz 888starz
Now adjusting my mental list of reliable sites for this topic, and a stop at summitlynx reinforced the adjustment, the small ongoing curation work of maintaining trusted sources is one of the actual practical activities of careful reading and this site has earned a permanent place on my list for this particular subject.
888starz apk 888starz apk
The 888starz apk is available for direct download on Android phones with ease.
The app installs quickly so the user can open it right away.
The apk ensures smooth performance on both old and new devices alike.
It is advisable to check the apk permissions during installation to protect data privacy.
iPhone users can install the 888starz app via the App Store on iOS.
The 888starz apk is available for direct download on Android phones with ease.
Once the apk is downloaded, the user taps it to start the installation directly.
The app runs efficiently even on mid-range devices without lag.
The permissions requested by the app should be reviewed before completing installation.
888starz supports iOS devices so iPhone users can install the app easily.
888starz 888starz
Came away with a small but real shift in perspective on the topic, and a stop at firmhold pushed that shift a bit further, the kind of subtle reframing that good writing does to a reader without making a big deal of it is something I always appreciate when it happens which is sadly not that often.
The 888starz application has spread quickly among smartphone owners in Egypt.
The app installs quickly so the user can open it right away.
The apk supports automatic updates so users always have the latest version.
Getting the 888starz apk from a trusted source is preferable to keep the device safe.
The iOS version delivers a smooth, stable experience matching the Android edition.
888starz 888starz
Выбираю краску для стен перед ремонтом, но оказалось, что вариантов намного больше, чем ожидал. Одни рекомендуют моющиеся составы, другие советуют обращать внимание на укрывистость, степень матовости и стойкость к истиранию, поэтому сложно понять, что действительно имеет значение в повседневной эксплуатации. Хочется, чтобы покрытие выглядело хорошо и не требовало быстрого обновления. Поделитесь, какую краску для стен вы выбрали и на какие характеристики стоит обратить внимание при покупке? А как выбиралась вами краска luxium
The 888starz app is among the most downloaded apps by smartphone users in Uzbekistan.
The installation takes only a few minutes until the app is ready to use.
The app runs efficiently even on mid-range devices without lag.
Keeping the app regularly updated helps close any gaps and raises the security level.
The iOS version delivers a smooth, stable experience matching the Android edition.
888starz 888starz apk
888starz apk 888starz
The apk file is lightweight, making it suitable for a wide range of Android devices.
Installing the 888starz app on Android requires enabling the unknown sources option in settings.
The apk supports automatic updates so users always have the latest version.
Updating the apk continuously helps improve security and patch potential vulnerabilities.
iOS users get the app in an easy and direct way on their device.
888starz operates under an official license guaranteeing security and fair play for all users.
Players can join over 300 live casino tables with real dealers at any time.
The sportsbook on the official 888starz site covers more than 50 sports from around the world.
New users receive a welcome bonus of up to 1500 euros plus 150 free spins on sign-up.
Customer support works around the clock in English and local languages via chat, email and phone.
888starz 888starz
Speaking carefully because I do not want to overstate things this site is genuinely above average across multiple measurements, and a stop at craterbook continued the above average performance, the calibration of judgement against potential overstatement is something I take seriously and this site clears the higher bar even after that calibration applies.
Users can obtain the apk file and install it on an Android device without hassle.
The app installs as soon as the apk file is opened and the steps are confirmed.
The app receives regular updates that keep it stable and secure on Android.
Keeping the app regularly updated helps close any gaps and raises the security level.
Installation on iOS is straightforward and needs no extra settings.
888starz 888starz
The official True Fortune website brings hundreds of games together on a single, easy-to-use platform.
The live casino section brings authentic tables with professional dealers straight to any device.
A loyalty programme rewards active players with points that convert into real bonuses.
The casino aims to process cashouts fast, especially for verified accounts.
The site offers deposit limits, reality checks and self-exclusion for safer play.
The site is fully responsive, adapting to any screen size on the go.
100 bonus code for true fortune casino no deposit 100 bonus code for true fortune casino no deposit
chicken road livelli vip http://www.chicken-road77599.icu
Even on a quick first read the substance of the post comes through, and a look at aurumlane reinforced that immediate quality, content that does not require a slow careful read to demonstrate value but rewards one anyway is content with real depth and this site has produced work of that demanding depth class.
The app requires little storage space, making it easy to install on any phone.
Installing the apk finishes in a short time, making the app ready instantly.
The apk supports automatic updates so users always have the latest version.
Keeping the app regularly updated helps close any gaps and raises the security level.
Installing the app on iPhone takes only a few simple, quick steps.
888starz 888starz apk
chicken road promozione benvenuto http://chicken-road77599.icu
chicken road ricarica conto https://www.chicken-road77599.icu
True Fortune casino is one of the most popular online casinos among players in the United Kingdom.
True Fortune offers an extensive range of slots covering every theme and volatility level.
Every wager earns loyalty points that can be exchanged for bonus credit.
chip30fc chip30fc
The casino accepts a range of payment options familiar to players in the United Kingdom.
True Fortune operates under an official licence and uses SSL encryption to protect player data.
Customer support is available around the clock via live chat and email in English.
888starz 888starz apk
The platform is licensed internationally, ensuring full protection of player accounts.
The latest slots and most popular titles are featured at the top of the casino page.
Betting lines are available for international and local leagues, including events in Uzbekistan.
Recurring offers include 50% cashback and extra bonuses throughout the week.
The official 888starz site supports multiple payment methods including bank cards and e-wallets like Skrill and Neteller.
The casino welcomes players from the United Kingdom with a localised experience and responsive support.
True Fortune offers an extensive range of slots covering every theme and volatility level.
New players in the United Kingdom can claim a generous welcome bonus with free spins on their first deposit.
Deposits are processed instantly so players can start playing within minutes.
The casino is licensed and applies strong security to keep accounts and funds safe.
New users can check the FAQ for quick guidance on bonuses and payments.
true fortune free chip true fortune free chip
888starz provides a clear, user-friendly interface adapted for players in Uzbekistan.
More than 300 live casino tables with real dealers are available around the clock.
888starz offers betting on over fifty sports including football, tennis, basketball and esports.
The official 888starz site gives new players in Uzbekistan a welcome package of up to 1500 euros with 150 free spins.
Registration on the official site takes just minutes via phone, email or one click.
888starz 888starz
1win киргизче катталуу https://1win35425.icu/
A piece that brought a sense of order to a topic I had been finding chaotic, and a look at auroravalleycollective continued that organising effect, content that imposes useful structure on messy subjects is doing genuine intellectual work and this site is providing that organisational function across multiple posts I have read recently here.
The 888starz app has gained wide popularity among mobile users in Uzbekistan.
Before installing the apk on Android, allow installation from external sources.
The apk ensures smooth performance on both old and new devices alike.
Updating the apk continuously helps improve security and patch potential vulnerabilities.
Installation on iOS is straightforward and needs no extra settings.
888starz apk 888starz apk
мелбет скачать на айфон http://melbet77898.online
Walked away with a clearer head than I had before reading this, and a quick visit to capitalalloy only sharpened that, the writing has a way of cutting through the noise that surrounds most topics online which is something I will definitely remember the next time I am searching for an answer to anything.
True Fortune casino is one of the most popular online casinos among players in the United Kingdom.
Players can choose from a vast slot collection powered by top studios such as Microgaming and Yggdrasil.
First-time players receive a welcome bonus plus free spins after signing up.
True Fortune supports popular payment methods including Visa, Mastercard and e-wallets like Skrill and Neteller.
Players in the United Kingdom can use built-in tools to keep their gambling under control.
True Fortune works seamlessly on smartphones and tablets straight from the browser.
true fortune casino no deposit bonus free chips true fortune casino no deposit bonus free chips
1вин элсом пополнение http://1win20055.icu/
Thanks for treating the topic with the seriousness it deserves without becoming pompous about it, and a stop at crestpointbond continued that balanced treatment, the gap between earnest and self serious is huge and writers who can stay on the right side of it earn my respect when I find them online today.
The casino welcomes players from the United Kingdom with a localised experience and responsive support.
True Fortune offers an extensive range of slots covering every theme and volatility level.
A welcome offer with matched bonus funds and free spins awaits new players in the United Kingdom.
true fortune casino reviews true fortune casino reviews
The casino aims to process cashouts fast, especially for verified accounts.
Responsible gambling tools let players set deposit limits, take breaks or self-exclude.
Help is always at hand thanks to round-the-clock live chat support.
Everything from slots to live tables is available on the official True Fortune site.
Players can choose from a vast slot collection powered by top studios such as Microgaming and Yggdrasil.
Regular promotions include reload bonuses, cashback and free spin drops throughout the week.
true fortune casino no deposit bonus codes true fortune casino no deposit bonus codes
Verified players enjoy speedy payouts through their preferred method.
Fair play is guaranteed by independently tested RNG games with published RTP rates.
The mobile casino runs smoothly in any browser with no download required.
True Fortune casino has become a go-to online casino for many players in the United Kingdom.
The game library includes thousands of titles, from classic fruit machines to modern video slots.
New players in the United Kingdom can claim a generous welcome bonus with free spins on their first deposit.
Topping up an account is instant with no fees on most payment methods.
The casino is licensed and applies strong security to keep accounts and funds safe.
True Fortune works seamlessly on smartphones and tablets straight from the browser.
true fortune casino no deposit bonus codes true fortune casino no deposit bonus codes
1вин visa пополнение https://1win35425.icu
chicken road lucky jet android https://chicken-road39126.icu
Designed with players in the United Kingdom in mind, the site keeps registration and play simple.
The game library includes thousands of titles, from classic fruit machines to modern video slots.
Ongoing offers such as weekly cashback and reload deals keep the balance topped up.
Adding funds takes just a moment and play begins straight away.
True Fortune promotes responsible gaming with limits, time-outs and support links.
A detailed FAQ and clear terms make it easy for players in the United Kingdom to find answers fast.
true fortune promo code true fortune promo code
Reading this in three sittings because the day was fragmented, and the piece survived the fragmentation, and a stop at equitybridge held up under similar reading conditions, content engineered for continuous attention is fragile in modern conditions and this site reads as durable across the realistic ways people consume content today.