Tutorial: placing a tile on a planetary surface.

All tutorials about Celestia go in here. For Celestia itself, add-ons, textures, scripting, etc.
Avatar
Topic author
jogad
Posts: 458
Joined: 17.09.2008
With us: 15 years 11 months
Location: Paris France

Tutorial: placing a tile on a planetary surface.

Post #1by jogad » 05.05.2009, 19:59

Hello,

Few times ago someone :blue: asked how to place a tile on a planetary surface.
There are several good tutorials on how to do it from a complete planet texture but I did not find any on how to proceed from only a little piece of terrain.

This is a very simplified way to place a single tile on the surface of a planet. The placement of the texture is not absolutely accurate, but dimensions of the terrain are precise. This is well suited for fiction scenarios where the right place for a texture is where we place it.
Of course it is possible to place the terrain with very high precision. But here, we aim to build only one tile. So we’ll try to place our texture in the middle of a tile to have more room for it.

I have this image:
Image

This field is 830 meters by 727 m. I want to put it on Tethys at approximately latitude 30° south and 170° east.
We need to know that the radius of Tethys is 529.9 km. This is indicated in the text information in the upper left of the Celestia windows when Tethys is selected.

We need to do some calculations. To do this, load the calc sheet attached at this post. The green cells are the cells to enter the data. The others are protected. Do type only the numbers without units. You can remove the protection to adapt the table to your needs.

1) Enter the longitude and latitude. The cells in blue indicate the limits of the coordinates of the tile. The coordinates of the middle of the tile are important. These will be the exact coordinates of the center of our image.

2) Complete with the radius of the planet and the ground dimensions.

3) Determine the highest level possible so that the size of our ground is still less than the size of the tile (in pink). Bear in mind that the maximum possible level is 12. The calc sheet doesn’t control that.

4) Set the size of the tile so that the image size matches well with the one you have. You can see the resolution displayed in meters per pixel. In this example with a tile of 2048, I have a resolution of about 80 cm per pixel. It was roughly my original picture resolution.
The size of the tile must always be a power of 2.

We get the following table:
Image

-If you already have an image, adjust it to the size indicated (here 1045 pixels wide by 915 pixels high). Otherwise create directly your image with the size specified for the canvas below and skip the next step.

- Enlarge the frame as indicated (1774 x 2048), leaving the original image centered. You will need to complete the border added. For example, I added some grass around. Indeed it is not possible that part of the tile is transparent.

- Finally resize your image to the size of the tile (2048x2048) and save it with the name given by the calc sheet. You may choose png, jpg or dds for the format. I choose the jpg format for this example and I save my file as tx_1991_682.jpg

That's it. It remains only to define a virtual texture of Tethys for our tile.
I explain briefly.
Here is the directory structure:
Image

Save the file ‘tx_1991_682.jpg’ in the level10 folder. Intermediate levels are unnecessary but it is mandatory to complete the level0 directory.
To do this, take the whole texture of the planet and cut it into two halves. Save the western hemisphere as ‘tx_0_0.jpg’ and the eastern hemisphere as ‘tx_1_0.jpg’. Place these two files in the level0 folder.

The directory “TethysCapitol” is the folder of our add-on. It should be placed in the "extras" Celestia directory. It contains the file tethysCap.ssc with the following content

Code: Select all

Modify "Tethys" "Sol/Saturn"
{
Texture "tethysCap.ctx"
}

Location "Capitol" "Sol/Saturn/Tethys"
{
LongLat [170.07 -29.97 0] # tile's center coordinates
Importance 300
Type "City"
}

The file “tethysCap.ctx” is in hires folder and contains the following

Code: Select all

VirtualTexture
{
         ImageDirectory "tethys_VT"
         BaseSplit 0
         TileSize 64
         TileType "jpg"
}

Note the unusually small value of TileSize.

To easily find this small area of less than 1 km? on Tethys, just type “tethys/capitol” in the input window of Celestia to select it and then go to it with G. And here's the result to check that all is well at the expected location.

capLoin.jpg

It is even possible to zoom a bit more.

capPres.jpg

