Jump to content

Copy original UVs back to source geometry?


etudenc

Recommended Posts

Hi again,

I'm hoping someone can help me with this.

In Houdini, I want to animate a lego building being built up, brick by brick, using a bounding object and some grouping.

I'm importing the building made of lego blocks into Houdini from Maya. The blocks (1000's) are different colors and scales of one template box, so the UV map is the same for all blocks. To make it easier to re-assign the materials when I bring the building back into Maya, I've offset the UV maps on a per-material basis, so on those blocks that should get a red texture, I've offset the UV map up and to the right (staying with 0-1 UV space). Same goes for the blue blocks, etc.

I've combined the blocks and saved as an OBJ.

The OBJ is brought into Houdini and using a forEach SOP I find the size, orientation and center of each box (thanks, Jonah Hall!) and pipe that into a copy SOP with a box attached as the source. So far this part works OK... I'm able to scale, orient and position the boxes according to the original. The different UV map offsets all "survive" to the copy SOP, but on the output geometry there's just one, centered UV map.

What I'd like to happen is for every box that gets created through the copy SOP, the original UV map position for the box that's being replicated gets copied onto the sourced geometry, basically so when I bring the animated build back in all the boxes have the same UV offset as the originals.

Would I do this thru a copy stamp operation? or could I use an attribute transfer and pipe the UV data prior to the copy SOP over to the box source (have tried but may not be doing it right)?

As always, any suggestions would be greatly appreciated!

Link to comment
Share on other sites

I kinda understand your problem. I will try my best to help you out without a file to see.

It sounds like a lot of geometry, so if the geometry you are copying has the same topology as the original, then you could use the AttributeCopy SOP. This is faster than the AttributeTransfer because its directly copying from point to point rather than solving a proximity.

You could also try the Vertex SOP, and in the first input goes the "new" geometry and the second goes the original geometry. Then in the Texture use $MAPU2, $MAPV2, and $MAPW2 to copy the original UV data.

Also, it sounds like since you are using foreach, the UV map is getting overwritten at every loop. I'm not exactly sure though.

Hope this helps. :)

Link to comment
Share on other sites

Boy I'm confused. Tried to follow what you were doing but couldn't.

Attribute transfer is normally used to copy attributes from a source geometry to a target geometry when the point counts are different. The transfer uses a meta-ball weighting algorithm to do the transfer, and I don't think that's what you need.

Sounds like a simple Attribute Copy will work.

Are these blocks all solid colors? or do will they be rendered with a texture on them?

Link to comment
Share on other sites

Thank you both for the quick responses. I'm attaching a simplified scene file and a template bgeo file with the maps offset.

If you scrub to frame 50 and look at the UVs on "copy2", you'll see they appear to be there but when I look in the spreadsheet they are not listed.

Ryan, you mentioned the vertex SOP... seems like a good idea, but do you think it should go before or after the copy SOP? To me it seems like it should go before so that for each template point the source geo gets copied to, it would inherit that point's UV info.

I tried adding an attribute copy SOP between the source geo and copy SOP, but doesn't seem to make a difference.

Hobpin, thanks for your suggestions as well... in the forEach when I replaced the attribute transfer with an attr copy, the copy SOP stopped working! :(

Anyhoo, if you get a sec to look at the file, please let me know any suggestions you might have.

copyUVs.zip

Edited by etudenc
Link to comment
Share on other sites

Ryan, you mentioned the vertex SOP... seems like a good idea, but do you think it should go before or after the copy SOP?

yep, vertex sop should solve that, add it after copy sop. But I'm also confused why it's not copying uv attribute.. also add sop adds 5 vertices so You have 125 vertices instead 120 ;]

Edited by tmdag
Link to comment
Share on other sites

yep, vertex sop should solve that, add it after copy sop. But I'm also confused why it's not copying uv attribute.. also add sop adds 5 vertices so You have 125 vertices instead 120 ;]

Good point re. the add SOP, I might as well remove it.

I added the vertex SOP after copy but it just zero's out the UVs. However, I tried adding the attribute copy SOP (as was suggested) but *after the copy SOP, then connected the output of the template geo and now it appears to be working! I don't understand why, though, so I guess it just means I still have a lot to learn about the copy SOP!

Thanks so much for the help, guys. Ryan, I have visited your blog several times - very helpful stuff!

Link to comment
Share on other sites

Yea, tmdag got it right. That is strange that the UVs didnt go through the copySOP...

One small thing I noticed is the point order of the original and new geometry doesn't match. I dont know if it will make a difference in the end. But, you'll probably be OK.

Thanks for checking out my blog. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...