• Mods are now organized as resources. Use the Mods link above to browse for or submit a mod, tool, or prefab.

    The TFP Official Modding Forum Policy establishes the rules and guidelines for mod creators and mod users.

Editing heightmap with correct smoothing

Qnut

Refugee
Hello,

I have a problem with smooth terrain after editing a height map from RWG which was converted to PNG. I took the dtm.raw from the generated world and converteted it with old KingGen to 16 bit dtm.png. Also tried converting with Photoshop 2025 - same result. Problem is that the processed world has not that fine smoothing between several heights as it is with the original RAW file.

This is what it looks like with original dtm.raw as it should:
V2.2_2025-07-29_16-41-54.jpg

Here is the dtm.png processed with slight stairs:
V2.2_2025-07-29_16-11-52.jpg

And this is what happens if saved as Photoshop RAW, when just opened the original RAW in Photoshop:
V2.2_2025-07-30_16-16-24.jpg
Seems to be just 8 bit.

Has anybody any idea what is wrong with the PNGs or its grayscale colors/values? Even when I convert RAW to PNG, not touching the file and let process the world ingame, I have the same stairy result as in the second picture. In the PNG itself Gimp for example shows me comma values for colors.

Thanks in advance for your help.
 
If a heightmap is 8 bit at any point, you aren't going to have good looking terrain. You can somewhat fix it by manually editing it and using a lot of smoothing and blurring, but it will be a lot of work if you want it to look good. Converting to 16 bit doesn't fix the problem. The best option is to avoid it ever being 8 bit.

Btw, if you are using Teragon, you can easily convert RAW to PNG. Just import it and export it. If you need help with that, there is a preset that was posted in the #presets channel on Teragon's discord to do that. That doesn't solve an 8 bit heightmap problem, though.

You can also convert it from PNG to RAW.

Btw, you shouldn't edit the RAW. Edit the PNG and convert it using Teragon. The RAW file is likely not the same kind of RAW format that Photoshop uses.
 
If a heightmap is 8 bit at any point, you aren't going to have good looking terrain. You can somewhat fix it by manually editing it and using a lot of smoothing and blurring, but it will be a lot of work if you want it to look good. Converting to 16 bit doesn't fix the problem. The best option is to avoid it ever being 8 bit.

Btw, if you are using Teragon, you can easily convert RAW to PNG. Just import it and export it. If you need help with that, there is a preset that was posted in the #presets channel on Teragon's discord to do that. That doesn't solve an 8 bit heightmap problem, though.

You can also convert it from PNG to RAW.

Btw, you shouldn't edit the RAW. Edit the PNG and convert it using Teragon. The RAW file is likely not the same kind of RAW format that Photoshop uses.
Thanks for your answer. Always was working with 16 bit grayscale color (with and without alpha) - as you can see in the last screenshot, which is an example of 8 bit that I never worked with.

I tried to import the RAW file in Teragon with the import heightmap command and as I remember it came to the error that it is not readable. Perhaps I'm doing something wrong and will try again. Also I'm not familar with Discord. 😅
 
Thanks for your answer. Always was working with 16 bit grayscale color (with and without alpha) - as you can see in the last screenshot, which is an example of 8 bit that I never worked with.

I tried to import the RAW file in Teragon with the import heightmap command and as I remember it came to the error that it is not readable. Perhaps I'm doing something wrong and will try again. Also I'm not familar with Discord. 😅
If you already saved it as RAW from something like Photoshop, you may have "broken" it. The game's RAW isn't a normal RAW from something like a digital camera.
 
If you already saved it as RAW from something like Photoshop, you may have "broken" it. The game's RAW isn't a normal RAW from something like a digital camera.
No, it is the original RAW file generated by RWG. Don't know if it was the same with Navezgane's RAW. I'm looking forward to trying it again tomorrow.
 
No, it is the original RAW file generated by RWG. Don't know if it was the same with Navezgane's RAW. I'm looking forward to trying it again tomorrow.
If it was the original, it should load fine in Teragon. Make sure you have the map size set correctly to match it, though. All RWG heightmaps can load into Teragon. If you have trouble, the best option is to visit the Discord channel and share the heightmap and whatever preset you're using to import it so someone else can test it.
 
Tested a bit with Teragon. I exported the RWG generated RAW with your ImportHeightMapExample Preset in Teragon to PNG. Opened the PNG in Gimp and exported it in 16 bit GRAY. Let the game process the PNG, terrible smoothing. Then I let Teragon do the RAW conversion with the RAW Converter preset and let the game process this RAW. Smoothing is fine but there is an offset of +5.2 color value (seen in Gimp) with the whole heightmap, which results in a terrain about 5.50 meters higher:

V2.2_2025-08-03_20-48-27.jpg

