ArrowLobMeshSet.as - Rain Of Arrows

Got an idea to batch draw as much 3D arrows as possible. It's even possible to squeeze all per-arrow constant values into a single FLOAT4 register: Arrow launch velocity (xyz) + offset (w whole) (ie. dot product of arrow launch velocity and position) + (w fractional) time fractional over MAX_ARROW_TRAVEL_TIME. Then, get the vertex shader to batch draw that those arrows, deriving the offset vertex positions (and resultant projectile orientation) from the given velocities and time of each arrow! Arrows positions can be determined either as a straight-line from launch position or include trajectory (ie. launchPosition.y + .5 * GRAVITY*t*t + velocity.y*t;) The result? You don't need to update individual arrow positions and matrix orientations per frame on the CPU. Just send the existing velocity+offset and time values to GPU and let the GPU do the rest!