Random Ranges - Noise - Shader Learning

Noise

Random Ranges

Task

Given code that generates particles every few milliseconds in the centre of the screen. The following changes need to be made:


1. initialize new particles at the position (0.5, 0.1).


2. each particle should move in a direction randomly interpolated between two vectors: dir0 and dir1.


3. use the particle's sequence number float(i) to determine a random interpolation parameter.


4. each particle should move along its selected direction by a certain distance, which is calculated using the progress variable (ranging from 0 to 1). This variable represents how far the particle has traveled from its starting point.

Theory

Interpolation can be used to generate random values within a specified range. The values within the range can be of different types, such as colors, directions, positions, or any other parameters.


To generate a random value in the range [V0, V1], we can use a random value that varies between 0 and 1 as the interpolation parameter:

V = mix(V0, V1, random());