纳金网

标题: 用程序生成地形 [打印本页]

作者: 会飞的鱼    时间: 2011-12-12 14:40
标题: 用程序生成地形
看来在unity3d中制作地形的方法有多了一种,那就是直接用一段程序来生成地形,这个好像很方便,不过本机测试时,导入作者提供的资源包,却没成功,不知是什么原因。有兴趣的朋友可以试试!

So I’ve been working on a simple procedural terrain script in the Unity engine. It currently defines a 2D array of floats, then assigns random values within a certain range. I then call a function that adds rows and collumns between the existing data points, generating midpoints. These midpoints are then given a new value based on the average of the two points on either side with an added noise value.




wp-image-21" />

The next step was to procedurally texture the terrain. I wanted something that would blend textures smoothly, so the grass would become less dense as it progressed up the mountains. I accomplished this by writing my own shader. It currently takes two textures, and combines them based on the alpha values in a blend-map computed based on the altitude of the terrain.
The shader uses a single pass to combine all of the textures together and applies the final texture to the terrain.

wp-image-17" />

The shader also uses lightmaps combined with built in pixel and vertex lights in order to add pre-computed shadows that can also be tinted using ambient light and point lights. The lightmaps are made using a raycast system, where a cast vector is specified, and is projected in a number of itterations along the surface of the terrain. This then writes to the texture on the UV coordinate that is mapped to the hit location. This way, any point that the ray does not hit has a default color value ( Black ), and wherever a ray collides, the value is set to white. This allows simple shadow computation based the slope of the mountain. The lightmap is then blurred to remove any sharp edges. This produces a simple black and white texture that can be multiplied over any other base texture to create shadows.






aligncenter" />
This system allows the user to create a random terrain of a specified size and resolution, with an adjustable lightmap accuracy, and tiling textures that are still shadowed correctly.
示例资源包下载地址:



http://www.dbank.com/download.action?t=40&k=MTgxODczMzM=&pcode=LCwxMzkyNTEsMTM5MjUx&rnd=4
由 u8  发表
作者: C.R.CAN    时间: 2012-2-5 23:20
沙发不解释

作者: 奇    时间: 2012-2-26 23:21
我看看就走,你们聊!

作者: 晃晃    时间: 2012-5-14 23:19
已阵亡的 蝶 随 风 舞 说过  偶尔按一下 CTRL A 会发现 世界还有另一面

作者: 菜刀吻电线    时间: 2012-7-21 23:20
再看一看,再顶楼主

作者: 晃晃    时间: 2012-7-22 23:21
我看看就走,你们聊!

作者: 驰骋的风    时间: 2012-7-24 09:33
高手速来赐教!kismet里面怎么加一个延迟DELAY??



unity特效大家PP_武功盖世呀








【严重分享】Unity3D_3.0破解版[安装包][下载]






高手请赐教!用模型做的特效动画材质丢失








antares_universe(vizio)可视化编辑

作者: 晃晃    时间: 2012-7-25 23:19
好铁多多发,感激分享

作者: 奇    时间: 2012-10-21 23:38
不错哦,顶一下......





欢迎光临 纳金网 (http://old.narkii.com/club/) Powered by Discuz! X2.5