Tutorial request: How to work with existing assets.
9360 14 1- DASD
- Member
- 453 posts
- Joined: Feb. 2013
- Offline
I want to use Houdini to procedurally position assets that are already inside a Unity scene. So basically I want to generate an environment, but instead of generating geometry I want the user to plug in her/his own (modular) assets. And I want the result to be instanced placements of those assets.
How would I set up the input and how would set up the output for Houdini Engine so that I don't loose any properties the assets already have and so that the output is perfectly optimized and instanced?
Also: How would I (automatically) assign materials that exist in a Unity scene to Houdini Engine output? So to go with the scenario of instanced prefabs: The user would plug in a couple of his materials and then Houdini Engine would assign those to the placed instances to create additional variation.
How would I set up the input and how would set up the output for Houdini Engine so that I don't loose any properties the assets already have and so that the output is perfectly optimized and instanced?
Also: How would I (automatically) assign materials that exist in a Unity scene to Houdini Engine output? So to go with the scenario of instanced prefabs: The user would plug in a couple of his materials and then Houdini Engine would assign those to the placed instances to create additional variation.
- damian
- Member
- 402 posts
- Joined: March 2013
- Offline
Both of the workflows you describe are possible in the Unity plugin, however, not at the same time.
For instancing Unity objects using a Houdini asset, you need to just create a Houdini asset that instances some geometry. Unity will automatically detect the use of a instancer in your asset and allow you to overwrite the Houdini geometry being instanced with any Unity GameObject from the scene or Prefab from your project you want. I've attached a relatively simple example asset that uses instancing and allows you to instance different objects per point.
For assigning Unity materials to a Houdini asset you need to add a special primitive string attribute called “unity_material” to your geometry that contains a path within your Unity project to a .mat Unity material (the .mat is important and should be included in the path). Again, I attached an example asset with the .unitypackage containing the dependent Unity materials.
That said, you can't instance Unity objects AND overwrite their materials from Houdini Engine. You have to chose one workflow or another. There is also no way to provide Unity materials as material inputs to a Houdini asset. The Houdini asset would need to know about specific Unity materials ahead of time.
For instancing Unity objects using a Houdini asset, you need to just create a Houdini asset that instances some geometry. Unity will automatically detect the use of a instancer in your asset and allow you to overwrite the Houdini geometry being instanced with any Unity GameObject from the scene or Prefab from your project you want. I've attached a relatively simple example asset that uses instancing and allows you to instance different objects per point.
For assigning Unity materials to a Houdini asset you need to add a special primitive string attribute called “unity_material” to your geometry that contains a path within your Unity project to a .mat Unity material (the .mat is important and should be included in the path). Again, I attached an example asset with the .unitypackage containing the dependent Unity materials.
That said, you can't instance Unity objects AND overwrite their materials from Houdini Engine. You have to chose one workflow or another. There is also no way to provide Unity materials as material inputs to a Houdini asset. The Houdini asset would need to know about specific Unity materials ahead of time.
- DASD
- Member
- 453 posts
- Joined: Feb. 2013
- Offline
- DASD
- Member
- 453 posts
- Joined: Feb. 2013
- Offline
Concerning the object instancing:
The Houdini Instance Manager Script allows to add (and remove) additional inputs. I would like to use this to add optional variation to my project. As far as I can tell, the objects assigned to the additional inputs are randomly assigned to the instance points.
Is there a way to control this behavior inside Houdini Engine?
What exactly is happening there under the hood? Is this behavior even intentional and what is the original idea?
Specifically I want to control the probability of occurrence and the ability to paint (or otherwise specify) areas to use specific instance variations. For example the user would be able to specify that the first input would occur roughly 50% of the time and all other inputs occur about equally often. Or that the inputs occur in descending order of probability. (And of course the user should be able to control the seed value…)
I see how I would be able to do this by manually adding input slots. But I am intrigued by the options here.
The Houdini Instance Manager Script allows to add (and remove) additional inputs. I would like to use this to add optional variation to my project. As far as I can tell, the objects assigned to the additional inputs are randomly assigned to the instance points.
Is there a way to control this behavior inside Houdini Engine?
What exactly is happening there under the hood? Is this behavior even intentional and what is the original idea?
Specifically I want to control the probability of occurrence and the ability to paint (or otherwise specify) areas to use specific instance variations. For example the user would be able to specify that the first input would occur roughly 50% of the time and all other inputs occur about equally often. Or that the inputs occur in descending order of probability. (And of course the user should be able to control the seed value…)
I see how I would be able to do this by manually adding input slots. But I am intrigued by the options here.
- damian
- Member
- 402 posts
- Joined: March 2013
- Offline
The variations support in the Houdini Instance Manager Script were never meant to be extensive. They are there as an extra bit of extensibility on top of assets that do instancing.
If you want to do something more complicated with better control of the random distribution you should do it on the Houdini/asset side. The example I attached “HAPI_Test_Instancing_ByAttribute.otl” uses attributes to control what each point is instancing. Using groups and possibly vop nodes, you can easily control random variations within Houdini.
If you want to do something more complicated with better control of the random distribution you should do it on the Houdini/asset side. The example I attached “HAPI_Test_Instancing_ByAttribute.otl” uses attributes to control what each point is instancing. Using groups and possibly vop nodes, you can easily control random variations within Houdini.
- DASD
- Member
- 453 posts
- Joined: Feb. 2013
- Offline
- winkel
- Member
- 218 posts
- Joined: March 2006
- Offline
Hi that looks fine but not everything is working for me.
For my example I try to create random grounds in a building with materials predefined in Houdini.
1. I can't get my “Ground” and “Corners” to be Prefabs in Unity
2. Do I have to export “Ground” and “Corners” as FBX and import them into unity manually?
3. I can't get the materials bind to the objects as placed in Houdini
Thanks for help
Detlef
For my example I try to create random grounds in a building with materials predefined in Houdini.
1. I can't get my “Ground” and “Corners” to be Prefabs in Unity
2. Do I have to export “Ground” and “Corners” as FBX and import them into unity manually?
3. I can't get the materials bind to the objects as placed in Houdini
Thanks for help
Detlef
- damian
- Member
- 402 posts
- Joined: March 2013
- Offline
Hi. I had a look at your asset. The problem is that Unity does not apply the material on the Instancer OBJ to the objects being instanced.
For example, you have no material assigned to master/OUT_GROUND but you have “../shopnet/Ground2” set on the instanceGround1 node's Material tab. In Houdini, everything instanced by instanceGround1 gets assigned the Ground2 material but Unity doesn't consider instanceGround1's material so no material gets applied.
It's not going to be a trivial thing to add to Unity. We'll look at adding support for this but can't promise anything soon.
Regarding your questions 1. and 2., I'm not sure I understand. The Ground and Corners come into Unity just fine for me. Are you looking at making <i>just</i> the Ground and Corners into Prefabs? Should this be done every cook?
I'm not sure if it answers your question but there is a Bake button in the asset's Inspector that will bake the entire asset into a standalone, native Unity Prefab.
For example, you have no material assigned to master/OUT_GROUND but you have “../shopnet/Ground2” set on the instanceGround1 node's Material tab. In Houdini, everything instanced by instanceGround1 gets assigned the Ground2 material but Unity doesn't consider instanceGround1's material so no material gets applied.
It's not going to be a trivial thing to add to Unity. We'll look at adding support for this but can't promise anything soon.
Regarding your questions 1. and 2., I'm not sure I understand. The Ground and Corners come into Unity just fine for me. Are you looking at making <i>just</i> the Ground and Corners into Prefabs? Should this be done every cook?
I'm not sure if it answers your question but there is a Bake button in the asset's Inspector that will bake the entire asset into a standalone, native Unity Prefab.
- winkel
- Member
- 218 posts
- Joined: March 2006
- Offline
Thanks a lot,
I try to make a game width different levels, so my thought was to make Prefabs out of my ground-objects. Also it makes a lot of Ground instances outside my object. See picture
I put a prefab (1) into Instance (2) brings a lot of Objects outside my Asset (3)
I can't find any way to bring a collider into my game. Inserting f.e. a box collider to my ground prefab deletes my objects.
I can't find the right point where to add textures and colliders -I'm sure it's my beginners mistake;o)
Hopefully
Detlef
I try to make a game width different levels, so my thought was to make Prefabs out of my ground-objects. Also it makes a lot of Ground instances outside my object. See picture
I put a prefab (1) into Instance (2) brings a lot of Objects outside my Asset (3)
I can't find any way to bring a collider into my game. Inserting f.e. a box collider to my ground prefab deletes my objects.
I can't find the right point where to add textures and colliders -I'm sure it's my beginners mistake;o)
Hopefully
Detlef
- damian
- Member
- 402 posts
- Joined: March 2013
- Offline
A couple things:
1. Do not try to make a Prefab out of the Houdini asset or any components from inside the asset by dragging them to the Project tab. This will break a lot of things. The only thing you can do with Houdini Assets and Prefabs is to bake a specific Houdini Asset state into a Prefab (as a whole).
2. There should be no need to set anything on the Houdini Instancer Manager (the way you dragged Ground2 under instanceGround2). You are already instancing Ground2 coming from Houdini. Those fields under each instancer are if you want to instance something from Unity instead of what is coming from Houdini.
3. To add collision meshes to your objects just put everything in a primitive group in Houdini called “rendered_collision_geo”.
4. Textures should come across if you assigned them to your SHOP shaders. Currently only Diffuse comes across though. Remember to first fix the problem mentioned in my previous post by assigning materials on the instances themselves and not just on the Instancer OBJ otherwise materials won't work at all.
1. Do not try to make a Prefab out of the Houdini asset or any components from inside the asset by dragging them to the Project tab. This will break a lot of things. The only thing you can do with Houdini Assets and Prefabs is to bake a specific Houdini Asset state into a Prefab (as a whole).
2. There should be no need to set anything on the Houdini Instancer Manager (the way you dragged Ground2 under instanceGround2). You are already instancing Ground2 coming from Houdini. Those fields under each instancer are if you want to instance something from Unity instead of what is coming from Houdini.
3. To add collision meshes to your objects just put everything in a primitive group in Houdini called “rendered_collision_geo”.
4. Textures should come across if you assigned them to your SHOP shaders. Currently only Diffuse comes across though. Remember to first fix the problem mentioned in my previous post by assigning materials on the instances themselves and not just on the Instancer OBJ otherwise materials won't work at all.
- winkel
- Member
- 218 posts
- Joined: March 2006
- Offline
Hi Damian,
thanks a lot for your support! Otherwise I find no help!
Now the collision works perfect, now the only problem are the materials, see attached my new hda. Where in Unity I can apply the textures automatically?
And is there a list of attributes I can apply from within Houdini to Unity like the collision? And always I get this warnings in Unity:
'Assets/Materials/Frame01.mat' does not exist
UnityEditor.AssetDatabase:ImportAsset(String, ImportAssetOptions)….
Sorry about that late answer but now we 17:00 here in germany;o)
And have a nice day.
Detlef
thanks a lot for your support! Otherwise I find no help!
Now the collision works perfect, now the only problem are the materials, see attached my new hda. Where in Unity I can apply the textures automatically?
And is there a list of attributes I can apply from within Houdini to Unity like the collision? And always I get this warnings in Unity:
'Assets/Materials/Frame01.mat' does not exist
UnityEditor.AssetDatabase:ImportAsset(String, ImportAssetOptions)….
Sorry about that late answer but now we 17:00 here in germany;o)
And have a nice day.
Detlef
- Dmitryy Vusatyy
- Member
- 4 posts
- Joined: March 2016
- Offline
- dpernuit
- Staff
- 553 posts
- Joined: Sept. 2016
- Offline
Hi,
This should be what you're looking for:
Instancing by Parameter [www.sidefx.com]
Instance Vartiations [www.sidefx.com]
Instancing by attributes [www.sidefx.com]
This should be what you're looking for:
Instancing by Parameter [www.sidefx.com]
Instance Vartiations [www.sidefx.com]
Instancing by attributes [www.sidefx.com]
- trojanfoe
- Member
- 67 posts
- Joined: May 2016
- Offline
dpernuit
Hi,
This should be what you're looking for:
Instancing by Parameter [www.sidefx.com]
Instance Vartiations [www.sidefx.com]
Instancing by attributes [www.sidefx.com]
The first and third video are actually the same, despite being different URLs.
Edited by trojanfoe - June 26, 2017 02:31:57
- winkel
- Member
- 218 posts
- Joined: March 2006
- Offline
-
- Quick Links