python 侵蚀_代码之夏:地形侵蚀工具的进步

python 侵蚀_代码之夏:地形侵蚀工具的进步

python 侵蚀

This blog post is written by Sándor Moldán who is working on a set of Terrain Erosion tools for Unity. The project is one of four selected projects that were selected for the Unity Summer of Code.

该博客文章由SándorMoldán撰写,他正在为Unity开发一套Terrain Erosion工具。 该项目是为Unity夏季代码选择的四个选定项目 之一

The objective of this Unity Summer of Code project was to develop a toolset for the Unity Editor which would streamline and improve the workflow involved in creating terrains for games.

这个Unity Summer of Code项目的目的是为Unity编辑器开发一个工具集,该工具集将简化和改善创建游戏地形的工作流程。

While there are currently a number of third party tools that can already produce high quality terrains, I felt that they lacked two vital qualities. Besides the impact of the additional cost of these tools – particularly to indie developers, when using these tools it is left to the artist to develop an effective workflow for getting height and texture maps out of their proprietary software and into Unity. This can be a somewhat painful process. Secondly and more importantly, it is impossible to leverage the power of the tools to procedurally generate landscapes at runtime. My aim was to overcome these constraints by integrating terrain generation tools directly into the Unity engine and editor.

尽管目前有许多第三方工具已经可以生成高质量的地形,但我认为它们缺乏两个至关重要的品质。 除了这些工具的额外成本的影响(特别是对独立开发人员而言)之外,使用这些工具时,还要由艺术家来开发有效的工作流程,以将高度和纹理贴图从其专有软件中转移到Unity中。 这可能是一个痛苦的过程。 其次,更重要的是,不可能利用工具的功能在运行时以程序方式生成景观。 我的目标是通过将地形生成工具直接集成到Unity引擎和编辑器中来克服这些限制。

The toolset I am developing is divided into three areas – terrain generation, erosion and texturing. So far there are 5 different erosion filters – thermal, tidal, wind and two types of hydraulic erosion, 2 ‘generators’ that use Voronoi and cloud fractal algorithms to create base terrain, a couple of useful tools that allow the user to smooth or normalise the terrain and finally a procedural terrain texturing tool.

我正在开发的工具集分为三个区域-地形生成,侵蚀和纹理化。 到目前为止,共有5种不同的侵蚀过滤器-热,潮汐,风和两种水力侵蚀; 2个使用Voronoi和云分形算法创建基本地形的“发电机”,两个有用的工具可让用户平滑或标准化地形,最后是程序化地形纹理工具。

All ten of these features will be provided both as filters which can be applied in the Unity Editor and as fully documented API functions which will allow users to generate terrain and apply filters at runtime through their own scripts. Additionally, thermal, fast-hydraulic and tidal erosion filters can also be applied directly to the terrain object using brushes in the editor.

所有这十个功能都将作为可在Unity Editor中应用的过滤器以及作为文档全面的API函数提供,这些API函数将允许用户生成地形并在运行时通过自己的脚本应用过滤器。 此外,还可以使用编辑器中的画笔将热,快速水力和潮汐侵蚀过滤器直接应用于地形对象。

Where it’s up to, what still needs to be done

到底要做什么,还需要做什么

I feel that the project has progressed well over the last five or so weeks. There have certainly been some obstacles and not everything has gone my way, but with just over a week remaining I am on track towards delivering at least 16 of the 19 features that I originally scoped for the project, plus two completely new ones. Given that my aim was to deliver a minimum of 12 of the scoped features within the Unity Summer of Code timeline, I’m quite happy with the result.

我觉得该项目在过去五周左右的时间内进展顺利。 当然存在一些障碍,但并非一切都顺其自然,但仅剩一周多的时间,我就有望实现最初为该项目确定的19个功能中的至少16个,以及两个全新的功能。 鉴于我的目标是在Unity Summer of Code时间轴内提供至少12个范围内的功能,因此我对结果感到非常满意。

Over the next week my main aim is to tidy up the documentation for this project, which I believe is vital in allowing Unity artists and developers to get the most out of these tools. I will also focus on cleaning up my code and optimising it where possible and finally I will continue working away on the remaining features – namely a few UI tweaks, yet a third different approach to hydraulic erosion, and glacial erosion.

在接下来的一周中,我的主要目的是整理该项目的文档,我认为这对于让Unity艺术家和开发人员充分利用这些工具至关重要。 我还将集中精力清理代码并在可能的情况下对其进行优化,最后,我将继续研究其余功能,即一些UI调整,这是第三种不同的水力侵蚀和冰川侵蚀方法。

