Howto:Create textures from photos

From FlightGear wiki
Jump to navigation Jump to search

Good textures are very important in 3-D modeling. They can make even low-poly models look quite convincing. You can either generate them from scratch, or use real-world photos. This article explains the latter, and focuses on trees and building facades. First it will provide some tips on how to take photos ready for texture extraction. Then it will explain the texture extraction in detail. The instructions use the tools and menu structure of GIMP, but other programs should allow for a similar workflow.

Finding GPL compatible photos online

First you need a photo to extract textures from. You will probably find photos of almost everything online. However, if you want to use them, make sure their license gives you the right to do so. If you plan to submit your textured model to FlightGear's scenery model data base, all parts of it must be compatible with the GPLv2.

GPLv2 compatible licenses:

  • CC0
  • Creative Commons: CC-BY-SA-4.0
  • Public domain (NASA or US government are sources of suitable licenses)

Licenses which are not compatible:

  • Google Earth / Google Streetview (No matter how convenient it is, Google's license is restrictive)
  • Creative Commons versions 1.0, 2.0, 3.0
  • GNU Free Document License (GFDL)

Getting a photo released under a compatible license

If you find a particularly good photo for a texture you can always simply email the author and ask for it to be released under a GPLv2 compatible license (e.g. CC-BY-SA 4.0). Often, an earlier version of the creative commons license will have been used - because it was the latest version available in the past. Most people will respond positively to an inquiry as Flightgear is a volunteer based community project.

It's possible to save a proof of an image's specific license page, or permission granted publicly by the author, using archive.org or archive.is.

The "Credits" file in the $FGDATA/Textures directory can be used to credit the photographer if that is required.

Sources of GPLv2 compatible photos

Wikimedia commons

Wikimedia commons has a huge repository of photos. Many of them were released under early Creative Commons licenses.

Tips: Use advanced search. Under "one of these words" put licenses like: "CC-BY-SA-4.0" , "CC0". Put the search query under "these words". Set "File type" to "image". Remove unwanted "search in" areas. You can add the country name to your query if it helps - photos will usually mention the country somewhere in their page or category names. Look at the file pages of relevant results: at the bottom you can find names of categories with lots of suitable photos for your purpose. 500 results at a time can be shown by clicking at the bottom of the results page.

Categories:

List

Flickr also contains many suitable photos; search for those that allow both modification and commercial use. The "Credits" file in the $FGDATA/Textures directory can be used tocredit the photographer if that is required.

Open Aerial Map has some high resolution aerial photos that could be useful for terrain texturing. There's limited coverage as of September 2020.

Earth Explorer has Aerial photography that could be useful for terrain texturing. The data is from USGS and does not have any restrictions or copyright (public domain) see their FAQ.

Sites:

Taking your own photos

As good quality GPLv2 compatible photos suitable for textures are hard to come by, one way is for FG-ers to take their own photos. This also sources photos of vegetation, terrain, etc. from all around the world.

Flightgear's can do a lot with a few textures. Contributing photos suitable for terrain or vegetation textures is one of the areas that can make a huge visual difference per contribution, currently.

General approach

A good photo from an artistic point of view is often quite unsuited for texture extraction. The best ones for this job are the pale, boring ones: shot orthogonal, in overcast conditions.

If you get to take the photo yourself, you can save a lot of work if you:

  • pick a somewhat cloudy day to avoid strong light/shadow contrast. It's easy to adjust saturation, constrast, and brightness later on, but it's very hard to equalize unwanted light and shadows. Set the white balance accordingly.
  • have the sun directly in your back if there is considerable direct sunlight

Trees and bushes

Flightgear's vegetation system can handle multiple layers of trees and bushes. It can also handle change of leaf colour from summer greens to autumn colours.

Existing tree textures extracted from photos are in $FGDATA/Textures/Trees/.

To do: make a list of regional forests/scrub that need to textures sorted by impact on FG scenery, and the dominant tree/vegetation species in those. (September 2020)

To do: find out, if given a choice of trees of the same species, which one looks better in the simulator? Possibly the one with more holes or gaps rather than a solid shape - but not to an extremely level like something that's very unusual or a twisted tree (reasoning: one of the strengths of alpha masks is that tiny gap detail can be done.)

To do: find info about, any lens filters to remove distorsion and feasibility of slight perspective correction if the overhead view is not precisely top down. See the section on texture extraction for facades.

Tips for finding trees to take photos of: Google street view may help you scout out trees, and an angle to take the photo against an easy to separate background, if you are traveling to an unfamiliar region.

To see what trees, bushes, and plants are most needed currently (best impact for contribution) see the Scenery forum.

Specifically for trees, the "hardest" part will be to separate the tree from the background. Therefore,

  • Choose a tree that grows more or less alone and slightly elevated, such that the background is pure sky (example)
  • Make sure your camera exposure metering is set to 'spot', otherwise the bright sky might cause the tree to be under-exposed. Even better, manually set/correct exposure; often you need values as high as +1 EV or more.

Separating vegetation from harder backgrounds

If it's not possible to obtain a photo of a tree against a blue sky, you can try manually separating the tree yourself.

  • The main requirement is to have a background that's of a different colour to the leaves and trunk of the tree. These days photo-editors like GIMP have selection tools of various types that can add or subtract from selections, but using these takes more time than having a simple blue sky. If you are familiar with an editor you could try separating a tree against an overcast sky (clouds example), light coloured ground/rock, or a building.
  • What to avoid: leaves of your tree against a background of other leaves (example). The dark trunk of a tree against green grass can be separated. For the trunk, if necessary, you can manually draw a selection with a tool like the free draw selection in GIMP.

(The technical term for separating different parts of an image (partitioning) is image segmentation. In a photo-editor it's just a case of selecting the object you want. See the section on texture extraction below - just submitting the photo is useful, if image manipulation is beyond you right now.)

Terrain

Fightgear's procedural texturing system can use textures of the landscape on different scales (different camera height or zoom) as input. Flightgear can do a lot with few textures.

As GPL compatible photos of good top-down views are hard to find, a simple way to get photos is for FG-ers with a drone camera This is a link to a Wikipedia article to take pictures of terrain in their region.

As of August 2020, photos of different types of agriculture (farm land) from around the world are a priority. Contributions here can make a large difference.

To do: list some types of terrain photos that are higher priority (make a larger impact)

Existing terrain textures extracted from photos are in $FGDATA/Textures/Terrain/. The high quality textures as of September 2020 are in 2048x2048 format (example).

To see what terrain photos are most needed currently (best impact for contribution) see the Scenery forum.

Aerial drone photos should:

  • be from a top down view
  • not have strong shadows. Preferably taken under overcast conditions
  • not have snow, puddles, trees with autumn colours - Flightgear can place these procedurally. Water in terrain from water bodies like reservoirs, lakes, rivers, streams, pools, etc. are fine.
  • To do: list more requirements

It's possible to do a lot of powerful editing in photo editors like GIMP to prepare textures and things like changing soil colours to make textures suitable for other regions. See the section below on extracting textures from photos for details.

Building facades

Specifically for facades,

  • avoid close distance shots of buildings, for two reasons. First, the closer you are to the object, the shorter you need to set the focal length to capture it. Almost all lenses produce some distortions then (e.g., barrel distortions: straight lines bending outwards). Fortunately, there is software which can correct these, which we'll discuss later. Second, the closer you are, the more obstructions you'll get, and there is no automatic correction for that.

Extracting textures

Now open the photo in GIMP or a similar program. In generally, work with the largest image resolution possible. You can scale down the final texture later.

Trees

Process

  • use the "fuzzy select tool" or "select by color tool" to select the sky
  • erase the sky to white
  • repeat until everything is white except for the tree
  • add alpha channel (Layer > Transparency > Add alpha channel)

Now there are two options, YMMV.
Either

  • select white, erase to transparency (press Del).
  • This might leave bright seams. To erase them, color-select the now transparent background, then Select > Grow by 1px, erase to transparency. Repeat if neccessary.

Or

  • make color white transparent (Layer->Transparency->Color to alpha)
  • this will also leave e.g. the stem slightly transparent, so use Layer > Transparency > Threshold alpha with value around 50
  • finally you might want to adjust Colors > Brightness/Contrast and/or Colors > Hue/Saturation
  • The tree texture sheet is typically a PNG file with 4 rows of trees. The rows from top to bottom correspond to summer, summer snow (!), winter and winter snow, and the number in the row is given in the material definition (see <tree-varieties>). Typically a single tree occupies a 256x256 or 512x512 pixel square. The trunk must be located in the centre of the base of the square, as the tree is rendered as 2 perpendicular 2D images intersecting along the central axis. An off-centre trunk will therefore produce a two-trunked tree. Furthermore, the top of the tree should be separated from the trunk above it by about 8 pixels (for a 512 pixel square) to avoid a top-hat effect when the tree is shrunk. Further information on the tree texture sheet layout is in $FGDATA/Docs/README.Materials. Typical examples are in the $FGDATA/Textures/Trees directory (sourceforge).
  • You might want to View > Show Grid and Image > Configure Grid to a spacing of 256 or 512 to help arrange the individual trees
  • copy over your new tree textures, make sure that the stem is centered in the individual tree's box and no parts of the tree overlap with the neighbouring boxes

GIMP tips (Selections)

1. You can add and subtract from a selection, to build or take away from a selection - using a variety of tools for the part of the image you are working with
2. Undo/re-do helps: Crl+z/Ctrl+y
3. The fuzzy selection tool: selects an area around a point you click with similar colours. Adjust the threshold if you select too much. Use with add and subtract from selection to build a selection of the tree one part a time. Remember you can also set the threshold low, select subtract from selection, and
4. Intelligent scissors: click points along a path along the border of an object and background. The path will try to follow the border
5. Free select tool: Zoom in and click along the path similar to 4)
6. You can stop unwanted parts of the image from interfering by getting rid of them. Use 4) or other selection tools to roughly define the area containing the object, then delete the rest, or just copy/paste the area congaing the object to a new image. This will make it easy to use tools like "Select regions with similar colours" to get an initial selection you can then subtract from - if that's the best approach.
7. Change the background sky colour to be even more different, to make selection easy.
8. You should save the original photo sources as people in future might want to improve on textures by converting the photo to higher resolution textures, or using filters to improve image etc.


