Search Unity

Terrain from ASCII file.

Discussion in 'Getting Started' started by sasantv, Feb 23, 2017.

  1. sasantv

    sasantv

    Joined:
    Jul 20, 2016
    Posts:
    7
    Hello!

    The title says it all. I know that this is asked and answered before. And I have seen that people suggest to convert the ASCII file to 16-bit integer (raw) files and use heightmaps. But there is something that I can't figure out yet. The Unity heightmaps must be a square, and only in certain resolutions (513, 1025, etc.). So what if I need to load a rectangular terrain with a grid size of say 1082 x 823!? This must be something very easy to do, but I have spent the whole day to figure out it, and still no luck. So all I need is to read matrix of arbitrary size, preferably in ASCII, load it on Texture2D and then show it on a terrain in Unity. The texture2D part is because I need to do computations on the GPU.

    The only thing that I can think of now is tiling a rectangular grid with squares ...
    Or not to use terrain at all, and use another object with a meshgrid.
     
  2. Bill_Martini

    Bill_Martini

    Joined:
    Apr 19, 2016
    Posts:
    445
    A rectangle can be sliced into squares, no?
     
  3. sasantv

    sasantv

    Joined:
    Jul 20, 2016
    Posts:
    7
    Sure it can. That's what I mean be tiling. But there must be an easier way. Plus, even with tiling you can't achieve all the resolutions (unless you really want to use tiles of size 1 or 2!)
     
  4. Bill_Martini

    Bill_Martini

    Joined:
    Apr 19, 2016
    Posts:
    445
    Not really grasping your problem, sorry.

    What's wrong with creating 3x2 grid using a 512x512 heightmap. This is larger than you need, is having a border of unused and unneeded terrain a problem?
     
  5. sasantv

    sasantv

    Joined:
    Jul 20, 2016
    Posts:
    7
    Thanks for your comment. Yes indeed it is. Have a look at
    .
    This is the sofware I have developed for wave simulation. I am trying to redo this in Unity. So I need to have a one to one correspondence between a topography in a texture2D and terrain. The borders are indeed very important.
     
  6. Bill_Martini

    Bill_Martini

    Joined:
    Apr 19, 2016
    Posts:
    445
    Nice fluid dynamics demo. So you are building a simulation and not a game? And the clipped water and land is what you want? Usually games don't want the player to see or be aware of the edges of the game environment.

    I'm still not understanding why you need that grid size and why a different size and scale can't work for you. When I first started working in Unity, I brought along a lot of knowledge from other development software. I immediately tried to force Unity to work as I was use to, which was the past products I used. Obviously, things didn't go well, because Unity works like Unity and not other software. While there are many similarities there are big differences. Once I learned Unity well enough porting old projects became doable but mostly were a rewrite to accommodate how Unity works and to take advantage of Unity's strengths. I think if you give up some preconceived expectations and work with Unity you can do what you want. Logic and physics are transferable, but but most others will require some tweaking.

    I don't think I can help you any further on this, maybe someone else that has more experience in this area can help.
     
  7. sasantv

    sasantv

    Joined:
    Jul 20, 2016
    Posts:
    7
    Yes I see your point. Perhaps I need to remold my project and then redo it in Unity.
    As you mentioned, I am designing an engineering tool, and not a game. In such a simulation software, the boundaries are control points, and we force boundary conditions. That's why they need to be precise. Thanks for your comments, hopefully I will figure it out.