L3DT users' community
Large 3D terrain generator

Need to change DPI of heightmap

Got a problem or need advice?

Need to change DPI of heightmap

Postby Calenmiriel » Fri May 13, 2011 2:03 am

I have a heightmap that I made in L3DT that i want to import in Unity 3. Every time I try to do so, the resolution is very bad. I think it might be because of low DPI. I use Gimp to change the file format to RAW (which is the format needed for Unity 3). My question is:

1- The DPI of the L3DT file is 72. When i export it, it's automatically 72 DPI and I can't find a way to change it. Is there a way to increase the DPI to at least 1024?
Calenmiriel
New member
 
Posts: 2
Joined: Fri May 13, 2011 1:48 am

Re: Need to change DPI of heightmap

Postby Telarus » Tue May 17, 2011 8:56 pm

Hi Calenmiriel,

DPI (dots per inch) is a term which measures pixels across a real-world item, such as a screen or a printed piece of paper.

As such, it's not relevant to working with height-fields. By "the resolution is very bad" do you mean that Unity is displaying "stair stepping" artifacts? That might be because your file spent some time as an 8-bit (as opposed to 16-bit) image.

To get some of your terrain 'flow' back, you can open your file in an imaged editing program. Make sure you then switch to 16-bit editing mode.

Then, double your file resolution (if you were @ 512 x 512, double it to 1024 x 1024). Then, perform a Gaussian blur with a 1px radius (make sure your file is "flattened" to the background layer, if it's on a 'floating layer' the edges might pick up some transparency).

Then, resize the file-size back down to the original size (512 x 512 in our example).

Then, test your file in a renderer. If there are still noticeable "stepping" artifacts, repeat the process.

If this destroys too much info (your terrain begins to look muddy and looses detail), you could then import the map into L3DT as a Design Map, and play with the erosion, etc, etc, features. Works pretty good, I just carved 8 new mountain ranges onto a map of the Black Sea/ Caspian Sea/ Volga river basin area using L3DT to carve a detail map, and then blending it with a "peaks" map to get some of the high peaks back.

Hope this helps.
Namaste'

-Telarus, KSC
Telarus
Doyen
 
Posts: 112
Joined: Mon Jun 01, 2009 12:34 am

Re: Need to change DPI of heightmap

Postby Aaron » Tue May 17, 2011 10:41 pm

Hi Calenmiriel,

Can you post a screenshot of what you mean by "the resolution is very bad"? It would help us diagnose the problem. Please also post a screenshot from the Sapphire 3D renderer so that we can compare the scaling in Unity with the original scaling in L3DT.

I'm with Telarus on this one; the DPI value in the file has no influence on resolution or quality of the rendered terrain. It's a throwback to printers and scanners, and has little if any impact in computer graphics. Moreover, when you convert it to a RAW file in the GIMP, the DPI is discarded (RAW files have no metadata), so Unity 3 has no idea what the DPI of the image data was anyway.

That said, although we don't use DPI for terrain rendering, scaling values are still used to project from pixels to real-world units. In L3DT, there is a horizontal scale value in metres per pixel, and I imagine Unity 3 has something similar. We can't use DPI because the 'true' value of the DPI for terrain would be less than 1, and image formats can't store fractional DPIs. For example, reasonable quality FPS terrain of 1 metre per pixel is equivalent to 0.0254 dots per inch. The Shuttle Radar Topography Mission data, which is one of the finer sources of real-world terrain data, was captured at ~30 metres per pixel, which is ~0.000847 DPI.

Anyway, since you're using the GIMP, you will be crunching the height data down to 8 bits, which will introduce ugly terraces and steps as described by Telarus. If you directly export the RAW file from L3DT you will preserve the 16-bit precision of the height data.

Another cause for poor resolution is too few pixels spread over too large an area. What horizontal scaling are you using in L3DT and Unity? Also, what is your map size (in pixels)?

Best regards,
Aaron.

PS: Thanks Telarus for your most helpful answer!
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Re: Need to change DPI of heightmap

Postby Calenmiriel » Wed Jun 01, 2011 3:06 am

I took the heightmap into Gimp and followed Telarus' suggestions then imported the map into L3DT (can't save a raw file in gimp). In L3DT, the map was then saved as a raw file. The size of the file is 2048x1024. Pixel resolution is 1024. The horizontal value is 10. I then imported it in Unity. Two different scenarios happened:

1- In the Import Heightmap window, I chose Bit16 for depth, Width 2048, Height 1024 (I used the same numbers for my terrain resolution). The program loaded the map but only on half of the available space. The other half looked like a flat gray and white aria. So instead of being 2048x1024, it was 2048x512 (my settings, to the best of my knowledge are correct).
2- I decided to try the option of the Bit8 for Depth 2048, Height 2048. I get my full map but I get way too much lag on the computer. If I put a Height of 1024, I get a terrain on half of the available space.

I have tried taking the original picture and export it from L3DT to Unity (used Telarus' suggestions in L3DT) but I get the same result as I did when I first wrote this post or the Unity program goes unresponsive. I can't display an image here. I think the best way I can describe what it looks like, is a the lines in a polygraph on all the terrain.

Thank you for taking the time to respond to my post.

Sincerely,
Calenmiriel
Calenmiriel
New member
 
Posts: 2
Joined: Fri May 13, 2011 1:48 am

Re: Need to change DPI of heightmap

Postby Aaron » Thu Jun 02, 2011 11:59 am

Hi Calenmiriel,

Calenmiriel wrote:I took the heightmap into Gimp and followed Telarus' suggestions then imported the map into L3DT (can't save a raw file in gimp). In L3DT, the map was then saved as a raw file.


Last I checked, GIMP doesn't support 16-bit layer depth, so any blending/smoothing/resizing/etc you may have done will have had no effect on the stepping artefacts. You need to use an image editor with support for 16-bit layer depth (PhotoShop springs to mind), AND you need to use an image format throughout that is in 16-bit layer mode. This means bitmaps and JPEGs should never ever be used for heightfield data, but PNG, TIFF and RAW are OK if and only if you ensure they're saved in 16-bit depth mode.

By the way, another way to remove the stair stepping artefacts in L3DT (in 32-bit precision, no less) is to use the built-in smoothing operation at 'Operations→Heightfield→Smooth (curvature)' (user guide here). Of course, L3DT doesn't generate stepping artefacts*, but this feature will allow you to 'clean' the artefacts out of a heightfield that has been wrecked by passing through a program or image file at 8 bit depth.

Anyway, can anyone confirm whether Unity supports non-square heightfields? If not, this would explain some of the odd behaviour described by Calenmiriel.

Best regards,
Aaron.

* Well, I suppose as a pedant I'll have to concede 32-bit floats still produce these quantisation effects, but at such an incredibly fine scale you'll never notice. In fact, they're 1 part in ~17 million, so for example at a height of 1 metre above sea-level, the stepping artefacts from 32-bit floats are about 60 nanometres high.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia


Return to Help and support

Who is online

Users browsing this forum: No registered users and 16 guests

cron