The Mystery of Blend- and LandWaterMasks

Introduction Blend- and LandWaterMask’s are essential for Photoreal Scenery Creation. This process is also the most time consuming and tedious part if done seriously and exactly. For this process sophisticated Painting programs are required like , Corel Painter, Corel Photo Paint Pro, Autodesk SketchBook Pro, GNU Image Manipulation Program (GIMP), IrfanView, Paint.NET or any Photo Painting Program which supports Layers and Alpha-channels can be used, depending on the taste and requirements of the user. Searching the Internet reveals that a lot of people have problems – including the Author of this document himself – with the above mentioned subject.

One important note: This is not a tutorial on how to create Blend- and LandWaterMasks because the Internet contains quiet a lot of tutorials in written form and in form, some are good, some are bullshit. FSDeveloper.com provides an exhausting competent and comprehensive lot of information regarding this subject. The Author of this document gained a lot of this information from this source!

Another requirement is a good understanding of the Photo Paint Program you are using. Also a thorough knowledge of the Flight Simulator Terrain SDK is required or is even essential for the process. You need also a basic understanding of technical terms used in the Computer Graphic Environment. Technical Background and Terms As usual, there is a bit of technical explanations and technical term's required. I will keep this very very short, because the Internet, i.e. Wikipedia provides exhausting information regarding this subjects, I will provide the relevant Hyperlinks so you can navigate to the pertinent Web-pages.

BMP file format The BMP file format, also known as image file or device independent bitmap (DIB) file format or simply a bitmap, is a image file format used to store bitmap digital images, independently of the display device (such as a graphics adapter), especially on and OS/2 operating systems.

The BMP file format is capable of storing two-dimensional digital images both monochrome and color, in various color depths, and optionally with , alpha channels, and color profiles. The (WMF) specification covers the BMP file format. Among others wingdi.h defines BMP constants and structures. Source: https://en.wikipedia.org/wiki/BMP_file_format

TIFF Tagged Image File Format Tagged Image File Format, abbreviated TIFF or TIF, is a computer file format for storing raster graphics images, popular among graphic artists, the publishing industry,

Author: Conrad F. Staeheli 1 1st Ed April 2018 The Mystery of Blend- and LandWaterMasks and photographers. TIFF is widely supported by scanning, faxing, word processing, optical character recognition, image manipulation, desktop publishing, and page-layout applications. The format was created by Aldus Corporation for use in desktop publishing. It published the latest version 6.0 in 1992, subsequently updated with an Adobe Systems copyright after the latter acquired Aldus in 1994. Several Aldus or Adobe technical notes have been published with minor extensions to the format, and several specifications have been based on TIFF 6.0, including TIFF/EP (ISO 12234-2), TIFF/IT (ISO 12639,9),TIFF-F (RFC 2306) and TIFF-FX (RFC 3949). Source: https://en.wikipedia.org/wiki/TIFF

GeoTIFF file format GeoTIFF is a public domain metadata standard which allows georeferencing information to be embedded within a TIFF file. The potential additional information includes map projection, coordinate systems, ellipsoids, datums, and everything else necessary to establish the exact spatial reference for the file. The GeoTIFF format is fully compliant with TIFF 6.0, so software incapable of reading and interpreting the specialized metadata will still be able to open a GeoTIFF format file.

An alternative to the "inlined" TIFF geospatial metadata is the *.tfw World File sidecar file format which may sit in the same folder as the regular TIFF file to provide a subset of the functionality of the standard GeoTIFF described here. Source: https://en.wikipedia.org/wiki/GeoTIFF

Truevision TGA file format Truevision TGA, often referred to as TARGA, is a raster graphics file format created by Truevision Inc. (now part of Avid Technology). It was the native format of TARGA and VISTA boards, which were the first graphic cards for IBM-compatible PCs to support Highcolor/truecolor display. This family of graphic cards was intended for professional computer image synthesis and video editing with PCs; for this reason, usual resolutions of TGA image files match those of the NTSC and PAL video formats.

TARGA is an acronym for Truevision Advanced Raster Graphics Adapter; TGA is an initialism for Truevision Graphics Adapter.

