Community Tutorial: Introduction to Procedural Generation plugin in UE5.4

I found a bug with the CreatePointsGrid node.

I have a scene where it is working when I open the scene. However when I make any change or move the PCG graph, it suddenly stops executing correctly.

On scene open it looks like this:

Then I move the PCG volume and it disapears:

I attempt to debug the “CreatePointsGrid” node and nothing shows up:

I found the solution is odd, I need to move the PCG volume back to world zero. The volume was here:

Now here:

I open the PCG Graph. And select the “CreatePointsGrid” node. Check “Local” on.

Now check “Local” off.

Then go back to the final PCG and turn debug back on for the whole graph.

Move the PCG graph back to where it was. It works again.

I am happy to share my scene. I am having this happen also with the PCG levels in the engine content provided with the latest Unreal 5.2 preview.

Ryan

1 Like

I think I figured out more about what the bug is. When you reopen a level with the “CreatePointsGrid” it must have a cache of some sort because it displays correctly to start. As soon as I move the volume the points that were part of the “CreatePointsGrid” disappear. I noticed that it had a property called “Cull Points Outside Volume” if I check it off the points show up again:

But if I check it back on, they disappear.

This works differently than when you first create the PCG graph from scratch. After you save the scene, thats when it breaks. I would expect it to continue to draw the points even though technically they are outside the volume. The “CopyPoints” node should inform the PCG graph to continue to draw the points since they are now in the parent space of the points from a “Surface Sampler” node.

image

1 Like

I have this very simple graph what just scatter a given mesh. But instead of doing it with the mode PCGMeshSelectorWeighted, I’m using PCGMeshSelectorByAttribute.

Then I can add an attribute to all my points, named “MyMesh” which is a SoftObjectPath (internally converted to a String), where I can specify a mesh.

And in my static mesh spawner, I just set “MyMesh” as the attribute name where the path to the mesh is.

And with that it will spawn the right mesh.

You can also turn it into a subgraph, with a custom pin for the mesh to spawn, and make the graph re-usable for multiple meshes, like this:

Unfortunately, it shows an error, because the graph can’t be used as-is, you need to use it as a subgraph.
That’s something we are looking at internally.

Hope it helps!

5 Likes

That’s strange. I have this rainbow texture, that targets the Red channel for density and got this:

Possible that Texture Sampler was renamed to GetTextureData in the latest version, but it should be the same options.

I am on preview 2. And there is no such thing as Get Texture Data. This what I get:

Has anyone figured out if it is possible to Transform Points by density? I try to apply the Transform Points node to Attribute and no matter what I do it never works. Is it a bug?

As I said, Texture Sampler was renamed to GetTextureData in the latest. Preview 2 doesn’t have it it seems, but underneath, it’s the same.
Therefore I’m a bit surprised your setup doesn’t work, since it’s the same than what I showed you.
I’ll start preview 2 and look at it.

1 Like

You have an error which might be informative. Your source attribute need to be a transform, which doesn’t seem to be the case here.
I’m not sure I’m following you, on what you want to do.
If you want for example use the distance to change the scale of your points, you can use the “AttributeOperation” node, with input attribute “Distance” and output attribute “$Scale”, meaning you will set, for each point, the value of Distance into your scale.
If you want to do other operations like Addition, there are other operations, look under Metadata in the palette.

1 Like

Hi guys, I can’t use UE 5.2 PROCEDURAL GENERATION… :smiling_face_with_tear:
Even though I turn on ‘debug, inspect’ , my engine create anything.
Help me please, :smiling_face_with_tear:
I installed all plugins, and followed the tutorial video that was mentioned in this page.

Ok on Preview 2 it seems to not work correctly… Might be broken on that version… Sorry for that :confused: It should be good in the final version of 5.2

2 Likes

Multiple things to check:

  • Have you set your graph on a PCG Volume?
  • Have you clicked “Generate”?
  • Do you have a landscape?

The Mesh Sampler could have input (MyMesh) attributes like the mesh spawner.

PCG subgraph/graph`s attributes should have default values as well as actor parameters.

P.S.: A data/attribute struct or array would be also useful, that could be used in static mesh spawner.
For example a simple forest with one spawner node, but 3 kind of trees should be reusable by blueprint array parameter(meshes and weights).

OMG!! Thank you for your answer.
I soveld my problem.
My PCG Volume was located too high …
I thought it was attached to the landscape, but it was floating in the air…!!
Thank you so much :blush:

Hi, I have a question related to PCG Volume and DataLayers.
When “IsPartitioned” is disabled, we could put PCG Volume into DataLayers, and it will behave as expected.
But when “IsPartitioned” is enabled, PCG Volume in DataLayers doesn’t work properly. Adding PCG World Actor into DataLayers also doesn’t work properly.
The only thing that works is to put PCG Partitioned Actor directly into DataLayers, but this will trigger a crash when Editor is loaded.
Is this a known issue? or is there any proper pipeline for PCG Partition actor and Data Layer.

DataLayer is runtime mode, and InitiallyVisible, InitiallyLoaded set to false

This is perhaps a foolish question, but when working in the PointLoopBody function, is there any way to get the Index of the current point? I was looking at adding something that would give me distance to the next point in the array, but I have been unable to find any variable that gives current point Index


Thanks!

LevelInstances and DataLayers are not very well supported for the moment, it is something we will work on for future versions.

Note that if you enabled multithreading on your BP (it’s an option from PCG), incrementing an index will not work, as the order will not be respected.
And indeed point loop body doesn’t forward the index. I’ll talk with the team to see if we should add this one. In the mean time, you can try IterationLoopBody, you’ll have the index.

2 Likes

Thanks, the increment in there was a test of exactly that, and I did indeed find that it never incremented. Obviously if I can get the index of the current point then the incrementing is totally irrelevant (sorry if that confused the question!).
I love the parallels with Houdini in PCG, and general access to the current ptNum is such a useful piece of data it would be great to expose it wherever we might do work on a point. Total number of points might be useful too.

Hello, I have a question about how to get index inside loop on points.

I understand it is impossible to count how many times the loop is executed, but I wonder wheter I can get index “attribute” on current point.
I tried to get index by “Get Integer Attribute”, but it won’t work. So is there any possible way to do that?