• Welcome to SC4 Devotion Forum Archives.

Technical data for the RGB importer tool for SCTF 1.1 and higher and SC4 Mapper

Started by moganite, December 21, 2006, 02:06:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

moganite

Technical Stuff.HTML
This file describes how the RGB scale for Wouanagaine's SCTF 1.1 and later works

The reason why this was done is to bypass the requirement of having photoshop 10 or another similarly expensive program to create and edit 16 bit grayscales.


How It works

The RGB scheme for importing can be though  of as a number system of sorts. It uses the three channels of an RGB image to emulate a 16 bit greyscale.

The number system is based on hexadecimal and has the blue representing the lower byte of the 16 bit  system the higher byte is represented by green and red with Red being the higher half of that Byte.   Writing the number as number of steps above RGB 0,0,0  FFFF  is the highest possible step being 65536 steps higher than 0000.

Table removed refer to  Simtropolis Forum Tech data for SCTF RGB import

Each blue represents 0.1 m for each blue and rolls over ever 25.6 m
Each green state is 16 Greens higher and 25.6m than the previous one and rolls over every 409.6 m.
Each Red State is 16 Reds and 409.6m than the previous one.

The lowest State being Zero is also 0 in the Red and Green states and increments by 16 for each state stopping at 240 in each channel.


Now here gets the fun part Making a colour scale for Global mapper
With the spread sheet you should be able to see that the RGB and elevations are computed from a small number of variables

These are
Distance between each step
Start point at zero steps
Number of states for a "digit"  to go through its cycle.


You will see a number of coloured boxes along with 5 long columns The coloured boxes are
Orange: lowest elevation of terrain. If you want to make a scale for a higher elevation range just input the lowest elevation of your terrain. Useful if you have high altitude maps eg Mount Everest had a lowest point of 3000 m.

Yellow: vertical distance between each step you can use this to compress your image before import to SCTF.


Green: Smallest step of your GIS visualization program can resolve in the case of Global Mapper 0.000001 m or 1 micron.  This is used to round up values at the rollover point so you don't have noise. Leave it out and you will get Values that are not divisible by 16 in the RG chanels. This is at the start of every cycle apart from the first one as it is defined as 0,0,0 and all terrain lower than this should show as black.

It should be set at the elevation scale prescision that the program uses.

The reason we don't define every elevation explicitly is that the colour scale file would be 128 times larger if we define each elevation explicitly.

Formulas for Scale Creation


For the purpose of this table
X: distance between each step
Y: resolution of your GIS program
START as the starting elevation
S number of STEPs
R Red
G Green
B Blue

Table removed refer to  Simtropolis Forum Tech data for SCTF RGB import
The scale continues untill you get to RGB 240,240,255. Although you only need 60000 Steps for SCTF if the range is increased  you will be able to have a range of 65536 steps or 6.5536 km

The reason why you have the variable X is so that you can adjust the scale so that larger steps are taken this is especially useful if you have a terrain that has a relief larger than 6000 m.

Wouanagaine's SCTF import function uses the default values which came with this tool. It ignores the Round up line as that is only for the benefit of programs like Global mapper so that you don't have noise in your terrain that renders the terrain pitted. Y is the variable which controls the round up at the Rollover it rounds up to the next colour which is the next number and on the other side. Without this Global Mapper and other GIS programs would require that every colour be explicitly defined and the size of the colour scale file would be much larger.

The SCTF import function sets values without the rounding as all values are discrete and it assumes all Red and Green Values not divisible by 16 are null and sets those to 0,0,B which is the lowest band of the scale and has the range –250 m to -224.5m


CLR files

This file type is normally produced by a third party application called surfer and used for import to Global Mapper. If your program supports importing text file it will have something similar. However You will have to look up the system it uses if you arent using Global Mapper.

The CLR file template is located on Sheet 2 and is set up correctly and only the elevation numbers ever need to be changed if you want to make a scale with a different starting point.

The textile is a space delimited text file.

The structure of the file is

ColorMap          1    1
-250.000000      0    0        0
-224.500000      0    0     255

and continues down the page.

As you can see the file has a header ColorMap     1     1  and the elevation  is on the right. The template is contains only values and not formulae as formulae will cause problems with this file. The three columns to the right of the elevation column are the RGB values and these never change for our purposes.

As Stated earlier this is a plain text file So why don't we just manually input those numbers into a text editor and save? The awnser is Time and the risk of error typing in all those numbers.  Also the spreadsheet will calculate all the values if you want a new colour scale and will even back calculate from an elevation to give RGB values. Although the spreadsheet may take a while to make the work has already been put in and you don't need to do it because it has already been done for you.



Back Calculator

This little tool is for the calculation of the RGB values given a given number it is



Realistically I only expect this part to be only used for touching up images of terrains in preparation of imports.

The 2 values in the coloured boxes are the start elevation of your scale normally it is set to the same value as the default colour scale and will change if that changes. This is also true for the variable individual step size.

It calculates the RGB values by the below method

First calculate the number of Steps between the bottom of the scale and your elevation. This then passes through each channel.

Red channel
Number of steps/4096
The whole number is multiplied by 16 to give the Red value, the remainder is multiplied by 4096 and passed to the Green channel.

Green channel
Divide Red remainder by 255 and take the part left of the decimal point and multiply by 16. The remainder is passed to the blue channel which only multiplies by 255.
You then set this colour in your image editor.

Blue channel
Multiplies by 255

The RGB values are displayed in bordered Cells

ERRATA:
If the tables dont show correctly i dont know how to make the html tables tables here. The original document is part of the RGB  importer tool at ST uploaded by NHP and this was lifted directly from the mapping forum at ST. The table should look something like it does in those 2 sources. the reason a table was used is it was the best way to represent that info.
New Horizons Productions
Berethor ♦ beskhu3epnm ♦ blade2k5 ♦ dedgren ♦ dmscopio ♦ Heblem
jplumbley ♦ moganite ♦ M4346 ♦ Shadow Assassin ♦ Tarkus ♦ Vandy
wouanagaine

wouanagaine

Thx mog for this great resource

I point everyone to the SC4Terraformer development thread ( last page ) where the latest version of SC4TF can be download

If I recall correctly the one that is on the modds&download section at ST does not have thoses features


New Horizons Productions
Berethor ♦ beskhu3epnm ♦ blade2k5 ♦ dmscopio ♦ dedgren ♦ emilin ♦ Ennedi ♦ Heblem ♦ jplumbley
M4346 ♦ moganite ♦ Papab2000 ♦ Shadow Assassin ♦ Tarkus ♦ wouanagaine
Divide wouanagaine by zero and you will in fact get one...one bad-ass that is - Alek King of SC4