SEED - Falloff function: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Tels (talk | contribs)
stub out
 
Tels (talk | contribs)
add clamp
Line 11: Line 11:
When setting '''falloff''' to '''func''', the probability that an entity will spawn is computed from a function given here:
When setting '''falloff''' to '''func''', the probability that an entity will spawn is computed from a function given here:


  p = s * (Xt * x + Yt * y + a)
  p = f( min, max, s * (Xt * x + Yt * y + a) )


whereas:
whereas:
Line 24: Line 24:
|p
|p
|resulting probability, clamped to the range 0 (no entity) and 1.0 (entity always appears)
|resulting probability, clamped to the range 0 (no entity) and 1.0 (entity always appears)
|-
|f
|Restricting function. Either "clamp" (default) (values < '''min''' are set to '''min''', values > '''max''' to '''max'''), or "zeroclamp" (values < '''min''' and > '''max''' are set to 0.0f)
|-
|min
|0 .. 1.0. Minimum value for '''p''', values lower than that get restricted (see "f").
|-
|max
|0 .. 1.0. Maximum value for '''p''', values greater than that get restricted (see "f").


|-
|-
Line 55: Line 67:
== Values ==
== Values ==


Possible values are for all parameters, constant floating point numbers (like "0.5", "-1.0", "-2" etc).
Possible values are for all parameters are given above, or otherwise are constant floating point numbers (like "0.5", "-1.0", "-2" etc).


For '''Xt''' and '''Yt''', the following values are possible (replace "X" with "Y" for y-axis):  
For '''Xt''' and '''Yt''', the following values are possible (replace "X" with "Y" for y-axis):  
Line 78: Line 90:




{{infobox|Note:<br> Make sure that the result of the function (p) is always in the range 0 .. 1.0. Values < 0 or greater than 1.0 will simply clamped to the range 0 .. 1.0. To ensure this, set '''func_s''' accordingly.}}
{{infobox|Note:<br> Make sure that the result of the function (p) is in the range 0 .. 1.0. Values < 0 or greater than 1.0 will simply clamped to the range 0 .. 1.0. To ensure this, set '''func_s''' accordingly.}}


Values that result in a range of f.i. 0.2 .. 0.8 '''do work''', though. This can f.i. be used to spawn less entities of one type than of another.
Values that result in a range of f.i. 0.2 .. 0.8 '''do work''', though. This can f.i. be used to spawn less entities of one type than of another.
Line 124: Line 136:
That means the probability only depends on the Y-axis, and not on the Y-axis. Here is how it looks in game:
That means the probability only depends on the Y-axis, and not on the Y-axis. Here is how it looks in game:


=== A triangle, with probability incr. along the axes ===
=== A triangle ===
 
This is also the default shape if you use '''func''':


<pre>
<pre>
Line 133: Line 143:
  "func_s" "0.5"
  "func_s" "0.5"
  "func_a" "0"
  "func_a" "0"
"func_min" "0.5"
"func_max" "1.0"
"func_f" "zeroclamp"
</pre>
</pre>


The resulting formula will be:
The resulting formula will be:


  p = 1 * (X * 1 + Y * Y * 1 + 0)
  p = Zeroclamp( 0.5, 1.0, 0.5 * (X * 1 + Y * 1 + 0) )


or simplified:
or simplified:


  p = 0.5 * (X + Y)
  p = Zeroclamp( 0.5, 1.0, 0.5 * (X + Y) )


== See also ==
== See also ==

Revision as of 19:49, 14 July 2010

Note: This is a design document and not actually implemented or available yet!

Introduction

The new LODE system can generate entities in random patterns, and the distribution is controlled by the spawnarg falloff. The normal values ("none", "cutoff", "square" and "exp") only generate entities in symmetrical patterns all over the place, but creating f.i. a triangle shaped distribution is not possible with them.

This article describes how to use the variant func to achieve such effects.

Parameters

When setting falloff to func, the probability that an entity will spawn is computed from a function given here:

p = f( min, max, s * (Xt * x + Yt * y + a) )

whereas:

Name Description
p resulting probability, clamped to the range 0 (no entity) and 1.0 (entity always appears)
f Restricting function. Either "clamp" (default) (values < min are set to min, values > max to max), or "zeroclamp" (values < min and > max are set to 0.0f)
min 0 .. 1.0. Minimum value for p, values lower than that get restricted (see "f").
max 0 .. 1.0. Maximum value for p, values greater than that get restricted (see "f").
s Scaling factor (default 0.5)
x Scaling factor for the X-coordinate (default 1.0)
y Scaling factor for the Y-coordinate (default 1.0)
a Additive factor (default 0.0)
Xt X coordinate, (default "X", running from 0 .. 1.0, automatically set)
Yt Y coordinate, (default "y", running from 0 .. 1.0, automatically set)

The parameters are set with the spawnargs having as prefix func_, so s is set with func_s.

Values

Possible values are for all parameters are given above, or otherwise are constant floating point numbers (like "0.5", "-1.0", "-2" etc).

For Xt and Yt, the following values are possible (replace "X" with "Y" for y-axis):

whereas:

Value Description
X the relative coordinate (0..1.0)
X*X the relative coordinate (0..1.0), multiplied with itself


Note:
Make sure that the result of the function (p) is in the range 0 .. 1.0. Values < 0 or greater than 1.0 will simply clamped to the range 0 .. 1.0. To ensure this, set func_s accordingly.

Values that result in a range of f.i. 0.2 .. 0.8 do work, though. This can f.i. be used to spawn less entities of one type than of another.

Examples

A ramp along the X axis

 "func_x" "1"
 "func_y" "0"
 "func_s" "1"
 "func_a" "0"
 "func_Xt" "X"

The resulting formula will be:

p = 1 * (X * 1 + Y * 0 + 0)

or simplified:

p = X

That means the probability only depends on the X-axis, and not on the Y-axis. Here is how it looks in game:

A ramp, squared along the Y axis

 "func_x" "0"
 "func_y" "1"
 "func_s" "1"
 "func_a" "0"
 "func_Yt" "Y*Y"

The resulting formula will be:

p = 1 * (X * 0 + Y * Y * 1 + 0)

or simplified:

p = Y * Y

That means the probability only depends on the Y-axis, and not on the Y-axis. Here is how it looks in game:

A triangle

 "func_x" "1"
 "func_y" "1"
 "func_s" "0.5"
 "func_a" "0"
 "func_min" "0.5"
 "func_max" "1.0"
 "func_f" "zeroclamp"

The resulting formula will be:

p = Zeroclamp( 0.5, 1.0, 0.5 * (X * 1 + Y * 1 + 0) )

or simplified:

p = Zeroclamp( 0.5, 1.0, 0.5 * (X + Y) )

See also