Author Topic: Tiled terrains  (Read 7747 times)

Offline bigben

  • Member
  • *
  • Posts: 2129
  • The Long Stranger rides again
    • Tinkering with Terragen
Tiled terrains
« on: August 13, 2007, 11:36:00 PM »
Had another go with tiling non-flattened terrains but this time I got it to work. I was actually pretty close the last time I tried. My main problem was that I over-complicated things te last time and possibly had one setting wrong in the blend shader.

I replace "Border blending" with a blending shader that does pretty much the same thing. The terrains are stacked in width order with the widest terrain on the bottom. Each terrain (except for the bottom one) has a matching blend shader made with the image map. The top terrain uses it's own blend shader, but each terrain below it uses the inverted blend shader from the terrain above it.

The image map is inserted as a 100m square centred at 0,0,0 and a transform shader is then used to produce the variations to match each terrain to save RAM.

5360-0

Off-centred terrains will require a bit more creative masking, but the approach is basically the same and a few simple colour subtract/add nodes should do the trick.  I'll have to refine my mask for some of my terrains that only have a very small overlap, but after that I should be able to re-release the wider terrains for my terrain sets.

Another issue that appeared in this demo is that the TERs may need to be adjusted to match each other just to fine tune things.  The accuracy of elevations for each terrain will have a tolerance of +/- 0.5 terrain spacing. While this may not have much impact between terrains in mountainous areas it can have substantial effects on flat areas. The main flat area of course is sea level. For example, my 50m resolution Ben Nevis terrain has a seal level of -25m, wile the 200m resolution terrain in this demo has a sea level of 100m.  I'll probably use TG0.9 to "burn" the required adjustments into the TER files rather than add extra adjustment nodes in TG2.  The difference in scale between terrains will also exacerbate any variations.

While this method of padding terrains is limited because of the way TG2 projects the terrain onto the planet, it should be possible to provide a wide enough terrain to allow for a camera position high enough that the rest of the planet could be covered using an spherically projected image map as a displacement function. The trick then is to remap the global bump map to the right orientation which is also relatively straight forward.

Demo images are the Swiss Alps, 3 terrains (50, 100, 200m resolution). Surfacing is just an image map from 3DEM so I could see where the sea was.
« Last Edit: September 05, 2007, 12:48:46 AM by bigben »

Offline bigben

  • Member
  • *
  • Posts: 2129
  • The Long Stranger rides again
    • Tinkering with Terragen
Re: Concentric terrains
« Reply #1 on: August 14, 2007, 11:35:38 PM »
I'll blab on to myself for the benefit of lurkers  ;)

One thing I forgot to do was to have a very close look at the border between the terrains. There was a minor glitch but this was partly due to the use of an image map and the way TG uses images. The steep drop pictured is only 3m and occurs at the outer edge of the image map on the terrain using the image map as an inverted shader.  This is *not* due to differences in terain heights at the border (since one of the terrains has been dropped to 0m at this point (the image actually had all of the other terrains disabled).

As the masking image was small, the steps for the shading were relatively coarse. I was relying largely on TG's antialiasing to smooth things out (which it did superbly) but that still left this small glitch of 3m (terrain resolution is 100m). To get around this I resorted to my usual "fix" of plugging the image map into a white surface shader's fractal breakup.

5393-0


There is still a very small bump, probably exacerbated by fractal detail.  I'll have to test this later tonight with some higher resolution terrains.

The second image is the other edge of the mask, with and without the adjoining terrain.

Offline rcallicotte

  • Member
  • *
  • Posts: 9542
Re: Concentric terrains
« Reply #2 on: August 15, 2007, 02:46:27 AM »
Looks interesting and perhaps over my brain power tonight.  I'll look at this tomorrow and rehash.   ;D
So this is Disney World.  Can we live here?

Offline bigben

  • Member
  • *
  • Posts: 2129
  • The Long Stranger rides again
    • Tinkering with Terragen
Re: Concentric terrains
« Reply #3 on: August 15, 2007, 04:33:00 AM »
i wouldn't rush... it's not working entirely yet  ;)

I'm trying it out on my Grand Canyon terrain set which is a little more complicated in that it has two terrains at the same resolution that overlap. The first clip I posted was fundamentally flawed for anything more than 2 terrains as it didn't provide blending in both directions across the border of subsequent intermediate terrains. It was more luck that the initial test looked good, which stopped me from thinking it through properly.

