L3DT users' community
Large 3D terrain generator

Improving appearance of splat terrain

Any and all chit-chat regarding L3DT.

Improving appearance of splat terrain

Postby schamberlin » Tue Oct 21, 2014 5:53 pm

Are there any tricks or best practices for getting splatted terrain to look nice? I have it working in my homebrew graphics engine, using alpha maps exported from L3DT. It works, but the areas of different terrain types have blocky, ugly-looking borders:
screenshot-1.jpg

screenshot-4.jpg


Compare this to the splatting example from the L3DT wiki:
Image

or the top Google Image Search result for "terrain splatting":
terrain-splatting.png


Those transitions between terrain types are much smoother than mine. Is my problem simply that the alpha maps exported from L3DT are too low-resolution? I'm using "alpha express" export, which generates alpha maps the same resolution as the attribute map, which is all the detail that exists. So the alpha map resolution is the same as the heightmap resolution. I'm a little dubious that that's the problem, since I've looked at literally hundreds of splat terrain example images from other sources, and none seem to show this problem I'm getting.

Maybe the problem is the hard edges in the alpha maps? Here's a magnified version of part of mine:
splat-zoom2.png
splat-zoom2.png (5.09 KiB) Viewed 10775 times


It may be hard to see here, but every pixel is either solid red, green, blue, or black. There's no smoothing or blurring, no alpha map pixels that are blue-green, etc. Should there be?

Is it just my choice of textures - too much contrast between white snow and everything else? It's true the rock-to-grass transition in my screenshot isn't as jarring as snow-to-grass. But that Google Image Search result has a high-contrast transition between sand and grass, and still looks quite smooth.

Is my splat fragment shader too naive? It just sums the terrain textures using the alpha map values. Maybe there's something fancier I could here, like a noise texture or procedural noise to fuzz the edges somehow?

Code: Select all
vec4 alphaMap = texture2D(alphaMapTextureSampler, texCoord1);
vec4 outColor = alphaMap * texture2D(type1TextureSampler, texCoord0);
outColor += alphaMap * texture2D(type2TextureSampler, texCoord0);
outColor += alphaMap * texture2D(type3TextureSampler, texCoord0);
outColor += alphaMap * texture2D(type4TextureSampler, texCoord0);


If you've implemented terrain splatting before, how did you approach it to avoid the blockiness I'm seeing?
schamberlin
New member
 
Posts: 4
Joined: Mon Oct 20, 2014 5:25 pm

Re: Improving appearance of splat terrain

Postby schamberlin » Wed Oct 22, 2014 6:05 am

I did some more investigation into this, and it's mainly an issue with the hard edges in the alpha map. I tried a few different methods to fix it. The differences aren't easily visible in the thumbnails, so click each image to see the full-sized version.

1. Original 512x512 alpha map, as exported using Alpha Express:
screenshot-2.jpg


2. Same alpha map, with changes to the fragment shader to use a noise texture that makes the terrain transitions grainer. This dropped my frame rate by about 20% vs case #1. Looks better, but the blockiness is still visible.
screenshot-3.jpg


3. 1024 x 1024 alpha map exported using Generate Maps with "Make high-res alpha maps" checked and 4x anti-alias cutoff. No frame rate difference vs case #1.
[too many attachments]

4. 1024 x 1024 alpha map exported using Generate Maps with "Make high-res alpha maps" checked and anti-alias disabled, then blurred 4x4 Gaussian blur in Gimp. No frame rate difference vs case #1. The difference vs #3 is subtle, but I think this method produces better results, and it's a lot faster to create the alpha map. But both methods #3 and #4 make the terrain boundaries too blurry for my taste - snow looks like a puffy cloud.
screenshot-5.jpg


5. 512 x 512 alpha map from case #1, resized to 1024 x 1024 in Gimp, then with the "pick" noise filter applied. No frame rate difference vs case #1. I think this is the best of all. Terrain transitions don't look blocky, but don't look like puffy clouds either.
screenshot-1.jpg
schamberlin
New member
 
Posts: 4
Joined: Mon Oct 20, 2014 5:25 pm

Re: Improving appearance of splat terrain

Postby Aaron » Wed Oct 22, 2014 9:34 am

Hi Schamberlin,

I'd recommend the 'Operations->Alpha map->Generate maps' menu option. The reason being that with this method, unlike with GIMP, you can readily control the anti-aliasing of each land type separately using the 'blend radius' setting in the land type editor (appearance tab pane). This allows you to, for example, have smooth blending from, say, grass to sand, but sharp transitions from grass to rock.

Consider this alpha map, which was generated with a ridiculously high AA cutoff of 16:

alpha_aa.png


In the screenshot above you can see that the grass land type (alpha channel) has a sharp transition with the rock land type (green channel), but a smooth transition with the coastal grass land type (blue channel). So, if you find, for instance, that the snow is too cloudy, reduce that land type's blend radius.

If your texture memory budget allows, you may also like to try generating a high-resolution alpha map, say a 1024x1024 res alpha map for a 512x512 heightmap. This works best (and faster) if you've also generated a high-res attributes map too. This way you don't have to add the high-frequency blending noise in the shader, but I guess it depends on the relative performance penalties of larger alpha maps versus more shader processing. Your mileage may vary. Anyway, here is the same example above, but with 2x resolution, and only 2x anti-aliasing. If one looks closely at the two images, you can see that the sharp transitions (red->green, which were sand->cliffs) are more noisy and less blocky in the high-res version.

alpha_aa_2x.png


Obviously you get better results still with higher resolutions, at the cost of larger alpha maps clogging the GPU.

Cheerio,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia


Return to General discussion

Who is online

Users browsing this forum: No registered users and 10 guests

cron