DrawingStrategy
In this section you will learn about InputDrawingStrategy - a class that manages a whole Randomization Machine in
SkyRenderer and is responsible for passing to the Randomization Machine, how particular elements of the scene
should be randomized, synchronized and interpolated.
Agenda
- Drawing Strategy
- Drawing Rule
- Distribution
- Synchronization
- Interpolation
- Constant Value
- Predefined Drawing Strategies
Drawing Strategy
Drawing Strategy describes the way the random numbers are drawn in SkyRenderer. Drawing Strategy should be thought
of as a recipe, that tells randomization machine, how we want to randomize a scene, its content and different
traits. We can randomize such things as number of spawned objects, their transformation (translation, rotation,
scale), color, assigned textures, environment and many, many more - basically the majority of scene elements.
Even though we want to randomize things, yet there are a few aspects that we might want to control. Further, in
this case we will briefly walk through each aspect that Drawing Strategies allow to control:
- Drawing Rule - How values are drawn?
- Distribution - What distribution values that we draw from have?
- Synchronization - Are values for different objects synchronized and, if yes, how?
- Interpolation - Is interpolation between drawn values performed and, if yes, how?
- Constant Value - If using Drawing Rule supporting Constant Value, what is the value?
Drawing Rule
It is the principle of randomization machine behavior. It describes in what manner values are drawn. there are
six drawing rules. Dependent on the used drawing rule, other functionalities of DrawingStrategy become available
or unavailable to use:
- RANDOM - random value is drawn.
ENABLES: Distribution, Synchronization - SMOOTH - random value is drawn for key frames and interpolated between them, used for animation.
ENABLES: Distribution, Interpolation - CONSTANT_DEFAULT - default value is used.
- CONSTANT_VALUE - value provided in DrawingStrategy's Constant Value is used.
- PASS_FRAME_NUMBER - the frame number is used as the value, default for frames number from mesh animations.
Distribution
Probability function that modifies the probabilities for randomization outcomes. SkyRenderer has a few most common
distribution functions implemented natively:
- Uniform
- Gaussian
It is possible to implement custom distribution functions. In SkyRenderer such examples are variation of Gaussian
distribution:
- RandomGaussian
- RelativeGaussian
Synchronization
By default, all the values are drawn independently, but if you wish to link them together, you can use
DrawingStrategy to synchronize objects via DrawingStrategy and randomization groups. The objects can be either
forced to be the same, forced to be different or independent.
There are multiple types of synchronization available in SkyRenderer:
- UNRESTRICTED - no synchronization,
- UNIQUE - each element in the strategy is different,
- UNIQUE_IN_GROUP - each element inside a randomization group is different,
- EQUAL - each element in the strategy is equal,
- EQUAL_IN_GROUP - each element inside a randomization group is equal,
- DISTINCT_EQUAL_GROUPS - each element inside a randomization group is equal, but each randomization group
has a different value (each group is unique).
Interpolation
Works only for SMOOTH Drawing Rule. Specifies the interval between drawn keyframes, between which the value is
interpolated. Currently Linear Interpolation is only supported.
Constant Value
Value that is directly applied in case CONSTANT_VALUE Drawing Rule is used.
Predefined Drawing Strategies
There are some predefined Drawing Strategies, that are combinations of particular DrawingRules, Distributions and
Synchronizations. Some of them are:
- UniformRandomInput
- EqualEverywhereInput
- EqualInStrategyInput
- DifferentInStrategyInput
- ConstantInput
- SynchronizedInput
Summary
In this section you have learnt:
- InputDrawingStrategy class manages randomization machine in SkyRenderer.
- Multiple aspects can be managed with DrawingStrategy, such as way of drawing values, distributions,
synchronization and more. - There are some predefined Strategies for the most common use cases.