2017-01-10 15:18:30 +00:00
|
|
|
# Nasa2FGearthview
|
|
|
|
A bash-script to convert NASA satellite images to ready-to-use
|
2019-03-25 17:20:43 +00:00
|
|
|
textures for FG's EarthView using ImageMagick and normalmap
|
2017-01-10 15:18:30 +00:00
|
|
|
|
2019-03-25 17:20:43 +00:00
|
|
|
You can get "normalmap" there:
|
|
|
|
https://github.com/planrich/normalmap
|
|
|
|
|
|
|
|
For info about FGearthview, see the forum thread:\
|
2017-01-10 15:18:30 +00:00
|
|
|
https://forum.flightgear.org/viewtopic.php?f=6&t=15754
|
2019-03-25 17:20:43 +00:00
|
|
|
|
|
|
|
or this FG-wiki-page:\
|
2017-01-10 15:18:30 +00:00
|
|
|
http://wiki.flightgear.org/Earthview
|
|
|
|
|
2019-03-25 17:20:43 +00:00
|
|
|
### Caution!
|
|
|
|
Don't use this script on a server! It will most likely cause
|
|
|
|
Denial-of-service (DoS). When working on these huge images, the
|
|
|
|
harddisk throughput will cease occasionally and CPU / RAM usage will
|
|
|
|
spike tremendously! So, only use this script on your home desktop
|
|
|
|
computer, or if you don't mind several long server-outages...
|
|
|
|
|
2017-01-10 15:18:30 +00:00
|
|
|
|
|
|
|
------------------------------------
|
2019-03-25 17:20:43 +00:00
|
|
|
## About:
|
2017-01-10 15:18:30 +00:00
|
|
|
|
|
|
|
This script runs on Linux (maybe Mac also?) in a Bash
|
|
|
|
(Bourne Again Shell) - Windows is not supported (by the nature of the
|
|
|
|
script). Maybe it works on windows as well, I don't know, feel free
|
|
|
|
to try, and please let me know! :)
|
|
|
|
|
|
|
|
In the end you will have 8 world-textures in .png and .dds format.
|
|
|
|
Generally .dds is better in performance, but it won't work on some
|
|
|
|
graphics cards. If this is the case for you, then try the .png files.
|
2019-03-25 17:20:43 +00:00
|
|
|
For further information see:\
|
2017-01-10 15:18:30 +00:00
|
|
|
http://wiki.flightgear.org/index.php?title=DDS_Textures_in_FlightGear&redirect=no
|
|
|
|
|
2019-03-25 17:20:43 +00:00
|
|
|
If you also converted the clouds and the height maps, then you'll also
|
|
|
|
find 8 cloud- and 8 height textures (as well as their conversion to
|
|
|
|
normal maps) in the format .png. Because the .dds-format has trouble
|
|
|
|
with rendering heavy alpha images, which is because of it's
|
|
|
|
compression algorythm [1], I think it's useless to also build faulty
|
|
|
|
files. However, this is not entirely true! It is possible to switch
|
|
|
|
off the .dds/DXT compression. But this results in huge files and is
|
|
|
|
rather heavy on the GPU's RAM.
|
2017-01-10 15:18:30 +00:00
|
|
|
|
|
|
|
Buckaroo has created a nice overview on dds-compression:
|
|
|
|
[1] http://www.buckarooshangar.com/flightgear/tut_dds.html
|
|
|
|
|
|
|
|
------------------------------------
|
2019-03-25 17:20:43 +00:00
|
|
|
## Installation and usage:
|
2017-01-10 15:18:30 +00:00
|
|
|
|
|
|
|
Simply copy "convert.sh" into a folder of your liking and run it:
|
|
|
|
|
2019-03-25 17:20:43 +00:00
|
|
|
```shell
|
|
|
|
./convert.sh
|
|
|
|
```
|
2017-01-10 15:18:30 +00:00
|
|
|
|
|
|
|
This will show a help text, since you didn't specify any target(s).
|
|
|
|
Possible targets are:
|
|
|
|
* world
|
|
|
|
* clouds
|
2019-03-25 17:20:43 +00:00
|
|
|
* heights
|
2017-01-10 15:18:30 +00:00
|
|
|
* all
|
|
|
|
|
|
|
|
Additionally, there are some options you could specify (further
|
|
|
|
explained below):
|
|
|
|
* 1k | 2k | 4k | 8k | 16k
|
2019-03-25 17:20:43 +00:00
|
|
|
* download | no-download
|
|
|
|
* world
|
|
|
|
* clouds
|
|
|
|
* heights
|
2017-01-10 15:18:30 +00:00
|
|
|
* cleanup
|
|
|
|
* rebuild
|
|
|
|
* check
|
|
|
|
|
|
|
|
So your call could look sth like this:
|
|
|
|
|
2019-03-25 17:20:43 +00:00
|
|
|
```shell
|
|
|
|
./convert.sh world download alt cleanup 8k
|
|
|
|
```
|
2017-01-10 15:18:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
------------------------------------
|
2019-03-25 17:20:43 +00:00
|
|
|
## Requirements:
|
2017-01-10 15:18:30 +00:00
|
|
|
|
|
|
|
WARNING!
|
|
|
|
|
2019-03-25 17:20:43 +00:00
|
|
|
This script uses a *lot* disk space! In my last test run, which
|
|
|
|
generated all maps in all resolutions, the disk usage was about 330GB!
|
|
|
|
Beware!\
|
|
|
|
Also, I wouldn't recommend doing this on a SSD! While SSDs are
|
|
|
|
generally faster, they also get more wear-and-tear when write such
|
|
|
|
huge files. So this script might cause your SSD to die earlier as it
|
|
|
|
should. Generally speaking, this won't kill your SSD, but it might
|
|
|
|
cause it to die earlier. HDDs are much more robust in that respect.
|
2017-01-10 15:18:30 +00:00
|
|
|
|
|
|
|
Also, this script will run for a *very long* time! It might be best to
|
|
|
|
let it run over night - your computer might become unresponsive from
|
|
|
|
time to time, due to the heavy CPU and memory load, which tends to
|
|
|
|
occur, when converting 54000x27000 images. ;-)
|
2019-03-25 17:20:43 +00:00
|
|
|
|
2017-01-10 15:18:30 +00:00
|
|
|
I also recommend to deactivate swapping!
|
2019-03-25 17:20:43 +00:00
|
|
|
```shell
|
|
|
|
sudo swapoff -a
|
|
|
|
```
|
2017-01-10 15:18:30 +00:00
|
|
|
To reactivate swapping do:
|
2019-03-25 17:20:43 +00:00
|
|
|
```shell
|
2017-01-10 15:18:30 +00:00
|
|
|
$ sudo swapon -a
|
2019-03-25 17:20:43 +00:00
|
|
|
```
|
2017-01-10 15:18:30 +00:00
|
|
|
|
2019-03-25 17:20:43 +00:00
|
|
|
This script relies on wget, ImageMagick and, for converting the height
|
|
|
|
maps to normal maps, on "normalmap". Some of these programs are easily
|
|
|
|
installed by your systems package-management-system.\ (On
|
|
|
|
Debian/Ubuntu this is "apt-get").
|
2017-01-10 15:18:30 +00:00
|
|
|
|
|
|
|
So, on Debian for instance, you only need to put the following into
|
|
|
|
the console:
|
|
|
|
|
2019-03-25 17:20:43 +00:00
|
|
|
```shell
|
|
|
|
sudo apt-get install wget imagemagick
|
|
|
|
```
|
2017-01-10 15:18:30 +00:00
|
|
|
|
|
|
|
Depending on your distro, the package names might differ slightly! Use
|
|
|
|
a search engine of your choice to find out, how the packages are named
|
|
|
|
in your distro!
|
|
|
|
|
|
|
|
You may want to check:
|
|
|
|
|
2019-03-25 17:20:43 +00:00
|
|
|
```shell
|
|
|
|
apt search imagemagick
|
|
|
|
```
|
|
|
|
|
|
|
|
### IMPORTANT!
|
|
|
|
Check out your ```/etc/ImageMagick-6/policy.xml```
|
|
|
|
On some distros, there are limits set, which will cause IM to abort
|
|
|
|
the conversion of images larger than
|
|
|
|
[rediculously small images](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=860763).
|
|
|
|
Edit and set to our needs:
|
|
|
|
* width: at least 55000
|
|
|
|
* height: at least 55000
|
|
|
|
* area: less than your free RAM
|
|
|
|
|
|
|
|
### Normalmap
|
|
|
|
For normalmap, you can download and compile it from
|
|
|
|
https://github.com/planrich/normalmap
|
2017-01-10 15:18:30 +00:00
|
|
|
|
2019-03-25 17:20:43 +00:00
|
|
|
You can install the binary into your system, or just copy it next to
|
|
|
|
convert.sh - both should work.
|
2017-01-10 15:18:30 +00:00
|
|
|
|
|
|
|
------------------------------------
|
2019-03-25 17:20:43 +00:00
|
|
|
## Targets:
|
|
|
|
|
|
|
|
**world**\
|
|
|
|
Generates the world tiles, needed to run FG with EarthView.
|
|
|
|
You will find the results in output/[$resolution]/\*. Copy
|
|
|
|
these into $FGDATA/Models/Astro/\*. More about the installation
|
|
|
|
of these textures can be found here:
|
|
|
|
http://wiki.flightgear.org/Earthview#Customization
|
|
|
|
|
|
|
|
**clouds**\
|
|
|
|
Generates the cloud tiles, needed to run FG with EarthView.
|
|
|
|
The locations are the same as the other textures mentioned
|
|
|
|
above. Note that clouds are only available with up to 8k
|
|
|
|
resolution, due to the available data at NASA.
|
|
|
|
|
|
|
|
**heights**\
|
|
|
|
Generates the height tiles, which are then converted to the
|
|
|
|
normal maps needed to run FG with EarthView. The locations are
|
|
|
|
the same as the other textures mentioned above. Note that
|
|
|
|
heights are only available with up to 8k resolution, due to the
|
|
|
|
available data at NASA.
|
|
|
|
|
|
|
|
**all**\
|
|
|
|
Converts everything needed for a full-blown earthview texture
|
|
|
|
set. Does the same as:
|
|
|
|
```./convert.sh world clouds heights```
|
|
|
|
|
|
|
|
|
|
|
|
## Options:
|
|
|
|
|
|
|
|
**1k | 2k | 4k | 8k | 16k**\
|
|
|
|
Lets you specify a desired resolution of the textures.
|
|
|
|
Possible values are 1k, 2k, 4k, 8k and 16k. If nothing is
|
|
|
|
specified, the script will generate all of the resolutions.
|
|
|
|
16k is recommended only for earth textures, it will induce
|
|
|
|
oversampling from clouds and height maps.
|
|
|
|
|
|
|
|
**download**\
|
|
|
|
Causes the script to download the needed data, this is the
|
|
|
|
default behavior (and can be omitted).
|
|
|
|
|
|
|
|
**no-download**\
|
|
|
|
Causes the script to skip the download function. If you
|
|
|
|
already have the source images, then you don't need to
|
|
|
|
re-download them. (About 2.4GB!)
|
|
|
|
If omitted, the script will download the source images from
|
|
|
|
the default location.
|
|
|
|
|
|
|
|
**cleanup**\
|
|
|
|
Deletes the temporary files created during texture generation.
|
|
|
|
These can be found in tmp/
|
|
|
|
Note: if for some reason you later want some other resolution,
|
|
|
|
then it's good to have the data there. So only do this, when
|
|
|
|
you're quite sure that you're done.
|
|
|
|
Frees up a lot of disk-space! Which would have to be
|
|
|
|
regenerated if needed again.
|
|
|
|
|
|
|
|
**rebuild**\
|
|
|
|
Deletes only the temporary files of the given target. So if
|
|
|
|
you call ```./convert.sh rebuild world``` the script will delete
|
|
|
|
all corresponding temp-files of the target world, which will
|
|
|
|
trigger a complete regeneration of the relevant (instead of
|
|
|
|
skipping existing files)
|
|
|
|
|
|
|
|
**check**\
|
|
|
|
Creates mosaics of the tiles, so you can look at them and see
|
|
|
|
if all went well.
|