| 1 |
Configuring 3D Clouds |
| 2 |
===================== |
| 3 |
|
| 4 |
3D clouds can be created in two ways: |
| 5 |
- By placing individual clouds using a command (e.g. from Nasal) |
| 6 |
- Using the global weather function, which reads cloud definition from |
| 7 |
an XML file. |
| 8 |
|
| 9 |
Placing Clouds Individually |
| 10 |
=========================== |
| 11 |
|
| 12 |
Clouds are created using the "add-cloud" command, passing a property |
| 13 |
node defining the location and characterstics of the cloud. |
| 14 |
|
| 15 |
Location is defined by the following properties: |
| 16 |
|
| 17 |
<layer> - The cloud layer number to add the cloud to. (default 0) |
| 18 |
<index> - A unique identifier for the cloud in the layer. If a cloud |
| 19 |
already exists with this index, the new cloud will not be |
| 20 |
created, and 0 is returned. |
| 21 |
<lon-deg> - Longitude to place the cloud, in degrees (default 0) |
| 22 |
<lat-deg> - Latitude t place the cloud, in degrees (default 0) |
| 23 |
<alt-ft> - Altitude to place the cloud, relative to the layer (!) in ft |
| 24 |
(default 0) |
| 25 |
<x-offset-m> - Offset in m from the lon-deg. +ve is south (default 0) |
| 26 |
<y-offset-m> - Offset in m from the lat-deg. +ve is east (default 0) |
| 27 |
|
| 28 |
The cloud itself is built up of a number of "sprites" - simple 2D textures |
| 29 |
that are always rotated to be facing the viewer. These sprites are handled |
| 30 |
by a OpenGL Shader - a small program that is run on your graphics card. |
| 31 |
|
| 32 |
The cloud is defined by the following properties: |
| 33 |
|
| 34 |
<min-cloud-width-m> - minimum width of the cloud in meters (default 500) |
| 35 |
<max-cloud-width-m> - maximum width of the cloud (default min-cloud-width-m*1.5) |
| 36 |
<min-cloud-height-m> - minimum height of the cloud (default 400) |
| 37 |
<max-cloud-height-m> - maximum height of the cloud (default min-cloud-height-m*1.5) |
| 38 |
<texture> - texture file of sprites to use (default cl_cumulus.png) |
| 39 |
<num-textures-x> - number of cloud textures defined horizontally in the |
| 40 |
texture file (default 4) |
| 41 |
<num-textures-y> - number of cloud textures defined vertically in the |
| 42 |
texture file (default 4) |
| 43 |
<height-map-texture> - whether to choose the vertical texture index based on |
| 44 |
sprite height within the clouds (default false) |
| 45 |
<num-sprites> - Number of sprite to generate for the cloud (default 20) |
| 46 |
<min-sprite-width-m> - minimum width of the sprites used to create the cloud |
| 47 |
(default 200) |
| 48 |
<max-sprite-width-m> - maximum width of the sprites used to create the cloud |
| 49 |
(default min-sprite-width-m*1.5) |
| 50 |
<min-sprite-height-m> - minimum height of the spites used to create the cloud |
| 51 |
(default 150) |
| 52 |
<max-sprite-height-m> - maximum height of the sprites used to create the cloud |
| 53 |
(default min-sprite-height-m*1.5) |
| 54 |
<z-scale> - vertical scaling factor to apply to to the sprite after |
| 55 |
billboarding. A small value would create a sprite that |
| 56 |
looks squashed when viewed from the side. (default 1.0) |
| 57 |
<min-bottom-lighting-factor> - See Shading below (default 1.0) |
| 58 |
<max-bottom-lighting-factor> - See Shading below (default min-...-factor + 0.1) |
| 59 |
<min-middle-lighting-factor> - See Shading below (default 1.0) |
| 60 |
<max-middle-lighting-factor> - See Shading below (default min-...-factor + 0.1) |
| 61 |
<min-top-lighting-factor> - See Shading below (default 1.0) |
| 62 |
<max-top-lighting-factor> - See Shading below (default min-...-factor + 0.1) |
| 63 |
<min-shade-lighting-factor> - See Shading below (default 0.5) |
| 64 |
<max-shade-lighting-factor> - See Shading below (default min-...-factor + 0.1) |
| 65 |
|
| 66 |
Shading |
| 67 |
------- |
| 68 |
|
| 69 |
the [min|max]-...-lighting-factor properties allow you to define diffuse lighting |
| 70 |
multipliers to the bottom, middle, top, sunny and shaded parts of the cloud. In |
| 71 |
each case, individual clouds will have a random multiplier between the min and |
| 72 |
max values used to allow for some variation between individual clouds. |
| 73 |
|
| 74 |
The top, middle and bottom lighting factors are applied based on the pixels vertical |
| 75 |
positon in the cloud. A linear interpolation is used either between top/middle (if |
| 76 |
the pixel is above the middle of the cloud) or middle/bottom (if the pixel is below |
| 77 |
the middle of the cloud). |
| 78 |
|
| 79 |
The top factor is also applied to _all_ pixels on the sunny side of the cloud. The |
| 80 |
shade factor is applied based on the pixel position away from the sun, linearly |
| 81 |
interpolated from top to shade. E.g this is not a straight linear interpolation |
| 82 |
from top to shade across the entire cloud. |
| 83 |
|
| 84 |
The final lighting factor is determined by the minimum of the vertical factor and |
| 85 |
the sunny/shade factor. Note that this is applied to the individual pixels, not |
| 86 |
sprites. |
| 87 |
|
| 88 |
Textures |
| 89 |
-------- |
| 90 |
|
| 91 |
The texture to use for the sprites is defined in the <texture> tag. |
| 92 |
To allow some variation, you can create a texture file containing multiple |
| 93 |
sprites in a grid, and define the <num-textures-x/y> tags. The code |
| 94 |
decides which texture to use for a given sprite : randomly in the x-direction |
| 95 |
and based on the altitude of the sprite within the cloud in the y-direction |
| 96 |
if <height-map-texture> is set. Therefore, you should put sprite textures |
| 97 |
you want to use for the bottom of your cloud at the bottom of the texture |
| 98 |
file, and those you want to use for the top of the cloud at the top of the |
| 99 |
texture file. |
| 100 |
|
| 101 |
For example, the following Nasal snippet will create a cloud immediately above the |
| 102 |
aircraft at an altitude of 1000 ft above /environment/clouds/layer[0]/elevation-ft : |
| 103 |
|
| 104 |
var p = props.Node.new({ "layer" : 0, |
| 105 |
"index": 1, |
| 106 |
"lat-deg": getprop("/position/latitude-deg"), |
| 107 |
"lon-deg": getprop("/position/longitude-deg"), |
| 108 |
"alt-ft" : 1000 }); |
| 109 |
fgcommand("add-cloud", p); |
| 110 |
|
| 111 |
Moving Individual Clouds |
| 112 |
======================== |
| 113 |
|
| 114 |
Clouds may be moved by using the "move-cloud" command. This takes the following |
| 115 |
property arguments. |
| 116 |
|
| 117 |
<layer> - The cloud layer number containing the cloud to move. (default 0) |
| 118 |
<index> - The unique identifier of the cloud to move. |
| 119 |
<lon-deg> - Longitude to place the cloud, in degrees (default 0) |
| 120 |
<lat-deg> - Latitude t place the cloud, in degrees (default 0) |
| 121 |
<alt-ft> - Altitude to place the cloud, relative to the layer (!) in ft |
| 122 |
(default 0) |
| 123 |
<x-offset-m> - Offset in m from the lon-deg. +ve is south (default 0) |
| 124 |
<y-offset-m> - Offset in m from the lat-deg. +ve is east (default 0) |
| 125 |
|
| 126 |
Deleting Individual Clouds |
| 127 |
=========================== |
| 128 |
|
| 129 |
Clouds may be deleted by using the "del-cloud" command. This takes the following |
| 130 |
property arguments. |
| 131 |
|
| 132 |
<layer> - The cloud layer number containing the cloud to delete. (default 0) |
| 133 |
<index> - The unique identifier of the cloud to delete. |
| 134 |
|
| 135 |
Global 3D Clouds |
| 136 |
================ |
| 137 |
|
| 138 |
The global weather system uses sets of clouds defined in |
| 139 |
FG_ROOT/Environment/cloudlayers.xml |
| 140 |
|
| 141 |
The file has 3 distinct sections: layers, cloud boxes and clouds, |
| 142 |
described below. |
| 143 |
|
| 144 |
Notes for those editing clouds: |
| 145 |
- All distances are in m. Note that this is in contrast to cloud heights |
| 146 |
in METAR etc. which are in ft. |
| 147 |
- The XML file is loaded into the properties system, so you can modify |
| 148 |
the settings in-sim, and see the results by re-generating the cloud |
| 149 |
layer. The simplest way to do this is to disable METAR, and control |
| 150 |
the cloud layers using the Clouds dialog, and in particular the coverage. |
| 151 |
- Texture files are in .png format, and have a transparent background. |
| 152 |
To make the textures easier to edit, create a black layer behind them, |
| 153 |
so there is some contrast between the background and the white cloud. |
| 154 |
Having a grid based on the texture dimensions also helps, so you don't |
| 155 |
bleed over the edges, which causes ugly sharp horizontal and vertical |
| 156 |
lines. |
| 157 |
|
| 158 |
Clouds |
| 159 |
====== |
| 160 |
|
| 161 |
The cloud definitions are as described above for placing individual |
| 162 |
clouds, but no position information is used (this is defined in the |
| 163 |
cloud box and layers below). |
| 164 |
|
| 165 |
Cloud Boxes |
| 166 |
=========== |
| 167 |
|
| 168 |
The <boxes> section contains definitions of groups of cloads,for example |
| 169 |
an entire towering CB mass. |
| 170 |
|
| 171 |
The <boxes> section contains a number of named types, which are referenced |
| 172 |
by the <layers> section, described below. Therefore, the names used are |
| 173 |
completely user-defined. |
| 174 |
|
| 175 |
Each of the named section consists of one or more <box> section, |
| 176 |
defining a particular cloud type |
| 177 |
|
| 178 |
Each <box> section contains the following tags: |
| 179 |
|
| 180 |
<type> - The cloud to use, defined above |
| 181 |
<count> - The number of clouds to generate (+/- 50%) |
| 182 |
<width> - The x and y within which these clouds should be generated |
| 183 |
<height> - The height within which the clouds should be generated |
| 184 |
<hdist> - The horizontal distribution of the clouds within the area. |
| 185 |
Equates to a sum of random distributions. Defaults to 1. |
| 186 |
1 = even distribution, 2 = distributed towards the center. |
| 187 |
3 = very strongly distributed towards the center. |
| 188 |
<vdist> - The vertical distribution of the clouds. As for hdist. |
| 189 |
|
| 190 |
|
| 191 |
If the /sim/rendering/clouds3d-density is less than 1.0 (100%), then a |
| 192 |
proportional number of clouds will be displayed. |
| 193 |
|
| 194 |
The following example shows a stratus cloud group, which consists of 5 |
| 195 |
st-large clouds and 5 st-small clouds, distributed in a box 2000mx2000m, |
| 196 |
and 100m high, evenly distributed. |
| 197 |
|
| 198 |
<st> |
| 199 |
<box> |
| 200 |
<type>st-large</type> |
| 201 |
<count>5</count> |
| 202 |
<width>2000</width> |
| 203 |
<height>100</height> |
| 204 |
</box> |
| 205 |
<box> |
| 206 |
<type>st-small</type> |
| 207 |
<count>5</count> |
| 208 |
<width>2000</width> |
| 209 |
<height>100</height> |
| 210 |
</box> |
| 211 |
</st> |
| 212 |
|
| 213 |
|
| 214 |
Layers |
| 215 |
====== |
| 216 |
|
| 217 |
The <layers> section contains definitions for a specific layer type. |
| 218 |
The layer type is derived from the METAR/Weather settings by FG itself. |
| 219 |
|
| 220 |
Each layer type is a named XML tag, i.e.: ns, sc, st, ac, cb, cu. |
| 221 |
If a layer type is not defined, then a 2D layer is used instead. |
| 222 |
|
| 223 |
The layer type contains one or more <cloud> definitions. This |
| 224 |
defines a type of cloud box, and a weighting for that type (<count>). |
| 225 |
|
| 226 |
For example, the following XML fragment will produce 3 "cb" cloud boxes |
| 227 |
for every 1 "cu": |
| 228 |
|
| 229 |
<cloud> |
| 230 |
<name>cb</name> |
| 231 |
<count>3</count> |
| 232 |
</cloud> |
| 233 |
<cloud> |
| 234 |
<name>cu</name> |
| 235 |
<count>1</count> |
| 236 |
</cloud> |
| 237 |
|
| 238 |
Clouds are randomly distributed across the sky in the x/y plane, but the |
| 239 |
height of them is set by the weather conditions, with a random height range |
| 240 |
applied, defined by <grid-z-rand> |