docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class SamplerUtility

    A set of utility functions for defining sampler interfaces

    Inheritance
    object
    SamplerUtility
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Perception.Randomization.Samplers
    Assembly: Unity.Perception.Runtime.dll
    Syntax
    public static class SamplerUtility

    Fields

    largePrime

    A large prime number

    Declaration
    public const uint largePrime = 539662031
    Field Value
    Type Description
    uint

    samplingBatchSize

    The number of samples to generate per job batch in an IJobParallelForBatch job

    Declaration
    public const int samplingBatchSize = 64
    Field Value
    Type Description
    int

    Methods

    AnimationCurveSample(float[], float, float, float, float)

    Generate samples from probability distribution derived from a given AnimationCurve.

    Declaration
    public static float AnimationCurveSample(float[] integratedCurve, float uniformSample, float interval, float startTime, float endTime)
    Parameters
    Type Name Description
    float[] integratedCurve

    Numerical integration representing the AnimationCurve

    float uniformSample

    A sample value between 0 and 1 generated from a uniform distribution

    float interval

    The interval at which the original AnimationCurve was sampled in order to produce integratedCurve

    float startTime

    The time attribute of the first key of the original AnimationCurve

    float endTime

    The time attribute of the last key of the original AnimationCurve

    Returns
    Type Description
    float

    The generated sample

    GenerateRandomSeed()

    Non-deterministically generates a non-zero random seed

    Declaration
    public static uint GenerateRandomSeed()
    Returns
    Type Description
    uint

    A non-deterministically generated random seed

    GetSamplerDisplayName(Type)

    Returns the sampler's display name

    Declaration
    public static string GetSamplerDisplayName(Type samplerType)
    Parameters
    Type Name Description
    Type samplerType

    The sampler type

    Returns
    Type Description
    string

    The display name

    Hash32(uint)

    Hashes using constants generated from a program that maximizes the avalanche effect, independence of output bit changes, and the probability of a change in each output bit if any input bit is changed. Source: https://github.com/h2database/h2database/blob/master/h2/src/test/org/h2/test/store/CalculateHashConstant.java

    Declaration
    public static uint Hash32(uint x)
    Parameters
    Type Name Description
    uint x

    Unsigned integer to hash

    Returns
    Type Description
    uint

    The calculated hash value

    Hash32NonZero(uint)

    Generates a 32-bit non-zero hash using an unsigned integer seed

    Declaration
    public static uint Hash32NonZero(uint seed)
    Parameters
    Type Name Description
    uint seed

    The unsigned integer to hash

    Returns
    Type Description
    uint

    The calculated hash value

    Hash64(ulong)

    Based on splitmix64: http://xorshift.di.unimi.it/splitmix64.c

    Declaration
    public static ulong Hash64(ulong x)
    Parameters
    Type Name Description
    ulong x

    64-bit value to hash

    Returns
    Type Description
    ulong

    The calculated hash value

    IntegrateCurve(float[], AnimationCurve)

    Numerically integrate a given AnimationCurve using the specified number of samples. Based on https://en.wikipedia.org/wiki/Numerical_integration and http://blog.s-schoener.com/2018-05-05-animation-curves/ Using the trapezoidal rule for numerical interpolation

    Declaration
    public static void IntegrateCurve(float[] array, AnimationCurve curve)
    Parameters
    Type Name Description
    float[] array

    The array to fill with integrated values

    AnimationCurve curve

    The animation curve to sample integrate

    Exceptions
    Type Condition
    ArgumentException

    IterateSeed(uint, uint)

    Generates new a new non-zero random state by deterministically hashing a base seed with an iteration index

    Declaration
    public static uint IterateSeed(uint index, uint baseSeed)
    Parameters
    Type Name Description
    uint index

    Usually the current scenario iteration or framesSinceInitialization

    uint baseSeed

    The seed to be offset

    Returns
    Type Description
    uint

    A new random state

    TruncatedNormalSample(float, float, float, float, float)

    Generates samples from a truncated normal distribution. Further reading about this distribution can be found here: https://en.wikipedia.org/wiki/Truncated_normal_distribution

    Declaration
    public static float TruncatedNormalSample(float uniformSample, float min, float max, float mean, float stdDev)
    Parameters
    Type Name Description
    float uniformSample

    A sample value between 0 and 1 generated from a uniform distribution

    float min

    The minimum possible value to generate

    float max

    The maximum possible value to generate

    float mean

    The mean of the normal distribution

    float stdDev

    The standard deviation of the normal distribution

    Returns
    Type Description
    float

    A value sampled from a truncated normal distribution

    Exceptions
    Type Condition
    ArgumentException
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)