Next try I just converted my edited PNG, that was previously converted by KingGen from the generated RAW, with RAW Converter preset in Teragon and now I have the result I wanted:

V2.2_2025-08-04_12-54-16.jpg

The job Teragon does is amazing. Why is the game processor (Unity) not able to do correct smoothing from given PNG as its RWG does within the RAW?

In any case thank you @Riamus for your tips.

Finally GOT IT! 😁
 
Tested a bit with Teragon. I exported the RWG generated RAW with your ImportHeightMapExample Preset in Teragon to PNG. Opened the PNG in Gimp and exported it in 16 bit GRAY. Let the game process the PNG, terrible smoothing. Then I let Teragon do the RAW conversion with the RAW Converter preset and let the game process this RAW. Smoothing is fine but there is an offset of +5.2 color value (seen in Gimp) with the whole heightmap, which results in a terrain about 5.50 meters higher:

View attachment 36060

Next try I just converted my edited PNG, that was previously converted by KingGen from the generated RAW, with RAW Converter preset in Teragon and now I have the result I wanted:

View attachment 36061

The job Teragon does is amazing. Why is the game processor (Unity) not able to do correct smoothing from given PNG as its RWG does within the RAW?

In any case thank you @Riamus for your tips.

Finally GOT IT! 😁
The game doesn't use the PNG. It uses the RAW. That's why you need to convert it back to the RAW. The PNG just offers a way to edit it before converting it back to RAW. Someone who uses GIMP can probably give you a reason why you were off by that much in GIMP. It may be some setting. I know a number of people who edit the heightmaps in GIMP without a problem, so I know it can be done. I don't edit heightmaps by hand myself.
 
The game doesn't use the PNG. It uses the RAW. That's why you need to convert it back to the RAW. The PNG just offers a way to edit it before converting it back to RAW.
That's not fully true. I always deleted the RAW file, so there only is the PNG and the game processes this PNG to a dtm.raw first and then the dtm_processed.raw while loading into the map/world. So obviously the game is not able to fully take over the exact color gradients from the PNG to the RAW for fine smoothing. GIMP does its job fine when exporting as PNG in "16 bpc GRAY". It's just Teragon that is able to convert the given PNG to the right RAW, that then can be used to let the game process the world. Game's process order is first the RAW. If there is no RAW but a PNG it processes PNG to RAW and uses this RAW for further processing.
 
When I directly use Teragon to export the RAW to a PNG with the preset then the colors are offset by arround +5.2. The full heightmap then is a bit lighter than the original, that KingGen or Photoshop can export the right way.
 
This preset (image below, copy it to the clipboard to load it) can be used to import a vanilla 7 days world or one that was created by Teragon, doesn't.

It does the following steps
1. import the dtm.raw
2. export it as dtm.png (and dtm.raw but that's not used)
3. import the dtm.png
4. export it as dtm.png and dtm.raw

Result is that the POIs are still perfectly flush with the terrain after that cascade of imports and exports. Unless, I am overlooking something this proves that Teragon doesn't add an offset or changes the data in any other way.

1754373556263.png
 
This preset (image below, copy it to the clipboard to load it) can be used to import a vanilla 7 days world or one that was created by Teragon, doesn't.

It does the following steps
1. import the dtm.raw
2. export it as dtm.png (and dtm.raw but that's not used)
3. import the dtm.png
4. export it as dtm.png and dtm.raw

Result is that the POIs are still perfectly flush with the terrain after that cascade of imports and exports. Unless, I am overlooking something this proves that Teragon doesn't add an offset or changes the data in any other way.

View attachment 36085
Does this picture work as a QR code for Teragon?

Thank you @Pille for your hard work. Would be perfect if Teragon doesn't add any offsets. So one can work with RWG maps, if only just to fix road conflicts from RWG. I have not found any other solution for converting RAW -> PNG -> RAW with fine smoothing.
 
If you still have any problems with the conversion, you can contact. If I knew the exact procedure and had the involved files (if it's anything else than a vanilla heightmap), I would certainly be able to tell where the issue comes from.

I guess "RAW -> PNG -> RAW" is actually "RAW -> PNG -> Edited PNG -> RAW"?

Will have more time at the weekend to re-read this thread...
 
I guess "RAW -> PNG -> RAW" is actually "RAW -> PNG -> Edited PNG -> RAW"?

It is equal wheather directly first editing the PNG or not. I was trying with my RWG RAW to convert it to PNG and directly back to RAW in Teragon. The first step RAW -> PNG in Teragon adds the offset. It can be seen in the PNG and results in 5+ blocks higher terrain in the world. No matter if using PNG or back converted RAW. The only difference is that the direct use of the PNG for world processing results in ugly smoothing.

I can test it with a copy of the original Navezgane map if that helps. I would expect the same result.
 
Back
Top