Terrain RAW Files

From Osgrid Wiki
Jump to: navigation, search

Tips for Creating Heightfields and Details on Terrain RAW Files

Land

Land in SecondLife is stored as a 2D grid of height values. This means the ground can never overlap, nor can there be made holes through the ground. The grid has a resolution of 1m in each direction, resulting in 256x256 grid points (0 to 255) per Simulator. It can be modified with the built-in terraforming tools or the LSL function llModifyLand. It can also be read using llGround. Land height between the grid points is interpolated, giving it a smooth look. The surface is textured, using multiple textures based on the land height and slope. Island owners can set their own ground textures and upload raw heightmaps in a special 13 channel RAW graphic file format (see below).

Land is either public (a rare sight now) or owned by agents or groups. Such land parcels consist of blocks with at a resolution of 4x4m size. Land owners can disallow the rezzing of objects or running scripts (effective up to 40m above ground). Sound can optionally be restricted to a parcel, with no sound leaving or entering it. Land parcels can have an audio stream associated with them.


Notes for Creating Height Field Maps for Second Life

As of Second Life v. 1.3, terrain height fields are created and uploaded into a new simulator via a 13 channel .raw graphics file. Each channel in the file contains specific information represented by a gray color value between 0 (black) and 255 (white). The size in pixels of 1 simulator's .raw file is 256x256. A simulator is 256x256 meters, so the resolution of the .raw file is 1 square meter per pixel.

You can view a .raw file in Photoshop. When opening the file you are prompted for and must specify the height and width of the file size in pixels, as well as the number of channels (13). Since bulk uploaded .raw files can be an arbitrary size (dimentions must be divisible by 256) and since the file will not load correctly unless these values are correct, it's important to keep track of the dimensions of the file. It's helpful to imbed the dimesion in the name of the file itself, for example "snowregion_hf_2560x1024_v2.raw". This information is required during for bulk sim upload. There should be no spaces in the raw file name since the raw file uploader utility can't handle spaces.


Here are how the 13 channels in the raw file are defined:

Channel Number Gray Value Range Description

     1(red) 0-255 Height Field

     2(green) 0-255 Height Multiply Factor

     3(blue) 0-255 Water Height of sim in Meters

     4 0-255 Land Parcels

     5 (alpha 1) 0 or 255 For Sale land

     6 (alpha 2) 0 or 255 Public Edit Object

     7 (alpha 3) 0 or 255 Public Edit Land

     8 (alpha 4) 0 or 255 Safe Land

     9 (alpha 5) 0 or 255 Flying Allowed

     10 (alpha 6) 0 or 255 Create Landmark

     11 (alpha 7) 0 or 255 Outside Scripts Allowed

     12 (alpha 8) 0-255 Original Heightfield

     13 (alpha 9) 0-255 Original Height Multiply Factor


