Assigning texture file paths based on group names.

   8866   11   1
User Avatar
Member
338 posts
Joined: Sept. 2006
Offline
Hey guys,

Im not to sure how to approach this best. What im trying todo is to automatically assign the correct textures to 100s of different buildings with 1 shader.

So I have 1000 buildings in maya which we have exported to Houdini with groups based on shader names in Maya. We then have textures that contain the group name with a postfix for the type of texture I.e diffuse, spec etc.

So im trying to utilize the group names that have the shader attached it and assign the group with the correct texture. Anyone know or have any ideas of how todo this?

Thanks
Nick
User Avatar
Member
7773 posts
Joined: July 2005
Offline
Assign your shader with some non-default parameters using a Shader SOP. Turn off the Use indirect references parameter on the Shader SOP. Now use as an example, the primitive attribute values that get created from it. The idea here is that you manually specify the correct shader string based on your primitive with some expressions and the AttribCreate SOP to mimic what the Shader SOP does.
Edited by - Aug. 27, 2007 11:24:54
User Avatar
Member
338 posts
Joined: Sept. 2006
Offline
Still a little confused with what you mean. Are you saying that i need to create a shader for each texture. Then use expressions to assign the correct group that shader?
User Avatar
Member
401 posts
Joined:
Offline
no, a shader can read point/particles attributes and construct the path to the texture based on this.

You can also construct the ‘shader string’, wich holds all parameters for that shader on a per object basis.

I know what edward means, but I cannot explain it in plain words.
There is a video tutorial that explains the point-instancing of lights which explains this workflow very well, but as usual I cannot find the url.

Georg
this is not a science fair.
User Avatar
Member
7773 posts
Joined: July 2005
Offline
I mean to use the AttribCreate SOP to manually assign your own shader with different texture names. The Shader SOP with indirect references turned off gives an example of how to construct the proper shader string values.

The technique is similar to the files found in these threads:
http://forums.odforce.net/index.php?showtopic=4462&st=0 [forums.odforce.net]
http://forums.odforce.net/index.php?showtopic=3186 [forums.odforce.net]
User Avatar
Member
338 posts
Joined: Sept. 2006
Offline
Thanks guys, Edward this should helpout for sure. If i have any other problems with it i will drop another post. I will also do a quick search for that video rdg

Cheers
Nick
User Avatar
Member
338 posts
Joined: Sept. 2006
Offline
I had a look at the example for the attribute create. Which works great if you are copying objects and using stamps. The issue I have is the objects are already created in maya. So cant use a copy sop in the same way. What i will have is groups with the correct name for the textures to be generated from.

Which is what im struggling to use. So if i have a building with a group called

“warehouse_A”

I would need to use the attributeCreate to pick up the group name “warehouse_A” and compile it into a texture path. “asset/location/city1/textures/warehouse_A_diffuse.rat”

This would need to be looped for every group I guess. Is that looping of attributeCreate on the groups possible?

Thanks
Nick
User Avatar
Member
1390 posts
Joined: July 2005
Offline
Here you have an example!
There is a new ForEach SOP but I can't use it yet ops: so I'm doing this oldschool way.


hope this help!
sy.

Attachments:
primGroupsAndTextures.hipnc (167.7 KB)

User Avatar
Member
338 posts
Joined: Sept. 2006
Offline
Hi SYmek

Thanks for the example, i think that would be a solution for sure. Probably a last resort tho as we have a lot of enviroments with thousands of buildings. But would work for sure. I have taken a look at the “for each shop in houdini 9” very cool node !! I think this will do exactly what i need it to. If I can find out hot to access the group name it is currently dealing with it will work. Thanks for pointing me to this one.

Thanks
Nick
User Avatar
Member
1390 posts
Joined: July 2005
Offline
You can do this also in hscript or python. I just wanted to show you “orthodoxy procedural” way . But in case of thousands of buildings maybe there is no reason to hesitate and you should consider scripting. It would be easier to handle textures name for example.


cheers,
sy.
User Avatar
Member
338 posts
Joined: Sept. 2006
Offline
Quite possibly hit a brick wall :¬/ The “for each” sop would work for what I need. But I dont know how to get the attributeCreate to use the name of the current group that the “for each” node is treating.

I have a slight feeling that what i want todo isnt currently possible with out creating the networks manually as in SYmeks example scene.

Ifs its not possible a big to everyone with the fast responses :¬)
Cheers
Nick

edit–Ive never done any Hscript so wouldnt really know where to start, i can mel script tho …. I guess it should be pretty simple tho just a loop on the groups with a specfic pattern from the original geo file. Might as well try.
User Avatar
Member
338 posts
Joined: Sept. 2006
Offline
If anyone is interested ive figured out how to use the group name that is currently being used by the “for Each” node.

Basically inside the “for Each” node there is an “each” node. This node helps to split up the the groups to allow the “for each” node to repeat the cooking of the sops within the “for each” node.

The each node has a “cull group” parameter. This outputs the current group name. I just referenced this into the “attributeCreate” sop to allow me to generated the texture path from the group name.

Sorted :¬)

Mucho Thanks
Nick
  • Quick Links