Scattering Trees and Details on Unity Terrain

   10217   9   5
User Avatar
Member
28 posts
Joined: March 2015
Offline
Hi,

I've been using Houdini (using regular hdas and PDG) to scatter prefabs with the unity_instance attribute on Unity terrain, but as you would expect, scattering 100 000+ prefabs in a Unity scene brings it to its knees because it create so many game objects in its scene hierarchy.

I was wondering if it would be possible to output data from Houdini Engine right into the Unity Terrain TerrainData [docs.unity3d.com], so that the points we output get picked up by Unity's native terrain.
This way, we would more efficiently scatter trees and details on terrain, and we could even use the regular painting tools to add/remove some scattered objects.

I know some plugins on the asset store like Map Magic [assetstore.unity.com] are able to spawn trees and grass, so I hope we can do the same kind of things with all the Houdini power behind it

Thanks,
Alex
User Avatar
Member
571 posts
Joined: May 2017
Offline
That is something I can investigate. Please submit an RFE for it.

In the mean time, I wonder if you can try grouping your assets instead of creating them as individual trees (so instance sets of trees). One (experimental?) feature that Unity blogged about was hierarchical LODs which might help with something like this as well, though I don't think its supported natively yet.
User Avatar
Member
1 posts
Joined: Nov. 2019
Offline
it's so simple to do the thing with unity tree prefab in terrain ( you can use tree prototype to convert your data to unity standard tree prefab) check out Houdini unity plugin doc in below link it will give you the base idea of that
https://www.sidefx.com/docs/unity/_terrain.html [www.sidefx.com]
User Avatar
Member
5 posts
Joined: Jan. 2021
Offline
If somebody got an example ! I did not understand how to use TreeInstances and TreePrototypes in the Houdini unity plugin doc.

Thanks !
User Avatar
Member
100 posts
Joined: Dec. 2020
Offline
Here is an example of a tree instancing for a prefab "Assets/Prefabs/Trees/TestTree.prefab".

Attachments:
treeinstance_test.hda (27.3 KB)

User Avatar
Member
5 posts
Joined: Jan. 2021
Offline
anthonyt2
Here is an example of a tree instancing for a prefab "Assets/Prefabs/Trees/TestTree.prefab".
Thanks a lot ! It looks easy now !
User Avatar
Member
385 posts
Joined: July 2018
Offline
What if its not a heightfield but a regular mesh?
it doesnt seem to work for me! Is there some attribute that is missing?

Attachments:
unity_instance_testHDA.hda (8.3 KB)

User Avatar
Member
100 posts
Joined: Dec. 2020
Offline
For people still experiencing this problem, I added the point attribute "unity_hf_tile" in Houdini 18.5.589 to specify which tile unity_instance should be applied on: https://www.sidefx.com/docs/unity/_attributes.html [www.sidefx.com]
User Avatar
Member
1 posts
Joined: June 2021
Offline
Hi,

I am learning to build terrains for a student project. I have trouble understanding the part of documentation regarding scattering objects with detailed layers. I successfully scattered trees and gave them random scale, rotation, etc. I have a nice texture and terrain layers, but I can not find any tutorial regarding this specific topic and I am not understanding well the highlighted section(by me) of the quote from the documentation. I am a beginner so I hope my question is not inappropriate. I would be thankful if somone create test network like the 1st here regarding tree protoypes.
papsphilip
What if its not a heightfield but a regular mesh?
it doesnt seem to work for me! Is there some attribute that is missing?
-For regular mesh you should use unity_instance attribute. unity_hf_tree_prototype could be used only on higfield/terrain.



Thank you!


Detail Layers
For smaller sized environment details such as grass, shrubs, etc., height field layers can be specified to be converted to Unity terrain's detail layers for efficient drawing.

A Unity terrain detail layer contains a map of integer values that specify the number of instances for the area covered by each value in the height field. These values must be integers between 0 and 16, so the float values from the height field will be simply converted to integers as they are. For a point in the height field, a value of 0 denotes no instances, while values between 1 and 16 denote the number of desired instances for the area covered by the height point. The area covered by each height point is determined by dividing the terrain size by the Detail Resolution, which is inferred from the size of the height field layer. For example, a terrain of size 1024x1024 with the Detail Resolution of 256 means that for each height point in a detail layer, it covers a 4x4 area.

Note that the Detail Resolution cannot be set via attribute. It is inferred from the detail layer's size, which must be a square size between 0 and 4048, as required by Unity. Therefore all specified detail layers must be of the same size.

In order to use detail layers, the height field network requires setting detail properties, as described below.

Detail Layer Properties:
The height field layer to be converted to detail layer must be marked as detail type. This is done by setting a Primitive String attribute named unity_hf_layer_type on the layer with the value detail.
On the same heigthfield layer, a DetailPrototype must also be specified via the following attributes:
To use a prefab, set a Primitive String attribute named unity_hf_detail_prototype_prefab on the layer with the path to the prefab or mesh to instantiate, relative to Assets/.
Or to use a texture, set a Primitive String attribute named unity_hf_detail_prototype_texture on the layer with the path to the texture, relative to Assets/.

Optionally:
unity_hf_detail_prototype_bendfactor - Set a Primitive Float attribute with a bend factor value.
unity_hf_detail_prototype_drycolor - Set a Primitive Color (4 float) attribute with dry color value.
unity_hf_detail_prototype_healthycolor - Set a Primitive Color (4 float) attribute with healthy color value.
unity_hf_detail_prototype_maxheight - Set a Primitive Float attribute with maximum height value.
unity_hf_detail_prototype_maxwidth - Set a Primitive Float attribute with maximum width value.
unity_hf_detail_prototype_minheight - Set a Primitive Float attribute with minimum height value.
unity_hf_detail_prototype_minwidth - Set a Primitive Float attribute with minimum width value.
unity_hf_detail_prototype_noisespread - Set a Primitive Float attribute with a noise spread value.
unity_hf_detail_prototype_rendermode - Set a Primitive Integer attribute with a DetailRenderMode value of 0 for GrassBillboard, 1 for VertexLit, and 2 for Grass (Default).
Global Detail Properties:
On the height layer, the following attributes can be specified to set the detail values for the generated TerrainData:
unity_hf_detail_distance - Set a Detail Integer attribute with value from 0 to 250 for Detail Distance.
unity_hf_detail_density - Set a Detail Float attribute with value from 0 to 1 for Detail Density.
unity_hf_detail_resolution_patch - Set a Detail Integer attribute with value from 8 to 128 for Density Resolution Per Patch.
User Avatar
Member
4 posts
Joined: Aug. 2020
Offline
pungerart
Hi,

I am learning to build terrains for a student project. I have trouble understanding the part of documentation regarding scattering objects with detailed layers. I successfully scattered trees and gave them random scale, rotation, etc. I have a nice texture and terrain layers, but I can not find any tutorial regarding this specific topic and I am not understanding well the highlighted section(by me) of the quote from the documentation. I am a beginner so I hope my question is not inappropriate. I would be thankful if somone create test network like the 1st here regarding tree protoypes.

Google brought me here because I'm having the same problem. After a couple hours I was able to (kind of) get this to work.
I'm able to make it add either a grass texture or a detail mesh, but not both at the same time. Although it does add both detail layers, and I can then manually paint them on the terrain in Unity.

I attached the HDA I came up with.

Attachments:
terrain_detail_test.hdalc (39.2 KB)

  • Quick Links