Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

◆◄ 2.5D Terrain (3D mesh from 2D curves) ►◆

Discussion in 'Assets and Asset Store' started by _geo__, May 11, 2022.

  1. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    794
    Hi all,
    I have just relased my asset which helps you spice up 2.5D games with some sweet 3D terrain.

    ForumCoverImage.jpg

    How does it work?
    Easy: you draw a 2D shape and from it this tool generates a 3D mesh and PolygonCollider2D for you. Best just watch the video :)

    Asset Store Link:
    https://assetstore.unity.com/packages/slug/220783



    Features:
    ● 3D Mesh from 2D Splines (with holes)
    ● 2D Collider Generator
    ● Procedural Foliage Generator
    ● Full Source Code included

    ForumStepA.jpg

    FoumStepB.jpg

    FoumStepC.jpg

    FoumStepD.jpg

    In case you wonder what you can do with it. Pretty much all the levels in this game (forum link) have been made using this tool.
     
    Last edited: May 11, 2022
  2. benjamin666

    benjamin666

    Joined:
    Jan 11, 2019
    Posts:
    9
    hi, I purchased the asset 2.5D Terrain you developed.
    There are amazing ideas for 2d and 2.5d game scenarios, and I'm having some trouble. Since I'm using a vertex-shaded shader, I want the model to generate a higher number of uniform meshes. This way I was able to do vertex painting.
    Whether in the new development plan, it is possible to adjust the parameters of the number of generated model meshes in the three axes of xyz.
    Figure 2 below is the effect diagram of the expected grid generated by me.
     

    Attached Files:

    • 1.png
      1.png
      File size:
      56.1 KB
      Views:
      13
    • 2.png
      2.png
      File size:
      500.8 KB
      Views:
      12
  3. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    794
    Hi,
    thank you for using the terrain tool. I see so you want to have a mesh with uniformly distributed vertices to get some higher "resolution" for vertex painting. It's an interesting idea yet at the moment it's not easy to do as the tool right now does try to do quite the opposite (reduce vertices as best it can). Also you would run into trouble quickly with areas of high curvature. No quick feature I am afraid. I am currently busy with other stuff but I'll put it on my "things to think about" list, no promises though.

    However, it should be possible to do even with the current tool. From the top of my head here is how I would approach a quick solution: The asset already has the ability to add custom vertices (it's described in the manual). You could absue this and just add a ton of them via code to increase resolution. So the steps would be:
    1) Generate the mesh as you are doing now.
    2) Generate a 3D mesh collider from the mesh.
    3) Do some raycasts in a regular grid from every side and record the hit positions.
    4) Add each recorded position as a custom vertex.
    5) Generate again.

    I think that should work, though I am not sure how performant that will be.
     
  4. benjamin666

    benjamin666

    Joined:
    Jan 11, 2019
    Posts:
    9
    thanks geo
    Yes, the vertex shader needs more points of "resolution".
    I will try the method you said, but my code level is very low. It can be very expensive to add points one by one.
    However, I think that if you can increase the grid distribution, it is also a way to expand the various requirements of the generative model. It would be really great to have these parameters. More meshes means that you can do a lot of terrain height changes and adjustments, which is a very efficient way to build levels.
     
  5. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    794
    I think adding the points won't be the main problem (it's just a list) but am just not sure how the clipper and tesselation libs will handle this many internal points (not something I have testes). I also noticed the points method will only work for the sides. The middle part is not effected by that but it can be changed via code too.

    Look into MeshMiddleSegment.cs. There you will find 4 points (p0 to p3). In between those 4 points two triangles (tri1 and tri2) are made. There you can add as many tris betwen those 4 points as you want. This would be an easy way to increase the middle resolution. The sides may be tricky though (there you would need the points I mentioned).

    Here is a quick sketch showing what I mean (you could increase the subdivision of these middle patches in MeshMiddleSegment.cs). The middle is just an endless loop of these p0-p3 quads.
    upload_2023-2-11_12-10-24.png

    Hope this helps.
     
  6. benjamin666

    benjamin666

    Joined:
    Jan 11, 2019
    Posts:
    9
    sorry i'm here again
    Yes, I would like to increase the amount in the middle of the mesh, so that I can freely make various changes to the ground vertices.
    I've tried to understand this part of the generative and cyclic process, and I admit I've failed, not knowing enough about this part.
    Modified the number of segments, etc., resulting in an array error, etc.
     

    Attached Files:

    • 1.png
      1.png
      File size:
      21.5 KB
      Views:
      11
    Last edited: Feb 12, 2023
  7. _geo__

    _geo__

    Joined:
    Feb 26, 2014
    Posts:
    794
    Hi,
    I have been able to take a quick look. Here is a version which at least allows you to increase the middle resolution on the z-axis. There is no UI so you will have to just change it in code, like this:

    upload_2023-2-12_12-45-43.png

    Just replace the file with the one I attached and change the zDivisions parameter.

    Hope this helps :)
    Anything more elaborate would require more time and I can't do it right now (sry).
     

    Attached Files:

  8. benjamin666

    benjamin666

    Joined:
    Jan 11, 2019
    Posts:
    9
    Thank you very much for the help of geo. This terrain plug-in is the best one for 2.5D in my opinion. I will study and add an adjustable parameter of zDivisions to the interface. Go and understand your improved code writing.
    Now the resolution can basically be adjusted to a suitable distribution. ^-^
     

    Attached Files:

    • 2.png
      2.png
      File size:
      207.4 KB
      Views:
      11
    _geo__ likes this.