[quote name='projectionmatrix' timestamp='1318876917' post='4873576']
My question is i want to make the ripple temporary, like someone had dropped an object into the water.
That is have it only start in the center, move outward then calm back down.
Any ideas on how this effect could be achieved?
Thanks for all the help so far everyone!
Every point within some radius of the impact point is going to oscillate. Points at an equal distance from the impact are going to be at the same value, which is determined by the phase at that distance and the attenuation value for that distance. A nice looking attenuation wave would look Gaussian.
If you can get the DDS algorithm I provided to work for you, then you can get phase-continuous samples for a sine wave (meaning if you want the frequency to decrease over time it will look perfect). By taking each of these samples and multiplying it by the corresponding attenuation sample, you will construct a "ripple wave". You can then map the distance from impact into a phase-lookup in the ripple table.
This solution eliminates your sine computation *for every value*, so long as you can output a sine wave from the DDS algorithm, which itself doesn't even compute sine values.
You also mention that you were having trouble implementing the DDS algorithm. Are you calling the "UpdateSineWaves" equivalent function at an exact frequency? If so, what is that frequency (500Hz, 1KHz, 10KHz)? Is this value defined as INC_FREQ? Is the accumulator variable 32 bits? If not, you need to set ACC_BITS to the number of bits. Is it unsigned (This algorithm works because of wraparound)? Is ACC_VALUES 2^(ACC_BITS)? If SAMPLE_BITS is 8, do you have a sine wave with 2^8 (256) values?
If you still can't get it to work, post what you have and I'll be happy to take a look.