RandomSeed Struct
Namespace: Stride.Core.MathematicsAssembly: Stride.Core.Mathematics.dll
The RandomSeed is a structure for deterministically acquiring random values. One RandomSeed should be able to reproduce the same pseudo-random value for a fixed offset, but provide enough random distribution for different offsets or different random seeds Although other methods exist, the current implementation can easily be replicated in the shaders if required
public struct RandomSeed
Name | Description | |
---|---|---|
Constructors | ||
RandomSeed(UInt32) | Initializes a new instance of the RandomSeed struct from a target uint. |
|
Methods | ||
GetDouble(UInt32) | Get a deterministic double value between 0 and 1 based on the seed |
|
GetFloat(UInt32) | Get a deterministic float value between 0 and 1 based on the seed The calculations are still made as doubles to prevent underflow errors. |
Constructors
RandomSeed(UInt32)
Initializes a new instance of the RandomSeed struct from a target uint.
public RandomSeed(uint seed)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | seed | The seed value to initialize the deterministic random generator. |
Methods
GetDouble(UInt32)
Get a deterministic double value between 0 and 1 based on the seed
public double GetDouble(uint offset)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | offset |
Returns
Type | Description |
---|---|
System.Double | Deterministic pseudo-random value between 0 and 1 |
GetFloat(UInt32)
Get a deterministic float value between 0 and 1 based on the seed The calculations are still made as doubles to prevent underflow errors.
public float GetFloat(uint offset)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | offset |
Returns
Type | Description |
---|---|
System.Single | Deterministic pseudo-random value between 0 and 1 |