Friday, July 11, 2014

Jerry Tessendorf's iWave in Unity

Interactive build for Unity Webplayer here.

It's one of those days when you get struck by inspiration, and I was like "OMG OMG! I must implement this in Unity". So I tried, and with some luck managed to get a version of it done. The source code was attached to "Simulating Ocean Water", which frankly, most of it I am puzzling over.

Adapting the code to C# was quite straightforward, however, there was a function used to generate a 13x13 kernel that utilized a j0() function. I was like.... was that some kind of typesetting error? Some googling indicated it was a bessel function. This does not appear to be part of C#'s math libraries, but it is for C/C++. Odd. Anyways, I found - after much searching - source code for the j() function in C that I adapted for C#.

Don't really know why this kernel was chosen, and I was wondering how different kernels like Gaussian would work. Something to explore another time.

The emission also uses a kernel, but only a 3x3 grid that I put in some pre-calculated values. A better solution really, would be to interpolate between positions. Now that I've figured out stuff like this, it's time to explore other stuff!

No comments: