FilterFactory - Function "rst" (undocumented)

Back to function listing

UNDOCUMENTED! Sets a seed for rnd(). Parameter i has the range of 0..32767 .
Note: Modifies internal state

Syntax

rst(i)

Description

Sets a seed for rnd(a,b). i has the range of 0..32767. If the argument is not within this range, the operation "and 0x7FFF" will be applied to it to extract the low 15 bits.

The default seed is 0.

The return value of this function is always 0. So e.g. the formula "rnd(20)+x" would result in "x"

If rst(i) is called in Filter Factory, an internal Seed-Variable (RND_SEED) is set. It does NOT influence any calls of rnd(a,b), because a lookup-table needs to be built first. The building of the lookup-table is probably done before the processing of the first pixel (x,y,z=0). It is suspected that the call of rst(i) will take effect on the next calculation. Due to a bug (or feature?), the random state is not reset to its initial state (0) before the filter is applied. The preview image processing will modify the random state, and once the filter is actually applied (pressing "OK"), the random state that was set in the preview picture, will be used. This could be considered as a bug, but it is probably required, otherwise the call of rst(i) (inside the preview calculation) won't affect the rnd(a,b) in the real run. However, in a standalone filter without dialog/preview, there is no preview that could set the internal seed, so the rnd(a,b) functions will always work using the default seed 0, and only the subsequent calls will use the rst(i) of the previous call.

More information and disassembly, see Randomization procedures