Painting Landscape programmatically using C++

Hello,

I’m abording the procedural environtment generation to my master’s thesis, and i found this part of the topic a bit hard: I want to paint a landscape using PCG algorithms, but for that i need to paint it using C++.

Is it possible in UE?

1 Like

ULandscapeComponent should have all things you need:

This is probably what would be interested the most

And here is example of how to generate UTexture2D:

Alternaticly, since you want to do some algorithm, you could use normal multi polygonal plane and use world displacement in material shader, not sure if you could use landscape for it too. This would make your generation done in GPU, ofcorse if it’s not too heavy

2 Likes

Dude, you’re a life-saver! I don’t know if this helps the OP with his question, but it solves what I have been trying to do! Upvoted!

So let’s say I plan to GetHeightmap() to get the landscape height map, perform some work on the HM based on something at a particular spot on the landscape then put it back with SetHeightmap()… is there a way to quickly correlate a particular point on the landscape based on an object placed on it in the editor with a particular point on the landscape HM?

Are you working in something related to?

About the generated texture, i’m planing to use custom existing assets(textures), i just need to paint the landscape with that textures using C++.

Perhaps, I think so; I am attempting to create building assets that flatten out the landscape around where you place them, just a little bit, so that they can line up better with the landscape with having to resort to - potentially huge and drastic - additional areas of mesh which in most cases would just be completely below the landscape.

Sounds like you’re creating a custom brush?