I’m working on a detail-mesh generator for my games to efficiently cover wide landscapes with small meshes.
Here’s the list of features currently implemented:
General:
Generates meshes using scattermaps and uniform distribution method and combines them.
Ability to select of a scattermap color channel (ex: to generate grass using green channel and rocks using red etc.).
Ability to define offset and scale of the scattermap (in case you need only part of the image for generation).
LayerMasks to determine where to generate detail-meshes and which layers to discard from generation with offset value (ex: to generate some grass in shallow water).
Generator itself:
Terrain alignment.
Random selection from mesh arrays.
Scattermap channel strength scale multiplier.
Base rotation offset (in case you didn’t fix pivots before exporting your meshes to Unity).
Random rotation offset.
Normals generation (keep original, user defined, terrain aligned, spherical) - for better lighting.
Other:
Caching and storing uniform scattering points as assets (in case of very large maps).
Capturing and saving a snapshot of the area below generator (which you can use to draw a scattermap).
Ability to write custom data modifiers and override any vertex data before uploading it into the mesh.
World-space position storing in uv modifier.
Push vertices along terrain normal modifier.
Simple LODing shader.
Ability to uniformly divide the generation area (in case of very large maps - for better culling).
Ability to generate uv2 for lightmapping.
Future features:
Ability to override other stuff with custom scripts (like uniform points distribution).
Added ability to write custom modifiers to change any vertex data before uploading it into the combined mesh.
It’s just a matter of writing a simple script and attaching it to the generator’s gameObject.
public class MR_PositionToUVModifier : MR_DetailGeneratorModifier {
public int savePositionUvChannel = 2;
public override void ModifyDataPerSubMesh( int subMeshId, float scattermapValue, Vector3 localSubMeshPos, Vector3 terrainNormal, Transform rootTransform,
List<Vector3> vertices, List<Vector3> normals, List<Vector4>[] uvs, List<Color> colors ) {
for ( int i = 0; i < vertices.Count; i++ ) {
Vector3 pos = rootTransform.position + rootTransform.rotation * localSubMeshPos;
if ( uvs[savePositionUvChannel].Count < vertices.Count ) {
uvs[savePositionUvChannel].Add( new Vector4( pos.x, pos.y, pos.z, 0f ) );
} else {
uvs[savePositionUvChannel][i] = ( new Vector4( pos.x, pos.y, pos.z, uvs[savePositionUvChannel][i].w ) );
}
}
}
}
Added ability to divide a generated mesh into several GameObjects for better occlusion\frustum culling.
Added ability to select desired Layer for output mesh.
Improved UI a bit.
Assuming nothing happened with this in the end? Massive shame. This would be incredibly useful for us individual developers.
I’ve been attempting to do something very similar but with limited results at present for an extensive underwater game and as you can imagine, filling all that space and having it look as good as you’ve demonstrated is extremely difficult if you’re using your own custom detail meshes.
I found out that using Houdini might provide even better results for scattering, baking and generating other stuff.
This mesh-generator became obsolete very quickly.