-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
16 Bit Output #41
Comments
Did you find any way? |
Yes - turns out the data written to the web canvas is really noisy, probably due to browser resampling and the data not being 1:1 for the display. Because I was using this to generate 3D terrain data, this was no good. So in the end I wrote a python script that outputs the tiles directly and stitches them together. Also using python and numpy I translate the 8 bit colour PNGs to 16 bit grayscale (for unreal engine import). |
If it's not secret.. how it should work, that python script? Please, if it possible, share answer , or probably has alternative method to access 16bit data? (i not strong in python, but me too saw "stairs" on mountains in blender, and that makes me sad how close good maps of whole planet but I don't have the required skills to access it). I will be grateful. |
Because I only had to generate a single map (I wasn't planning on doing this multiple times) my code for this is very hacky. It actually is in three stages:
I have cleaned it up a bit and put it in a gist for convenience, with examples: https://gist.github.com/manticorp/3759cdbb3488c529c7d1f0c9b3c74ccf |
Well, after all the preparations, I was finally able to run the php script, but it doesn't work very well. Latitude and longitude can have negative values, but the script does not want to accept them, reporting invalid syntax. |
Haha that's quite possible as I happened to only need it for areas in northeastern hemispheres! I will have a look later as it sounds like a relatively simple fix 😊
|
So, I've been having a look, it was a bug in the CLI command library I was using. I've updated and created a proper repo here: https://github.com/manticorp/Nextzen16bitGrayscaleHeightmap I've added some convenience stuff as well (config files, location storage, etc). It should all work now! Any more issues please post them in the issues on the new repo. I've even managed to export that map of the colorado river :) |
It's just wonderful, I don't know what to write, man, you're just cool. |
Amazing! I'm so glad that it worked for you, and you're pleased with the result. Thank you so much for taking the time to say so. I have noticed a lot of people using the Tangram heightmapper website for unreal engine, and notice that they all suffer from the same low resolution and banding/jaggies. Perhaps I will release this as a standalone software, or perhaps a website, one day. |
have taken the trouble to compare 3 images in UE5: 1 - An image of tangrams downloaded to 8 bits and converted to 16 bits (here you will lose information and it will look bad) The resulting effect is not so bad either. Let's say it's 90% good. They look pretty good with that script. Why do you have the alpha channel disabled? Can you apply this tool or that extra plugin when on the tangrams page so that when the user downloads he does it in 16 bits instead of 8 bits? |
I was using these images to generate heightmaps for the landscape feature in UE5. Unreal Engine expects the data to be in 16 bit grayscale PNG - it does not support alpha channel for landscape heightmaps (and how would that work? Semitransparent landscape?)
2^8 (i.e. regular RGB grayscale) only gives 256 height levels, and so at a resolution of 1m you only have 256m max elevation, or 10m resolution for 2560m elevation. 2^16 gives 65536 height levels, so for example at a resolution of 1m you could have a 65536m high mountain. I believe the mapzen terrarium data is at 10m with interpolation, so 2^16 (16 bit grayscale PNG) is more than enough. You could theoretically have a 24 bit PNG for even greater resolution, as the Mapzen data has fractional metre info. More information from Mapzen here If one could write a terrarium reader for UE5 this would solve all these problems outright, though I'm not sure on the resolution used by UE5 internally - I expect it's only 16 bit anyway.
The way the map viewer works introduces 2 problems that I'm aware of:
Point 1) could be solved by writing a custom export function (either in JS or server side, either is possible) - but this would take some time. I may have a look at this and see if a quick way is possible in browser (which would mean not having to pay for the expensive hosting/processing costs) however, writing a 16 bit PNG implementation for combining all this data in a fast and memory efficient way will be difficult whilst supporting all UE5 image sizes. Point 2) could be fixed by only allowing zoom levels that display the tile data at native resolution. I'm not sure if this means just allowing integer zoom levels or not. It would be a lot more convenient if one was able to just export from the heightmapper tool. |
The alpha channel in a heightmap is not essential, but it can be useful in some cases. A heightmap represents the height or elevation of a terrain in an image, and can be represented using only a grayscale information channel. However, some terrain creation programs may use the alpha channel to store additional information, such as texture, moisture, vegetation, etc. In these cases, the alpha channel is important. In short, the importance of the alpha channel in a heightmap depends on its intended use. If only elevation information is needed, a grayscale channel is sufficient. But if additional information is required, then the alpha channel can be useful.
It looks good, you can do a pullrequest with that functionality and if the "tangrams" accepts it, that would be nice. Something like a button and it will run your PHP and download it. |
I have created a version of this that runs in-browser, you can find it here: https://manticorp.github.io/unrealheightmap/ Let me know how you get on! Should be a lot easier than running it from the command line. |
I tested on Ubuntu 22.04 with Firefox 110.0 (64-bit) and it works time to time, i have two results: it works fine and even greatly more faster than previous console method, tiles are downloaded very fast and final image generated for several seconds, or something going wrong... |
Aha - This should be fixed in the latest version. It is because the Longitude was overflowing (going below -180) - the Leaflet map doesn't clamp the value! |
Hello! The app and web interface are awesome. A huge help in my work. Thank you so much! Thank you again for your work. |
@gerchprung Thank you for showing your appreciation! Do you get the issue using the web app at Manticorp - Unreal Heightmap? If so, would you be able to post screenshot showing the problem here: Manticorp - Unreal Heightmap - Issues? Is possible, a screenshot showing the console output would be great as well - the over/underflow issue should be fixed in current version. All the best, |
Thanks for rapid fast responce) Yes, issue with the web app. I already posted new issue report by attached link. |
This is the absolute bomb! |
Shout out to AerialOD Ephtracy! Can anyone suggest a simple way to modify the terrain raster? I want to show elevation changes due to mining (cut and fills) in different terrain models (mining progress by year) with recolored RGB drapes. |
Yay! Glad you're getting good use out of it 😅 Consider supporting it on Ko-fi here. With regard to editing, Photoshop supports 16 bit editing, or Photopea. Otherwise, PNGs are a very simple file format, and relatively easy to write a program to do so 😁 |
This is an amazing tool - the data is available in 16 bit format, but the restrictions of web canvases mean in grayscale the data is limited to 8bit, which is a shame, because for use in many game heightmap imports, 8 bit data is not granular enough and results in large steps.
Is it possible to toggle 16 bit output, in the form of the straight terrarium data output by the tangram api?
I think this would be possible by creating a shader that doesn't perform the conversion from the terrarium style data to grayscale, which necessarily clamps to 8bit when writing to the canvas, and being able to toggle that on for rendering.
A separate tool could then be created to convert that data into a 16bit grayscale PNG file.
The text was updated successfully, but these errors were encountered: