GenSurf Features

GenSurf produces a .map file consisting of triangular brushes arranged in a uniform grid. There are several advantages to using uniform-sized triangles rather than randomly-placed triangles:

  • Less brush fragmentation in Q2-engine games than an equivalently complex random arrangement (though the latest version can also produce non-rectangular meshes with the decimation feature).
  • Allows you to take advantage of hint brushes with the detail property to eliminate most, if not all, brush fragmentation. (See Detail/Hint brushes)

GenSurf-generated maps contain integer values for all brush coordinates (GenSurf uses integer coordinates by design - it doesn't simply round off floating point values to the nearest integer). This ensures compatibility with the widest variety of map editors, but much more importantly it minimizes the likelihood of roundoff errors causing gaps and/or overlaps between brushes.

GenSurf has several methods of generating surfaces. You may choose between canned trigonometric functions or a fractal surface, then lock specific vertices at a given value and specify the range away from that vertex that other vertices are effected. You can also import a bitmap image representing contour values. If you own Microsoft Excel 5.0, the latest version of GenSurf allows you to describe a surface with a mathematical function.

With the executable version you can use the "add skybox" option and append one surface to another, building a complete, ready-to-compile outdoor area with ground surface and surrounding cliff walls without opening a map editor.

Fix Points

You can use the "Fix Points" parameters to force specific vertices to values you enter. In addition, you can specifiy the range away from this vertex that other vertices are affected. Entering a 0 range results in a spike shape at this vertex. The shape of the hill or valley created with a fixed point is dependent on both this range and the "rate of change" entry. A value of 0 for "rate of change" results in a smooth sinusoidal curve, while negative values take on a spiked shape, and positive values become progressively more boxlike. The "rate of change" is forced to fit within the limits -30 to 30. To set the same value of more than one vertex at the same time, select each vertex with Ctrl+Click. Alternatively, you can select a rectangular range of vertices using Shift+Click. In either case, the value, range, and rate of change for all selected vertices will be the same.

 

Fractal surfaces

The procedure used by GenSurf for these surfaces is very simple, yet can produce very realistic outdoor ground surfaces. Simply put, the algorithm goes like this: starting with known values at the corners of the surface, use linear interpolation to find the values at the midpoints of each side, and add a random value multiplied by the distance between corners. After setting the midpoint values, use bilinear interpolation for the center point and again add a random number. The surface now has 4 rectangles with known values at the corners. Repeat this sequence recursively for each rectangle, until the sides of the rectangles are 1 grid square long. The multiplier for the random number produces large variations in early steps and progressively smaller variations in later steps - which is what we want for realistic terrain. NOTE: Not quite happy with the surface generated by GenSurf? Changing the random number seed will produce a completely different surface, so you've got 65536 possibilities.... first one to test them all gets a free lobotomy.

Ground surface generated with fractal method

NOTE: When using the "fix points" feature and fractal surfaces, it helps to keep in mind how the surface is generated. For example, fixing vertices at midpoints and quarter-points will have a much larger effect on the overall appearance than fixing the points immediately adjacent to those points.

 

Bitmaps

GenSurf will interpret a 256-color bitmap (.bmp) file as different values (elevations for a ground surface) for each color index. Although the program will work with any 256-color .bmp file, gray scale images are easier (for the user) to interpret. You supply a value corresponding to colors 0 and 255, and GenSurf uses linear interpolation to find values at vertex locations. Note that the aspect ratio of the bitmap is not taken into account: GenSurf maps the entire bitmap to the user-specified corners for the surface. Example:

 

Excel Formulas

If you have Microsoft Excel 5.0 or a later version installed on your system, you can make use of GenSurf's "Formula" waveform to describe a terrain surface mathematically. Any valid Excel formula may be used. The formula should be a function of the horizontal dimension (specified by H) and/or the vertical dimension (specified by V), and optionally the radius from the center of the grid ("radius"). The radius is obviously a derived characteristic that could be replaced by a function of H and V... it has been added for your convenience when making axisymmetric surfaces.

The surface depicted below was generated with the equation:

value=256-radius/4+128*sin(radius/128)

Conditionals are allowed in formulas and have the general syntax:

IF(test,if true,if false)

For example, following is a formula used to generate an ellipsoid on a 2048x2048 grid, centered at 0,0 with the vertical radius equal to 1/2 the radius in the horizontal direction:

value=IF(H^2+V^2<1048576,0.5*sqrt(1048576-H^2-V^2),0)

which could also be expressed as:

value=IF(radius<1024,0.5*sqrt(1048576-radius^2),0)

You must have Microsoft Excel 5.0 or later version installed on your system for this feature to function. For more information on valid Microsoft Excel formulas, search the Excel Help file for "Math and Trigonometry Functions".