Howto:Create textures from photos: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
m (→‎Facades: Link update: lensfun - Moved to SourceForge April 2014 and migrated to Git)
(updated for the post-2013 tree format)
Line 5: Line 5:
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 GPL.  
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 GPL.  


TODO: link good sources of free to use photos
TODO: link more good sources of free to use photos


here are some GPL textures and photos:  
here are some GPL textures and photos:  
Line 12: Line 12:
* http://commons.wikimedia.org/wiki/Category:Roofs_textures
* http://commons.wikimedia.org/wiki/Category:Roofs_textures
* http://commons.wikimedia.org/wiki/Category:Tileable_textures
* http://commons.wikimedia.org/wiki/Category:Tileable_textures
[http://www.flickr.com 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 to
credit the photographer if that is required.


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.  
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.  
Line 48: Line 51:
* finally you might want to adjust "Colors->Brightness/Contrast" and/or "Colors->Hue/Saturation"
* finally you might want to adjust "Colors->Brightness/Contrast" and/or "Colors->Hue/Saturation"


'''Note that the following refers to the old (pre-April-2013) tree textures format'''
* 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.
* now look at how the trees are arranged in $FGDATA/Textures/Trees/summer-...png. It has a size of e.g. 2048x512, so each tree gets a 256x512 box. You might want to "View->Show Grid" and "Image->Configure Grid" to a spacing of 256 to help arrange the individual trees
* 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 8 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
* 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


=== Facades ===  
=== Facades ===  

Revision as of 08:35, 21 July 2019

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.

Obtaining photos

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 GPL.

TODO: link more good sources of free to use photos

here are some GPL textures and photos:

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 to credit the photographer if that is required.

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

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
  • 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.

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 similiar program. In generally, work with the largest image resolution possible. You can scale down the final texture later.

Trees

  • 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.
  • 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

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)