x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How would you create terrain that doesn't lag?

Here's my situation. I have a function in a blueprint class that inputs an x and y position and outputs a height. I want to create an infinite world that is generated as a character walks through it, so basically during runtime. I have created something that works, but when new chunks are loaded it lags tremendously like down to 20 fps. I started using the procedural mesh component to generate terrain, that was too laggy, so I moved on to using the Runtime Mesh Component (which is a plugin) which solved most of the lag except when chunks were generated. So if anyone knows any different ways of generating terrain with blueprints please reply!

Thank you all, - Will

Product Version: UE 4.16
Tags:
more ▼

asked Aug 24 '17 at 01:37 PM in Blueprint Scripting

avatar image

kαngrew
13 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I don´t know if you already resolved the problem, its already a bit ago.

What i´ve done is creating a quad tree, each node represents two different quality levels, the full detail and one of the parent (if not all 4 children can be displayed at full, then the parent mesh can be displayed)

Most if the stuff is done in async, as this was killing my performance (generating vertices, triangles, normals etc.) After the task is done, i can create one to two new nodes per frame, with rock solid 120 fps.

Async snipped (reduced):

 TFuture<FLandscapeGenerationTask> GenerationFuture = Async<FLandscapeGenerationTask>(EAsyncExecution::ThreadPool, [this]
 {
     FLandscapeGenerationTask GenerationTask;
 
     GenerationTask.FullMesh = GenerateLandscapeMeshSegment(GenerationTask, MeshTesselation);
     GenerationTask.ParentMesh = GenerateLandscapeMeshSegment(GenerationTask, MeshTesselation / 2);
 
     return GenerationTask;
 });
 

ProcessingTasks.Add(CallbackNode, GenerationFuture.Share());

A few numbers: Numbers of vertices: 30 per site, 900 total Numbers of tris: around 5000 Numbers of UV, normals, tangents: each 900

if i split the tree, each children has only the half site length (4 children), so i double the quality with each deeper level in the tree.

At level 1 its 900 vertices, if you would replace the level 1 with the level 8 children (4096 of them), i end up having 1920 vertices for one site and 3686400 overall. But not all are displayed all the time for sure, its only around the player based on the distance.

Hint: Make the collision only were you need them, and set:

     NewMesh->SetCollisionUseAsyncCooking(true);
 NewMesh->CreateMeshSection(0, MeshData, true, EUpdateFrequency::Infrequent);
 NewMesh->SetMaterial(0, Quadtree->Material);
     NewMesh->LastRenderTime = GetWorld()->GetTimeSeconds();
     NewMesh->RegisterComponent();
 

to have async cooking of collision (before creating a new section or registering the compontent)

Cheers, Maik

more ▼

answered Mar 21 '18 at 07:46 AM

avatar image

Krustenkaese
8 2 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question