Board index FlightGear Development Effects and shaders

Terrain Perlin noise could have a shorter wavelength?

An exciting "new" option in FlightGear, that includes reflections, lightmaps, the particle system etc.. A lot is yet to be discovered/implemented!

Terrain Perlin noise could have a shorter wavelength?

Postby frtps » Sun Aug 09, 2020 1:57 pm

In my endless attempts to improve the Australian scenery textures I have been developing base + overlay + hires textures with a 2kmx2km boundary, which seems to be the most common texture size in FG. During this process I noted some things when texturing large tracts of uniform bush.

  • The Perlin noise for the overlay texture and hires textures leaves large-enough empty areas to allow tiling to appear
  • The areas covered by the overlay texture are nowhere near half of the total
  • Large areas have no hires texture at all
  • As a result, the optimum real-world size for the texture is at least 4kmx4km

Have a look at these pictures, taken from 60000ft at 32S, 152.5E. Instead of the overlay and hires textures I have used the "unknown.png" texture for clarity (so 4 squares red-white-red-white is a single texture swatch), and both the bush and unknown textures are specified to be 2000x2000m. I have deliberately not tried to hide the boundaries of the bush texture.

The stock distribution, with a tweak in terrain-ALS-ultra.frag to provide closer to 50% coverage:
Code: Select all
mix_factor = smoothstep(0.45, 0.49, nSum);

instead of
Code: Select all
mix_factor = smoothstep(0.50, 0.54, nSum);


Image

With an even bigger version of the above tweak, but at a notionally double frequency obtained by changing
Code: Select all
nSum =  0.18 * (2.0 * noise_2000m + 2.0 * noise_1500m + noise_500m);

to
Code: Select all
nSum =  0.18 * (2.0 * noise_1000m + 2.0 * noise_750m + noise_250m);

Image

My feeling is that the top picture has too much tiling evident in the non-overlay area, and the second one is acceptable, just. So therefore either the "standard" texture size for materials that could stretch for long distances should be 4kmx4km, or the overlay noise should be doubled in frequency. I note that the Brazilian textures often use 4km as the texture border size, perhaps because of this, however, almost all other regions of the world stick with 2kmx2km. I think 2km x 2km is desirable for improved resolution at low altitudes, this means that the hires texture is 500mx500m which is pretty nice.

So my questions:
  • Would there be any issues with adjusting the Perlin noise in terrain-ALS-ultra.frag as I have done above to make 2x2km the optimum size?
  • Would there be any issues adjusting the mix factor as I have done above? Is it possible that other coordinates and/or GPUs will work in the opposite direction and overweight the overlay areas?
  • Is there any appetite for a better-behaved noise function (see below) at the expense of slightly more GPU time?

As a coda, here is the same area using a more modern Open Simplex noise with notionally the same noise frequency mix as the stock FG shader[*]. Clearly much more effective across the board in detiling and mixing in hires, and there are no signs of a grid-like pattern emerging (not that that is really an issue for this application). This could be added to noise.frag tomorrow as an alternative noise function, as it is licensed by the "Unlicense" - I just copied it wholesale from the internet - and I suspect any tiling issues would be largely a thing of the past.
Image

[*] I say the same noise frequency mix but that is assuming that Open Simplex noise "repeats" on an integer grid; however I don't understand the noise function well enough to know if this is the case.
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Terrain Perlin noise could have a shorter wavelength?

Postby Thorsten » Sun Aug 09, 2020 7:04 pm

I don't see any qualitative difference in any of your shots - the overlay pattern is different in each case - what is better depends...

... on how the landscape looks like in reality and on the content of the texture underneath. So basically if you write a custom shader for every region, you'll have the best result. On some, large overlays really look much better, on some you'd want it smaller - the possibilities are really endless.

So I guess you'll be happiest if you write your own terrain-australia.eff with associated shaders which does whatever you feel is needed (to a degree, I've done the same with the agriculture and the rock effects).
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Terrain Perlin noise could have a shorter wavelength?

Postby frtps » Mon Aug 10, 2020 9:36 am

Thorsten wrote in Sun Aug 09, 2020 7:04 pm:So I guess you'll be happiest if you write your own terrain-australia.eff with associated shaders which does whatever you feel is needed (to a degree, I've done the same with the agriculture and the rock effects).


The difference in our response to these images may be because I am not using the overlay effect to produce areas of notably different colour or brightness, rather I wish to simply change the detailed pattern and thereby remove tiling within each of the base/overlay areas.

As for making a whole lot of effects and Shaders specialised for Australia, I'd rather not unnecessarily duplicate code, that seems like the wrong way to approach software. I'm essentially talking about changing the values of 3 numbers, which could be easily achieved e.g. by adding another uniform (real-world texture size) rather than copying a whole set of shaders just because there is no universal setting that we all agree on.

In any case, your comment has made me realise that for the problem at hand I can just add the Open Simplex noise function as a separate routine in the Shader directory, and then specify it in "Australian" effects as a drop-in replacement for noise.frag. That will destroy tiling adequately.
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Terrain Perlin noise could have a shorter wavelength?

