{"id":849,"date":"2016-11-21T12:08:40","date_gmt":"2016-11-21T12:08:40","guid":{"rendered":"http:\/\/spaceengine.org\/ru\/?page_id=849"},"modified":"2020-04-25T20:26:38","modified_gmt":"2020-04-25T20:26:38","slug":"planet-textures","status":"publish","type":"page","link":"https:\/\/spaceengine.org\/manual\/making-addons\/planet-textures\/","title":{"rendered":"Planet textures"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><p>[vc_row row_type=\"row\" use_row_as_full_screen_section=\"no\" type=\"full_width\" text_align=\"left\" box_shadow_on_row=\"no\"][vc_column][no_accordion active_tab=\"1\" background_transparency=\"no\" style=\"boxed_accordion\"][no_accordion_section title=\"Planet textures\" accordion_type=\"accordion_icon\" icon_pack=\"font_elegant\" fe_icon=\"icon_cog\"][vc_column_text]<\/p>\n<p><b>CubeMap<\/b> is a software package for conversion of textures in a cylindrical projection to a quadrilateralized spherical cube projection (a cubemap projection for short). Supported any resolution of an input texture, any number of channels per pixel, 8-bit or 16-bit, signed or unsigned integers. The format of the input textures is <span class=\"se_path\">raw<\/span> (plain uncompressed data array). The format of the output texture is <span class=\"se_path\">raw<\/span> and\/or an array of tiles of different levels of detail in the <span class=\"se_path\">raw, tga, dds, jpg<\/span> or <span class=\"se_path\">png<\/span> format.<\/p>\n<p>Actual version: 1.16<\/p>\n<p>Download: <a href=\"\/\/spaceengine.org\/media\/2020\/04\/CubeMap_1_16.zip\">CubeMap 1.16<\/a><\/p>\n<p>Files:<\/p>\n<p><span class=\"se_path\">CubeMap.exe<\/span> - utility for conversion of textures in a cylindrical projection to a cubemap projection<br \/>\n<span class=\"se_path\">Glue.exe<\/span> - utility for gluing tiles into a single raw-file<br \/>\n<span class=\"se_path\">default_cub.ccf<\/span> - default configuration file for the CubeMap<br \/>\n<span class=\"se_path\">default_glue.gcf<\/span> - default configuration file for the Glue<\/p>\n<h4 class=\"se_h4\">The configuration file and command line<\/h4>\n<p>All parameters for the program are described in the <span class=\"se_path\">default_cub.ccf<\/span> file in the program's folder. It is a simple text file that contains a set of lines of the form:<\/p>\n<p><span class=\"se_script\">var value #comment<\/span><\/p>\n<p><span class=\"se_script\">var<\/span> - a name of a parameter, <span class=\"se_script\">value<\/span> - a value of a parameter, the sign # separates comments. A comment can be either in the beginning of the line (then the entire line is a comment), or in the end of line (after the parameter's value). The value can be of four types:<\/p>\n<p><span class=\"se_script\">string<\/span> - the string of characters without quotation marks and spaces;<br \/>\n<span class=\"se_script\">int<\/span> - an integer number;<br \/>\n<span class=\"se_script\">float<\/span> - a real number;<br \/>\n<span class=\"se_script\">bool<\/span> - a binary value: true or 1, false or 0.<\/p>\n<p>Both utilities can work with other configuration files, in case when they are passed to them as a command line parameter:<\/p>\n<p><span class=\"se_script\">CubeMap myconfig.ccf<br \/>\nGlue myconfig.ccf<br \/>\n<\/span><\/p>\n<p>In this case the file <span class=\"se_path\">default_cub.ccf<\/span> or <span class=\"se_path\">default_glue.ccf<\/span> is ignored. It is recommended to associate a <span class=\"se_path\">.ccf<\/span> files with the program <span class=\"se_path\">CubeMap.exe<\/span> in the system, then click on a <span class=\"se_path\">*.ccf<\/span> file will launch the <b>CubeMap<\/b>. A <span class=\"se_path\">*.ccf<\/span> files can be considered as a scripts for texture conversion with the <b>CubeMap<\/b> utility. The same is true for the <span class=\"se_path\">.gcf<\/span> extension used with the <b>Glue<\/b> utility.<\/p>\n<p>You can specify paths to the input file and output folder in the command prompt. In this case the corresponding parameters from the configuration files are ignored:<\/p>\n<p><span class=\"se_script\">CubeMap [myconfig.ccf] [-i InputFile] [-o OutFolder] [-o TempFolder] [-h]<br \/>\nGlue [myconfig.gcf] [-i InputFolder] [-o OutFile] [-h]<br \/>\n<\/span><\/p>\n<p>Option <span class=\"se_script\">-h<\/span> shows the prompt on the command line parameters.<\/p>\n<h4 class=\"se_h4\">Format of the planet textures in SpaceEngine<\/h4>\n<p>The path to the source cylindrical texture is specified by the <span class=\"se_script\">InputFile<\/span> parameter; the path to the output folder for the cubemap texture is specified by the <span class=\"se_script\">OutFolder<\/span>. If the path contains white spaces, it must be enclosed in quotation marks: \"the path with spaces.\" The <span class=\"se_script\">TempFolder<\/span> parameter specifies the path to the temporary folder, used by the utility to store a temporary files. If it is not specified, the temporary files will be stored in the <span class=\"se_script\">OutFolder<\/span>. If the folder does not exist, it is created automatically; inside it the subfolderl named <span class=\"se_path\">neg_x, neg_y, neg_z, pos_x, pos_y, pos_z<\/span> are created.<\/p>\n<p><img decoding=\"async\" src=\"\/\/spaceengine.org\/media\/2016\/11\/cylindrical.jpg\" alt=\"The cylindrical texture\" \/><\/p>\n<p>The source cylindrical texture should be in the <span class=\"se_path\">raw<\/span> format. The <span class=\"se_path\">raw<\/span> format is a plain two-dimensional array of pixels, the size and capacity (bit-depth) of which is described by the following parameters in the configuration file:<\/p>\n<p><span class=\"se_script\">InputWidth<\/span> - width of the source image<br \/>\n<span class=\"se_script\">InputHeight<\/span> - height of the source image<br \/>\n<span class=\"se_script\">InputChannels<\/span> - number of channels (Grayscale - 1, RGB - 3, RGBA - 4, etc.)<br \/>\n<span class=\"se_script\">Input16bit<\/span> - capacity (bit-depth): 16 or 8 bits per channel<br \/>\n<span class=\"se_script\">InputByteSwap<\/span> - for 16-bit only: true for little-endian (MAC), false for big-endian<br \/>\n<span class=\"se_script\">InputUnsigned<\/span> - for 16-bit only: true for unsigned, false for signed value<br \/>\n<span class=\"se_script\">InputLatOffset<\/span> - longitude offset, in degrees<\/p>\n<p>The cubic texture is a set of folders and files which are organized as follows:<\/p>\n<p><span style=\"font-family: courier;\"><br \/>\ncubemap ----------- folder specified in the OutFolder parameter<br \/>\nneg_x ----- folder of the neg_x face<br \/>\n0_0_0.jpg ----- 1 tile of the level 0<br \/>\n1_0_0.jpg --\\<br \/>\n1_0_1.jpg --+-- 4 tiles of the level 1<br \/>\n1_1_0.jpg --|<br \/>\n1_1_1.jpg --\/<br \/>\n2_0_0.jpg --\\<br \/>\n2_0_1.jpg --|<br \/>\n2_0_2.jpg --|<br \/>\n2_0_3.jpg --+-- 16 tiles of the level 2<br \/>\n2_1_0.jpg --|<br \/>\n2_1_1.jpg --|<br \/>\n2_1_2.jpg --|<br \/>\n2_1_3.jpg --|<br \/>\n.........<br \/>\nneg_y ----- folder of the neg_y face<br \/>\nneg_z ----- folder of the neg_z face<br \/>\npos_x ----- folder of the pos_x face<br \/>\npos_y ----- folder of the pos_y face<br \/>\npos_z ----- folder of the pos_z face<br \/>\n<\/span><\/p>\n<p>The cubemap texture consists of six faces, with names given to them in accordance with the semi-axes of the coordinate system, which they crosses. Let the origin is in the center of the planet. Then the Y-axis is passing through the poles of the planet: the North pole is in the <span class=\"se_path\">pos_y<\/span> face, the South pole is in the <span class=\"se_path\">neg_y<\/span> face. The X-axis is passing from left to right, i.e. the left face is <span class=\"se_path\">neg_x<\/span>, the right one is <span class=\"se_path\">pos_x<\/span>. The Z axis is passing towards the observer, i.e. the further face is <span class=\"se_path\">neg_z<\/span>, the closer face is <span class=\"se_path\">pos_z<\/span>. In the original cylindrical texture, this corresponds to: the upper bound is the North pole, the lower bound is the South pole, junction of the left and right boundaries runs vertically through the <span class=\"se_path\">neg_x<\/span> face, the central meridian runs vertically through the <span class=\"se_path\">pos_x<\/span> face, and the center of the cylindrical texture is located in the center of the <span class=\"se_path\">pos_x<\/span> face. Scan of the cubemap texture is standard:<\/p>\n<p><img decoding=\"async\" src=\"\/\/spaceengine.org\/media\/2016\/11\/cubemap.png\" alt=\"The cubemap texture\" \/><\/p>\n<p>Some planetary maps are not centered on the zero meridian. For example, it may run on the left boundary of the texture. In this case, you can set the longitude offset of 180\u00b0, to \"rotate\" the resulting cubic texture into the correct position: <span class=\"se_script\">InputLatOffset 180<\/span>.<\/p>\n<p>The resolution of cubemap faces is calculated as a quarter of the width of the original texture, rounded up to the nearest power of 2. For example if the original texture resolution is 86400 x 43200, it will give the resolution of each face of 32768 x 32768 (131072\/4).<\/p>\n<p>Each face is organized as a set of tiles. Resolution of the tile is determined by the parameter <span class=\"se_script\">TileWidth<\/span> and must be no more than the resolution of the face. For example, if <span class=\"se_script\">TileWidth<\/span> = 512, and the resolution of the face is 32768, then we'll have 7 levels of tiles: Log2(32768\/512) + 1 = 7. The levels are numbered from 0 to 6; the number of level is the first digit in the file name of the tile: (<span class=\"se_path\">0_0_0.jpg<\/span>, ..., <span class=\"se_path\">6_63_63.jpg<\/span>). The total resolution of each level is doubled sequentially, and the number of tile files is quadruplicating. Thus, we will have one tile of the level 0 (<span class=\"se_path\">0_0_0.jpg<\/span>) with resolution of 512 x 512. It will have the reduced image of the whole face. There will be 4 tiles of the level 1 (<span class=\"se_path\">1_0_0.jpg ... 1_1_1.jpg<\/span>), each comprising a quarter of the entire face image. Resolution of each tile is again 512 x 512, thus the common resolution of the level 1 will be 1024 x 1024. The level 2 will have 16 tiles, and so on. The end (most detailed) level 6 will have 64 * 64 = 4096 tiles (512 x 512 each), with total resolution of 32768 x 32768. The second and third digits in the tile's file name are vertical (v) and horizontal (u) indices. Indexing is carried out from the left to the right and from the top to the bottom. Here is the example picture of the first three levels (with tile resolution of 128 x 128):<\/p>\n<p><span style=\"font-size: 20pt;\"><span style=\"color: #ff00ff;\">level 0<\/span><\/span><br \/>\n<img decoding=\"async\" src=\"\/\/spaceengine.org\/media\/2016\/11\/level0.jpg\" alt=\"Level 0\" \/><\/p>\n<p><span style=\"font-size: 20pt;\"><span style=\"color: #ff00ff;\">level 1<\/span><\/span><br \/>\n<img decoding=\"async\" src=\"\/\/spaceengine.org\/media\/2016\/11\/level1.jpg\" alt=\"Level 1\" \/><\/p>\n<p><span style=\"font-size: 20pt;\"><span style=\"color: #ff00ff;\">level 2<\/span><\/span><br \/>\n<img decoding=\"async\" src=\"\/\/spaceengine.org\/media\/2016\/11\/level2.jpg\" alt=\"Level 2\" \/><\/p>\n<h4 class=\"se_h4\">The CubeMap utility<\/h4>\n<p>Converting of the source cylindrical texture to the tiled cubemap texture is performed in several stages. It is possible to perform conversion for certain faces only. This is controlled by the following parameters in the configuration file (setting the parameter to <span class=\"se_script\">false<\/span> or <span class=\"se_script\">0<\/span> disables all stages for the corresponding face):<\/p>\n<p><!--uzcode--><\/p>\n<div class=\"bbCodeBlock\">\n<div class=\"bbCodeName\" style=\"padding-left: 5px; font-weight: bold; font-size: 7pt;\">Code<\/div>\n<div class=\"se_code\" style=\"border: 1px inset; max-height: 200px; overflow: auto;\"><!--uzc-->Create_NEG_X 1<br \/>\nCreate_POS_X 1<br \/>\nCreate_NEG_Y 0 # this face will be skipped<br \/>\nCreate_POS_Y 0 # this face will be skipped<br \/>\nCreate_NEG_Z 1<br \/>\nCreate_POS_Z 1<!--\/uzc--><\/div>\n<\/div>\n<p><!--\/uzcode--><\/p>\n<p>Execution of any stage can be disabled by setting the appropriate parameter in the config to <span class=\"se_script\">false<\/span> or <span class=\"se_script\">0<\/span> (see below):<\/p>\n<p><!--uzcode--><\/p>\n<div class=\"bbCodeBlock\">\n<div class=\"bbCodeName\" style=\"padding-left: 5px; font-weight: bold; font-size: 7pt;\">Code<\/div>\n<div class=\"se_code\" style=\"border: 1px inset; max-height: 200px; overflow: auto;\"><!--uzc-->CreateBaseTex\u00a0\u00a0\u00a01\u00a0\u00a0\u00a0# create a base texture<br \/>\nComputeFaces\u00a0\u00a0\u00a0\u00a01\u00a0\u00a0\u00a0# process selected faces (compute temporary raw-files of the latest level)<br \/>\nDownsizeFaces\u00a0\u00a0\u00a01\u00a0\u00a0\u00a0# compute LODs of selected faces (compute temporary raw-files of other levels back to 0)<br \/>\nTileFaces\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a01\u00a0\u00a0\u00a0# split temporary raw-files of the selected faces into tiles<br \/>\nOptimizeTiles\u00a0\u00a0\u00a00\u00a0\u00a0\u00a0# delete homogeneous tiles<!--\/uzc--><\/div>\n<\/div>\n<p><!--\/uzcode--><\/p>\n<p>Lets look at all the steps in order.<\/p>\n<h5 class=\"se_h5\">1) Creating a base cylindrical texture<\/h5>\n<p>To perform this operation, the configuration file must have <span class=\"se_script\">CreateBaseTex 1<\/span>.<\/p>\n<p><b>SpaceEngine<\/b> uses a special small cylindrical texture (called the \"base texture\") to render planets which are far away from the camera. Creating this texture is implemented by simple downsampling of the source cylindrical texture by averaging pixels in square blocks. The resolution of the base texture is the same as the resolution of tiles (<span class=\"se_script\">TileWidth<\/span>). The <span class=\"se_script\">BaseTexFormat<\/span> parameters specifies the format of the base texture.<\/p>\n<h5 class=\"se_h5\">2) Computing faces of the cubemap texture<\/h5>\n<p>To perform this operation, the configuration file must have <span class=\"se_script\">ComputeFaces 1<\/span>.<\/p>\n<p>The conversion is performed by bilinear filtering: to derive the color of the current pixel in the face, the floating-point coordinates of the corresponding point in the cylindrical texture are computed, and the color is obtained by a linear interpolation of the four pixels closest to this point. This method gives a very good result, the artifacts may be noticeable only at the poles.<\/p>\n<p>The program uses a cache memory for storing parts of the original cylindrical texture. It is therefore possible to perform complete transformation of original texture without loading it into memory. This is great for large textures, such as NASA Earth texture <b>Blue Marble Next Generation<\/b>, witch has a size of 86400 x 43200 x 3 = 10.4 GiB. If system has enough free RAM at the moment of the Cubemap start to load the source texture, it will do that. Otherwise the cache will be used. Cubemap will allocate as much RAM for the cache as possible, or amount, specified by MaxMem parameter in the config, if free memory is too small. In case of using cache, processing speed will be slower, because Cubemap will load chunks of the source file multiple times.<\/p>\n<p>A temporary subfolder called <span class=\"se_path\">raw<\/span> will be created in the temporary folder specified by the <span class=\"se_path\">TempFolder<\/span> parameter. Inside it, subfolders <span class=\"se_path\">neg_x, neg_y, neg_z, pos_x, pos_y, pos_z<\/span> will be created, where raw-files of the corresponding cubemap faces will be saved. In our example, each face raw-file will have a name of <span class=\"se_path\">level6.raw<\/span> (because we will have 7 levels, starting from 0), with resolution of 32768 o 32768.<\/p>\n<p>If the <span class=\"se_script\">TileBorder<\/span> parameter is set to 2, a border 2 pixel-wide is added to the perimeter of each tile. This border contains pixels from adjacent tiles. The resolution of tiles remains the same, i.e. border pixels are added from inside, with corresponding scaling of the central part of the tile texture. The temporary file level*.raw will have the same resolution as well, in our example, it will be 32768 x 32768.<\/p>\n<p>Additional pixels make it easy to eliminate gaps in the landscape and sharp borders at the junction of textures when rendering in SpaceEngine using linear filtering. It is important to save tiles in lossless format for elevation map texture in this case. Best of all is 16-bit png.<\/p>\n<p>The elevation maps (<span class=\"se_script\">InputChannels 1<\/span>) can use normalization, i.e. changing values so they implements the full dynamic range of the bit-deepness. For example, 16-bit elevation map <span class=\"se_path\">gebco_bathy.21601x10801.bin<\/span> have a minimum and maximum pixel values of -10577 and 8430, that does not fully implements the dynamic range of a 16-bit integers (-32768 ... 32767). Specifying the <span class=\"se_script\">Normalize true<\/span> enables normalization. In that case, if the parameter <span class=\"se_script\">EnterNormData<\/span> is set to <span class=\"se_script\">false<\/span>, the minimum and maximum values are searched by scanning all pixels in the source cylindrical texture. For large textures it can take considerable time, so it is enough to perform this search once, then set <span class=\"se_script\">EnterNormData true<\/span> and enter the data that the program derived in the previous launch:<\/p>\n<p><!--uzcode--><\/p>\n<div class=\"bbCodeBlock\">\n<div class=\"bbCodeName\" style=\"padding-left: 5px; font-weight: bold; font-size: 7pt;\">Code<\/div>\n<div class=\"se_code\" style=\"border: 1px inset; max-height: 200px; overflow: auto;\"><!--uzc--><br \/>\nNormalize&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;true&nbsp;&nbsp;&nbsp;# normalize the output image (the height map)<br \/>\nEnterNormData&nbsp;&nbsp;&nbsp;true&nbsp;&nbsp;&nbsp;# true to enter the normalization data manually, false to find them automatically<br \/>\nNormMinValue&nbsp;&nbsp;&nbsp;&nbsp;-10577&nbsp;# minimum pixel value<br \/>\nNormMaxValue&nbsp;&nbsp;&nbsp;&nbsp;8430&nbsp;&nbsp;&nbsp;# maximum pixel value<br \/>\nNormIgnoreValue&nbsp;-32768&nbsp;# skip this value while reading normalization data<!--\/uzc--><\/div>\n<\/div>\n<p><!--\/uzcode--><\/p>\n<p>Some maps uses special value to mark \"no data\" pixels. This may break out reading of normalization data. For example, if your map is 16-bit signed integer, you may find what normalization data reading stage reports <span class=\"se_script\">NormMinValue<\/span> of -32768, while you know what real heights on this map starts from something like -10000. In this case, specify <span class=\"se_script\">NormIgnoreValue -32768<\/span>. This will tell the program to ignore this value during normalization data reading stage.<\/p>\n<h5 class=\"se_h5\">3) Computing a LODs of faces<\/h5>\n<p>To perform this operation, the configuration file must have <span class=\"se_script\">DownsizeFaces 1<\/span>.<\/p>\n<p>A consequential 2-times downscaling of the temporary raw-file is performed, resulting in appearing of files (in our example) <span class=\"se_path\">level5.raw, level4.raw, level3.raw, level2.raw, level1.raw, level0.raw<\/span> in the temporary folder, with a resolution of 16384 x 16384 to 512 x 512 respectively.<\/p>\n<h5 class=\"se_h5\">4) Splitting the temporary raw-files into tiles<\/h5>\n<p>To perform this operation, the configuration file must have <span class=\"se_script\">TileFaces 1<\/span>.<\/p>\n<p>The temporary files are split into the tiles with the resolution of <span class=\"se_script\">TileWidth x TileWidth<\/span>, and are saved to the folder named after face, in one of the following formats:<\/p>\n<p><span class=\"se_path\">raw<\/span> - 8 or 16 bits, any number of channels, no compression<br \/>\n<span class=\"se_path\">tga<\/span> - 8 bits, 1, 3, 4 channels, no compression<br \/>\n<span class=\"se_path\">dds<\/span> - 8 bits, 1, 3, 4 channels, no compression<br \/>\n<span class=\"se_path\">jpg<\/span> - 8 bits, 1, 3, channels, lossy compression<br \/>\n<span class=\"se_path\">tif<\/span> - 8 or 16 bits, 1, 3, 4 channels, lossy compression<br \/>\n<span class=\"se_path\">png<\/span> - 8 or 16 bits, 1, 3, 4 channels, lossless compression<\/p>\n<p>The tile format is described by the following parameters:<\/p>\n<p><span class=\"se_script\">OutFormat<\/span> - the tile format (raw, tga, dds, jpg, tif, png)<br \/>\n<span class=\"se_script\">OutFormat2<\/span> - the tile format (raw, tga, dds, jpg, tif, png) for the low-byte, or for the alpha-channel (see SeparateHiLo and SeparateRGBA)<br \/>\n<span class=\"se_script\">TileWidth<\/span> - the tile resolution, default for SE: 256<br \/>\n<span class=\"se_script\">TileBorder<\/span> - the width of a border with additional pixels, default for SE: 2<br \/>\n<span class=\"se_script\">Out16bit<\/span> - capacity (bit-depth): 16 or 8 bits per channel (16 is allowed only for raw and png)<br \/>\n<span class=\"se_script\">OutByteSwap<\/span> - for 16-bit only: true for little-endian (MAC), false for big-endian<br \/>\n<span class=\"se_script\">OutUnsigned<\/span> - for 16-bit only: true for unsigned, false for signed value<br \/>\n<span class=\"se_script\">OutInvertAlpha<\/span> - invert the alpha channel for the RGBA images<br \/>\n<span class=\"se_script\">OutJPEGquality<\/span> - the quality of saving into JPEG (0...100)<br \/>\n<span class=\"se_script\">SeparateRGBA<\/span> - save RGBA tiles as a two separate files: RGB and alpha<br \/>\n<span class=\"se_script\">SeparateHiLo<\/span> - save 16-bit tiles as a two separate files: the high-byte and the low-byte<br \/>\n<span class=\"se_script\">MaxOversampling<\/span> - don't save tiles of the last level it its oversampling rate is greater than this value<\/p>\n<p>The <span class=\"se_script\">MaxOversampling<\/span> parameter is used to avoid generating of tiles with excessive resolution. This saves conversion time and disk space. For example, if the original texture had a resolution of 36000x18000, it will be effectively upscaled to the nearest power of two upwards, i.e. 65536\u044532768. This will make the last level look very blurry; its oversampling rate will be 65536\/36000 = 1.82. If it is higher than the <span class=\"se_script\">MaxOversampling<\/span> value, raw files and tiles of this level will not be created (although internally <b>CubeMap<\/b> will work in the resolution of 65536).<\/p>\n<p>Another possible scenario for using this option is converting a texture with exact power-of-two dimensions (for example 32768x16384) and using a non-zero TileBorder. In this case, <b>CubeMap<\/b> will slightly stretch the original texture to a resolution of 32768 + 4 * (32768\/256) = 33280 to take into account the slight compression of the tile area visible in <b>SpaceEngine<\/b> (256 - 2 * 2 = 252 pixels). Therefore, the working resolution will be 65536 (the nearest greater power-of-two), and the oversampling value will be 65536\/33280 = 1.969. Without the use of <span class=\"se_script\">MaxOversampling<\/span>, these would create the last level of tiles that would look very blurry.<\/p>\n<p>To disable this limiting and save tiles of all levels, simply specify <span class=\"se_script\">MaxOversampling 2<\/span>.<\/p>\n<p>It is necessary to dwell on the parameters <span class=\"se_script\">OutFormat2<\/span>, <span class=\"se_script\">SeparateRGBA<\/span> and <span class=\"se_script\">SeparateHiLo<\/span>. <b>SpaceEngine<\/b> supports a special way to store RGBA texture of the planetary surface in the form of two separate texture files - a color files for the RGB components and a black-and-white files for the alpha channel. This can be used to save disk space. For example, the Earth surface requires RGBA textures with color specified in the RGB channels, and a water mask specified in the alpha channel. The compressed texture formats which support 4 channels (RGBA) are only <span class=\"se_path\">png<\/span> and <span class=\"se_path\">tif<\/span>. But files of these formats are quite large, while the color information in could be compressed in <span class=\"se_path\">jpg<\/span> with a sufficiently good quality, and the water mask could be compressed in the lossless <span class=\"se_path\">png<\/span> very well. Such a combined set of two textures <span class=\"se_path\">jpg<\/span> + <span class=\"se_path\">png<\/span> takes much less space than a single 4-channel <span class=\"se_path\">png<\/span>. To use this method, set the <span class=\"se_script\">SeparateRGBA true<\/span>, and specify the format for the RGB texture by the <span class=\"se_script\">OutFormat<\/span>, and for the alpha texture by the <span class=\"se_script\">OutFormat2<\/span>:<br \/>\n<!--uzcode--><\/p>\n<div class=\"bbCodeBlock\">\n<div class=\"bbCodeName\" style=\"padding-left: 5px; font-weight: bold; font-size: 7pt;\">Code<\/div>\n<div class=\"se_code\" style=\"border: 1px inset; max-height: 200px; overflow: auto;\"><!--uzc-->OutFormat\u00a0\u00a0\u00a0\u00a0jpg<br \/>\nOutFormat2\u00a0\u00a0\u00a0png<br \/>\nSeparateRGBA\u00a0true<br \/>\n<!--\/uzc--><\/div>\n<\/div>\n<p><!--\/uzcode--><br \/>\nWith this configuration, the <b>CubeMap<\/b> will save two files for each tile: the RGB file with the suffix <span class=\"se_path\">_c<\/span> and the alpha file with the suffix <span class=\"se_path\">_a<\/span>, for example:<br \/>\n<span class=\"se_path\">3_2_16_c.jpg<\/span><br \/>\n<span class=\"se_path\">3_2_16_a.png<\/span><\/p>\n<p>For the 16-bit elevation maps, it is also can be used the separation of the 16-bit tile image into two files: a low-byte and a high-byte. Sometimes saving them separately into a 8-bit files gives an advantage in size compared to saving in a single 16-bit image (<span class=\"se_path\">png<\/span> or <span class=\"se_path\">tif<\/span>). To do this, set the <span class=\"se_script\">SeparateHiLo true<\/span>, and specify the format for the high-byte texture by the <span class=\"se_script\">OutFormat<\/span>, and for the low-byte texture by the <span class=\"se_script\">OutFormat2<\/span>:<br \/>\n<!--uzcode--><\/p>\n<div class=\"bbCodeBlock\">\n<div class=\"bbCodeName\" style=\"padding-left: 5px; font-weight: bold; font-size: 7pt;\">Code<\/div>\n<div class=\"se_code\" style=\"border: 1px inset; max-height: 200px; overflow: auto;\"><!--uzc-->OutFormat\u00a0\u00a0\u00a0\u00a0png<br \/>\nOutFormat2\u00a0\u00a0\u00a0jpg<br \/>\nSeparateHiLo\u00a0true<br \/>\n<!--\/uzc--><\/div>\n<\/div>\n<p><!--\/uzcode--><br \/>\nWith this configuration, the <b>CubeMap<\/b> will save two files for each tile: the high-bytes file with the suffix <span class=\"se_path\">_h<\/span> and the low-bytes file with the suffix <span class=\"se_path\">_l<\/span>, for example:<br \/>\n<span class=\"se_path\">3_2_16_h.png<\/span><br \/>\n<span class=\"se_path\">3_2_16_l.jpg<\/span><\/p>\n<p><span class=\"se_warn\">Note:<\/span> the high-bytes must be saved in a lossless format, such as <span class=\"se_path\">png<\/span>. Otherwise, the terrain will have large artifacts! The lower-bytes may be saved in a format with lossy compression, such as <span class=\"se_path\">jpg<\/span>, but it also leads to artifacts. Only the combination of <span class=\"se_path\">png<\/span> + <span class=\"se_path\">png<\/span> does not gives the artifacts, and sometimes it makes an advantage in a file size; in this case when this method is recommended to use.<\/p>\n<p><b>SpaceEngine<\/b> automatically detects and loads the dual-file textures, no additional tweaking of the planet script is required.<\/p>\n<p><span class=\"se_warn\">WARNING:<\/span> if the tile files already exist in the folder, <span class=\"se_warn\">they will be overwritten!<\/span>.<\/p>\n<h5 class=\"se_h5\">6) Optimizing tiles<\/h5>\n<p>To perform this operation, the configuration file must have <span class=\"se_script\">OptimizeTiles 1<\/span>.<\/p>\n<p><b>SpaceEngine<\/b> supports the tiled cubemap textures with any level of detail in any place. This means that you can, for example, have an Earth texture with resolution of 6 x 32768 x 32768 (obtained from <b>Blue Marble Next Generation<\/b>), and in some places such as the Grand Canyon, the level detail can be improved by adding an additional tiles with higher levels. Or vice versa, the large homogeneous areas with no detail - the oceans - can have only lower-level tiles (from 0 to 2) with the rest removed, which saves the disk space and improves loading time. The <b>Cubemap<\/b> can try to identify such homogeneous areas and remove them. Thus, it is recommended to use this optimization only with texture with large homogeneous areas such as the oceans; it is not recommended to do that for other textures.<\/p>\n<p>Detecting of homogeneity is doing by calculating the variation of the pixel colors across the tile (the weighted sum of the absolute value of the difference between the color of a pixel and the average color of the tile). If this variation is less than the value specified by the parameter <span class=\"se_script\">MinVar<\/span> in the configuration file, the tile is considered homogeneous and is moved to a temporary location.<\/p>\n<p>The subfolder called <span class=\"se_path\">optimized<\/span> is created in the temporary folder specified by the <span class=\"se_path\">TempFolder<\/span> parameter. Inside it, the subfolders called <span class=\"se_path\">neg_x, neg_y, neg_z, pos_x, pos_y, pos_z<\/span> are created. A detected homogeneous tiles are moved into that subfolders. They are candidates for removal.<\/p>\n<p>A general guidelines for optimization are the next. After generating the tiles without optimization (<span class=\"se_script\">OptimizeTiles false<\/span>), start from some value <span class=\"se_script\">MinVar<\/span> and run <b>CubeMap<\/b> with <span class=\"se_script\">OptimizeTiles true<\/span> while the rest stages are disabled (parameters <span class=\"se_script\">CreateBaseTex<\/span> to <span class=\"se_script\">TileBaces<\/span> are set to <span class=\"se_script\">false<\/span>). It is better to do that for only one face, choosing it by the parameters <span class=\"se_script\">Create_NEG_X ... Create_POS_Z<\/span>. Next, look which tiles were moved to a temporary folder. If not satisfyingly, move the tiles back (manually), adjust the <span class=\"se_script\">MinVar<\/span> value, and repeat until you get an acceptable result. Then do the optimization of the other faces using the optimal value of the <span class=\"se_script\">MinVar<\/span> you have found.<\/p>\n<p>The MinOptLevel specifies from which level the optimization process should start. SpaceEngine requires at least 2-3 levels of textures even in flat areas like oceans to maintain sphere tessellation at a good level to prevent visual artifacts.<\/p>\n<p>The current version (1.16) does not use a good algorithm, so errors are possible - e.g. tile with a small island and homogeneous ocean around it can be considered as homogeneous, while the tile with a slight color gradient can be considered as heterogeneous. Therefore it is recommended to look at all the tiles in the temporary folder and move back those which seems to be not suitable for removal. It is also recommended to save these removed tiles somewhere, so you can quickly restore incorrectly deleted tiles, without launching again a full conversion process with the <b>CubeMap<\/b> (especially if the source cylindrical texture is large).<\/p>\n<p>Optimization is not supported for the dual-file tiles (<span class=\"se_script\">SeparateRGBA<\/span> or <span class=\"se_script\">SeparateHiLo<\/span>).<\/p>\n<h4 class=\"se_h4\">The Glue utility<\/h4>\n<p>The <b>Glue<\/b> utility is designed for glueing up the tiles back to a single raw-file. The utility has its own configuration file with the following parameters:<\/p>\n<p><span class=\"se_script\">InputFolder<\/span> - path to a folder with tiles<br \/>\n<span class=\"se_script\">OutFile<\/span> - path to an output raw-file<br \/>\n<span class=\"se_script\">TilePrefix<\/span> - string, a prefix in the file names of a tiles (the level number)<br \/>\n<span class=\"se_script\">TileExt<\/span> - string, an file name extension of a tiles<br \/>\n<span class=\"se_script\">StartU<\/span> - initial U (horizontal) tile index<br \/>\n<span class=\"se_script\">StartV<\/span> - initial V (vertical) index<br \/>\n<span class=\"se_script\">EndU<\/span> - final U (horizontal) tile index<br \/>\n<span class=\"se_script\">EndV<\/span> - final V (vertical) tile index<br \/>\n<span class=\"se_script\">SwapUV<\/span> - swap U and V indices<br \/>\n<span class=\"se_script\">TileWidth<\/span> - tile width<br \/>\n<span class=\"se_script\">TileHeight<\/span> - tile height<br \/>\n<span class=\"se_script\">TileBorderWidth<\/span> - width  of border in pixels, which Glue will skip<br \/>\n<span class=\"se_script\">TileBorderHeight<\/span> - height of border in pixels, which Glue will skip<br \/>\n<span class=\"se_script\">ChannelsPerPixel<\/span> - number of channels (Grayscale - 1, RGB - 3, RGBA - 4, etc.)<br \/>\n<span class=\"se_script\">BytesPerChannel<\/span> - bytes per channel: 1 for 8-bit, 2 for 16-bit, etc.)<\/p>\n<p>The tile file name has a form of: <span class=\"se_path\">TilePrefix_v_u.TileExt<\/span>; for example, for this configuration file:<\/p>\n<p><!--uzcode--><\/p>\n<div class=\"bbCodeBlock\">\n<div class=\"bbCodeName\" style=\"padding-left: 5px; font-weight: bold; font-size: 7pt;\">Code<\/div>\n<div class=\"se_code\" style=\"border: 1px inset; max-height: 200px; overflow: auto;\"><!--uzc--><br \/>\nTilePrefix\u00a05_<br \/>\nTileExt\u00a0\u00a0\u00a0\u00a0png<br \/>\nStartU\u00a0\u00a0\u00a0\u00a0\u00a02<br \/>\nStartV\u00a0\u00a0\u00a0\u00a0\u00a03<br \/>\nSwapUV\u00a0\u00a0\u00a0\u00a0\u00a0false<br \/>\n<!--\/uzc--><\/div>\n<\/div>\n<p><!--\/uzcode--><\/p>\n<p>the first tile will have a name <span class=\"se_path\">5_3_2.png<\/span>; the names of the next tiles will be obtained by increasing the indices u and v until values specified by <span class=\"se_script\">EndU\/EndV<\/span> is reached. Extension of <span class=\"se_path\">*<\/span> indicates that the program should look for a tiles in any of the supported formats, in the following order: <span class=\"se_path\">dds, png, jpg, jpeg, tif, tiff, tga, raw<\/span>. For example, if the folder contains the two files <span class=\"se_path\">3_1_2.jpg<\/span> and <span class=\"se_path\">3_1_2.tga<\/span>, the first one will be loaded.<\/p>\n<p>If the extension does not match one of the above, the tool switches to the raw-mode: the input tiles are considered to have the raw format, i.e. a simple uncompressed pixel arrays without a title. The extension can be <span class=\"se_path\">.raw, .img<\/span> or any other, renaming of the tiles to the <span class=\"se_path\">.raw<\/span> is not required. In the raw-mode, the number of channels (<span class=\"se_script\">ChannelsPerPixel<\/span>) and capacity (<span class=\"se_script\">BytesPerChannel<\/span>) are not limited. It can be used for glueing of arbitrary arrays of data (not necessarily a textures), as if they are a rectangular blocks. Tiles do not necessarily have to be square-shaped - thus the separate parameters <span class=\"se_script\">TileWidth<\/span> and <span class=\"se_script\">TileHeight<\/span> are provided.<\/p>\n<p>The <b>Glue<\/b> tool can skip borders on sides of the tiles (useful for merging back tile of some maps, processed by Cubemap before). The parameter <span class=\"se_script\">TileBorderWidth<\/span> defines width of the border, which will be skipped on both left and right sides of the tile; <span class=\"se_script\">TileBorderHeight<\/span> do the same for top and bottom sides.<\/p>\n<h4 class=\"se_h4\">The RawConv utility<\/h4>\n<p>The <b>RawConv<\/b> utility is a simple tool useful for preprocessing of the raw files. Usage:<\/p>\n<p><span class=\"se_script\"><br \/>\nRawConv [options] -i input_file -o out_file [-a alpha_file]<br \/>\n<\/span><\/p>\n<p>Options determines what operation are performed over the input_file:<\/p>\n<p><span class=\"se_script\">-t<\/span>: insert 8-bit grayscale image alpha_file into 8-bit RGB image input_file as an alpha channel.<br \/>\n<span class=\"se_script\">-s<\/span>: convert signed 16-bit image to unsigned 16-bit image or back.<br \/>\n<span class=\"se_script\">-b<\/span>: swap byte order of 16-bit image (convert between Mac and Windows format).<\/p>\n<p>The result is saved to out_file. All input and output files must be in raw format. Options <span class=\"se_script\">-s<\/span> and <span class=\"se_script\">-b<\/span> can be used together; their order defines order of operations performed on every 16-bit word of the input file.<\/p>\n<h4 class=\"se_h4\">General recommendations<\/h4>\n<p>1) Placing the source texture, the temporary folder and output folder on a different physical drives can significantly increase performance. Performance is also increased if the source file and temporary raw-files are defragmented.<\/p>\n<p>2) Write the information about the format of the source raw-texture in its name, for example: <span class=\"se_path\">Earth-surface-32k-RGBA.raw<\/span> is a RGBA texture of 32768 x 16384; <span class=\"se_path\">Mars-bump-16k-16bit.raw<\/span> is a 16-bit elevation map of 16384 x 8192. This will help to avoid confusion.<\/p>\n<p>3) Conversion of the texture of any format to the raw format can be done in the Photoshop, IrfanView and other programs. Using them can also view the temporary raw-files (if you have enough RAM so these programs were able to load large raw-files). Graphic editors do not understand images in the signed 16-bit format, therefore, it makes sense to convert such textures to unsigned 16-bit using RawConv.<\/p>\n<p>4) Save the configuration files for each converted texture, they can by useful in the future. Associate the <span class=\"se_path\">.ccf<\/span> file extension with the program <b>CubeMap.exe<\/b>, and the <span class=\"se_path\">.gcf<\/span> with the <b>Glue.exe<\/b> in the system, then double-click on a configuration file will automatically launch the corresponding utility. You can also drag and drop the configuration file on the shortcut of the <b>CubeMap<\/b> or <b>Glue<\/b>.<\/p>\n<p>5) It is recommended to view the result of conversion of the polar faces <span class=\"se_path\">pos_y<\/span> and <span class=\"se_path\">neg_y<\/span>, and, if there are noticeable artifacts present, edit the raw-files of the polar faces in the graphics editor. To do this, run the <span class=\"se_script\">ComputeFaces<\/span>, edit the raw-files, disable <span class=\"se_script\">ComputeFaces<\/span> and perform the rest operations.<\/p>\n<p>6) In order to avoid the loss of precision it is not recommended to normalize the height map, the dynamic range of which is \"almost implemented\", for example (1 ... 252) for the 8-bit and (-32000 ... 32000) for the 16-bit.<\/p>\n<p>7) If you want to save the tiles into a format not supported by the <b>Cubemap<\/b>, it is necessary to perform the conversion into a lossless format such as <span class=\"se_path\">tga<\/span>, and then perform a batch conversion of all tiles into the desired format using third-party software such as <b>IrfanView<\/b> or <b>ImageMagic<\/b>.<\/p>\n<p>[\/vc_column_text][\/no_accordion_section][\/no_accordion][\/vc_column][\/vc_row]<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>[vc_row row_type=\"row\" use_row_as_full_screen_section=\"no\" type=\"full_width\" text_align=\"left\" box_shadow_on_row=\"no\"][vc_column][no_accordion active_tab=\"1\" background_transparency=\"no\" style=\"boxed_accordion\"][no_accordion_section title=\"Planet textures\" accordion_type=\"accordion_icon\" icon_pack=\"font_elegant\" fe_icon=\"icon_cog\"][vc_column_text] CubeMap is a software package for conversion of textures in a cylindrical projection to a quadrilateralized spherical cube projection (a cubemap projection for short). Supported any resolution of an input texture,...<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":519,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-849","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/pages\/849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/comments?post=849"}],"version-history":[{"count":11,"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/pages\/849\/revisions"}],"predecessor-version":[{"id":3675,"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/pages\/849\/revisions\/3675"}],"up":[{"embeddable":true,"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/pages\/519"}],"wp:attachment":[{"href":"https:\/\/spaceengine.org\/wp-json\/wp\/v2\/media?parent=849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}