Math wizard for calculating landscape tile Z offsets

Hi hello!

I am using rather a very unconventional way of adding landscape tiles using World Composition and I am seeking for some math wizard to give me some hints to do this:

  1. using World Machine I am using Tiled export to export seperate tiles of one big landscape. Now…the catch here is that I am autoleveling each single tile. In WM, using clamp and turn on ‘normalize’. This gives me an autoleveled tile, similar to Photoshop → autolevel.
    The expected output will be a tiled landscape where every single tile won’t align and have different scales. Flat areas will look very bumpy, and hills will look normal’sh.

The reason for doing so is, that I have a rather very big landscape and the exported tiles would look super flat and therefor in UE4 scale them up to high numbers and get stepping effects.
So, I want to map the entire range of height data to a single tile and not losing any fidelity.
E.g. one tile would have a min value pixel of 0.2 and the max value of pixel would be 0.215, that is the range of one tile.

  1. I can calculate the correct scale for each single tile but I have to manually align them on Z axe. This is tweaking until it fits. This does work, but I feel there must be some formula to calculate the correct Z offset.
    Again, I realise this is ‘not the way to do landscape in UE4’ but I like to think out of the box.

Anyone tried to do some crazy things with landscape tools and could hint me in correct direction?
All the best! T

Make a single tile with an image scaled correctly in a 0 to 65535 range and a resolution that fits inside 1 tile.
stretch the x/y to fit the landscape overall size.
Set the Z to the magic number for 1:1 which is .0019 etc. * 65535 in order to get a resolution of 1px per meter in the z axis.

With that as the backing you have the master template to move the other tiles around visually and match the heights to where they should be.
make sure you use increments in 100 units (1m) so that the edges will eventually just match once at the correct spot.

As far as doing it mathematically. You could, but you have a variable z per tile, so you’d have to do the math one by one.

The problem with it is that the position of the landscape is not necessarily driven by the end point of the bounding box. * see note*

The visual aid tile is probably the best approach.
at least with maps less than around 112km^2
Consider that 8km stretched to 100km is a massive amount of visual distortion. Only really useful to line stuff up on the fly. Not even worth the load for a distant impostor…

what this means is that a landscape can go like this


And your tile could be just the mountain
at which point the bounding box may read a size that doesn't tell you anything at all because the second tile doesn't even need to be moved to match position.

KINDA forgot to mention.

Your seams across maps will never match unless you cut in 1px edge from the other normalized images all around. Think about that for a minute.

Now that you did.

If, 1 bit = 1cm in map A, and 1bit = 2cm in map B, how can you get a map that has no gap between A and B when the same bit value is used? Ya can't.
You'd have to set all the tiles to the same Z and have all the edges match with the same bit value - which is what is normally done.
Like you said, you can Manually, calculate things. scaling down the bit value from B to match A's at the edge. You can make a Python script to help a bit. But it's not an immediate task.

Hi MostHost La!
thnx for your detailed feedback!
”As far as doing it mathematically. You could, but you have a variable z per tile, so you’d have to do the math one by one.”

…is exactly what i am looking for.
i guess, trying to solve one thing is opening an issue elsewhere.

Btw…all this, is only because i cannot import 32bit raw files. The stepping is noticable despite the 16bit raw export. The landscape has a very long low slope. And the tiles are rather dense.
(32 x 32 x 2017)
again: not the most common workflow, i know.

Whatever you do, when you normalize the tiles individually you create gaps in the geometry across tiles when using the same Z scale.

If you calculated the z scale individually for each you could potentially get to the point where no gaps exist.

On 94 tiles that’s insane.

the individual z value is calculated just like you always do.

Z ratio .019 whatever it is (get it off the docs) x the actual height variance of the tile in cm.

To place it who knows really.

What you can do is script a bluetily to try and place it when you activate it based on a trace from under the camera position thar gives you the height in world units of the landscape you hover.
make it more complex maybe.
2 cubes. Place A on the good tile. B on the bad one. Adust the one B interact with based on the world z of A.

Still not a fast solution as you’d have to go manually tile over tile.

I already fixed the scaling issue.I thought, I did mention that in my first post. If I manually align the tiles on Z back using translate, not scale, I can fix the gaps…it is the translate Z that is causing trouble. I can drag the tile until fits, but I do wonder if there is some good formula to sort this out to get the exact pixel perfect number. Don’t mind to go through a lot of tiles. As long as the result looks outstanding. :wink:

Having said all that… I do wonder if I really should go down this road now. I am starting to kind of accept that I cannot squeeze things out of the landscape techniques the way I would love and instead, just accept that this whole landscape workflow is just not used to render insane details. Quite time consuming to find ways that doesn’t fit in the regular worklfow. Or maybe try again in the future when I am even more smarter.
Anyhoe… thnx again for the detailed feedback!
cheers! T