Version: 2017.1
テレインテクスチャ
SpeedTree

木 (Tree)

木の領域はハイトマップやテクスチャをペイントするのとほぼ同じ方法で地形にペイントすることができ、表面から生成される木は 3D オブジェクトになります。Unity は最適化(例:距離による木のビルボード化)により良好なレンダリングパフォーマンスを維持します。それにより、数千の樹木からなる密林を持ちつつも、充分なフレームレートを保つことができます。

Terrain with trees
Terrain with trees

Enabling trees

ツールバー上のツリーボタンでツリーペインティングが可能です。

初めは地形に tree はありません。Edit Trees をクリックして Add Tree を選択することでプロジェクトから tree アセットを選択するウィンドウがあらわれます。

Add Tree ウィンドウ
Add Tree ウィンドウ

Unity comes with several sample SpeedTree tree objects in the Standard Assets packages for prototyping purposes Assets > Import Package > Terrain Assets) but you can also create suitable objects with SpeedTree Modeler app, Unity Tree Creator tools or other 3D modelling apps.

選択した tree オブジェクトが Tree Creator で生成される際には、風への反応を調整するためのベンド係数がウィンドウに表示されています。下段にある Making trees bend in the wind セクションを参照してください。

Painting trees

tree を選択することで、テクスチャやハイトマップをペイントするのと同じように景色をペイントすることができます。ペイント中に shift キーを押しっぱなしにすることでエリアから tree を削除することができます。現在選択されている tree タイプのみを削除する場合は、control キーを押しっぱなしにしてペイントします。tree ペインティングでは Brush Size オプションを使用することが可能です。Opacity プロパティーは Tree Density へと取って代わられ、それはエリア内の指定されたユニットにおける tree の平均数を制御するものです。

スライダーを使って tree の高さの最小値と最大値を制御できます。ランダムを無効にした場合、すべての tree の高さを決めうちすることもできます。標準では、常に均一なスケーリングができるように、tree の幅は高さにあわせてロックされています。しかし Lock Width to Height オプションを無効にすれば、幅を個別に決める事もできます。

また、Color Variation の制御も存在し、tree の高さと幅を細く指定することも可能です。バリエーションのオプションは同一の木による人工的な林ではなく、ランダムな印象の自然な感じの林を作成するのに役立ちます。

Mass Place Trees ボタンは景色すべてをペイントすることなく、全体を覆う tree を作成することができます。Mass Place Trees 使用後も、密集した、もしくはまばらなエリアを作成するために、ペイントを使用して tree の追加や削除をすることができます。

SpeedTree/LOD trees

Unity5からは IDV 社製の SpeedTree Modeler を使う事ができるようになりました。smooth LOD transition、fast billboarding、natural wind animation などのより高度なビジュアルエフェクトを伴う tree の生成が可能です。より詳細な情報はSpeedTree のサイトを参照してください。SpeedTree のアセットは、アセットストアのパッケージやサードパーティの配布先から、プロジェクトフォルダーへ自由にインポートできます。

詳細はこちらを参照してください。

Tree Creator による木

Unity には tree アセットを新たに作成することができる Tree エディターがあります。また、一般的な 3D モデリングアプリケーションを使用して作成することも可能です。tree メッシュは 2000 トライアングル以下に抑え(パフォーマンスのため)、アンカーポイントは tree の根元、地面から出てくる部分に設定してください。メッシュは常に、必ず 2 つのマテリアルで構成してください。一つは tree の幹の部分、もう一つは葉の部分に使用します。

Tree は Nature/Soft Occlusion LeavesNature/Soft Occlusion Bark shader を使用する必要があります。これらのシェーダーを使うために、Tree は“Ambient-Occlusion”の名前を含む、特別なフォルダーに配置しなければなりません。モデルをフォルダーに配置したり、再インポートしたりすると、Unity は Tree に特化された、Soft Ambient Occlusion を計算します。“Nature/Soft Occlusion”シェーダーには、この情報が必要です。もし、命名ルールに従わなければ、樹木は真っ黒な変なものに見えてしまうでしょう。

モデリングアプリケーションから tree アセットを保存するとき地形上で tree の最新版を見るために Refresh ボタン(tree ペインティングツール選択時にインスペクター内に表示される)をクリックする必要があります。

Using colliders with trees

You can add a Capsule Collider to a new tree asset by instantiating it in the scene, adding the collider (menu: Component > Physics > Capsule Collider) and creating a new prefab for the modified tree object. When you add the tree to the terrain for painting, make sure you select the prefab with the collider rather than the original object. You should also enable Create Tree Colliders in the terrain’s Terrain Collider component inspector.

風で動く木をつくる

The first thing you will need to do is create a wind zone. You can do this by selecting from the menu: Game Object > 3D Object > Wind Zone.

At this point, you will need to make sure that your trees are set to bend. Select your Terrain, click the Place trees button in the Inspector and then select Edit Trees > Edit Tree. Setting the Bend Factor to 1 will cause the trees to adjust if you have not already done this.

You may notice that your trees are moving about quite violently. To fix this, you can change your bend value, but it is probably easier to set the values on the Wind Zone directly, keeping your tree bend factor set to 1. To keep the trees from fluttering around too much, adjust the wind turbulence down to around 0.1 to 0.3 and everything will become much smoother. If you don’t want the trees blowing all the way to one side, set the Wind Main value down to the same value as your turbulence.


  • 2017–07–27 限られた 編集レビュー で修正されたページ

  • GameObject メニューは Unity 4.6 で変更

テレインテクスチャ
SpeedTree