-
Posts
710 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by Slastraf
-
Hmmm. I cant tell for sure but copy seems to make it lag even less than Instantiate.
-
That would be doable if copy takes a long time. For now the Idea is to copy it and iterate over vertices for every new chunk and hide out of bound ones.
-
I was very happy with performance of Instance. Does Copy have similar performance ?
-
Here another screenshot without the block. The hole in the middle should only generate 3 times, as the other times the offset for this position is 0. But it is there on every chunk.
-
I Instantiate a loaded model like this worldGenerator->terrainChunk = Model::Load("Models/terrain_Plane.mdl"); ... c->chunkModel = (Model*)terrainChunk->Instance(); then I applied some previously tested code on the surface of the model like this: Surface* surface = c->chunkModel->GetSurface(0); for(int i = 0; i<surface->CountVertices(); i++) { Vec3 xy = surface->GetVertexPosition(i); float height = (rand()%(3)); if(i==surface->CountVertices()*0.5) { height = -100*(rand()%(3)); cout<<"Offset height:"<<height; } if(i==0)cout<<"height at: "<<height<<endl; surface->SetVertexPosition(i, xy+Vec3(0,height*.1,0)); } surface->Update(); c->chunkModel->UpdateAABB(Entity::LocalAABB | Entity::GlobalAABB); For every vertex, I set a randomly generated position. This is simplified to show the issue. All the generated model chunks are the same. A good guess would be that LE copies an already Instantiated model over, and overwrites all changes of the current one to all previous ones, or somehow ignores changes otherwise. I put a screnshot of the console and two images showing duplicate chunks. There are 9 chunks and each of them looks the same. How to fix this behaviour ?
-
Most .mdl files have a hierarchy similar to this STATIC_MESH (< no surface) - OBJECT THING (< with surface) The surface count in the latter case will be zero, even if there is a surface in the OBJECT THING The workaround is to collapse the whole thing in the model editor. It would be nice if getsurface will check the first child for surface too if the top level doesn't have one because it is exported like this in most modeling software.
-
GetSurface is promising
-
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 ?
-
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
-
How infinite terrain can be implemented in Leadwerks Engine 5
Slastraf commented on Josh's blog entry in Development Blog
I cant wait and implement my own infinite perlin noise based terrain in c++. The blog is coming, need to just finish up some AI stuff and then can write about the prototype. -
That pointed me in the right direction. I made everything into one model, it still lagged, then I also made only one surface and then I got acceptable performance. Still it should not lag in the first place. The code looks like this and now I can proceed. void generateTest(){ // std::random_device rd; // std::uint32_t seed = rd(); //const siv::PerlinNoise perlin(seed); Surface* surface = NULL; Model* model = NULL; model = Model::Create(); model->SetColor(1.0, 0.0, 1.0); surface = model->AddSurface(); for(int i = 0; i<1000; i++) { surface->AddVertex(0.5, 0, 0.5, 0, 0, 1); surface->AddVertex(0.5, 0, -0.5, 0, 0, 1); surface->AddVertex(-0.5, 0, 0.5, 0, 0, 1); surface->AddVertex(-0.5, 0, -0.5, 0, 0, 1); surface->AddTriangle(0, 1, 2); surface->AddTriangle(1, 2, 3); surface->Update(); model->UpdateAABB(Entity::LocalAABB | Entity::GlobalAABB); } }
-
void generateTest(){ //const siv::PerlinNoise perlin(seed); Surface* surface = NULL; Model* model = NULL; for(int i = 0; i<1000; i++) { model = Model::Create(); model->SetColor(1.0, 0.0, 1.0); surface = model->AddSurface(); surface->AddVertex(0.5, 0, 0.5, 0, 0, 1); surface->AddVertex(0.5, 0, -0.5, 0, 0, 1); surface->AddVertex(-0.5, 0, 0.5, 0, 0, 1); surface->AddVertex(-0.5, 0, -0.5, 0, 0, 1); surface->AddTriangle(0, 1, 2); surface->AddTriangle(1, 2, 3); surface->Update(); model->UpdateAABB(Entity::LocalAABB | Entity::GlobalAABB); } } Hello after I wanted to make a mesh generation algorithm I found out that I get a lot of lag when trying to have a small amount of vertex (<10k) in the scene If you run the test example above, it will make the game run at 2 fps or less. It does not max out my ram / gpu at all. I guess it has to do with memory leaks because I did not delete surface and model pointer. Then I tried to do the latter but it made different errors. 2021-04-09 18-23-58.mp4
-
I dont want to add my libs in :/SteamLibrary/steamapps/common/Leadwerks\Include but in the project files somewhere.
- 1 reply
-
- 1
-
yes
-
Hello, what is happening ? Please see the video. 1102370169_2021-04-0811-18-04.mp4
-
I am trying to implement this and the more I look into it the harder the math gets. Hats off I cant do it but is so crucial in a game engine and has been done in LE before. https://www.ultraengine.com/community/blogs/entry/94-ik-animation/
-
And this whole thing makes me stuck at my project right now because there really is no alternative