This high level of detail is possible at only level 10 with a not so big texture because I chose a small body to host it. Don’t expect this for super giant planets.

If something seems strange, don’t hesitate to bring corrections. I apologize for the bad English. I translate my original text with Google’s help. So some inexactitudes or worse are possible and even probable.

Regards
Last edited by jogad on 15.05.2009, 10:38, edited 4 times in total.

BobHegwood
Posts: 1803
Joined: 12.10.2007
With us: 16 years 10 months

Re: Tutorial: placing a tile on a planetary surface.

Post #2by BobHegwood » 06.05.2009, 12:06

Hey, thanks *very* much for that Joel. :)

You wouldn't want to upload a package to the Motherlode would you?
Seems like with 8 downloads already, that more people might be
interested if you could make this available to a wider audience.

Just a thought.

Thanks again, Brain-Dead :wink:
Brain-Dead Geezer Bob is now using...
Windows Vista Home Premium, 64-bit on a
Gateway Pentium Dual-Core CPU E5200, 2.5GHz
7 GB RAM, 500 GB hard disk, Nvidia GeForce 7100
Nvidia nForce 630i, 1680x1050 screen, Latest SVN

Reiko
Posts: 1119
Joined: 05.10.2006
Age: 41
With us: 17 years 11 months
Location: Out there...

Re: Tutorial: placing a tile on a planetary surface.

Post #3by Reiko » 06.05.2009, 15:09

Than k you very much! This is greatly appreciated. :D :D

Avatar
Topic author
jogad
Posts: 458
Joined: 17.09.2008
With us: 15 years 11 months
Location: Paris France

Re: Tutorial: placing a tile on a planetary surface.

Post #4by jogad » 06.05.2009, 19:42

Hi,

Bob, Reiko, thank you for your support.
Bob, I sent a PM to you.

In the example above, it was assumed that it was important to respect the exact size of the field but we could tolerate a small deviation on the position.

I completed the calc sheet in the first post so that the error on the position is known with precision. :!:
This gives a way of placing texture at accurate coordinates if really needed.

If the exact size is not important, just choose a convenient the size for the tile by varying the level number. Create the image with the dimensions given to the canvas. Then resize to the size of the tile. This step is still necessary to preserve the image dimensions. Indeed the image on the tile undergoes a distortion that depends on latitude.

If the size AND the center’s position are important, at the final stage just shift the image by a number of pixels as indicated below.
Image

In the above example there is an error of 611 meters on the position. To correct it, just shift the image by 796 pixels on the left and 341 pixels down.
The drawback is that the left side of the image is no longer in the tile. We are therefore obliged to create a second tile to ensure that our image is complete. This tile is the previous one and its name is tx_1990_682.

twoTiles.png

Depending on circumstances we can have 2 or 4 tiles instead of one for the same utile ground. This is a waste of space that is not always indispensable.

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 22
With us: 22 years 5 months
Location: Hamburg, Germany

Re: Tutorial: placing a tile on a planetary surface.

Post #5by t00fri » 06.05.2009, 19:48

That's certainly a useful tutorial. I think it should be displayed as a sticky post or equivalent...

Fridger
Image

Avatar
Topic author
jogad
Posts: 458
Joined: 17.09.2008
With us: 15 years 11 months
Location: Paris France

Re: Tutorial: placing a tile on a planetary surface.

Post #6by jogad » 07.05.2009, 18:57

Hi,

Thank you very much :) . I take the suggestion as a compliment and I tagged the post as sticky.
However it is somewhat embarrassing that it ends at the top of the list. :oops:

You may have noticed that this tutorial is very simple and not really designed to create complete close-ups especially on the Earth.
I wrote a much more comprehensive tutorial which explains in detail the method that I used to create the close-ups that I have loaded on ML.
Unfortunately it is a rather long tutorial in French and is beyond my capacity for translation.
You can take a look HERE.

If anyone is interested to translate, adapt or improve it, just PM me (in French if possible).
Anyway, you can use it without any restrictions 8) and I am at your disposal to provide my files.

Regards

Reiko
Posts: 1119
Joined: 05.10.2006
Age: 41
With us: 17 years 11 months
Location: Out there...

