September 2018
Intermediate to advanced
472 pages
15h 36m
English
We'll create two buffers (or a single interleaved buffer) to store our input attributes. The first buffer will store the initial velocity for each particle. We'll choose the values randomly from a limited range of possible vectors. To create the cone of particles in the previous image, we'll choose randomly from a set of vectors within the cone. We will tilt the cone toward some direction by applying a rotation matrix (emitterBasis). The following code is one way to do this:
glm::mat3 emitterBasis = ...; // Rotation matrix auto nParticles = 10000;glGenBuffers(1, &initVel);glBindBuffer(GL_ARRAY_BUFFER, initVel);glBufferData(GL_ARRAY_BUFFER, nParticles * sizeof(float) * 3, nullptr, GL_STATIC_DRAW);glm::vec3 v(0); float velocity, ...
Read now
Unlock full access