查看: 2465|回复: 8
打印 上一主题 下一主题

用程序生成地形

[复制链接]

5552

主题

2

听众

8万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
11

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2011-12-12 14:40:14 |只看该作者 |倒序浏览
看来在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  发表
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

5969

主题

1

听众

39万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

沙发
发表于 2012-2-5 23:20:54 |只看该作者
沙发不解释
回复

使用道具 举报

   

671

主题

1

听众

3247

积分

中级设计师

Rank: 5Rank: 5

纳金币
324742
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

板凳
发表于 2012-2-26 23:21:09 |只看该作者
我看看就走,你们聊!
回复

使用道具 举报

1023

主题

3

听众

359

积分

设计实习生

Rank: 2

纳金币
335582
精华
0

最佳新人

地板
发表于 2012-5-14 23:19:44 |只看该作者
已阵亡的 蝶 随 风 舞 说过  偶尔按一下 CTRL A 会发现 世界还有另一面
回复

使用道具 举报

462

主题

1

听众

31万

积分

首席设计师

Rank: 8Rank: 8

纳金币
2
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

5#
发表于 2012-7-21 23:20:38 |只看该作者
再看一看,再顶楼主
回复

使用道具 举报

1023

主题

3

听众

359

积分

设计实习生

Rank: 2

纳金币
335582
精华
0

最佳新人

6#
发表于 2012-7-22 23:21:16 |只看该作者
我看看就走,你们聊!
回复

使用道具 举报

3795

主题

2

听众

5万

积分

版主

Rank: 7Rank: 7Rank: 7

纳金币
53202
精华
32

活跃会员 优秀版主 推广达人 突出贡献 荣誉管理 论坛元老

7#
发表于 2012-7-24 09:33:48 |只看该作者
高手速来赐教!kismet里面怎么加一个延迟DELAY??



unity特效大家PP_武功盖世呀








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






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








antares_universe(vizio)可视化编辑
回复

使用道具 举报

1023

主题

3

听众

359

积分

设计实习生

Rank: 2

纳金币
335582
精华
0

最佳新人

8#
发表于 2012-7-25 23:19:01 |只看该作者
好铁多多发,感激分享
回复

使用道具 举报

   

671

主题

1

听众

3247

积分

中级设计师

Rank: 5Rank: 5

纳金币
324742
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

9#
发表于 2012-10-21 23:38:49 |只看该作者
不错哦,顶一下......
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2024-9-20 23:45 , Processed in 0.210443 second(s), 31 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部