Re: Tutorial: placing a tile on a planetary surface.

Post #7by Reiko » 14.05.2009, 06:03

I can't seem to make this work. Wanted to place a 2048x2048 texture onto mimas at coordinates 180Wx10N (-180x10) and this is what the calc sheet brought up.

Image

Here is my SSC file

Code: Select all

Modify "Mimas" "Sol/Saturn"
(
Texture "MimasEvac.ctx"
)

Location "Evac" "Sol/Saturn/Mimas"
(
LongLat [-179.82422 10.01953 0] # tile's center coordinates
Importance 300
Type "City"
)


Here is the ctx file named MimasEvac.ctx and I did put it in the hires folder.

Code: Select all

VirtualTexture
(
         ImageDirectory "mimas_VT"
         BaseSplit 0
         TileSize 64
         TileType "jpg"
)


Also in the hires folder I have the folder named mimas_VT

Inside the mimas_VT I have two folders named level0 and level9

Inside level0 are two 2048x2048 textures labled tx_0_0.jpg and tx_0_1.jpg

In the level 9 folder is one 2048x2048 texture labeled tx_0_227.jpg

The only steps that confuse me were these two.

-If you already have an image, adjust it to the size indicated (here 1045 pixels wide by 915 pixels high). Otherwise create directly your image with the size specified for the canvas below and skip the next step.

- Enlarge the frame as indicated (1774 x 2048), leaving the original image centered. You will need to complete the border added. For example, I added some grass around. Indeed it is not possible that part of the tile is transparent.

I have no idea what any of that means. Please help.

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 22
With us: 22 years 5 months
Location: Hamburg, Germany

Re: Tutorial: placing a tile on a planetary surface.

Post #8by t00fri » 14.05.2009, 07:29

Reiko,

just in passing: your TileSize is highly incorrect. You forgot to modify it from Jogad's example:

You need

TileSize 2048
(or just a little smaller, like TileSize 1024)

Fridger
Image

Reiko
Posts: 1119
Joined: 05.10.2006
Age: 41
With us: 17 years 11 months
Location: Out there...

Re: Tutorial: placing a tile on a planetary surface.

Post #9by Reiko » 14.05.2009, 08:02

t00fri wrote:Reiko,

just in passing: your TileSize is highly incorrect. You forgot to modify it from Jogad's example:

You need

TileSize 2048
(or just a little smaller, like TileSize 1024)

Fridger
I tried that and it still not work. Tried both 1024 and 2048 sizes. The city marker doesn't even show up on the moon. :(

Avatar
selden
Developer
Posts: 10190
Joined: 04.09.2002
With us: 22 years
Location: NY, USA

Re: Tutorial: placing a tile on a planetary surface.

Post #10by selden » 14.05.2009, 10:02

VTs need to include all of the intermediate empty directories, too, even though they don't contain any tiles. Celestia stops scanning VT directories when it can't find one. In other words, you need to create the directories level1 through level8, but you don't need to put any tiles in them.
Selden

Reiko
Posts: 1119
Joined: 05.10.2006
Age: 41
With us: 17 years 11 months
Location: Out there...

Re: Tutorial: placing a tile on a planetary surface.

Post #11by Reiko » 14.05.2009, 11:05

selden wrote:VTs need to include all of the intermediate empty directories, too, even though they don't contain any tiles. Celestia stops scanning VT directories when it can't find one. In other words, you need to create the directories level1 through level8, but you don't need to put any tiles in them.
Added those and still doesn't work. I doubled and tripled check to make sure each folder was named properly. :(

Image

Avatar
selden
Developer
Posts: 10190
Joined: 04.09.2002
With us: 22 years
Location: NY, USA

Re: Tutorial: placing a tile on a planetary surface.

Post #12by selden » 14.05.2009, 11:17

Sorry, I overlooked your statement
The city marker doesn't even show up on the moon.
That means there is a typo in the definition of the city in its SSC file, of a type which makes the entire definition invalid.

If you turn on Celestia's "console log" by typing a ~ (tilde)
it often shows the line number which has the problem.

