spimort / TerraBrush

MIT License
698 stars 27 forks source link

Please help me with LOD Initial Cell Width. Too many polygons #87

Open MihaSmit opened 6 months ago

MihaSmit commented 6 months ago

I want the initial grid to be larger than the default. изображение

I use the LOD Initial Cell Width setting to increase the width of the initial mesh. But the number of primitives does not change. And when the camera moves, these edges constantly “float” изображение

изображение

spimort commented 6 months ago

I'm not quite sure what you mean by the edges float but for the number of primitives, if you increase the initial cell width, you sould probably decrease the "levels" and/or the rows per level. Right now, in your example, it still creates 5 levels of details that are not even visible because you have too many rows per level and each levels are too large to be displayed. The primitives exists but are not visible.

For example, if I reduce the levels to 3 here, the number of primitives goes down and a maximum of 3 levels will be visible : image

If I change the value of levels to 5, the primitives goes up but are not being display because they are out of bounds : image

So, you should change these numbers depending on the kind of terrain you want 🙂

I hope this helps!

MihaSmit commented 6 months ago

I'm sorry, you probably misunderstood me. I will ask the question differently. When I increase the initial values of the LOD cell width, the number of primitives is not removed. It's as if the visual grid is getting wider, but in fact the polygons then remember what they were originally, if you set the original width of the LOD cell to 1, they will return to their position. When creating the landscape, I needed to enlarge the grid so that there would be no distortion of the faces when rotating the camera. How can this be done? P.S Google translator

MihaSmit commented 6 months ago

I want to make the world in a low poly style. I need the primitives to be bigger, not visually, but "really", or I don't understand something, but I tried everything and everything brings me back to the fact that I need to increase the width of the primitives without changing the values of LOD Initial Cell Width

https://www.youtube.com/watch?v=vkge8LeDLiU

MihaSmit commented 6 months ago

Yes, thanks, I figured out the primitives with your help, among other things. But now I don't understand why when I have a LOD Initial Cell Width above 1, the landscape is distorted even if it is in the right square? + if I specify the brush size 1 and make a rock, then it will not be visually visible, but if I return the LOD Initial Cell Width to 1, then I will see this rock. Can there be problems with this later with collision? It seems to me that something is wrong here. I don't understand, I just want to make the initial grid of the world wider :(

spimort commented 6 months ago

Ohh I see what you mean, with the video. Let me check if I can do something about it!

spimort commented 6 months ago

I've done a fix, can you tell me if the version 0.5.1Alpha fixes your issue 🙂?

MihaSmit commented 6 months ago

Thank you so much! I also noticed that if you set the brush size to 1 and draw, then the grid does not change. LOD Initial Cell Width is at 4 at this moment. And if you return LOG Initial Cell Width to 1, then these small mountains will appear. As I understand it, it's stored somewhere in memory, I'm not sure if it's good. After all, I will no longer set the LOD Initial Cell Width to 1, but the system remembers that there should be a small mountain there. I don't know how this will affect performance in the future. Could there be problems with a collision in the future because of this?

MihaSmit commented 6 months ago

And now, when I add new areas, the error All images must share the same format has appeared, although I do not have any textures. And also, when a new section is spawned, it inherit the geometry of the original region and I can no longer change the grid изображение

MihaSmit commented 6 months ago

And I also noticed that you fixed a bug with the fact that the edges "floated" in the first region, but in the subsequent ones it remained, in the second region they also float, it turns out that at a distance from the player all the mountains will "jump" with each update of the grid, even if they do not change the region

spimort commented 6 months ago

Thank you so much! I also noticed that if you set the brush size to 1 and draw, then the grid does not change. LOD Initial Cell Width is at 4 at this moment. And if you return LOG Initial Cell Width to 1, then these small mountains will appear. As I understand it, it's stored somewhere in memory, I'm not sure if it's good. After all, I will no longer set the LOD Initial Cell Width to 1, but the system remembers that there should be a small mountain there. I don't know how this will affect performance in the future. Could there be problems with a collision in the future because of this?

The way it works is that you still draw pixels on an image that is the size of the terrain zone. If you increase the initial cell width, it skips pixels on the image but the pixels are still there. That's why you still see what you've done when going back to 1. The prefered initialcellwidth will always be 1 because it's the easiest one to compute, since 1 pixel on the image equals to 1 meter of the mesh. Keep in mind that even if you change the initialcellwidth, the collision will still be based on 1 because I don't have much control on that on the heightmap collision shape.

The option is there to accomodate but the 1 will still be the best option.

I was wondering, is there a reason why you don't want to use the default 1? Visually, you can get the same result and in term of perf, 1 is really not that bad in my opinion.

spimort commented 6 months ago

And now, when I add new areas, the error All images must share the same format has appeared, although I do not have any textures. And also, when a new section is spawned, it inherit the geometry of the original region and I can no longer change the grid изображение

That is strange, is there any way you can share the project so I can test it?

MihaSmit commented 6 months ago

Thanks for the clarification! now everything looks logical! I don't want to use the number 1, since my game assumes low poly graphics, and also works on android, I try to save polygons. and I don't want to see a smooth and detailed surface. I will reassemble the project a little later to make sure that I did everything correctly and write off whether the error will reappear.

MihaSmit commented 6 months ago

The problem with "All images must share the same format" went away after installing net 8 and recreating the project. Here is a video about floating faces in the second and next zone https://www.youtube.com/watch?v=sgd73C_D9tc

spimort commented 5 months ago

I think you are right, there is an issue here! I think I know how to solve it, I should do a fix soon 🙂

spimort commented 5 months ago

The version 0.5.3Alpha should fix it, please let me know if it works for you! 🙂

MihaSmit commented 5 months ago

Thank you very much! You've been very helpful! You are very good! Let me ask you a couple more things that I would suggest. At the moment, the collision does not match the grid as expected, you talked about it. Is it possible to come up with a way to improve the collision system if the standard specifies a value higher than 1 for "LOAD Initial Cell Width"? And I also noticed what's in the screenshot, I saw your video, I'll try to review it to figure out how to fix it. Everything else is fire! I really like it, everything is simple and convenient! изображение

MihaSmit commented 5 months ago

Yes, I double-checked these lines and they were not commented out in the code, as in your video, maybe me need to correct something here? изображение

spimort commented 5 months ago

Thank you very much! You've been very helpful! You are very good! Let me ask you a couple more things that I would suggest. At the moment, the collision does not match the grid as expected, you talked about it. Is it possible to come up with a way to improve the collision system if the standard specifies a value higher than 1 for "LOAD Initial Cell Width"? And I also noticed what's in the screenshot, I saw your video, I'll try to review it to figure out how to fix it. Everything else is fire! I really like it, everything is simple and convenient! изображение

Sadly, changing the size of the cells in the collision shape is not possible (as far as I know) 😔. I use the heightmapshape3D from godot and I don't think there's much I can do about it 🫤

https://docs.godotengine.org/en/stable/classes/class_heightmapshape3d.html

I'll try to take a look the the weird line, it feels like it's the average zone transition calculation that does that. We'll see.

MihaSmit commented 5 months ago

please see if it is possible to multiply the width of the collision or apply any mathematical actions to it so that the collision at least approximates the meshes of the landscape, if possible. Thank you very much for your addon, we really like it and we will use it in our first projects! изображение изображение