What went well

一切顺利

I started the project with a fairly limited knowledge about creating properly integrated custom tools for the Unity Editor and had only given the Editor GUI documentation a cursory glance. I found that despite a few minor hurdles, I was able to quite easily create a useful and intuitive interface for my tools. I was also pretty happy with some of the optimisations I was able made to my erosion code. Being able to run 50 thermal erosion iterations on a 512 x 512 terrain object in barely more than 6 seconds totally exceeded my wildest expectations.

我从为Unity编辑器创建正确集成的自定义工具的知识非常有限的时候开始了该项目,并且只给编辑器GUI文档粗略地浏览了一下。 我发现尽管有一些小障碍,但我仍然能够轻松地为我的工具创建一个有用且直观的界面。 我对腐蚀代码进行的一些优化也让我非常满意。 能够在短短超过6秒的时间内对512 x 512地形对象运行50次热腐蚀迭代,这完全超出了我的最高期望。

Also, after many unsuccessful attempts to get Unity’s undo feature to work with my code, one of the Unity guys, Rune, was kind enough to explain it to us – and in typical Unity style, it turned out to be much simpler that I had thought it would be.

另外,在尝试使Unity的撤消功能与我的代码一起使用的许多尝试失败之后,其中一位Unity专家Rune可以向我们解释它了–在典型的Unity风格下,事实证明,我使用它要简单得多以为会。

Even though I had originally considered undo as a ‘nice to have’ feature, I quickly realised that it was really an imperative. Getting the best results from these tools can require a bit of trial and error, and allowing users to run a filter, undo it, tweak a few settings and run it again without completely ruining their terrain object in the process is vital in making this project a practical solution for Unity artists and developers.

即使我最初将撤消功能视为具有“不错的功能”,但我很快意识到这确实是必须的。 要从这些工具中获得最佳结果可能需要反复试验,并且允许用户运行过滤器,撤消过滤器,调整一些设置并再次运行而不会在此过程中完全破坏地形对象,这对于制作此项目至关重要适用于Unity艺术家和开发人员的实用解决方案。

What didn’t go so well

不好的地方

While I consider my scripting skills in JavaScript and C# to be reasonably good, I have to admit that mathematics is not really my strong point. Some of the equations I used in my tools, such as Voronoi diagrams and the Diamond-Square algorithm were fairly easy to implement in code – but for the vast majority of my tools I initially approached the algorithms logically rather than algorithmically.

虽然我认为我在JavaScript和C#方面的脚本编写技能相当不错,但我不得不承认数学并不是我真正的强项。 我在工具中使用的一些方程式,例如Voronoi图和Diamond-Square算法,在代码中都非常容易实现-但对于我的大多数工具,我最初都是从逻辑而非算法上解决算法。

For the most part this worked well and produced good results. However, when I started looking for a more physically correct approach to erosion caused by fluid mediums – namely water and ice – I realised that the complexity of the mathematics involved in computational fluid dynamics, such as Shallow Water Models, Navier-Stokes equations and so on, was far beyond my level of understanding and well beyond my capacity to learn in such a short period. This was rather disappointing, as it has meant that I have not yet found an effective solution for glacial erosion.

在大多数情况下,此方法效果良好,并产生了良好的效果。 但是,当我开始寻找一种物理上更正确的方法来解决由水和冰之类的流体介质引起的腐蚀时,我意识到计算流体动力学所涉及的数学的复杂性,例如浅水模型,Navier-Stokes方程等。远远超出了我的理解水平,也远远超出了我在这么短的时间内学习的能力。 这相当令人失望,因为这意味着我尚未找到有效的冰川侵蚀解决方案。

That said, there is still a lot more that I want to achieve with this toolset. After I deliver my project at the end of the Unity Summer of Code, I fully intend to revisit some of these prohibitively complex features once I have the time to do all the learning and research that will be required to get them to work the way that I want them to.

也就是说,使用此工具集还有很多我想实现的目标。 在Unity夏季课程结束时交付项目后,一旦有时间进行使它们按以下方式工作所需的全部学习和研究,我将完全打算重新访问其中一些非常复杂的功能。我要他们。

翻译自: https://blogs.unity3d.com/2009/08/23/summer-of-code-progress-of-terrain-erosion-tools/

python 侵蚀