[Houdini procedural generation] UV-based generation tool



foreword

Opening a new hole (ow2 is really fun)
I remember it was a bit messy, because it was followed by the class and the hda file.


1. Goals

After the white box pulled in UE is put into the Houdini plug-in as a variable, a free-stacking wooden box that fills the inside of the white box is generated.
Tutorial guidance: here Chapter 2 Stacking Tools
Software used: UE5 and Houdini19

2. Preparatory work

Session Sync

The first is to export hda, you can refer to this article , which is quite comprehensive.

Next is this, which has troubled me for a very, very long time, about session sync between UE and Houdini. I searched for a long time. Let me record how I successfully connected.

My problem is that it does not report an error, and ue even shows that the connection has been successful, but the adjustments made by Houdini are not fed back to ue in real time, that is, there is no synchronization success at all.

First of all, a few points of attention.
The connection port of ue
insert image description here
and the connection port of Houdini
insert image description here
must be the same.
In addition, to find your own installation directory,
insert image description here
I have also seen on the Internet that some people blocked the call link because of a firewall, so you can try it.

Secondly, if you can’t use the session when you open Houdini directly, after opening Houdini in ue for writing and insert image description hereopening, there will only be one GlobalNotes node, first open the communication point of Houdini. insert image description here
If the connection is successful, after rebuilding or dragging a new HDA to the view panel of ue, Houdini will automatically create a node such as globalnotes1
insert image description here
or a node such as geometry,
insert image description here
both of which will be newly created, so that real-time communication can be realized.
I have been looking for the difference between these two types for a long time. The box icon of this DA is a subnet within a subnet, and the outermost subnet becomes this icon, as shown in the figure: this geometry is a single-layer
insert image description here
subnet
insert image description here

Click
insert image description here
to enter node editing, and then complete the communication.

Ue's database

First create a structure and add variables, as shown in the figure
insert image description hereinsert image description here

Create another data table to add data
insert image description here
using the previously declared structure , and make the width, length, and height equal to the numbers shown below (change according to the assets you added yourself) . In this way, the pre-preparation work is complete.
insert image description here

insert image description here

But sadly, ue only supports the commercial version of Houdini to open and edit hda files. The
hda source files he gave are OK, but if you want real-time debugging, just send them.

3. Houdini Compilation

Section 1: Processing Points

insert image description here
insert image description here
What connective does is to number the points and connect the points with the same number. A bit abstract, as shown in the figure below:
Connective for a single connection to sphere:
insert image description here
all 0

Connect it to the merge node of the Cube, and
insert image description here
you can see that the cube is all 0, and the sphere is all 1, so that the two objects can be distinguished, and there will be no mixing and chaos in the unpack node.

Next is attribpromote, which is to transform the attribute node
insert image description here
promotion method
insert image description here
. For the four common attributes: Point, Vertex, Primitive, and Detail, the first three can be read in this article.
detail is something similar to global variables, such as for the example just now, max = max(class)=1 insert image description here
next
insert image description here

Section 2: Making a Placement Plane

The first is the scatter and align node, the main function is to generate scatter points, but the function is powerful, see the link ( here is
insert image description here
a usage that I have not seen before spare input
spare input is also a substitute variable name, click here to add After
insert image description here
adding, hover the mouse, you can display the code name, and you can refer to it in the previous article with this code name. The
insert image description here
next step is to copy the assets to the scatter chart. After
insert image description here
the completion, it will look like this.
insert image description here
The next step is to adjust the size. After all, it looks the same at present. All kinds of boxes look the same size.
insert image description here
Here is the use of UV to complete the size scaling: UVlayout:
insert image description here
insert image description here
Now the problem is that in the packaging process, we have been using max, but in fact, this is a waste of resources, so we Change max to fixed. But this caused data overflow, so we turned on the nonpacked attribute and deleted it with the blast node.
insert image description here
In this way, the basic plane effect is completed
insert image description here

Section 3: Making stacking effects

insert image description here
insert image description here

  • Partition node: according to the rules entered, each point is placed in a group named after itself
  • If you need some more maximum size (there are more faces after Blast), change the size step in front
    insert image description here
  • clusterpoint sets a formula (ch(" ")*1.5) that has no actual physical meaning in order to set more cluster points than pack points (that is, one cluster per face) npoints(-2).
  • He mentioned here that due to some bugs in UVlayout, sometimes there will be grid overlapping problems. At this time, it can be normal after adjusting it with remesh (I really don’t understand this part very well, it seems that it will want to put Each separated space is packaged into an independent square space.)
    insert image description here
    At this point, the vertical stacking is basically completed
    , but there are still some work to be done
    insert image description here

The fourth section: real effect production

You can choose to make these wooden boxes appear to be shuffled.
With the above foundation, it should not be difficult to understand this string
insert image description here

Summarize

When I read it, I thought it was a bit difficult, but after finishing it, I felt that it was very subtle and I learned a lot.
There is no real usage habit that cares too much about functions. If you encounter any problems when forking, you can try it according to the original project.

Guess you like

Origin blog.csdn.net/woshi_wst/article/details/127332697