Slastraf Posted April 11, 2021 Share Posted April 11, 2021 I have coded a basic terrain generator which takes a perlin noise and builds a mesh from that. The problem is this is an expensive task for real time. So I put the whole function which calculates the chunks in a second thread which is handled in the game loop. This has not helped much with the performance, as I am using Leadwerks functions inside the thread which still accesses the game world and makes it freeze for a split second. Is there any way to calculate the mesh in a different thread and then "load" it into the world ? An explanatory video below. Thanks LE.mp4 Quote Link to comment Share on other sites More sharing options...
Rick Posted April 11, 2021 Share Posted April 11, 2021 What is actually causing the little pause? Is it the creation of the flat mesh itself? Is it manipulating the terrain mesh in 1 iteration? Off the top of my head I would copy the flat terrain mesh, which should be instant and I don't think cause a pause, and then as you're manipulating the vertices of the terrain that would have to be done over multiple frames so there is no noticeable pause. I think I did something like this back in the day and it was easiest to do in lua because of coroutines running over multiple frames. I was able to manipulate a handful of terrain vertices every loop before I'd yield out of the coroutine to give cycles back to the game so it didn't cause a noticeable pause. 1 Quote Link to comment Share on other sites More sharing options...
Slastraf Posted April 11, 2021 Author Share Posted April 11, 2021 Just now, Rick said: What is actually causing the little pause? Is it the creation of the flat mesh itself? Is it manipulating the terrain mesh it 1 iteration? Off the top of my head I would copy the flat terrain mesh, which should be instant and I don't think cause a pause, and then as you're manipulating the vertices of the terrain that would have to be done over multiple frames so there is no noticeable pause. I think I did something like this back in the day and it was easiest to do in lua because of coroutines running over multiple frames. I was able to manipulate a handful of terrain vertices every loop before I'd yield out of the coroutine to give cycles back to the game so it didn't cause a noticeable pause. I generate new vertices, traingles for every new mesh completely new. Agreeably this takes long. To copy it over and iterate all verts to put them on the generated position could be much faster. The chunks don't have that many verts so it takes less than a few frames. How to access mesh information ? Quote Link to comment Share on other sites More sharing options...
Rick Posted April 11, 2021 Share Posted April 11, 2021 It's been awhile since I've done that but search for maybe "terrain manipulation" or raising lowering terrain on the forums here and you'll probably find something. Quote Link to comment Share on other sites More sharing options...
Slastraf Posted April 11, 2021 Author Share Posted April 11, 2021 1 minute ago, Rick said: It's been awhile since I've done that but search for maybe "terrain manipulation" or raising lowering terrain on the forums here and you'll probably find something. GetSurface is promising 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.