Embedding multiple masks in an image

Started by bigben, October 11, 2007, 07:28:08 PM

Previous topic - Next topic

bigben

The rock layer in the last image above has too great a coverage.  This is due to me setting too big a gap between two ranges of pixel values and a discrete pixel value for the rock layer. I originally did this to ensure that I could easily separate the masks from the tonal range, but this has caused additional problems.  In practise, I'm using two decimal places to specify black and white levels to extract masks from the full range of tones, and since TG does this properly (now that I've been setting the colour to linear) I should be using greyscale values to reflect this.... i.e. individual masks should have gaps in pixel values of no more than 2. In this case it is 10.  I've re-adjusted (extended) the limits on the masks adjacent to the rock mask to create a more discrete rock mask. This looks better in the preview with a dry grass distribution closer to what I expected.

Rendering an oblique view to show the range of accuracy over different distances, (hopefully getting too close to show the detail degrading too much)

bigben

OK. Here's the oblique view clearly showing the banding and edge effects resulting from this masking method. The foreground lake has used this to advantage, creating the appearance of a band of shallow water around the lake.  From a distance, the banding also creates the impression of sharpening the textures but up close it's going to require some extra blending with fractals to disguise the edges, although this will still have limited success.

Arandil

Y'know, I'm gonna have to name the scuff mark forming on my jaw, from it hitting the floor, 'littleben' ...

Oshyan

The banding is definitely an issue from up-close, but the results still look very good. So are you working up toward an animation here or what? From orbit to ground? ;D

- Oshyan

bigben

Quote from: Oshyan on October 21, 2007, 04:43:23 PM
The banding is definitely an issue from up-close, but the results still look very good. So are you working up toward an animation here or what? From orbit to ground? ;D

- Oshyan

That pretty much entered my head with the first version (I've been itching to do one for ages), although it doesn't necessarily have to be using this method.  These tests have largely been looking at an alternative approach to that vexing compromise between mask resolution and RAM usage. Mixing different methods would probably complement each other, but I'd want to output something before I start exploring different combinations/permutations.

I'm still exploring the limitations of this method and still have some room for optimising the mask image. For testing purposes I've only used 30 greyscale values for each tonal mask. As I only have a few masks I could reallocate the remaining pixel values to get 50 values per mask.... and I haven't attempted to "disguise" the borders yet. 

I also haven't found a limit for the size of mask I can use. While I can't make the mask image much bigger, there's nothing stoppping me from tiling the mask in the same way that I have tiled the terrain. The limiting factor there would be the size of image I can work on in Photoshop, as the processing involved wouldn't work with separate images.

If I can figure out using matching smoothed and unsmoothed images in the same TGD then this opens up a few more possibilities, although not necessarily for this scale of work.  I'm almost at the end  ;)

I have a couple of ideas for "cheating" on the animation.... zoom down to some water and then move across to a forested/grassy terrain.... or fly into a conveniently placed low cloud and have trees appear as the camera comes out the other side.

Oshyan

The whole "switch scenes when you go through a cloud" thing is a very common approach. I'd actually hoped, with TG2's planet-to-ground scale capabilities, that future such scenes could eliminate that cliche. ;)

- Oshyan

bigben

Then I guess I'll be trying it without the cloud. No guts, no glory  ;) 

I'll be using multiple versions of populations/ surface substitutes masked by distance shaders to provide additional LOD fading with distance anyway... I'm just not too sure at the moment how well it will work so I was thinking of a fallback position.  That will be another set of tests again, although I have previously mocked up the masks for the proof of concept and now understand the quality settings in populations better. 

But I'll run an animation without objects prior to that 'cos I won't be able to wait that long to see it (just after I render a mega composite).

Oshyan

Sounds good, I can't wait! Depending on where I'm at with my own animation I may be able to help with rendering too, although I know you have some good horsepower at your disposal. ;)

- Oshyan

bigben

There was one step I forgot to include, and it fits in with the animation and my terrain tiling method...  I can get a lot closer to a small part of the terrain by using a full resolution mask for that area.  The mask above is the same resolution as the terrain (90m). Here's a small section out of the image I'm going to create a high res mask of.  15m per pixel  At this resolution the terrain detail will be the limiting factor requiring extra detail to be added. The extra mask will cover 90x90km.

bigben

Creating the masks takes a long time, so in the meantime I'm doing some stress testing and minor tweaking in preparation for an animation. The first stress test of course is memory usage for the up close renders, so I added a preliminary version of the high resolution mask (just contains lakes and rivers) and added a 30km square of billboard trees. My home PC died several months back and I'm using a decapitated laptop with only 1Gb of RAM. I expected a crash but I managed to squeeze this out... only 530,000 trees, billboard image about 420 pixels square.

After making a minor adjustment to the mask image I tried again but this time it crashed so I must have been close to the memory limit. So before I go too much further it's time for some slashing.

The first place is the terrains. All of the terrain here are at 90m resolution, done intentionally for producing a very large render from orbit. Shifting to an animation has changed the requirements so I'll go back to a concentric set of terrains of decreasing resolution. This will cut the terrain sizes down from 300Mb to 96 - 120Mb... which is exactly why I worked on the technique. I'll probably have to do the same thing with the mask images, although it may be possible to leave them as they currently are. Removing the Blue Marble images will get me a bit more room although they weren't excessively big. This will hopefully give me enough memeory to whack in another million billboard trees and 1-2km of full poly trees.  (and of course, this whole topic is geared at minimising the memory usage of image masks)