TGA files commonly have the extension ".tga" on PC DOS/Windows systems and Mac OS X (older systems use the "TPIC" type code). The format can store image data with 8, 15, 16, 24, or 32 bits of precision per – the maximum 24 bits of RGB and an extra 8-bit alpha . Color data can be color-mapped, or in direct color or truecolor format. Image data may be stored raw, or optionally, a lossless RLE compression similar to PackBits can be employed. This type of compression performs poorly for typical photographic images, but works acceptably well for simpler images, such as icons, cartoons and line drawings. Source: https://en.wikipedia.org/wiki/Truevision_TGA

RGB color space A RGB color space is any additive color space based on the RGB color model. A particular RGB color space is defined by the three chromaticities of the red, green,

Author: Conrad F. Staeheli 2 1st Ed April 2018 The Mystery of Blend- and LandWaterMasks and blue additive primaries, and can produce any chromaticity that is the triangle defined by those primary colors. The complete specification of an RGB color space also requires a white point chromaticity and a curve. As of 2007, sRGB is by far the most commonly used RGB color space. RGB is an abbreviation for red–green–blue. Source: https://en.wikipedia.org/wiki/RGB_color_space

CMYK color model

The CMYK color model (process color, four color) is a subtractive color model, used in color printing, and is also used to describe the printing process itself. CMYK refers to the four inks used in some color printing: cyan, magenta, yellow, and key (black).

The reason for black ink being referred to as key is because in four-color printing, cyan, magenta, and yellow printing plates are carefully keyed, or aligned, with the key of the black key plate. Some sources suggest that the "K" in CMYK comes from the last letter in "black" and was chosen because B already means blue.However, some people disagree with this because there is no blue in the primary CMYK colors; it is made with cyan and magenta. Some sources claim this explanation, although useful as a mnemonic, is incorrect, that K comes only from "Key" because black is often used as outline and printed first. It is more common in modern printing for the black to be printed last in order to yield deeper, cleaner shadows and crisper blacks than the imperfect black created by the CMY combination when those colors are printed over the black. The CMYK model works by partially or entirely masking colors on a lighter, usually white, background. The ink reduces the light that would otherwise be reflected. Such a model is called subtractive because inks "subtract" the colors red, green and blue from white light. White light minus red leaves cyan, white light minus green leaves magenta, and white light minus blue leaves yellow.

In additive color models, such as RGB, white is the "additive" combination of all primary colored lights, while black is the absence of light. In the CMYK model, it is the opposite: white is the natural color of the paper or other background, while black results from a full combination of colored inks. To save cost on ink, and to produce deeper black tones, unsaturated and dark colors are produced by using black ink instead of the combination of cyan, magenta, and yellow. Source: https://en.wikipedia.org/wiki/CMYK_color_model

HSL and HSV color space HSL (Hue, Saturation, Lightness) and HSV (Hue, Saturation, Value) are two alternative representations of the RGB color model, designed in the 1970s by researchers to more closely align with the way human vision perceives color-making attributes. In these models, colors of each hue are arranged in a radial slice, around a central axis of neutral colors which ranges from black at the bottom to white at the top. The HSV representation models the way paints of different colors mix together, with the saturation dimension resembling various shades of brightly colored paint, and the value dimension resembling the mixture of those paints with varying amounts of black or white paint. The HSL model attempts to resemble more perceptual color models such as NCS or Munsell, placing fully saturated colors

Author: Conrad F. Staeheli 3 1st Ed April 2018 The Mystery of Blend- and LandWaterMasks around a circle at a lightness value of 1/2, where a lightness value of 0 or 1 is fully black or white, respectively. Source: https://en.wikipedia.org/wiki/HSL_and_HSV

Alpha-compositing In computer graphics, alpha is the process of combining an image with a background to create the appearance of partial or full . It is often useful to render image elements in separate passes, and then combine the resulting multiple 2D images into a single, final image called the composite. For example, compositing is used extensively when combining computer-rendered image elements with live footage.

