- 最后登录
- 2018-6-29
- 注册时间
- 2011-7-1
- 阅读权限
- 20
- 积分
- 359
- 纳金币
- 335582
- 精华
- 0
|
非常有用的一个效果,用代码来实现动态矩阵效果,用来做一些视觉特效还是非常好的,下面是原贴!
Small update; Faster, removed the yields in the script as well, although it stops unity while the script is thinking. For a terrain using default settings (calculating 131,072 points), it should be created in under 2 minutes; still very slow, between 1000 & 1200 points per second.
I found some extra time these past couple of days, and decided I'd play with Unity for a bit. I figured that I'd come up with a procedural terrain system allowing overhangs, tunnels, etc.
I started last night, and got some of it working this morning. I began by looking up perlin noise, and making my own implementation of 3d perlin noise (or something similar) using the now-accessible multi-dimensional builtin arrays.
I have it working, but it is incredibly slow, as it always seems to be with codes in the first little while after writing them. Also, I'm making the terrain out of cubes, which means that it resembles minecraft a lot (hopefully I can change this by using something similar to marching cubes, and then smoothing).
It does work very similarly to minecraft, in that they both use 3d perlin noise. I also decided to generate terrain in blocks, because it seems to be the only feasible method to generate terrain in real time and save it (I'm still not there yet).
Well, I'm posting it in this early stage because I figure it could be a useful start for others who might know a lot more about this type of thing than me. I'm also not sure how much time I'll have in the next little while to improve it.
More notes can be found in the script itself.
Some blocky terrain generated by the script (cubes are prefabs)
Overdraw view of perlin noise (not terrain, see notes in script)
Settings:
Terrain Blocks : The amount of blocks in the x & y directions the script creates. (4 would be a 4x4 grid of terrain blocks)
Cube : A cube prefab goes here.
Detail Size : The distance between integral areas, or at least that's how I like to describe it. Basically, the size of the noise. (since it's not limited to a terrain size)
Persistence : How noisy the terrain will be. (persistence in Perlin noise)
Octaves :Amount of iterations it goes through, in which size and persistence change each iteration. (octaves in Perlin noise)
Terrain Size : The length and width of a terrain block; the total size of the terrain is (Terrain Size)^2*(Terrain Blocks)^2.
Terrain Height : The maximum height of the terrain (average height is half of this)
Seeded : The random terrain seed. The same seed will always generate the same terrain
|
|