Notes on Channels

  •      Channel 1(red) is the raw terrain heightfield data. In its simplest form it represents the ground height in meters of every point on the map, where black (grey level 0) is 0 meters high and white (grey level 255) is 255 meters high. However, the height of the terrain is often modified further by values in channel 2.
  •      Channel 2 (green) is a grayscale map that is used as a multiplier to scale the data in channel 1 resulting in the final height of each point on the map. The formula used to combine the 2 channels is not easily described, but a few examples will help to illustrate their interaction. "I was told by LindeLab a LONG time ago that 1.0 multiplier was set when this channel had a value of 127. A value of 255 would have a multiplier of 2.0, 63 would have a multiplier of 0.5, 31 would create a multiplier of 0.25, so on and so forth. *notice that the 0 counts, this is why all the power of 2s are offset by -1* -NexusNash" "From my research into this, the values are basically 0=0, 127=1, and 255=2 and basically my interpretation from the discussion is that the formula is basically red x (green/127) = output height though it might be more complex than that." -Ice Brodie"
  •      Channel 3 (blue) is a gray value that sets the water height of the sim in meters. A sim can only have 1 water height, so fill the entire channel with 1 value. The default water level found in Second Life is 20 meters. This is the level of all "void" water, as well as the water level on the vast majority of existing sims. The water level can be set to other values on a per sim basis, but this should only be done in special cases since it leaves a noticeable vertical gap between sims whose visible water edges abut but are not at the same level. The water channel is not affected by the multiply channel, so the maximum height of water is 255.
  •      Channel 4 is parcel info. While you can always subdivide and create parcels using the in-world tools, it may be more convenient to draw the parcels in this channel. Gray value 0 represents existing owned parcels, so on new land make sure there is nothing set to 0 on this channel. A Value of 255 sets the parcel as owned by the region owner. Each gray value represents a distinct parcel, so you can have up to 254 parcels specified per sim. Parcels in a sim that aren't connected but share the same gray value will be considered as part of the same parcel, so be careful. The resolution of parcels is in 4 square meters chunks of land, so even though the dimentions of the parcel channel is 256x256 pixels it is really only sampled at a resolution of 64x64.
  •      Channel 5 is a flag for if land is for sale or not. It should only have 2 values, 0 for no and 255 is yes. Default files for bulk sim upload fill this channel with 0.
  •      Channel 6 is a flag for if land allows public edit object or not. It should only have 2 values, 0 for no and 255 is yes. Default files for bulk sim upload fill this channel with 0.
  •      Channel 7 is a flag for if land allows public edit land or not. It should only have 2 values, 0 for no and 255 is yes. Default files for bulk sim upload fill this channel with 0.
  •      Channel 8 is a flag for if land is safe or not. It should only have 2 values, 0 for no and 255 is yes. Default files for bulk sim upload fill this channel with 255.
  •      Channel 9 is a flag for if land allows flying or not. It should only have 2 values, 0 for no and 255 is yes. Default files for bulk sim upload fill this channel with 255.
  •      Channel 10 is a flag for if land allows landmarks to be set to it or not. It should only have 2 values, 0 for no and 255 is yes. Default files for bulk sim upload fill this channel with 0.
  •      Channel 11 is a flag for if land allows outside scripts or not. It should only have 2 values, 0 for no and 255 is yes. Default files for bulk sim upload fill this channel with 255.
  •      Channel 12 stores the pristine height of the land, similar to channel 1. It is accessed when in-world tools are used to to "revert" land back to it's unaltered state. When new land is bulk uploaded and after any additional modifications have been made, Content "bakes" the sim prior to auction. Baking places the resulting height field data here. It works in conjuction with channel 13.
  •      Channel 13 stores the pristine multiply factor of the land, similar to channel 2. In conjunction with channel 12, It is accessed when in-world tools are used to "revert" land back to it's unaltered state. When new land is bulk uploaded and after any additional modifications have been made, Content "bakes" the sim prior to auction. Baking places the resulting multiply data here.



Misc. Tips for Creating Terrain:

  •      While tempting, creating a 512 meter high mountain on a 256 square meter sim usually leads to disappointing results. Ground textures will be stretched and tiled unrealistically. Draw distance setting on most people's machines means that if they stood on top of the mountain they couldn't see the ground below. Artifacts in the skybox and frame rate slowdown due to lots of overlapping clouds viewed close up will be apparent. Steep cliffs often tessellate poorly resulting in jaggy terrain, and entire mountains may disappear when viewed from a distance due to the lower level of detail. Many of these artifacts can be reduced or avoided by keeping the range of the elevation in a sim to within 50-100 meters. Similarly, any radical changes in height over a short distance will exhibit some of these artifacts, so design accordingly. "This was reported fixed, so this might no longer be valid"
  •      Many commercial and shareware tools exist for creating terrain files. Existing real world terrain data is also available from various sources that can be useful starting points for creating your own height fields.
  •      Blurring the terrain channel slightly often improves the visual quality of the ground in world.