创建雨效果/水滴的算法?
What is the principle behind creating rain effect or water drops regardless of using any particular language. I've seen a few impressive rain and water effects done in Flash, but how does it actually work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
你问的问题好像这两个例子是相关的,但你实际上有
1)模拟空气中看到的雨滴(滴迹;简单但真实性很大程度上取决于照明),
以便你模拟以下事件
:其他答案中指出,可以使用各种算法创建新的水滴(大小和位置)。
至于速度,它们以恒定的速度移动。
最后,要显示您的踪迹,您需要查看简单的 投影
2)模拟飞溅波浪(水模拟,在示例中显示了反射表面)
为此,您只需要知道水滴落在哪里以及它们有多大,其余的就是波传播。然而,只有存在反射时,这才真正可见,这可能有点棘手。
笔记:
决定真实性的因素有很多,但主要归结为细节。
例如,通常只有在奇怪的照明条件下(靠近灯或在高对比度背景下)才能清楚地看到雨。不然的话就相当惨淡了。
还有交互中的细节 - 溅到它撞击的表面上,这可能会留下气泡(如果足够近可以注意到),或产生波浪。
另一个例子 - 如果您查看此教程,这不太现实,但它确实说明了一点,您会看到,尽管雨看起来更像雪,但它暴露了第一个示例的“平坦度”(绝对没有深度)。
所以,一切都与细节有关。
尝试根据必须模拟的事件对您所拥有的内容进行建模,然后分别模拟每个事件 - 例如,使用分形来播种降雨可能是一种矫枉过正,但如果您很好地对您的工作进行建模,那么您可以从随机播种开始,然后用替代方法使用更准确/复杂的方法。
You are asking a question as if the two examples were related, but you actually have
1) simulating drops of rain as seen in air (drop trails; simple but the realism depends on lighting very much)
for this you to simulate following events:
as pointed in other answers new drops (size and position) can be created with various algorithms.
as for speed they move with constant speed.
finally to show your trails you need to look at simple projections
2) simulating splash waves (water simulation, and in the example a reflective surface is shown)
For this you only need to know where the drops fall and how big they are, the rest is wave propagation. However that's only really visible if there is a reflection and that can be a bit tricky.
NOTES:
There are many things that determines realism, but mostly it boils down to detail.
For example rain is usually seen clearly only in strange lighting conditions - close to lamps or on high contrast background. Otherwise it is quite bleak.
Also the details in interaction - splashing on surfaces that it hits, which can leave bubbles (if close enough to notice), or create waves.
Another example - if you look at this tutorial, which is not really realistic, but it does illustrate one point, you will see that even though the rain looks more like a snow it exposes the 'flatness' of your first example (which has absolutely no depth).
So, it is all about detail.
Try to model what you have in terms of events that you have to simulate and then solve simulating each one separately - for example using fractals for seeding rain might be an overkill, but if you nicely model your work you start with random seeding and latter substitute with more accurate/complex methods.
这是 Mandelbrot 和 Lovejoy 撰写的论文,这是被引用最多的著作之一开发分形模型来表示降雨。
Here's a paper by Mandelbrot and Lovejoy which is one of the most cited works on developing fractal models to represent rain.
第二个(雨滴水效果示例)可能是使用波动方程模拟器完成的
The second one (Rain Drop Water Effect Example) is probably done with a wave equation simulator
他们可能主要使用粒子效果。
They probably use particle effects mostly.
一种非常便宜的老式方法是使用调色板循环。基本上,您设置颜色渐变并以固定间隔将一种颜色移动到下一种颜色。移动的颜色给人一种运动的错觉。我曾开发过一些游戏,其中雨、风、雪、瀑布、火等都使用调色板循环进行动画处理。这是一门即将消亡的艺术,但它仍然有效。 :)
An old school way that is dirt cheap is to use palette cycling. Basically, you setup a ramp of colors and move one color into the next in fixed intervals. The moving colors give the illusion of motion. I've worked on games where rain, wind, snow, waterfalls, fire, etc. have all been animated using palette cycling. It's a dying art, but it still works. :)