Terrain

Process

To do

For finished texture examples see: $FGDATA/Textures/Terrain directory (sourceforge)

GIMP tips (Creating textures)

1. It's possible to copy parts of the photo, or another photo, to get rid of unwanted bits or insert new terrain features. The Clone tool can help with this. You can use it to remove small shadows too.
2. The Resynthesizer plugin is extremely powerful. Download: windows , Linux. See here for a tutorial. Experiment and see what can be done
The plug-in is found under GIMP > Menu > filters > Map > Resynthesize. The plug-in can take a while to resynthesise depending on settings in the tweak section - you can experiment with low settings and increase settings for the final render.
The resynthesizer plugin can build a new output texture by taking parts of an input texture. It can build a new texture in such a way that it does not look randomly scrambled. That is, recognisable features and patterns in the input texture are preserved in the new texture.
Tweaks section: A high 'Sensitivity to outliers' makes the output look 'samey' or uniform - for textures using the agriculture effect that don't have to worry about tiling, a low sensitivity to outliers might be better.
Options section: Source image is your input photo/texture. The output image is the currently selected image, which should be different from input. For tileable textures select horizontal and vertical tiling/.
The output texture can be much larger than the input image.
3. Tileable textures can be created by using the resynthesizer plugin, followed by GIMPs Filters > Map > Tile seamless tool.
4. The resynthesizer plug can be used to delete unwanted bits, and fill in gaps with material from the rest of the image.
5. The GIMP Menu > Colors > Map > Rotate colors tool is useful. This tool maps a range of hues This is a link to a Wikipedia article (colours) to another range of hues.
To use just move the pointers and the source range will be mapped to the destination range. Select objects or areas to have it apply only to them. You can change the colours of anything using this - including man-made objects. Experiment and see.
6. Soil colours in a region can be made similar using Rotate Colors, so different land-class types blend together - hue blending. For example a dark soil can be changed to a lighter reddish-brown soil.
7. You should save the original photo sources and gimp files as people in future might want to improve on textures by converting the photo to higher resolution textures, creating new textures using parts of the photo, or using filters to improve images etc.


To do: Feel free to add more tips/techniques you come up with

Facades

(TODO)

  • correct distortions. Check out lensfun / GimpLensfun and see if your camera/lens is supported. If it is not, you could consider generating calibration data yourself.
  • correct perspective
  • crop
  • make seamless
  • optionally: use the heal tool to correct irregularities (power lines etc.)
  • duplicate layer
  • adjust saturation, brightness, contrast
  • add lightmap layer
  • save .xcf
  • scale image to a power of two size, export texture and lightmap to .png
  • quit without saving
  • run optipng on texture and lightmap

--Radi 18:45, 29 April 2013 (UTC)

Related Content