I went back towards my earlier version using subtraction nodes to generate a specific mask for both edges of each terrain. The results in the preview window looked great but it crashes as soon as you add lighting (VM explosion) :( 

I'll have a go at a functional mask rather than an image mask and see if that makes any difference. Setting up the function should be easy enough but what I'm wondering is whether it will be more efficient to generate a functional mask for each terrain or whether I can get away with the transform node method I used with the image map? 
« Last Edit: August 15, 2007, 11:51:58 PM by bigben »

Offline bigben

  • Member
  • *
  • Posts: 2129
  • The Long Stranger rides again
    • Tinkering with Terragen
Re: Concentric terrains
« Reply #4 on: August 15, 2007, 01:50:07 PM »
Produced a function version of the same mask which is a lot more useful as it's easier to customise.
5407-0

It saved 200Mb of RAM for the full TGD, but the VM still blows out as soon as lighting is turned on. Looks teasingly promising. If anyone can get a version of this to work it will have a lot of uses.

The attached clip file shows the expanded network of a single mask. The TGD uses my Grand Canyon terrains and has a "compacted" mask clip. The screengrab shows the border of 3 terrains.
« Last Edit: August 15, 2007, 11:52:42 PM by bigben »

Offline bigben

  • Member
  • *
  • Posts: 2129
  • The Long Stranger rides again
    • Tinkering with Terragen
Re: Concentric terrains
« Reply #5 on: August 16, 2007, 12:15:12 AM »
Just to verify that I wasn't going completely nuts, I ran a preview test of the masks on the widest terrain. That picked up a disconnected node in one of the masks which broke it, but fixing it made no difference to the original problem. So in summary:
  • The masks look correct
  • I can enable the atmosphere for the preview but not the lighting
  • In the image map version, the problem only appears when you combine two masks with a subtract node
  • In the function version, neither method (single inverted masks or combined masks) works with lighting


Offline bigben

  • Member
  • *
  • Posts: 2129
  • The Long Stranger rides again
    • Tinkering with Terragen
Re: Concentric terrains
« Reply #6 on: August 16, 2007, 11:50:34 PM »
Just finishing this off for anyone reading this... the final solution will be to wait for a new terrain mapping in TG2

http://forums.planetside.co.uk/index.php?topic=2045.msg20091#msg20091

Now works with v1.9.03.1     Read on...
« Last Edit: September 03, 2007, 11:17:51 PM by bigben »

Offline bigben

  • Member
  • *
  • Posts: 2129
  • The Long Stranger rides again
    • Tinkering with Terragen
Re: Concentric terrains
« Reply #7 on: September 03, 2007, 12:10:22 PM »
This is now working with the latest update   ;D ;D ;D

a) single function mask renders OK
b) adding masks together (add colour) doesn't blow out VM

More later.

Offline rcallicotte

  • Member
  • *
  • Posts: 9542
Re: Concentric terrains
« Reply #8 on: September 03, 2007, 12:41:25 PM »
Ben, I can't wait to see your results.  While I think I might understand, it will be easier to grasp what you're saying by seeing the end result.
So this is Disney World.  Can we live here?

Offline bigben

  • Member
  • *
  • Posts: 2129
  • The Long Stranger rides again
    • Tinkering with Terragen
Re: Concentric terrains
« Reply #9 on: September 03, 2007, 08:41:44 PM »
Prior to this, the only option that worked properly for merging multiple TERs was to use "Flatten first" in the displacement which produces a flat terrain.  If you have a terrain that's 400km wide the edges will be way up in the atmosphere, clouds will slip below the ground, you have to select "Use Y" for altitude and slope in shaders etc...

The other problem, with smaller terrains is that the perspective is not correct. Here are some test images. No real surfacing as such (1500m snow limit, canopy mask, lake mask around St Helens):

Flattened terrain, 10m res foreground, 40m res background terrains:
5778-0
You can see more terain behind t Rainier making it look closer than it really is.

Curved terrain (non-flattened):
5780-1
Curvature of Earth apparent with this this camera altitude/fov

Borders between multiple terrains (non-flattened), Vertical view showing multiple terrain masking. 10m terrains for St Helens and Adams (left and right) with a 40m res terrain providing a total area of 164x164km:
5782-2

Screengrab of the node network below using a compact version of the clip file above.



Offline rcallicotte

  • Member
  • *
  • Posts: 9542
Re: Concentric terrains
« Reply #10 on: September 03, 2007, 08:54:00 PM »
Very nice.  And hopefully I'll put some of this to good use on future work, especially when I find a better way to make Terrain files for TG2. 
« Last Edit: September 03, 2007, 08:57:03 PM by calico »
So this is Disney World.  Can we live here?

Offline bigben

  • Member
  • *
  • Posts: 2129
  • The Long Stranger rides again
    • Tinkering with Terragen
Re: Tiled terrains
« Reply #11 on: September 05, 2007, 01:01:19 AM »
Here are a couple of repeats of my test terrains. Basic surface tests only with minimal displacements so I can see errors more easily.

5817-0
Swiss Alps from northern Italy, 3 terrains (200, 400 and 800km wide) No water glitches :)

5819-1
Grand Canyon, single object and soft shadow test. I need to move the tree closer  to see the result of changes to my fill light setup incorporating soft shadows (and probably tweak the zenith lights a bit more)  3 terrains (40, 80 and 160km wide) Now I can try expanding this to the same sized terrains as the previous test :)

I still have to sort out the math for combining masks with overlapping edges...

 

anything