Need advice: Lines between MapPixels

Discuss modding questions and implementation details.
Post Reply
User avatar
Daniel87
Posts: 391
Joined: Thu Nov 28, 2019 6:25 pm

Need advice: Lines between MapPixels

Post by Daniel87 »

Hi everyone!

Progress is fast with my Wilderness Overhaul Mod, but there is one algorithm that gives me a hard time.
See picture for visualization of the problem:
Image

As you can see, there are seams between the Map Pixels due to a limitation in my algrorithm.
Basically I am comparing neighbouring points on the heightmap to calculate the steepness and texture a tile as stone if the hillside is
too steep.
Problem is, I don't know how to account for the neighbouring Map Pixel when comparing heightmapSamples without getting IndexOutOfBounds.
Does anyone have an idea how to approach this?

Code: Select all

static bool SteepnessTooHigh(float steepness, NativeArray<float> heightmapData, float maxTerrainHeight, int hx, int hy, int hDim, int upperBound, int index, int tdDim, NativeArray<byte> tileData)
        {
            if (JobA.Col(index, tdDim) + 1 >= tdDim ||
                JobA.Row(index, tdDim) + 1 >= tdDim)
            {
                return false;
            }
            else
            {
                    float minSmpl = 0;
                    float maxSmpl = 0;
                    float smpl = minSmpl = maxSmpl = heightmapData[JobA.Idx(hy, hx, hDim)] * maxTerrainHeight;
                    for (int a = 0; a <= 1; a++)
                    {
                        for (int b = 0; b <= 1; b++)
                        {
                            smpl = heightmapData[JobA.Idx(hy + a, hx + b, hDim)] * maxTerrainHeight;

                            if (smpl < minSmpl)
                            {
                                minSmpl = smpl;
                            }
                            if (smpl > maxSmpl)
                            {
                                maxSmpl = smpl;
                            }

                        }
                    }

                    float diff = (maxSmpl - minSmpl) * 10f;

                    if (diff > steepness)
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
            }
        }
Last edited by Daniel87 on Tue Apr 27, 2021 11:21 am, edited 1 time in total.
In Julianos we Trust.

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Need advice: Lines between MapPixels

Post by BadLuckBurt »

Thats going to be tricky. I suppose one way to do it would be to change the heightmap generator to also calculate the outer border of the adjacent map pixels. That way you can at least calulcate the slope correctly. Might cause problems on lower systems since the jobs will be running slightly longer

It worked in the original texturing process because thats just mapping tiles to Perlin Noise without regard for the steepness.
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
Daniel87
Posts: 391
Joined: Thu Nov 28, 2019 6:25 pm

Re: Need advice: Lines between MapPixels

Post by Daniel87 »

BadLuckBurt wrote: Tue Apr 27, 2021 11:19 am Thats going to be tricky. I suppose one way to do it would be to change the heightmap generator to also calculate the outer border of the adjacent map pixels. That way you can at least calulcate the slope correctly. Might cause problems on lower systems since the jobs will be running slightly longer

It worked in the original texturing process because thats just mapping tiles to Perlin Noise without regard for the steepness.
You're right, but problem is, that DaggerfallTerrain only injects the heightmap and mapData of the current MapPixel into the Script, so I won't have the neighbouring heightmap information available in that thread.
I am thinking if I should just simply extrapolate linerarly and "guess" my way through. As long as the result is not a straight line of non-stone or stone tiles, the human eye shouldn't be able to see the difference.

EDIT: Works like a charm! :D

Image
In Julianos we Trust.

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Need advice: Lines between MapPixels

Post by BadLuckBurt »

Sweet, that saves some headaches :) It looks great
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

User avatar
Daniel87
Posts: 391
Joined: Thu Nov 28, 2019 6:25 pm

Re: Need advice: Lines between MapPixels

Post by Daniel87 »

BadLuckBurt wrote: Tue Apr 27, 2021 11:45 am Sweet, that saves some headaches :) It looks great
Thanks!
Yes, after sinking too many hours in "exact" solutions, I have come to learn that achieving almost the same outcome with cheap tricks is THE way to go, hehe.
In Julianos we Trust.

User avatar
King of Worms
Posts: 4752
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

Re: Need advice: Lines between MapPixels

Post by King of Worms »

😊👍

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Need advice: Lines between MapPixels

Post by Hazelnut »

Daniel87 wrote: Tue Apr 27, 2021 11:51 am
BadLuckBurt wrote: Tue Apr 27, 2021 11:45 am Sweet, that saves some headaches :) It looks great
Thanks!
Yes, after sinking too many hours in "exact" solutions, I have come to learn that achieving almost the same outcome with cheap tricks is THE way to go, hehe.
Exactly! Chasing perfection is a bad return on time investment a lot of times. :D

This is especially true for games I think.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

Post Reply