Author Topic: I need to create terrain and export heights and normals to use in a simulation.  (Read 398 times)

Offline dknesek

  • Member
  • *
  • Posts: 4
I'm trying to decide if Terragen is the tool that I can use.

I am building an agent-based simulation where agents (animals) are moving around a complex and mountainous terrain. The way I would like to capture the terrain in the simulation as a 2D array of height values. I might add the surface normal vectors if I get ambitious.

Does Terragen enable export of the height and normal vectors (is this called terrain "geometry"?) into a non-binary format that I can parse easily with my simulation software.  I would also like to export a nice looking 2D rectangular top-down view of the terrain to load into the simulation.

Can anyone help with this?

Offline Oshyan

  • Planetside Staff
  • *
  • Posts: 13198
  • Holy snagging ducks!
There are two ways you can export a terrain, either as a Heightfield (EXR or TER format), or as Geometry (OBJ or FBX format). Since you want an "array of 2d values" you basically want a heightfield, and while EXR might not be directly supported by your simulation software, you should be able to convert to something that will be.

The export process for heightfields varies slightly depending on how you build your terrain. If you are using heightfields already in Terragen (e.g. Heightfield Generate), you can simply right-click the node and Save As to get a heightfield version of it. If you are using Procedural shaders (e.g. Power Fractal, Alpine Fractal, etc.), you will need to convert into a heightfield format to export. So you'd create a new Heightfield Generate and plug the last node in your terrain network into the Shader input of the Heightfield Generate, then set the size, resolution, and position parameters to cover the area you want to export, click Generate when that's done, and then again right-click and Save As. During save you specify the output format (EXR), file name, and location.

For normals, if you get the Professional version you'll have access to a Normals render element, I'm not 100% sure that's what you want, but it's available. There is also a "visualize normals" shader node which may be appropriate.

For the simple 2D rectangular top-down view, just move your camera up above the terrain and point it down, or use an Orthographic camera with appropriate settings.

You can test most of this in the Free version, with the exception of the Render Elements. You can apply for a 30 day evaluation license of Professional if you need to test that.

- Oshyan

Offline dknesek

  • Member
  • *
  • Posts: 4
There are two ways you can export a terrain, either as a Heightfield (EXR or TER format), or as Geometry (OBJ or FBX format). Since you want an "array of 2d values" you basically want a heightfield, and while EXR might not be directly supported by your simulation software, you should be able to convert to something that will be.

Thank you for the response, Oshyan. Can you point me in the direction of an EXR file spec? I can't seem to find one. I may be able to find a Java library that will allow me to extract this information from one of the file formats you suggest.

Any further advice you may have would be welcome.  :)

Offline jaf

  • Member
  • *
  • Posts: 785
(10jul19) Ryzen 1800x, 970 EVO 1TB NVME-M.2 SSD, Corsair Vengeance 64GB DDR4 3200 Mem,  EVGA GeForce GTX 1080 Ti FTW3 Graphics 431.36 (10jul19), Win 10 Pro x64, Terragen Frontier 4.4.18 BMark 0:10:18

Offline bobbystahr

  • Member
  • *
  • Posts: 10420
  • Turn, and face the Strange Ch Ch Changes...D Bowie
I guess an important question at this point would be what format is your target format?
something borrowed,
something Blue.
Ring out the Old.
Bring in the New
Bobby Stahr, Paracosmologist

Offline dknesek

  • Member
  • *
  • Posts: 4

Offline dknesek

  • Member
  • *
  • Posts: 4
I guess an important question at this point would be what format is your target format?

I don't really have a target format. I just want convert the terrain into a 2D array of numbers (heights) that I can use in a MASON simulation.

Offline bobbystahr

  • Member
  • *
  • Posts: 10420
  • Turn, and face the Strange Ch Ch Changes...D Bowie
I guess an important question at this point would be what format is your target format?

I don't really have a target format. I just want convert the terrain into a 2D array of numbers (heights) that I can use in a MASON simulation.

Cool, I see....
something borrowed,
something Blue.
Ring out the Old.
Bring in the New
Bobby Stahr, Paracosmologist

Offline Oshyan

  • Planetside Staff
  • *
  • Posts: 13198
  • Holy snagging ducks!
More specifically for Terragen, it will output an EXR file with the values in meters. So the value of each pixel will be a height in meters. It should be fairly simple to interpret and use in your simulation, either if an EXR plugin is available, or you can do custom coding to load it. If you have to convert the data you will need to find a way to maintain correct scaling values since meter values won't likely convert correctly to, say, a normal grayscale image representation.

- Oshyan

 

anything