chris-blues / Nasa2FGearthview

a bash-script to convert NASA satellite images to ready-to-use textures for FG's EarthView
GNU General Public License v2.0
3 stars 0 forks source link

[question] elevation map in alpha channel? #1

Closed dirteat closed 6 years ago

dirteat commented 6 years ago

Hi there, I have just entered FG SpaceShuttle world and I have used the script to generate 16K textures. However, I am wondering if the elevation is also rendered at 16K? In the script, I only see downloading of NASA earth maps.

High-res elevation maps are there: https://www.visibleearth.nasa.gov/view.php?id=73934

Thanks!

chris-blues commented 6 years ago

Well, I'm not sure why, but I planned to incorporate the generation of normalmaps into the conversion script, so that in the end, you'll have the world-tiles, cloud-tiles AND normalmaps. Somehow this didn't happen! But I have the script here if you're interested to merge it into the convert.sh, which lives in $FGMETA/Nasa2FGearthview

The trouble, as I remember, is that the script in FGMETA uses imageMagick, but only GIMP can create normalmaps. At least I didn't find out, how to do that with IM. Feel free to give it a shot! :o)

About the other question: you can't enlarge these height maps. At least it I wouldn't recommend it. As there will be funny artefacts along the way. My policy always was: you can scale down a map, but you can't scale it up! Imagine what would happen to a single pixel within these 10800x10800 maps if you scale them up to 16384x16384! Every pixel in that map will be about 1 1/2 pixels in the resulting map. so every 2nd pixel will be an average of the 2 neighbouring pixels. Not a good idea, IMHO.

So, no! I wouldn't generate 16k normalmaps out of 10800px heightmaps...

Next trouble is, that you can't just copy the heightmaps into some free alpha channel. In order to use it properly in a realtime rendering run, you'll need a normalmap instead, which has a precomputed mapping of the height information, ready to use in your GPU to display as a model. Or at least it's details. That means, you have a normal map, which by itself needs already 3 channels! RGB! No chance to merge that into some free channel! Well, you could use the normalmap's alpha channel, which is free, to do some other fancy stuff...

See my discussion with Thorsten on these details on the forum: https://forum.flightgear.org/viewtopic.php?f=5&t=29780

Hope this helps a bit!

Cheers! :o)

dirteat commented 6 years ago

Thanks a lot for the details and explanations! I'll read through the link and try!!

cheers

dirteat commented 5 years ago

Hi there, I finally had some time to dig into the script, I cannot tell that I fully understand it, but I got the basic logic blocks and I've added the normalmapping output. It looks to me that this is working, I am currently using 8192 normal maps generated with the script in Earthview, and they're beautiful :)

I have attached the new script there:

convert.sh.gz

PS: I wanted to try with super-sampling at 16K to see the damages, that is pointless but actually looks good too. In this process, I removed the hardcut to 8192 in some of your conditionals.

To generate the normal maps from the elevation maps, I have used this code:

(https://github.com/planrich/normalmap)

A standalone doing what the gimp plugging is doing, perfect ;)

Cheers, [Chris.]

chris-blues commented 5 years ago

Hi Chris!

Nice to see, you're making progress! :o)

To be honest, I had no time yet, to take a look at your code. Do I understand correctly, that you want to merge your code into here?

Cheers

dirteat commented 5 years ago

Hi Chris, If this can be useful for others, yes, I'll be happy to do a proper push request.

I just wanted your opinion first, then I can make a few improvements before doing a proper pull request. My main source of uncertainties is the arguments you're passing to convert, I am copy-pasting them for doing the normal maps, but some of these arguments maybe useless, or damaging, for the normal maps. If you could have a quick look at them, that would be nice.

Otherwise, things seem to have improved with NASA servers, they're fast now, no issue to download from the scripts.

Cheers, Chris.

chris-blues commented 5 years ago

Ok, I just looked over it, and it looks very nice! Aside from a few minor formal things, I would merge it as is. Here's my observations:

Other than that, I'll be waiting for your merge request! And thanks for your contribution.

BTW, if you have commit access to FGADDON, you could merge it there as well. If not, I can do the merging. You could add your 16k files there as well...

Edit: actually, it's FGMeta, where the script lives. The textures and maps are in FGADDON.

Cheers chris

dirteat commented 5 years ago

Thanks a lot for your comments, I'll do a cleanup of the script accordingly and a push request here. PS: don't have commit access to FG, better like this, I am a rookie in many things :)

chris-blues commented 5 years ago

Ok, I just added you as contributor, so you can push directly to the repo. Don't worry, I have backups, so you can't really break anything!

And I recommend you pull the latest ReadMe.md, I just polished up the markdown...

Have fun hacking! :o)

chris-blues commented 5 years ago

Hi Chris!

I'm just trying to test your contributions in order to push it to FGmeta, and stumbled at the compilation of the normalmap binary. Where do I get this "waf" tool? I couldn't find any straight answer to that, so, since you seem to have been able to do that, I thought I'd ask you...

Cheers

dirteat commented 5 years ago

Hi Chris, well, under Linux, "waf" was provided by my linux distribution (Mageia). As far as I understand, it is a lightweight python equivalent to configure. I would say it should be packaged in most of the linux distros. Otherwise, the website is there:

https://gitlab.com/ita1024/waf/

If I remember correctly, there is also a way to make a "waf" standalone package within the src files, I can inquire if you want, just let me know! Cheers, Chris.

dirteat commented 5 years ago

Hi chris, just commited a small change to convert.sh. I was testing the last version, and if "normalmap" is in the system PATH, the script was still disabling it. Just a copy-paste extra conditionals was there. Please check I did not introduce an unexpected bug by removing the spurious piece.

chris-blues commented 5 years ago

Hi!

Yeah, you're right! Good catch! Thanks for spotting this!

About waf: it's funny! I just couldn't find it on Debian Stretch... But, as you propably have seen on the mailing list, I "borrowed" the portable script from Ardour. That's where the wrong conditional above came from...

chris-blues commented 5 years ago

...and could you please let me know, how your testing went? So that I can update the script in FGmeta...

dirteat commented 5 years ago

yes, it is still running :) So far so good, I let you know tomorrow I guess, I am generating 8K and 16K textures.

dirteat commented 5 years ago

Well, there is something weird, the script started with

./convert.sh download world clouds heights 16k

stops at:

########################

Resize nightlights

########################

No suitable image found. Using NASA original... Resize/Image/tmp[nightlights_54000x27000.mpc]: 96767 of 96768, 100% complete.

And if I start it again, it goes on with the rest of leveling etc.. It is not obvious to me why it stops there, I'll inquire a bit more.

chris-blues commented 5 years ago

I opened a new thread: https://github.com/chris-blues/Nasa2FGearthview/issues/3