Exporting heightfields (or alpha brushes for Unreal) using orthographic renders

Started by Matt, June 19, 2019, 11:44:39 PM

Previous topic - Next topic

Matt

Hey everyone,

Someone recently asked me if it's possible to use Terragen to generate "alpha brushes" to use in Unreal's landscape sculpting system. Basically these are just texture maps which are usually black at the edges. You might want to generate these from heightfields in Terragen. You can also generate them from procedural terrains.

So basically the problem is: how do we export a heightfield (or height map) from a terrain in Terragen?

There are lots of ways to do this. If you work only with Heightfield nodes in Terragen, then you can right-click on a heighfield node (green node), save it an EXR file and convert it to an 8-bit (or 16-bit) format in Photoshop or some other image editing tool. Or you could save to .TER and use third party tools to convert the .TER to an 8-bit or 16-bit image. But it might be difficult to converting EXR or TER files to something you can use.

If you work with procedural terrains, you can convert them to heightfields using the Heightfield Generate node. Then you can export them like any other heightfield, but you still have the problem of converting them to the image format you want.

There is another way that may be easier: Render an orthographic view of the landscape, and use a shader that maps the altitude (or Y coordinate) to luminosity.

I created a project (TGD file) which shows you how to do this. The TGD is attached below so you can try it yourself. Here are some notes on how the TGD is set up:

- Set diffuse colour to 0 and use luminosity only. This makes it independent of lighting conditions; this is important for a raw capture of the heightfield.
- The orthographic camera's rotation is (-90, 0, 0). This points it directly downwards.
- The orthographic camera is positioned at (0, 10000, 0). If your terrain reaches a height above 10000 then you will need to increase the Y position.
- The orthographic camera has an "ortho width" of 1000. This renders at 1km x 1km area.
- The renderer's gamma correction is set to 1.0 and tonemapping is turned off. This allows you to get a raw capture of the heightfield.
- You can render at whatever resolution you need for your intended use. I decided on 512 x 512 so it renders in the free version.

Just because milk is white doesn't mean that clouds are made of milk.

WAS

Great share, to add to this, I'd like to add two previous shares for the same purposes. One to export terrain, and the other to export cloud fractals.


bobbystahr

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


WAS

Hey @Matt is there a way to use the Get Altitude to display an exact definition of the terrain. From the minimum displacement level to the maximum? I notice with a couple exports i end up having to adjust the amplitude to match Terragen, and if my colour adjust's maximum is too high from the maximum of displacement it lowers the definition of peaks, if I'm too close, it exaggerates peaks.

Matt

Quote from: WASasquatch on August 17, 2019, 06:09:34 PMHey @Matt is there a way to use the Get Altitude to display an exact definition of the terrain. From the minimum displacement level to the maximum? I notice with a couple exports i end up having to adjust the amplitude to match Terragen, and if my colour adjust's maximum is too high from the maximum of displacement it lowers the definition of peaks, if I'm too close, it exaggerates peaks.

For raster heightfields you could read the information off a Heightfield Load node, but procedural terrains needs to be sampled to get that information.

If you're trying to get some other 3D program to match Terragen, I don't see why you can't plug in the same numbers in both Terragen and the other program. The white point in the Colour Adjust Shader doesn't need to be the exact highest point, it just needs to be at least as high so that it doesn't clip. The same number should go into the amplitude of your other program. What are you importing it into?
Just because milk is white doesn't mean that clouds are made of milk.

WAS

Quote from: Matt on August 17, 2019, 08:39:37 PM
Quote from: WASasquatch on August 17, 2019, 06:09:34 PMHey @Matt is there a way to use the Get Altitude to display an exact definition of the terrain. From the minimum displacement level to the maximum? I notice with a couple exports i end up having to adjust the amplitude to match Terragen, and if my colour adjust's maximum is too high from the maximum of displacement it lowers the definition of peaks, if I'm too close, it exaggerates peaks.

For raster heightfields you could read the information off a Heightfield Load node, but procedural terrains needs to be sampled to get that information.

If you're trying to get some other 3D program to match Terragen, I don't see why you can't plug in the same numbers in both Terragen and the other program. The white point in the Colour Adjust Shader doesn't need to be the exact highest point, it just needs to be at least as high so that it doesn't clip. The same number should go into the amplitude of your other program. What are you importing it into?

That's exactly what I was doing. These programs read the displacement and than apply their amplitude on top of that... so if it's not exporting exactly as Terragen is interpreting, the same values won't yield the same results. That's where these specific issues I just explained come from where peaks can be extended or pancaked (not as high as they are in TG with same amplitude).

So there is no way to use blue nodes to get the minimum and maximums of procedural terrain, to sum up to have a more standardized output?

Heightfield is a good way, I use that mainly but it is limited to an area and gotta translate shaders rather than just roaming.

Matt

Quote from: WASasquatch on August 17, 2019, 09:18:57 PMThat's exactly what I was doing. These programs read the displacement and than apply their amplitude on top of that... so if it's not exporting exactly as Terragen is interpreting, the same values won't yield the same results. That's where these specific issues I just explained come from where peaks can be extended or pancaked (not as high as they are in TG with same amplitude).

Can you show us some screenshots of the other app? If I have more information maybe I can help. A well-behaved app should take the raw data and multiply it by whatever amplitude you provide. It should be completely deterministic. If you set the black point to 0 and the white point to 1000 in Terragen, you should set the amplitude to 1000 in the other app (adjusting for the different units if necessary). If the other app isn't working like this, can you show me?

QuoteSo there is no way to use blue nodes to get the minimum and maximums of procedural terrain, to sum up to have a more standardized output?

No, because to find the highest point in some arbitrary function you have to take many many samples (e.g. render it or convert it to a raster heightfield). Get Altitude just gives you the height of the current sample.
Just because milk is white doesn't mean that clouds are made of milk.

WAS

Quote from: Matt on August 17, 2019, 09:53:35 PM
Quote from: WASasquatch on August 17, 2019, 09:18:57 PMThat's exactly what I was doing. These programs read the displacement and than apply their amplitude on top of that... so if it's not exporting exactly as Terragen is interpreting, the same values won't yield the same results. That's where these specific issues I just explained come from where peaks can be extended or pancaked (not as high as they are in TG with same amplitude).

Can you show us some screenshots of the other app? If I have more information maybe I can help. A well-behaved app should take the raw data and multiply it by whatever amplitude you provide. It should be completely deterministic. If you set the black point to 0 and the white point to 1000 in Terragen, you should set the amplitude to 1000 in the other app (adjusting for the different units if necessary). If the other app isn't working like this, can you show me?

Quote from: undefinedSo there is no way to use blue nodes to get the minimum and maximums of procedural terrain, to sum up to have a more standardized output?

No, because to find the highest point in some arbitrary function you have to take many many samples (e.g. render it or convert it to a raster heightfield). Get Altitude just gives you the height of the current sample.


I see, so the amplitude should just be 1000 matching the white point? I was going off of amplitude of terrain so in most instances 2000. Also instances with excessive negative displacement for canyons or deep rooted mountains with PFs on funky noise settings.

See im used to a more uniform output. Think World Creator to Terragen or Gaea to Terragen. With the right export settings, loading a float tiff or exr TG seems to make an exact copy out of the box.  But I suppose it has that exact height data.