- Edited
So I am using ArrayMeshes to procedurally generate terrain. I am trying to add LOD support, and I am compiling the index arrays and passing them in like so:
'
surfaceArray[(int)Mesh.ArrayType.Vertex] = vertices.ToArray();
surfaceArray[(int)Mesh.ArrayType.Normal] = normals.ToArray();
surfaceArray[(int)Mesh.ArrayType.TexUV] = uvs.ToArray();
surfaceArray[(int)Mesh.ArrayType.Index] = indexesFull.ToArray();
surfaceArray[(int)Mesh.ArrayType.TexUV2] = uv2s.ToArray();
lodDictionary.Clear();
if(indexesHalf.Count < indexesFull.Count)
lodDictionary.Add(1,indexesHalf.ToArray());
if(indexesMin.Count < indexesHalf.Count)
lodDictionary.Add(2,indexesMin.ToArray());
arrayMesh.ClearBlendShapes();
arrayMesh.ClearSurfaces();
arrayMesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, surfaceArray, null, lodDictionary);
arrayMesh.RegenNormalMaps();
'
Which doesn't cause any errors, but it also doesn't seem to do anything either. That is the meshes always seem to use the full detail triangle indexes. I am checking to make sure there are fewer indexes in the LOD arrays because the way I have it working not all meshes benefit from this (sometimes they have the same number for more than one or all of the index arrays), and I am verifying that many of the meshes do have fewer triangles and do pass in these arrays. But these meshes don't show any change based on camera distance.
So I'm wondering two things: What is the floating point index in the dictionary really supposed to mean? The documentation says "key is roughly proportional to the distance at which the LOD stats being used" but I'm using very low numbers to test it and I'm not seeing any changes anywhere. Is there something else I need to be doing to make this work?