In order to combine these image elements correctly, it is necessary to keep an associated for each element. This matte contains the coverage information—the shape of the geometry being drawn—making it possible to distinguish between parts of the image where the geometry was actually drawn and other parts of the image that are empty. Source: https://en.wikipedia.org/wiki/Alpha_compositing

Alpha-channel An 8-bit layer in a graphics file format that is used for expressing translucency. The additional eight bits per pixel serve as a mask and represent 256 translucency levels from entirely clear (0) to opaque (255), with levels in between representing the degree of haziness. See translucency, RGBA and HSLA.

Not All Formats Have an Alpha Channel The TIFF, PNG and WebP graphics formats support the 8-bit alpha channel, whereas have none. GIF supports a 1-bit channel, which means that an area marked as alpha can be either transparent or not but no levels in between.

Layered graphics formats such as Photoshop's native PSD format can have many alpha channels while the image is being composed. When converted to another graphics format, the alpha channels are reduced to one or none depending on the destination format. See alpha blending.

Alpha-blending In computer graphics, the combining of the alpha channel with other layers in an image in order to show translucency. The alpha channel is an additional eight bits used with each pixel in a 32-bit graphics system that can represent 256 levels of translucency. Black and white represent opaque and fully transparent, while various gray levels represent levels of translucency.

More than one layer in a multilayered image may contain a translucent component, thus multiple levels of blending may be required. If the graphics accelerator performs the blending in its own hardware, the results are displayed considerably faster.

Author: Conrad F. Staeheli 4 1st Ed April 2018 The Mystery of Blend- and LandWaterMasks Water Mask A water mask adds water qualities to the image such as floating, splashing and bobbing. We have to show the Flight Simulator where the water is. If we don't add a watermask, the flight Simulator will take the entire photoreal area as land. So we have to put a water layer over the photoreal image layer.

Blend Mask A blend mask blends in the underlying landclass, water, roads. Normally you don't want the entire background image to show up in the Flight Simulator, you usually only want to show parts of it. So you need to carve out the parts you want to show or cover up those you don't want to be seen. You do that with a blendmask. It's similar to a watermask where everything painted in black will be water in the Flight Simulator. But when doing a blendmask, everything that is painted in black won't show up at all in the Flight Simulator. The good thing about the blendmask technology is, that it does not have to be in either black or white, it can have grey scales which means you can soften the edges of your image and let it blend in with the default Flight Simulator scenery or ocean water background.

The Terrain SDK gives a good example with “multichannel_multisource.inf”;

; Resample INFormation file ; Variations test with land/water and blend masks pulled from multiple files.

[Source] Type = MultiSource NumberOfSources = 4

[Source1] Type = BMP Layer = Imagery SourceDir = "SourceData" SourceFile = "variation1.bmp" ULXMAP = -122.308 ULYMAP = 0 XDIM = 4.27484E-05 YDIM = 4.27484E-05 Variation = Day

; pull the blend mask from Source3, band 0 Channel_BlendMask = 3.0

// pull the land/water mask from Source4, band 0 Channel_LandWaterMask = 4.0

[Source2] Type = BMP Layer = Imagery SourceDir = "SourceData" SourceFile = "variation2.bmp" ULXMAP = -122.308 ULYMap = 0 XDIM = 4.27484E-05

Author: Conrad F. Staeheli 5 1st Ed April 2018 The Mystery of Blend- and LandWaterMasks

YDIM = 4.27484E-05 Variation = Night Channel_BlendMask = 3.0 Channel_LandWaterMask = 4.0

[Source3] Type = TIFF Layer = None SourceDir = "SourceData" SourceFile = "BlendMask.tif" ULXMAP = -122.308 ULYMap = 0 XDIM = 4.27484E-05 YDIM = 4.27484E-05 SamplingMethod=Gaussian

[Source4] Type = TIFF Layer = None SourceDir = "SourceData" SourceFile = "LandWaterMask.tif" ULXMAP = -122.308 ULYMap = 0 XDIM = 4.27484E-05 YDIM = 4.27484E-05 SamplingMethod=Gaussian

[Destination] DestDir = "Output" DestBaseFileName = "MultiChannel_MultiSource" UseSourceDimensions = 1

