i’ve just finished making a mesh, and have added a basic LOD system into it, but when I change the LOD scale the mesh loses detail like it should but also gets bigger, what i beleive i need to do is to change the xSize,ySize dynamically but i don’t know how to do it.
theses are the same mesh but on the left it’s LOD 1 and on the right its LOD 2.
public int LOD = 1;
public int ySize,xSize = 140;
for (int i = 0, y = 0; y <= ySizeLOD; y+=LOD)
{
for (int x = 0; x <= xSizeLOD; x+=LOD)
{
vertices = new Vector3(x, perlin, y); i++; } } I want to clamp the size so when the LOD changes the mesh stayes the same size. If anyone could help i would appreciate it. thanks
It looks like you did not change how the triangle indices are computed. Obviously that would be different because for a start, there’s way less triangles in each successive LOD.
Yes. Think about the simplest two comparisons and how the triangles are going to lay out differently:
If the verts in the left are 0,1,2,3,4,5,6,7,8 and the verts on the right are 0,1,2,3, you’re going to need to change how the triangle indices are computed depending on your step rate.
It might be easier to control the number of steps on the side, and use that count to produce your triangle index. Then you can just adjust the reduced step count up to space apart an equivalent amount on any LOD.
ok if i’m not mistaken that shouldn’t matter, the reason why i say that is…
for (int i = 0, y = 0; y <= ySize; y+=LOD)
{
for (int x = 0; x <= xSize; x+=LOD)
{
vertices[i] = new Vector3(x, rands, y);
when i increment by LOD that sets the distance betwen the vertices so if LOD = 2 then when the loop is in process the x y iterate like this 0,2,4,6,8… but theses vertices are the same as if LOD =1, yes the iteration changes to 0,1,2,3,4,5… but in my Vector3[ ] vertices; array they are both = 0,1,2,3,4 so when i set
Actually I just updated the makegeo project to support making planes of varying sizes (dimensionally, vertex-count-wise, etc.), and you can supply a function to give it a height offset as well.
It’s super simple. It’s in the makegeo project, and it is the testmakequadplane scene.