Search Unity

Detail-Mesh Generator

Discussion in 'Assets and Asset Store' started by E-Cone, Nov 23, 2018.

?

Do you need this generator on the Asset Store?

  1. Yes!

    7 vote(s)
    87.5%
  2. Uncertain.

    1 vote(s)
    12.5%
  3. I'll wait for more features.

    0 vote(s)
    0.0%
  4. No.

    0 vote(s)
    0.0%
  1. E-Cone

    E-Cone

    Joined:
    Jul 4, 2013
    Posts:
    37
    Hello everyone!

    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).




    This is how generated mesh looks with terrain-aligned normals:

    And with original normals:


    Uniform mesh division:


    LOD shader in effect:


    Other tricks possible with the world-position stored in uv3:


    Generation without scattermap:
     
    Last edited: Nov 29, 2018
  2. Conferno

    Conferno

    Joined:
    Feb 27, 2014
    Posts:
    23
    Looks really nice! Would to see this asset on Asset Store. Useful stuff
     
  3. E-Cone

    E-Cone

    Joined:
    Jul 4, 2013
    Posts:
    37


    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.

    Code (CSharp):
    1. public class MR_PositionToUVModifier : MR_DetailGeneratorModifier {
    2.  
    3.     public int savePositionUvChannel = 2;
    4.  
    5.     public override void ModifyDataPerSubMesh( int subMeshId, float scattermapValue, Vector3 localSubMeshPos, Vector3 terrainNormal, Transform rootTransform,
    6.                                                 List<Vector3> vertices, List<Vector3> normals, List<Vector4>[] uvs, List<Color> colors ) {
    7.         for ( int i = 0; i < vertices.Count; i++ ) {
    8.             Vector3 pos = rootTransform.position + rootTransform.rotation * localSubMeshPos;
    9.             if ( uvs[savePositionUvChannel].Count < vertices.Count ) {
    10.                 uvs[savePositionUvChannel].Add( new Vector4( pos.x, pos.y, pos.z, 0f ) );
    11.             } else {
    12.                 uvs[savePositionUvChannel][i] = ( new Vector4( pos.x, pos.y, pos.z, uvs[savePositionUvChannel][i].w ) );
    13.             }
    14.         }
    15.     }
    16. }
     
  4. E-Cone

    E-Cone

    Joined:
    Jul 4, 2013
    Posts:
    37
    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.

     
  5. E-Cone

    E-Cone

    Joined:
    Jul 4, 2013
    Posts:
    37
    Added ability to generate uv2.
    Added new vertex modifier - push vertices along terrain normal.
     
  6. E-Cone

    E-Cone

    Joined:
    Jul 4, 2013
    Posts:
    37
    Added a Quickstart guide and documentation. Preparing the package for Asset Store.
     
  7. E-Cone

    E-Cone

    Joined:
    Jul 4, 2013
    Posts:
    37
    Today my package was rejected, so I had more time to improve some things.
    Here's new stuff:
    • Added support for Unity 5.6 and newer
    • Inspector windows multi-selection
    • Simple mode with just Generate button
    • Ability to change length of preview distribution points
    • Scattermap projection
    • Ability to use prefabs containing several meshes as a single instance for generator
    • Lightmap/Occludee Static options
    • Shadow Casting options
    • Generator now casts rays along it's down vector instead of arbitrary Vector3.down
    • Working area bounds are now scaled with generator's scale
     
  8. E-Cone

    E-Cone

    Joined:
    Jul 4, 2013
    Posts:
    37

    Added grass dynamics - bending by a pseudo-wind, stomping and burning.
     
  9. StevenPicard

    StevenPicard

    Joined:
    Mar 7, 2016
    Posts:
    607
    Have you tried submitting this to the Asset Store again?
     
  10. E-Cone

    E-Cone

    Joined:
    Jul 4, 2013
    Posts:
    37
    Yes, I added support for Unity 5.6 and submited pack again... and never heard anything from Unity since