L3DT users' community
Large 3D terrain generator

Do not use images for heightfields!

Got a problem or need advice?

Do not use images for heightfields!

Postby Aaron » Thu Jun 28, 2007 6:09 am

Hi all,

The issue of steps in heightfields has popped up a few times, so I thought I'd post a sticky to address this properly and (hopefully) finally. Here are a few facts to bear in mind:
  • The steps are caused by converting the heightfield to or from an 8-bit format (these can only encode 256 levels, which aren't enough).
  • Most image formats use 8-bit colour depth. PNG-16 and some TIF formats are the exception (these are OK).
  • Even 24-bit or 32-bit true-colour bitmaps and JPEGs use 8-bit colour depth.
  • Creating or editing your heightmap in an image editor will produce these 8-bit steps, because image editors work on 8-bit colour depths. This happens even if the input/output file formats are 16-bits or higher (note: Photoshop has very limited 16-bit support, and other programs usually have none).
  • You cannot remove these 8-bit steps, unless you blur/filter your map in a program that supports 16-bit height precision or greater (L3DT uses 32-bit precision).
  • Re-saving in 16-bit formats does not remove these artefacts.
  • If your heightmap has at any point been created/edited in an image editor, or converted to/from an format with 8-bit colour depth, you will have introduced 8-bit steps.
Now, if you must store your heightmap as an image, use 16-bit PNG or 16-bit RAW. If you must edit your heightmap in an image editor, use Photoshop and always use 16-bit mode. If you must use formats with 8-bit colour depth, use the 'Operations->Heightfield->Filter (diffusion)' to smooth the heightfield after loading.

Are there any questions?

Cheers,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3680
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby guy Riessen » Mon May 12, 2008 3:52 pm

Photoshop, at least CS3 (I haven't tried to go back an look with any older versions), supports 32-bit Tiff, but L3DT doesn't import Tiffs. Can you include a tiff heightfield importer in one of the upcoming releases so we can edit at full depth, please? :)
guy Riessen
Contributing member
 
Posts: 33
Joined: Wed Mar 05, 2008 5:25 pm

Postby Aaron » Mon May 12, 2008 9:33 pm

Hi Guy,

Thanks for the request. I've added it to the plugin requests page, and if no-one else wants to try their hand at plugin development, I'll get around to it eventually.

Cheerio,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3680
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Re: Do not use images for heightfields!

Postby Pauli » Wed Aug 20, 2008 3:07 pm

aaron wrote:
  • Creating or editing your heightmap in an image editor will produce these 8-bit steps, because image editors work on 8-bit colour depths. This happens even if the input/output file formats are 16-bits or higher (note: Photoshop has very limited 16-bit support, and other programs usually have none).
Now, if you must store your heightmap as an image, use 16-bit PNG or 16-bit RAW. If you must edit your heightmap in an image editor, use Photoshop and always use 16-bit mode.


You do not need to use Photoshop.
- I use Micrografx Picture Publisher. It has had 16-bit support much longer than Photoshop has had it.
- Paintshop Pro has had 16-bit support since version 9 (current version is X2).
- Free command line image editor ImageMagick has 16-bit support, too (there are versions both with and without the 16-bit support, be sure to download the correct one). ImageMagick is handy for example for image format conversions and image resizing (it has more advanced algorithms that give better results than for example Photoshop).

Are PNG and RAW the only formats on L3DT that support 16-bit?
According to the FAQ, L3DT supports PGM, too. PGM standard includes 16-bit color depth.
Pauli
New member
 
Posts: 2
Joined: Wed Aug 20, 2008 12:10 pm
Location: Helsinki, Finland

Postby Pauli » Wed Aug 20, 2008 4:18 pm

guy Riessen wrote:Photoshop, at least CS3 (I haven't tried to go back an look with any older versions), supports 32-bit Tiff, but L3DT doesn't import Tiffs. Can you include a tiff heightfield importer in one of the upcoming releases so we can edit at full depth, please? :)


I have heard that the 32bit HDR support on Photoshop CS3 is very limited. You can not do much more than merge photos into a HDR image, and do some levels adjustments and cropping. In 16-bit mode, at least some more functions are possible, even if not all the functions available in 8-bit mode. So I think it is better to use 16-bit mode than 32-bit mode.

I don't see any benefit in using 32-bit mode. 16 bits should be enough for all purposes. Even if you are rendering Mount Everest, 16 bits will give you vertical resolution of about 12cm.

BTW, it should be noted that the "32-bit" floating point actually has only 24 bits resolution (8 bits are used for exponent).

Floating point is typically used in order to be able to store all possible values without scaling. A typical heighfield only uses a small subset of the possible altitude range.

At least in Terragen .ter files, the altitude range is scaled such that the full 16-bit range is in use. So, in case of Mount Everest, the vertical resolution is 12cm, but if the altitude range you are using is for example 640 metres, then the resolution is 1cm. If horizontal point spacing is, say, 10m (or even 1m), you will not be able to see 12cm altitude change, and definitely not 1cm change.

BTW, if L3DT uses 32-bit resolution internally, does it mean 32-bit integers or 32-bit (24+8 bit) floating point? (The 32-bit TIF uses floating point.)
Pauli
New member
 
Posts: 2
Joined: Wed Aug 20, 2008 12:10 pm
Location: Helsinki, Finland

Postby Aaron » Wed Aug 20, 2008 10:01 pm

Hi Pauli,

Pauli wrote:Are PNG and RAW the only formats on L3DT that support 16-bit?
According to the FAQ, L3DT supports PGM, too. PGM standard includes 16-bit color depth.


Yes, the PGM format is supported in 16-bit mode. L3DT also supports 16-bit TER, 16/32-bit HFF and BT, and variable precision HFZ (8-32).

Pauli wrote:Can you include a tiff heightfield importer in one of the upcoming releases so we can edit at full depth, please? :)