I still haven't broken up the edges of the mask regions or tried any extra blending, but I have a couple of approaches to try for this. I also have a "cunning plan" to remove fractal detail from the rivers, although the impact on memory usage is yet to be determined.

The other thing to note is that using the paint brush in PSD to draw rivers is definitely not suitable for these low resolutions. Use a pencil and let TGs antialiasing do the smoothing. Having said that, it is possible to create even narrower rivers using the paint brush and multiple colour adjust nodes to repeatedly increase the contrast of the mask but that's not compatible with this multiple-mask image. The left hand river was wide enough to use the magic wand to select it (the gap was a glitch in the image), while the narrower river to the right was hand drawn with a 3pixel brush and has been reduced to a string of pools after smoothing. At this resolution a 1 pixel stroke around the water mask would produce a reasonable river bank of rocks.

bigben

Removed fractal detail from water without reloading terrains. Seethe post above, where you can see extra terrain detail in the water. The image in this post just has waves and the noise that coours in the elevation data. The banks are steep but this could be smoothed by using a separate colour adjust node to create a more appropriate blending mask.

* River/lake mask subtracted from terrain blending mask.
* Normal terrain blending mask applied to terrains without fratcal detail
* Terrain mask - water mask applied to terrains with fractal detail
* Both sets of terrains are then merged using the water mask as the merge function

This should be particularly helpful for manually drawn rivers on steeper slopes where fractal detail tends to be more pronounced.

Render times were longer, but that was to be expected.  Also note the round green patches which are antialiased square pixels from the low res mask image

bigben

Created a new terrain set and tracked down the displacement that was screwing up my water surface. It would seem that the most practical way of having smooth masked rivers is to remove fractal detail from the terrains and then add the detail manually as there is no practical way of masking the fractal detail (merging terrains is too costly from a performance point of view)

Some quick test renders to test memory usage. the first two contain just surfaces (blue marble texture and masked surfaces) and the third has a population of billboard trees added.  The billboard tree image is only 400x400 pixels, and the 500,000 odd trees didn't add much to the overall memory usage :) (about 1.4Gb (RAM+VM))

Running a full size render (1600x900) now to check, but so far it's looking like rationalising the terrains has got me another 600Mb of memory to play with.  There are now two mask images, one covering the entire south island, and the other covering the highest resolution terrain at 15m resolution.  I may split the number of masks in the last image into two separate images so that banding is not as much of a problem. 1: Water, sand and rock 2: Dry and green grass, trees. 

These are more likely to work nicely together (e.g. water and rocks will always be surrounded by a small amount of sand) and will let me do my normal displacements for lakes and rivers to give them a bit more of a noticeable bank.

Large render is almost 1/3 done and is looking quite promising from a memory usage perspective. Currently oscillating between 1.2 - 1.4Gb despite increased render size, detail and AA.

bigben

#42
OK, so by now you're probably thinking that this is still looking a bit too chunky to be real... and it is... but as I said, the high res masks take a lot of work to prepare. This next test is another memory test to see what happens when I add a second high res mask to the project (and removing the south island blue marble image)... The render consists of just the terrain (no fractal detail), two masked surfaces for water and dry grass and because the snow was at the bottom of the node network I left it in as well.  The grey bits are to be filled with sand, rock, green grass and forest.

The start of the render was promising, with memory usage still around the 1.4Gb mark, but this gradually crept up to 1.8Gb 1/3 of the way through at which point I went to bed. That's not going to leave me enough RAM for billboard and poly trees so I'll either have to try and make do with a single high res mask or split the tgd into two components at the end, one for the approach from orbit (minus objects), and one for camera angles within the central terrain (minus bathymetry image, outer terrain, island terrains etc....). I'm leaning towards the latter mainly because I want to have some overlap between some of the masked regions

The water surface in this contains no fractal breakup to keep it looking relatively blurred, although it needs an additional colour to shift the shallowest water closer towards a sand colour (easily done).  The dry grass layer consists of a surface layer using a boolean style BW mask (only black and white) for the fractal breakup to control the surface distribution, a power fractal for the light colour as the input and another power fractal for the dark tone using a tonal version of the distribution mask as a blending shader. If further disguising of the last mask is required at closer camera positions I'll multipy it by a power fractal with high/low values of 1, 0.7 respectively

This is getting back towards looking very cool again ;)

Running a render at the border between the high and low res masks  of the same view from the tgd used for the orbital render to demonstrate the difference in resolution.

bigben

Got impatient and stopped half way.  Here's a side by side comparison of the initial orbital render and the new  high res masks. Camera altitude is about 18km. There is some difference in the distribution as I have gone deliberately broader with the second mask to provide some overlap with green grass for extra variation. The tones in the mask are based on the original image, not the colourised version used for selecting the distribution, so this is greatly improved. Some gamma adjustment of the tonal mask is required to bring out the contrast a bit more, but the shading is there if you look closely.

bigben

Added an extra test surface and an updated 1 mask with more rivers. Camera height dropped to around 500m (too low :( )  Antialiasing killed off the 1 pixel wide rivers, so a 2 pixel pencil is definitely the minimum for making TG2 masks. To get finer detail after that you need to increase the resolution of the mask.

Using a wider brush than the detail you're tracing is a bit scary, but you have to rememebr that antialiasing will bring it back in line.

Still screwed up the subsurface masking order... will have to look at my ocean setup and copy it rather than build from scratch  ;).  The third colour is giving better variation but the colours need adjusting.

At least now I'm reaching the limits for the current data I have and can start some serious building of the final masks.