How to bake texture colors into vertex colors, preserve them in/after VDB, and merge coplanars after mirroring?

   11003   7   2
User Avatar
Member
7 posts
Joined: 1月 2018
Offline
Hello there.

I have three questions for you guys :

1- Is it possible to bake texture colors into vertex colors? I found an old thread from 2002 in which somebody explained how to sample a texture in a ‘Vertex’ node, but I've tried that and couldn't get it to work. Another problem here is that I would like to sample some/all pixels in adjacent triangles and get the average color, sampling a single pixel isn't a good way to get the approximate color.

2- When I convert polygons into VDBs and back into polygons, is there a way to somehow preserve more data, be it vertex colors or maybe even texture coords (approximated) so I can bake the vcols after the VDB? I don't think voxels can hold that data so I guess a simple solution but that would work only for my specific case is to simply get the color based on the closest vertices of the original mesh since I'm not modifying the object shape considerably.

3- After using the ‘Mirror’ node (actually I'm using clip and then mirror, but I'm not sure if that's the proper way to do it), you might end up with many coplanar faces, say for example you're clipping in half and mirroring a cube, the top square will consist of 2 rectangles that I would like to merge into one square again, but I couldn't find a way to do that, I've tried “Clean” and “Merge” and many other nodes to no avail.

If you guys are curious about what I'm trying to do: I'm trying to convert some models I have here that are too detailed into some kind of ‘google poly’ style, the idea is to use volumes in order to get a ‘solid’ shell (what works pretty well) and then use the amazing polyreduce (and perhaps a bit of remeshing and VDB smoothing depending on the situation) to get the low-poly style.

Thanks in advance.
User Avatar
Member
55 posts
Joined: 3月 2015
Online
Just to throw some quick ideas your way -

1. I heard that Vertex node isn't working anymore. I would love a solution to this as well for doing things like baking lighting to vertex colors. I think there is a way but you have to really do a lot of setup yourself and do things like blur a 2d image to average the colors etc. I think it's possible now but seems very complicated to setup.

2. I was able to do some sort of color transfer after the polygon->VDB convert. I forget exactly but it was one of those nodes where you transfer attributes.

Hope that helps a little bit at least.
User Avatar
Member
1743 posts
Joined: 3月 2012
Offline
1. The tab menu entry for Vertex now puts down an Attribute Expression SOP, which lets you write a one-line VEX snippet. Attribute Wrangle with Run Over set to Vertices will let you do a multi-line VEX snippet. The texture VEX function [www.sidefx.com] might help, though the docs say that the filter width will be zero if it's used outside the shading context (materials), and the first signature listed isn't available outside the shading context.

2. If you feed the original mesh into the second input of the Convert VDB that converts back to polygons, that can help transfer more data from the original mesh to the final mesh. There are a bunch of parameters on the node for controlling what it does with that additional information.

3. The Dissolve SOP can be used to remove the edges along the mirror plane.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
7 posts
Joined: 1月 2018
Offline
Thank you guys

I think the texture sampling can get a bit tricky because say for example the vertex is at the edge of a UV island if you get the average on the UV over a given radius, you might sample pixels from other islands or pixels that aren't mapped to any polygon at all. It was suggested sampling a higher mip level too.

Regarding the mirror, it's still not clear if the ‘normal’ workflow to have a symmetric object is the one I'm using. In other applications I've used the realtime ‘mirror’ function does the clipping and also allows limiting vertices and such. I don't see any of that in the mirror node in Houdini that's why I'm using other nodes for that and it's not a problem of course I'm just not sure if I'm not missing something obvious.

I'll give the suggestions a try very soon and report back the results. Volumes are really good for simplifying complex meshes and extracting a ‘solid’ shape with no hollow parts or unweld polygons from almost any model however ‘noisy’. In terms of mesh the results are great, I just need a way to get the other data, in my case it's just vertex colors but I think volumes and the polyreducer could be used for advanced LOD generation, but then textures are a must or even a way to somehow ‘bake’ the high poly details into the decimated mesh.

Thank you
User Avatar
Member
7 posts
Joined: 1月 2018
Offline
Hi guys,

So I've been studying Houdini a bit more and I must say that it never stops to impress me although the frustration is real for a n00b like me .

In any case the Attribute Transfer (with only Vertices ticked) really does copy the UV from the high poly model, however, when you decrease the polycount too much it fails badly (what's expected of course, software can't do miracles ):


So I'd like to try copying the texture color into vertex colors before that, and then transfering the colors from the high poly mesh, however, I couldn't figure how to actually sample the texture, I don't understand that VEX thing… I've tried to use the texture sampling function but for some reason my positions got converted into ‘snippet1’ and now I can't change it, here's how the line looks like:
texture("opdef:../..?squab_diffuse.jpg", snippet1.u, snippet1.v)
and it doesn't work too . Everything is setup correctly because I tried using random colors and that worked fine.

What am I doing wrong?

Thanks in advance.
Edited by alanqdev - 2018年2月17日 18:12:24

Attachments:
18-02-17-155.png (730.2 KB)

User Avatar
Member
7 posts
Joined: 1月 2018
Offline
OK guys, this setup did the trick to get the vertex colors in the low-poly mesh:


Problem now is sampling a larger area to get the vcols without sampling unmapped pixels… I think the best way would be to sample pixels in adjacent triangles but now that's totally outta my league :trollface: .

EDIT:
Attribute Transfer is only for UV (Vertices, ‘uv’ in the field).

EDIT2:
Adding an “Attribute Blur” before the last node and setting it to “Cd” did wonders
Edited by alanqdev - 2018年2月17日 18:16:24

Attachments:
18-02-17-156.png (40.9 KB)

User Avatar
Member
55 posts
Joined: 3月 2015
Online
Awesome! Thanks for posting up your solution!
User Avatar
Member
10 posts
Joined: 7月 2013
Offline
Is there a hip file we can looksi?
  • Quick Links