Source3 is the blendmask that just blends the edges of the photo. Black = totally transparent. White is opaque. Greys are semi-transparent. As you could tell, the tif file is a 8-bit greyscale. You can blend any area... not just the edges. You might want to grade a blend from shoreline outward, to blend the ocean to the default waterclass. The paint programs have a feather tool that might do this. So make a copy of your photo, change it to 8-bit ( 256 color ) and greyscale, and mask away.

Source4 is the watermask. This gives water characteristics to any black area. The mask is an 8-bit tif using only black and white. You would want to make a watermask of all the water in your photo. Again, make an 8-bit, greyscale of your photo, make all water black, and fill the rest of the photo with white, to designate land.

( Source2 is a night variation of Source1 )

In this example, all the sources are the same size and location.

Source: Richard Ludowise (aka: “rhumbaflappy”) https://www.fsdeveloper.com/forum/threads/bland-mask-water-mask-how-to.188 94/

Author: Conrad F. Staeheli 6 1st Ed April 2018 The Mystery of Blend- and LandWaterMasks Methods of defining Blend- LandWaterMask’s The most common known method is:

BLEND MASK 1. Open BMP image 2. Make a new layer, fill it with white 3. Make another blank layer, choose hard or semi-hard brush and start coloring in black the areas I don't want to see in FSX. 4. Make sure that 3 layers (background, white, and blend mask) are visible (discard hidden layers, if water mask layer is also present in the PSD file) and flatten the image. 5. Save as file *_B.TIF with default options (no compression, etc.) untouched.

WATER MASK 1. Open BMP image 2. Make a new layer, fill it with white 3. Make another blank layer, choose hard brush and start coloring in black the areas I want to see water in FSX. 4. Make sure that 3 layers (background, white, and water mask) are visible (discard hidden layers, if blend mask layer is also present in the PSD file) and flatten the image. 5. Save as file *_W.TIF with default options (no compression, etc.) untouched.

In fact, there are several ways of defining a Blend- and Watermask:

A. They can be part of the satellite image, in this case for the Watermask an Alpha-channel is defined and for the Blendmask another Alpha-channel is defined. So the Blend- and Watermask is part of the image. This works only for TIFF-format images. The BMP-format before Version 4 (Windows 95) does not support Alpha-channels. Alpha-channels and color correction were introduced with Version 4 (Windows 95) and Version 5 (Windows 98).

B. The Blend- and Watermask can also be defined as separate images in BMP-format, or better, in the TIFF-format.

C. A Blend- and Watermask can also be defined combined in a single image, a method which has been devised by Dottore Maurizio Giorgi from Florence, Italy. Certain Areas can be defined by special color masking.

On the following pages we will tackle each of the different methods a bit more in detail.

Author: Conrad F. Staeheli 7 1st Ed April 2018 The Mystery of Blend- and LandWaterMasks A. Satellite image integrated Blend- and Watermask For just a single satellite image, integrated Blend- and Watermasks can make quite sense. This way you have all combined in a single image. What you need is for each type of mask a separate Alpha-channel:

One important reminder: If you work with an georeferenced TIFF-file (GeoTIFF) than you will lose any georeference data (geotags), therefore you need to save the georeference data with a tool like the very handy GeoTIFF Tools GUI, from Kevin Chen, which you can download from here:

http://www.mediafire.com/file/hqncytzz0zt/libgeoGUI.zip

The tool works like this: First, the geotags are saved out to a .gtf file, then you can make the changes to the TIFF, including building water mask and blend mask, and then use GeoTIFF Tools to reinsert the geotags into the edited GeoTIFF again.

Author: Conrad F. Staeheli 8 1st Ed April 2018 The Mystery of Blend- and LandWaterMasks The GeoTIFF GUI

This program will allow you to save and restore georeferenced data (geotags) of an GeoTIFF-file.

The following pictures depict the Blend- and LandWaterMask as defined in the satellite image:

Author: Conrad F. Staeheli 9 1st Ed April 2018 The Mystery of Blend- and LandWaterMasks LandWaterMask:

Blendmask:

The “resample-tool “resample.exe” ” – which is part of the Environment Kit, Terrain SDK – assumes per default the watermask on Alpha-channel 3 and the Blendmask on Alpha-channel 4 (See Environment Kit, Terrain SDK “The Resample Tool”). If your image complies to this assumption, no Channel_BlendMask and Channel_LandWaterMask definition is required. Following is an example of such a definition (Photo03_TIF_INT_BMWM.INF):

Author: Conrad F. Staeheli 10 1st Ed April 2018 The Mystery of Blend- and LandWaterMasks

[Source] Type = TIFF Layer = Imagery SourceDir = "." SourceFile = "L16X5236X5247Y41990Y41998.tif" NullValue = SamplingMethod = Gaussian ulyMap = 54.1527843 ulxMap = -165.6188965 xDim = 1.07288411458351E-05 yDim = 6.28420138888851E-06

[Destination] DestDir = "." DestBaseFileName = "7AK_Photo01" DestFileType = BGL LOD = Auto UseSourceDimensions = 1 CompressionQuality = 85

Should your image not comply to this assumption, so you must define the correct sequence or order by the Channel_BlendMask and Channel_LandWaterMask definition. Following is an example of such a case (Photo02_TIF_INT_BMWM.INF):

[Source] Type = TIFF Layer = Imagery SourceDir = "." SourceFile = "L16X5236X5247Y41990Y41998.tif" Channel_LandWaterMask = 1.3 ; internal LandWaterMask on Alpha Channel 3 (per Default, see Environment SDK) Channel_BlendMask = 1.4 ; internal BlendMask on Alpha Channel 4 (per Default, see Environment SDK) NullValue = SamplingMethod = Gaussian ulyMap = 54.1527843 ulxMap = -165.6188965 xDim = 1.07288411458351E-05 yDim = 6.28420138888851E-06

[Destination] DestDir = "." DestBaseFileName = "7AK_Photo01" DestFileType = BGL LOD = Auto UseSourceDimensions = 1 CompressionQuality = 85

B. Separate Blend- and Watermask If you have several satellite images, lets say you have several images to reflect seasonal variation, than separate Blend- and Watermasks are the solution. In that case you will provide a Blend- and a Watermask as separate images.

Author: Conrad F. Staeheli 11 1st Ed April 2018 The Mystery of Blend- and LandWaterMasks LandWaterMask:

BlendMask:

In order to have the resample-tool “resample.exe” – which is part of the Environment Kit, Terrain SDK – doing the right job, care has to be taken to provide the correct definitions for “resample.exe”. Following are the definitions, which have been used for this example (Photo04_BMP_EXT_BMWM.INF):

Author: Conrad F. Staeheli 12 1st Ed April 2018 The Mystery of Blend- and LandWaterMasks

[Source] Type = MultiSource NumberOfSources = 3

[Source1] Type = BMP Layer = Imagery SourceDir = "." SourceFile = "L16X5236X5247Y41990Y41998.bmp" Channel_BlendMask = 2.0 ; separate BlendMask from Source2, Channel 0 (Red channel) Channel_LandWaterMask = 3.0 ; separate LandWaterMask from Source3, Channel 0 (Red channel) NullValue = SamplingMethod = Gaussian ulyMap = 54.1527843 ulxMap = -165.6188965 xDim = 1.07288411458351E-05 yDim = 6.28420138888851E-06

[Source2] Type = TIFF Layer = None SourceDir = "." SourceFile = "L16X5236X5247Y41990Y41998_B.TIF" SamplingMethod = Gaussian ulyMap = 54.1527843 ulxMap = -165.6188965 xDim = 1.07288411458351E-05 yDim = 6.28420138888851E-06

[Source3] Type = TIFF Layer = None SourceDir = "." SourceFile = "L16X5236X5247Y41990Y41998_W.TIF" SamplingMethod = Gaussian ulyMap = 54.1527843 ulxMap = -165.6188965 xDim = 1.07288411458351E-05 yDim = 6.28420138888851E-06

[Destination] DestDir = "." DestBaseFileName = "7AK_Photo01" DestFileType = BGL LOD = Auto UseSourceDimensions = 1 CompressionQuality = 85

