title: Using Perlin noise to create lightning?
body: <p>Actually I am having several questions related to the subject given in the topic title.</p>
  
  <p>I am already using Perlin functions to create lightning in my application, but I am not totally happy about my implementation.</p>
  
  <p>The following questions are based on the initial and the improved Perlin noise implementations.</p>
  
  <p>To simplify the issue, let's assume I am creating a simple 2D lightning by modulating the height of a horizontal line consisting of N nodes at these nodes using a 1D Perlin function.</p>
  
  <ol>
  <li><p>As far as I have understood, two subsequent values passed to the Perlin function must differ by at least one, or the resulting two values will be identical. That is because with the simple Perlin implementation, the Random function works with an int argument, and in the improved implementation values are mapped to [0..255] and are then used as index into an array containing the values [0..255] in a random distribution. Is that right?</p></li>
  <li><p>How do I achieve that the first and the last offset value (i.e. for nodes 0 and N-1) returned by the Perlin function is always 0 (zero)? Right now I am modulation a sine function (0 .. Pi) with my Perlin function to achieve that, but that's not really what I want. Just setting them to zero is not what I want, since I want a nice lightning path w/o jaggies at its ends.</p></li>
  <li><p>How do I vary the Perlin function (so that I would get two different paths I could use as animation start and end frames for the lightning)? I could of course add a fixed random offset per path calculation to each node value, or use a differently setup permutation table for improved Perlin noise, but are there better options?</p></li>
  </ol>