Postby bugman » Mon Aug 10, 2020 1:17 pm

Unlicensed is not ok. It has to be GPLv2 (with the or higher version clause) or public domain. Unlicensed content is strongly protected by copyright law.

Regards,
Edward
bugman
Moderator
 
Posts: 1808
Joined: Thu Mar 19, 2015 10:01 am
Version: next

Re: Terrain Perlin noise could have a shorter wavelength?

Postby frtps » Mon Aug 10, 2020 3:20 pm

bugman wrote in Mon Aug 10, 2020 1:17 pm:Unlicensed is not ok. It has to be GPLv2 (with the or higher version clause) or public domain. Unlicensed content is strongly protected by copyright law.


Always good to know that somebody is keeping an eye on the licensing.

The source for the open simplex noise is https://github.com/KdotJPG/OpenSimplex2

The license is https://github.com/KdotJPG/OpenSimplex2/blob/master/UNLICENSE which is an emphatic public domain dedication ("to the detriment of our heirs and successors" lol), thus my description as "licenced by the Unlicense", subtly different to "Unlicensed". So we're good.
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Terrain Perlin noise could have a shorter wavelength?

Postby Richard » Thu Aug 13, 2020 1:34 pm

I also find it hard to understand what is better from the screenshots with the unknown texture;

maybe you could post some actual screenshots with the correct texture to illustrate the improvements
Richard
 
Posts: 810
Joined: Sun Nov 02, 2014 11:17 pm
Version: Git
OS: Win10

Re: Terrain Perlin noise could have a shorter wavelength?

Postby Johan G » Thu Aug 13, 2020 11:29 pm

Some posts was split off to the new topic Photoreal vs. procedural scenery textures.
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Terrain Perlin noise could have a shorter wavelength?

Postby frtps » Fri Aug 14, 2020 5:39 am

Richard wrote in Thu Aug 13, 2020 1:34 pm:I also find it hard to understand what is better from the screenshots with the unknown texture;

maybe you could post some actual screenshots with the correct texture to illustrate the improvements


My point was technical: if there are large regions that would involve a repeat of the base/overlay texture multiple times with no interruption from the overlay/base texture or being broken up by the hires texture, then tiling is essentially inevitable. The "unknown" texture is included to provide a sense of scale: 4x4 squares is one tile. From the top picture I hoped it was clear that (in an otherwise featureless area) the base areas produced by the current default terrain shader will have quite a few neighbouring tiles with nothing to break them up, leading to a tiling effect. My contention is that the bottom picture shows a scenario where the noise is much more effective at breaking up these areas. Using actual textures would just obscure the point I was trying to make.

Anyway, I've since determined that using open simplex noise is too computationally expensive, and it is far more reasonable to do as Thorsten suggested and duplicate the current shader with my own parameters. That also gives more flexibility in how other parts of the shader are approached. I'll be submitting that to fgdata eventually, together with new Australian textures.
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Terrain Perlin noise could have a shorter wavelength?

Postby Thorsten » Fri Aug 14, 2020 6:04 am

My point was technical: if there are large regions that would involve a repeat of the base/overlay texture multiple times with no interruption from the overlay/base texture or being broken up by the hires texture, then tiling is essentially inevitable.


It really all depends on what's on the base texture.

Basically the eye is best deceived by two competing structures on the same scale. If you have a repeating pattern at 2 km size and you try to obscure it with a pattern at 200 m size, you'll find that this doesn't work, the eye can look 'through' the fine pattern the same way as you can look through dirt on the window or a fine grid - you actually need a large 2 km size noise to hide what is happening.

If there's prominent fine structure on the texture sheet and in essence you see that as the dominant pattern, you need a fine pattern to obscure it. There's no 'one size fits all'.

So Richard's question is justified - your point isn't evident at all with the dummy texture, because the checkerboard pattern dominates perception to the point that the eye doesn't key on anything else any more, and I would argue that this isn't a technical point at all, rather it has to do with how perceptions are processed in the brain.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Terrain Perlin noise could have a shorter wavelength?

Postby frtps » Fri Aug 14, 2020 10:00 am

Fair enough Thorsten, I'll stand somewhat corrected. The pointers on how to construct texture tiles are also appreciated. I haven't been able to come up with texture tiles that meet these requirements, so I might pursue using shorter noise wavelengths as a workaround.
frtps
 
Posts: 145
Joined: Sun Aug 05, 2018 10:58 am

Re: Terrain Perlin noise could have a shorter wavelength?

Postby www2 » Fri Aug 14, 2020 7:39 pm

@frtps this video [1] and blend[2] file shows some ideas for anti tiling.
[1] https://www.youtube.com/watch?v=-VgtSL5ZpYc
[2] https://www.dropbox.com/s/hn30svmf2s6at ... blend?dl=0
www2
 
Posts: 319
Joined: Thu Apr 16, 2009 2:58 pm
OS: Ubuntu


Return to Effects and shaders

Who is online

Users browsing this forum: No registered users and 4 guests