I'll put it on the to-do list. Can you please send an example file to aaron@bundysoft.com?

By the way, you can edit at full depth using Sapphire.

Pauli wrote:BTW, if L3DT uses 32-bit resolution internally, does it mean 32-bit integers or 32-bit (24+8 bit) floating point?


Floating point. Fixed point algebra would be unnecessarily restrictive on manual editing and certain algorithms.

Cheerio,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3680
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby Aaron » Sat Apr 18, 2009 10:27 am

Hi All,

Thread resurrection time!

Pauli wrote:Can you include a tiff heightfield importer in one of the upcoming releases so we can edit at full depth, please? :)


Done, in v2.7 build 6.

Cheerio,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3680
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby stevenc » Fri Jan 15, 2010 10:33 am

I've got the latest build (2.8.4 I think?),
yet it doesn't seem to be able to load .tif files as heightmap.

I've tried 24-bit png, and this loads, but it still gives terrible lines
and after using one of the smooth functions (I assume this replaces the filter-option you mention in the first post), the lines are gone, but it seems to lose a lot of detail then.

So, is the tif support removed or something ?

(tga support instead would also be fine for me)
stevenc
New member
 
Posts: 3
Joined: Fri Dec 11, 2009 8:32 am

Postby Aaron » Mon Jan 18, 2010 4:45 pm

Hi Steven,

stevenc wrote:yet it doesn't seem to be able to load .tif files as heightmap.


What error message do you get when you try to load a TIF? The plugin only loads GeoTIFF images, which are a subset of the TIF specification. Can you send me an example TIF file? (to aaron@bundysoft.com, please)

stevenc wrote:I've tried 24-bit png, and this loads, but it still gives terrible lines


24-bit (RGB) images have the same greyscale precision as 8-bit images (i.e. only 256 possible values), so the same problems with terraces will be evident.

stevenc wrote:So, is the tif support removed or something?


GeoTIFF are supported. However, not all of the possible TIF formats are supported.

Cheers,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3680
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Re:

Postby alina » Tue Feb 12, 2013 12:12 pm

Aaron wrote:Hi Guy,

Thanks for the request. I've added it to the plugin requests page, and if no-one else wants to try their hand at plugin development, I'll get around to it eventually.

Cheerio,
Aaron.



Hi Aaron , Pauli is absolutely right that no need to use photshop ...for this purpose you can use picasa or Micrografx picture publisher .i think it helps you a lot .
alina
Newbie
 
Posts: 1
Joined: Tue Feb 12, 2013 12:05 pm

Re: Do not use images for heightfields!

Postby baklazanek » Wed Jun 26, 2013 11:22 am

alina wrote:
Aaron wrote:Hi Guy,

Thanks for the request. I've added it to the plugin requests page, and if no-one else wants to try their hand at plugin development, I'll get around to it eventually.

Cheerio,
Aaron.



Hi Aaron , Pauli is absolutely right that no need to use photshop ...for this purpose you can use picasa or Micrografx picture publisher .i think it helps you a lot .


But,photoshop is way more proffesional... :roll:
Image
baklazanek
Newbie
 
Posts: 1
Joined: Wed Jun 26, 2013 11:20 am


Return to Help and support

Who is online

Users browsing this forum: No registered users and 4 guests

cron