I must admit that I don't see anything wrong with the example that you provided.
However, instead of making it a Location, I'd suggest making it an object with a Radius -- just for visibility.

Locations can't be seen until you enable rendering of locations, and are close enough to its specified position.
Selden

Reiko
Posts: 1119
Joined: 05.10.2006
Age: 41
With us: 17 years 11 months
Location: Out there...

Re: Tutorial: placing a tile on a planetary surface.

Post #13by Reiko » 14.05.2009, 12:59

Something has to be wrong with the textures. I even looked at other VTs I have installed and found out that the brackets in the SSC and CTX files should be { instead of ( still nothing works. I tried renaming the folders and nope.

EDIT:
The problem is certainly not in the SSC file. I removed the VT directories and put one 4k texture into medres and pointed the ssc file to it and it works. The marker shows up and I see a texture on the moon. So the breakdown is either in the ctx file or the textures in the VT directory.

EDIT 2:
Works now. I copied and pasted SSC files from other VT addons and just changed the names. What I was missing before I still don't know. :lol:

Thank you for the help guys. :)

Avatar
Topic author
jogad
Posts: 458
Joined: 17.09.2008
With us: 15 years 11 months
Location: Paris France

Re: Tutorial: placing a tile on a planetary surface.

Post #14by jogad » 15.05.2009, 11:11

Hello,

Hi,

Reiko, glad to see that it works for you! :)
T00fri, Selden, thanks for the help you provide on this tutorial. :)

Reiko wrote:The only steps that confuse me were these two.

-If you already have an image, adjust it to the size indicated (here 1045 pixels wide by 915 pixels high). Otherwise create directly your image with the size specified for the canvas below and skip the next step.

- Enlarge the frame as indicated (1774 x 2048), leaving the original image centered. You will need to complete the border added. For example, I added some grass around. Indeed it is not possible that part of the tile is transparent.
The lines in the yellow-orange rectangle are intended to respect the exact dimensions (in meters or kilometers) of your original picture. And the final image resize is to make a correction to the latitude deformation.

If I understand well, you had an already made texture whose dimensions were 2048x208 pixels but with no actual definite dimensions. I suppose that because you have left my original example dimensions in your calc sheet.
And at the chosen latitude, the deformation is very little but if you look carefully the image is not square in Celestia.
With that, your picture is not 0.83km by 0.73km but 1.2km by 1.219 km.
If I am wrong just describe your original picture with its dimensions (or show it) and I will try to explain how to do with it.

t00fri wrote:just in passing: your TileSize is highly incorrect. You forgot to modify it from Jogad's example:

You need

TileSize 2048
(or just a little smaller, like TileSize 1024)
This is of course badly inexact with a complete virtual texture. But in this particular case there are only 3 tiles in the whole VT and no risk to overload the computer. Actually 64k is the smallest allowed size. This value lets see the tile from higher quote.

selden wrote:VTs need to include all of the intermediate empty directories, too, even though they don't contain any tiles. Celestia stops scanning VT directories when it can't find one. In other words, you need to create the directories level1 through level8, but you don't need to put any tiles in them.
I don’t know if this is true on all platforms but at least on Windows and with celestia 1.5.1 and 1.60 that works well without intermediate levels. :?:

selden wrote:However, instead of making it a Location, I'd suggest making it an object with a Radius -- just for visibility.
Of course :blue: knows how to do that! But I don't :oops:
With a Location it is very easy. Don't forget to set the Labels features and the cities options on in the Locations... dialog.
Then from everywhere in the solar system type:
"Enter"  "Mimas/Evac"  "Enter"
to select the location, and type "G". That's it! If you don't see your texture, perhaps it is on the dark side of the satellite. :wink:

Reiko wrote:Works now. I copied and pasted SSC files from other VT addons and just changed the names. What I was missing before I still don't know.
Good :D . Now I know why you failed. The problem WAS in the ssc files:
When I copied from my text editor, curly brackets were automatically converted into parenthesis 8O . I have edited this in the tuto.

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 22
With us: 22 years 5 months
Location: Hamburg, Germany

Re: Tutorial: placing a tile on a planetary surface.