C. Combined Blend- and Watermask A Blend- and Watermask can also be defined combined in a single image. Certain Areas can be defined by special color masking, here is a depiction of the color composition as devised by Dottore Maurizio Giorgi:

Author: Conrad F. Staeheli 13 1st Ed April 2018 The Mystery of Blend- and LandWaterMasks

The following sentence is from a post in some blog from Maurizio:

"When converting the water mask to gray scale you loose a lot of functions.... depending on the color you use to draw the polygons, you have a different effect. For instance with a blue you hole the mask and FSX textures will be displayed. Using cyan you obtain a blend with FSX textures and your photoreal. For the water, using a red, you maintain the photoreal under.... very useful to obtain tropical sea or sand sea. Using a green, the classic FSX sea will be displayed. And, with the same mask, you can obtain also the night lights, coloring with a specific magenta, all in the same mask.

Try these suggestions and you will remain surprised how this system is powerful...."

"Basically, if you want to maintain the photoreal water, placing the water above the photoreal texture, you have to paint your watermask in red. Using the green, instead, FSX standard water will come out. Using the yellow, just near the coast, this creates water above the photoreal, preventing that some FSX texture comes out along the coast. To show you the system, I put an example of water mask."

"This system is more powerful than using a monochromatic mask, because each color has a different feature. The blue, drawn in the land area, creates an hole in the mask, and in this zone FSX textures will be shown. You could use it where there is vegetation, for instance, and you will have the autogen without making it. The cyan is used instead to make a transition. In the cyan area, FSX textures will be fused with the photoreal, smoothly. This is the technique I use. The photoreal tiles have to be corrected in their colors, otherwise the scenery won't look good. Use the contrast mask if the tile seems a little unfocused, to improve the image. The chromatic tendency of the pic have to be also corrected. Often, the satellite imagery tends a lot to blue or to red, due to a wrong white balance. Try, changing the different colors

Author: Conrad F. Staeheli 14 1st Ed April 2018 The Mystery of Blend- and LandWaterMasks [with an image open in a graphics editor ?] to correct this tendency. You can make reference to an area that you know it's white. With the counter-drop [eye dropper color tool ?] click on it and see what is effectively this color. If it's not really white, the color balance is wrong."

Following is an example of such a combined Blend- and Watermask:

In order to have the resample-tool “resample.exe” – which is part of the Environment Kit, Terrain SDK – doing the right job, care has to be taken to provide the correct definitions for “resample.exe”. Following are the definitions, which have been used for this example (Photo05_BMP_EXT_BMWM_DMG.INF):

[Source] Type = MultiSource NumberOfSources = 2

[Source1] Type = BMP Layer = Imagery SourceDir = "." SourceFile = "L16X5236X5247Y41990Y41998.bmp" Channel_BlendMask = 2.0 ;red channel, (note:green channel is the grey-info) Channel_LandWaterMask = 2.2 ;blue channel NullValue = SamplingMethod = Gaussian ulyMap = 54.1527843 ulxMap = -165.6188965 xDim = 1.07288411458351E-05 yDim = 6.28420138888851E-06

Author: Conrad F. Staeheli 15 1st Ed April 2018 The Mystery of Blend- and LandWaterMasks

[Source2] Type = TIFF Layer = None SourceDir = "." SourceFile = "L16X5236X5247Y41990Y41998_DMG_W.TIF" SamplingMethod = Gaussian ulyMap = 54.1527843 ulxMap = -165.6188965 xDim = 1.07288411458351E-05 yDim = 6.28420138888851E-06

[Destination] DestDir = "." DestBaseFileName = "7AK_Photo01" DestFileType = BGL LOD = Auto UseSourceDimensions = 1 CompressionQuality = 85

Epilog I hope, that this document will help to demystify the secrets of creating Blend- and LandWaterMasks. The process of disclosing the secrets is not yet finished, so I will continue to further enhance this document. It is good for you to check regularly for the advent of a newer version.

Freienbach April 13 2018

Conrad F. Staeheli Senior System Engineer (retired)

Author: Conrad F. Staeheli 16 1st Ed April 2018