GithubHelp home page GithubHelp logo

Comments (18)

colkassad avatar colkassad commented on May 27, 2024

Is it related to this?: https://docs.unrealengine.com/4.27/en-US/BuildingWorlds/Landscape/TechnicalGuide/#calculatingheightmapzscale

from unreal_mapbox_bridge.

delebash avatar delebash commented on May 27, 2024

I am not sure. I used the above formula to calculate the Z scale. Here is a video showing the problem. https://1drv.ms/v/s!Aq4OgSZRh__uieNLDnjytI0m9hf5WA?e=fdX9at

from unreal_mapbox_bridge.

colkassad avatar colkassad commented on May 27, 2024

A few things I found:

https://forums.unrealengine.com/t/what-is-unreal-unit-height-translation-after-importing-16bit-heightmap-to-level/157062

https://old.reddit.com/r/unrealengine/comments/li6xmi/ue_426_water_plugin_with_heighthmaps/

Not the best information. This person seems to have the same problem: https://stackoverflow.com/questions/70222487/how-do-you-reset-an-unreal-engine-4-5-landscape-back-to-0-z-height-or-sea-level

..but no answers :(

Perhaps you need to translate the elevations somehow, e.g. finding the center elevation in your range and adding that to all of your heightmap elevation values before import. Or just noting that value and adding it to your transform when placing it in the map. Try noting where a few heightmaps gets placed in the Z and compare with your elevation ranges to see if a pattern emerges (long shot, especially with the Z scaling involved).

Btw, I tried opening your plugin but had some issues with dependencies. Probably my lack of knowledge dealing with custom plugins.

from unreal_mapbox_bridge.

colkassad avatar colkassad commented on May 27, 2024

Perhaps you need to translate the elevations somehow, e.g. finding the center elevation in your range and adding that to all of your heightmap elevation values before import. Or just noting that value and adding it to your transform when placing it in the map.

You'll probably need to incorporate your z-scaling into this calculation as well. I'd try to work it out for you but I'm pretty terrible with math :)

from unreal_mapbox_bridge.

colkassad avatar colkassad commented on May 27, 2024

I'd probably start with testing something like:

z transform value = ((z transform value) + 32768) * (z scale value)

from unreal_mapbox_bridge.

delebash avatar delebash commented on May 27, 2024

Are you on Windows?

from unreal_mapbox_bridge.

colkassad avatar colkassad commented on May 27, 2024

from unreal_mapbox_bridge.

delebash avatar delebash commented on May 27, 2024

Cool! Currently I am just writing the coordinates to the output log. Then I add a few cubes on the landscape and set them to those coordinates to see how they look. To show the output log go to Windows/Developer Tools and select output log. Before running the import process right click on the output log window and choose clear. This just makes it easier to see the resulting coordinates. To edit the blueprints right click on the MabboxInterface and choose edit, then select Graph on the upper right corner. One other thing is that I am only looking for geojson features with id that are in this switch statement to make things easier for testing.
Vb8p5XSwwz

If you want, you can disconnect all of the switches but one if you know you have that feature in your geojson in order to reduce testing results.

from unreal_mapbox_bridge.

delebash avatar delebash commented on May 27, 2024

The id field under geometry in your geojson is what I am looking at to parse the data.

from unreal_mapbox_bridge.

delebash avatar delebash commented on May 27, 2024

Perhaps you need to translate the elevations somehow, e.g. finding the center elevation in your range and adding that to all of your heightmap elevation values before import. Or just noting that value and adding it to your transform when placing it in the map.

You'll probably need to incorporate your z-scaling into this calculation as well. I'd try to work it out for you but I'm pretty terrible with math :)

I am much worse with math than you. You made all the lon/lat calc's for creating the heightmap so you are much better at it than I am. What you did really helped me understand what was going on.

I am not sure I understand what you are talking about when you say incorporate your Z-scaling.

I tried adding the median elevations to all the elevations values in the array, but I still have the same problem. Also, the X and Y are not centered. I expect we need to fix this problem with the heghtmap before we can import the geojson correctly. What do you think?

from unreal_mapbox_bridge.

delebash avatar delebash commented on May 27, 2024

Tested Gae, World Machine, and World Creator. All of these programs heightmap had the same import problem. The landscape Z transform showed 100 but a cube actor placed on the landscape was always in the high negative range.

from unreal_mapbox_bridge.

colkassad avatar colkassad commented on May 27, 2024

from unreal_mapbox_bridge.

delebash avatar delebash commented on May 27, 2024

Cool, have a safe trip.

from unreal_mapbox_bridge.

delebash avatar delebash commented on May 27, 2024

More information about the problem:

UnrealEditor_VE6zJyMfse

This image is a picture of the imported landscape heightmap for Mt. Rainier. If you look at the hole this is as far down as the sculpting tool would let me dig. You will notice the cube Z position in that hole is --25500.0. So with the height range of 255 to -255 the landscape is importing almost at the bottom of the range.

  1. How do we find the sea level of a heightmap?

  2. How do we adjust the heightmap so it will import into Unreal correctly?

If we cannot adjust the sea level, then we cannot make sculpt deep Canyons or Rivers with the imported landscape.

from unreal_mapbox_bridge.

delebash avatar delebash commented on May 27, 2024

Further testing:

I created a new blank 2017x2017 landscape in Unreal. I sculpted so height features and then exported the heightmap from Unreal to png. Below is the resulting image

unrealexport

  1. What is Unreal using as it's color scale since this image is grey for land at sea level instead of Black and White?

from unreal_mapbox_bridge.

delebash avatar delebash commented on May 27, 2024

More Testing:

I compared the min max height of a new landscape hieghtmap to the one created by the web application

The Unreal min/max is
32768
43267

The webapp min/max for Mt. Rainier is
104
4381

The web app is using this formula from mapbox to convert the encoded elevation rgb data to meters
-10000 + ((r * 256 * 256 + g * 256 + b) * 0.1)

This data 4381 is the correct elevation in meters for Mt. Rainier.

How do we convert these numbers to the Unreal numbers?

Is Unreal using the 65,536 range for 16bit?
So we should not convert it to meters?

from unreal_mapbox_bridge.

delebash avatar delebash commented on May 27, 2024

This guy was having the same problem. Note for further exploration https://forums.unrealengine.com/t/what-is-unreal-unit-height-translation-after-importing-16bit-heightmap-to-level/157062/6

from unreal_mapbox_bridge.

delebash avatar delebash commented on May 27, 2024

I believe I have fixed the sea level issue by scaling the image using gdal js. '-scale', minelevation, maxelevation, '32768', '65535',
I got this info from this question on unreal forums. The only problem is re-calculating Z scale which I am not getting correct.

https://forums.unrealengine.com/t/what-is-unreal-unit-height-translation-after-importing-16bit-heightmap-to-level/157062/5

Text for future reference:

Starting from SRTM 1 image:
gdalwarp -co “COMPRESS=LZW” -r near -t_srs “EPSG:31983” S20W044.hgt S20W044.tif
To bring data values to a suitable orthogonal projection. Open image, select and clip some desired area. I selected some 505px x 505px (15150m x 15150m) area to have image exact size one of the recommended UE sizes. Then write down min max image pixel values (heights), for me is 683 ~ 1370.
Then
gdal_translate -ot UInt16 -scale 683 1370 32768 65535 S20W044_1.tif S20W044.png
This scale up pixel values to full range (of half space for Z - from 0 to 255.992 in UE). Also save it as 16bit unsigned, just to have image in same shape of ones exported from UE levels.
Spatial resolution (cell size) of SRTM is 30, so the real size is 505*30=15150m. The new scale for X Y is 15150/505=30x the size of actual scale=3000.
For Z scale, the real world height amplitude from the SRTM clip is 68600cm, and actual amplitude in uu is 256, so 68600/256=270.703 for Z scale.

from unreal_mapbox_bridge.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.