Post #15by t00fri » 15.05.2009, 13:52

Good :D . Now I know why you failed. The problem WAS in the ssc files:
When I copied from my text editor, curly brackets were automatically converted into parenthesis 8O . I have edited this in the tuto.

How about changing your editor!?

Fridger
Image

Avatar
selden
Developer
Posts: 10190
Joined: 04.09.2002
With us: 22 years
Location: NY, USA

Re: Tutorial: placing a tile on a planetary surface.

Post #16by selden » 15.05.2009, 14:27

jogad,

Exactly what editor were you using?

There have been similar issues when people use "word processors" instead of "text editors" to edit Lua files. Word processors assume you are working on a document for publication. They automatically convert two hyphens (used in Lua to specify a one-line comment) into an em-dash (double-wide dash), which Lua doesn't recognize.
Selden

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 22
With us: 22 years 5 months
Location: Hamburg, Germany

Re: Tutorial: placing a tile on a planetary surface.

Post #17by t00fri » 15.05.2009, 15:03

selden wrote:jogad,

Exactly what editor were you using?

There have been similar issues when people use "word processors" instead of "text editors" to edit Lua files. Word processors assume you are working on a document for publication. They automatically convert two hyphens (used in Lua to specify a one-line comment) into an em-dash (double-wide dash), which Lua doesn't recognize.

I was precisely thinking of such cases, too. Lua and Maple, for example use { } parantheses a lot. I would never use anything that changes characters without asking me...

Fridger
Image

Avatar
Topic author
jogad
Posts: 458
Joined: 17.09.2008
With us: 15 years 11 months
Location: Paris France

Re: Tutorial: placing a tile on a planetary surface.

Post #18by jogad » 15.05.2009, 15:35

I usually use Notetab Pro or Notepad2 if I must have characters with accents and I have no problem with that. 8)

The problem for me is that when I want to post a message in English I use Microsoft Word which corrects a little part of my spelling and grammar mistakes in this language.
In this case the original curve brackets were in the text but were converted when I pasted in the input box of the forum. This is strange and maybe I did something wrong. :oops:

But thanks to you this error is fixed in the tuto.
I am interested to know if the two points that you emphasized (64k TileSize and lack of intermediate levels) may cause troubles on some systems? :?:

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 22
With us: 22 years 5 months
Location: Hamburg, Germany

Re: Tutorial: placing a tile on a planetary surface.

Post #19by t00fri » 15.05.2009, 17:06

jogad wrote:I am interested to know if the two points that you emphasized (64k TileSize and lack of intermediate levels) may cause troubles on some systems? :?:

I bet 64k tile size would indeed cause problems. Fortunately you had only written 64 (pixels). While we have agreed since a long time that making the tile size somewhat smaller than the actual size retains better focus in the interpolation between the various levels, I would be surprised if making them smaller by a factor of 32, doesn't have some negative impact...If it hasn't, then there would be no good reason why one should specify this parameter at all...

Fridger
Image

Avatar
Topic author
jogad
Posts: 458
Joined: 17.09.2008
With us: 15 years 11 months
Location: Paris France

Re: Tutorial: placing a tile on a planetary surface.

Post #20by jogad » 15.05.2009, 19:57

Sorry, I did not understand the 64 pixels. :oops: For me, the statement TileSize 64 means 64k. I am wrong?

I am well aware that this is a particular case. Indeed there are only 3 tiles in the texture virtual instead of several hundreds or thousands.
And there is no interpolation between the levels because we go directly from level 0 to level 9 or 10.

The aim was that the texture appears from more away to spot it more easily. 8)
With the declaration TileSize 64, it appears on my screen at a distance of 24km while with a statement TileSize 2048, it appears only at about 700m and it is not possible to see it entirely.
On my system 64 is the smallest possible value that works and that is why I have chosen it.
This value works well only in this particular case with a single tile at the highest level and 2 tiles at level 0.

This is precisely why the value of this parameter can be specified depending on conditions. Otherwise I agree it would be needless to precise it.

What I do not know is if this value is possible whatever the system. If this is not the case, I'll change the tuto. :wink:


Return to “Tutorials”