Particle jitter is a little nifty feature that comes in handy when you need to add sense of random motion to particles. Jitter motion is the jumpy but slight displacement in the particle’s position; however the original trajectory or the particle dynamics is not altered. So a good place to put in the particle jitter displacement is at rendering stage where this displacement value is not written back into the particle position. Here is (pseudo) code snippet to perform the jitter displacement:
pPos = pointer to copy of particle world position
VRight = right vector of the particle geometry quad
VUp = up vector of the particle geometry quad
fJitter = 1.0f; // Jitter distance
VECTOR3 JitterVector;
int nDirection = rand() % 4;
Vec3Set(&JitterVector, &((VECTOR3)(nDirection < 2 ? ((nDirection == 0) ? VRight : -VRight) : ((nDirection == 2) ? VUp : -VUp))));
Vec3Normalize(&JitterVector, &JitterVector);
Vec3Scale(&JitterVector, &JitterVector, fJitter);
Vec3Add((VECTOR3*)pPos, (VECTOR3*)pPos, &JitterVector);
Tuesday, October 23. 2012
Particle Effects Rendering: Adding Jitter to Particles
Trackbacks
Trackback specific URI for this entry
No Trackbacks