1
$\begingroup$

Preamble: I'm attempting to make this tool to "blockify" any model that's tossed into it. Its goal is to turn the model into a Minecraft block structure. So far, it works perfectly for the basic function of building the pseudo-voxels. I can export this model and run it through other pieces of software to turn it into a usable format for placing in the world.

The Problem: I still want to add the ability for each instanced block to inherit the material from the faces (or vertices) of the original object that they are touching. Right now, I have a custom Suzanne with two materials applied, but it doesn't seem possible to do this without explicitly assigning the materials by hand or making bespoke changes for each new object I'm trying to convert.

The Question: Is it possible with the current geometry nodes to transfer materials to individual instances via proximity to the faces of another object? I plan on having dozens of materials, so I want this tool to assign them in the most generic way possible to avoid having to make any unique changes to the original object or the node network.

Here's what I have so far: Blockify01 (animated)

Here's what I want it to do automatically: Blockify02

Update 04/09/22: Just to clarify, I'm not spawning these instances on the faces of the object. Instead, I create a cube volume of equally-spaced points and the input model is what selects which of those points to spawn the cube instances at. This is to ensure that the end result is made at a specified resolution and there are no overlapping instances.

Update 2: It seems to work now! Many thanks to Chris and Robin Betts for bringing forth some key pieces to this puzzle. What I have now is a combination of their suggestions Wahoo! Of course, it is a bit janky. The material slots on the target object must contain all the materials in the node network and in the same order as the nodes. Also, it doesn't seem to apply the materials to mesh primitives created by nodes, so an external block object needs to be used.

$\endgroup$

3 Answers 3

2
$\begingroup$

I made it work with this node setup:

enter image description here

enter image description here

Note: I had to use these "set material nodes" else it won't work. I had to change the colors order to make it work:

enter image description here

It is a bit unpredictable and not logical for why the colors must be in that order...

$\endgroup$
2
  • $\begingroup$ I couldn't seem to get this work until I used a Transfer Attribute node instead of your Capture Attribute node. It is VERY fiddly, but once the material slots are in the correct order, it seems to work as intended. It's going to take a lot more work than I hoped to ingest a new model, but I think I can build a workflow from this. Thanks a lot! $\endgroup$
    – Reenuip
    Commented Mar 10, 2022 at 0:47
  • $\begingroup$ Glad I could help $\endgroup$
    – Chris
    Commented Mar 10, 2022 at 4:16
1
$\begingroup$

It surprises me that the Remesh modifier doesn't carry this as an option.. or that Material Index isn't available through Data Transfer.

I don't know if this suits, but [Monkey Right] is just a copy of [Monkey Left], with an additional Remesh (Blocks) modifier, and this GN Group at the bottom of the stack, to transfer material indices:

enter image description here

enter image description here

$\endgroup$
5
  • $\begingroup$ Initially, I was using the remesh modifier, but it doesn't have intuitive controls for getting the final output at a desired resolution. Currently, my tool creates a cube volume of equally distributed points and the input model selects which points in that volume spawn the blocks. If there's a way to use the remesh modifier so I could make sure the resulting mesh is, say, 32x32 blocks then I might reconsider this method. $\endgroup$
    – Reenuip
    Commented Mar 9, 2022 at 16:08
  • $\begingroup$ Check out @Kuboå 's very nice answer here, or my ancient one here.. they may help you out. $\endgroup$
    – Robin Betts
    Commented Mar 9, 2022 at 16:39
  • $\begingroup$ Okay, that looks interesting. I'd be a shame to scrap the node network I put together, but this might be the only way to do what I need. I'll play around with this and see what happens. $\endgroup$
    – Reenuip
    Commented Mar 9, 2022 at 22:29
  • $\begingroup$ I think you should be able to transfer the mat.idx from the original to your construction in the same way as to a remeshed version? This group should transfer mat. idx from anything to anything. will check on a baby example tomorrow. $\endgroup$
    – Robin Betts
    Commented Mar 9, 2022 at 23:02
  • $\begingroup$ Ah, yes, I was finally able to transfer the material index! I wish I could mark two answers as what solved my issue. Your suggestion of using the transfer attribute node is what got me through, but the bulk of the solution I've ended up with came from Chris. Thanks so much for the help. $\endgroup$
    – Reenuip
    Commented Mar 10, 2022 at 0:44
0
$\begingroup$
  1. get the index of material of monkey.
  2. distribute instance on monkey vert.
  3. combine all the instance as a whole.
  4. put the material on the instance I create,that means he has the same uv as monkey,so their color looks the same.

enter image description here

$\endgroup$
6
  • $\begingroup$ Sorry, but this doesn't seem to work for my case. I can get a single material to transfer, but the second material doesn't apply to any of the instanced cubes. Does your monkey have multiple materials assigned to different faces? $\endgroup$
    – Reenuip
    Commented Mar 9, 2022 at 1:20
  • $\begingroup$ Also, for some reason the instances won't take the material if it's not an existing object in the scene. My node network generates the cubes from a primitive Cube node and that completely breaks the material application. $\endgroup$
    – Reenuip
    Commented Mar 9, 2022 at 1:55
  • $\begingroup$ for 1, could you pls sent me a demo of your project?I want to know the exact ways you place your material,I think may be place the point on diffierent vertice group will help. for 2, I don't quite understand what you mean... $\endgroup$
    – NatureK
    Commented Mar 9, 2022 at 3:17
  • $\begingroup$ It's a bit strange, really. There are a few main functions in my node network. Since I want the blocks to spawn in a perfect grid (as if it were a Minecraft structure), I first create a volume of vertices equally spaced apart. The input model, Suzanne, acts as a selection mask for those vertices in the volume to instance cubes on. The Suzanne model has two materials applied to it. I did this by going into edit mode and selecting the faces of the eyes and gave it a different material on slot 2. I'm looking for a way to transfer the material data for each individual cube instance that touches $\endgroup$
    – Reenuip
    Commented Mar 9, 2022 at 5:04
  • $\begingroup$ I'll throw together a project tomorrow to clarify my point in my second post. $\endgroup$
    – Reenuip
    Commented Mar 9, 2022 at 5:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .