java 1.6 jogl issues on mac os x

marcus • April 30th, 2008

after apple released java 1.6 for mac os x today to the public i got curious to see how my processing (v0135) sketches/apps worked with the new version. unfortunately once you switch to 1.6 in your java preferences, processings opengl throws java.lang.UnsatisfiedLinkErrors after messing around with it for a while i discovered that you had to upgrade to the latest nightly jogl build to make it work...

until the processing team releases a fixed version use this updated library to solve your mac p5/opengl issues. (simply replace the old opengl folder in your ./Processing 0135/libraries/ directory) » opengl-mac-java1.6-fix.zip
 

liquids

marcus • April 4th, 2008



when i saw the fountain a while ago, i was stunned by the amazing liquid effects photography chris parks did for their surreal space backgrounds and since then wanted to get my head around the dynamics in these systems.
now having finished our patashnik piece (will be blogging about it soon) i had some time to get into that subject. but before going directly to the code i got hands on ... with ink, olive oil, washing detergent, soy sauce. here's what i got out of it after playing with it for a few hours.
» "liquids" on flickr.

its definitively amazing for me because normally i'd spend three months writing code before seeing a single image thats close to one of these photos. not exactly what you'd call "agile" ...



however speaking about code =)
i currently see two strategies to simulate this "liquid effect" in code:
a) do all the calculations for the complete area/ volume of the liquid. this is the traditional approach and has been implemented a number of times. however since your calculation costs increase exponentially with increasing resolution, it is impossible to generate hd images/ animations in realtime using this method, which is what i'm aiming for.
(i wrote a GLSL GPU-feedback based implementation a while ago, which works fine, even at higher resolutions, but is difficult to combine with other physical forces/ particle effects)

b) another approach i'm currently pursuing is simulating the fluid with a very large particle system where each particle varies in size to cover the complete area, therefore i'm currently rewriting/ optimizing my particle system to use multiple worker threads and improved opengl performance tricks (display lists, point sprites etc). that way i can now simulate 40.000 particles at 125 fps on my macbook pro – in java!

lets see where this goes...

by the way; the very talented maxim zhestkov also makes use of liquid effects in his latest video installation – very nice!

Predefined gcc #defines

marcus • January 2nd, 2008


echo  | gcc -dM -E -x c -  | sort

I thought I had this somewhere on my blog already, because that's something I always forget and neeed to use every few months or so.

Supercollider 3.1

marcus • November 5th, 2007

Hooray! I just noticed my audio-programming language of choice recieved has significant up date in the last days. You can download it here

SuperCollider is an environment and programming language for real time audio synthesis and algorithmic composition. It provides an interpreted object-oriented language which functions as a network client to a state of the art, realtime sound synthesis server.

SuperCollider was written by James McCartney (audiosynth.com) over a period of many years. It is now an open source GPL’d project maintained and developed by James and various others. It is used by musicians, scientists, and artists working with sound.

Fast Square Root

marcus • June 7th, 2007

void setup ()
{
    int runs = 100000;

    long ts = System.currentTimeMillis();
    for ( int i=0; i < runs; i++ )
    {
        fsqrt( random( 1000 ) );
    }
    long ts1 = System.currentTimeMillis() - ts;

    ts = System.currentTimeMillis();
    for ( int i=0; i < runs; i++ )
    {
        ffsqrt( random( 1000 ) );
    }
    long ts2 = System.currentTimeMillis() - ts;

    ts = System.currentTimeMillis();
    for ( int i=0; i < runs; i++ )
    {
        fastSqrt( random( 1000 ) );
    }
    long ts3 = System.currentTimeMillis() - ts;

    ts = System.currentTimeMillis();
    for ( int i=0; i < runs; i++ )
    {
        Math.sqrt( random( 1000 ) );
    }
    long ts4 = System.currentTimeMillis() - ts;

    ts = System.currentTimeMillis();
    for ( int i=0; i < runs; i++ )
    {
        invSqrt( random( 1000 ) );
    }
    long ts5 = System.currentTimeMillis() - ts;

    println( "fsqrt:  "+(ts1/(double)1000) );
    println( "ffsqrt:  "+(ts2/(double)1000) );
    println( "fastSqrt:  "+(ts3/(double)1000) );
    println( "Math.sqrt:  "+(ts4/(double)1000) );
    println( "invSqrt:  "+(ts5/(double)1000) );
}

public static float fsqrt(float x)
{
    if (x ==0) return 0;

    float root = x / 2;
    for (int k = 0; k < 10; k++)
  root = (root + (x / root)) / 2;
    return root;
}

public static float ffsqrt(float n)
{
    if(n==0) return 0;
    if(n==1) return 1;

    float guess = n/2.0;
    float oldguess = 0;
    while(guess!=oldguess)
    { 
        oldguess=guess;
        guess = (guess+n/guess)/2.0;
    }
    return guess;
}

public static float fastSqrt (float val)
{
    // http://en.wikipedia.org/wiki/Methods_of_computing_square_roots
    //

    int tmp = Float.floatToIntBits(val);
    tmp -= 1<<23;     /* Remove last bit to not let it go to mantissa */
                      /* tmp is now an approximation to logbase2(val) */
    tmp = tmp >> 1;   /* divide by 2 */
    tmp += 1<<29;     /* add 64 to exponent: (e+127)/2 =(e/2)+63, */
                      /* that represents (e/2)-64 but we want e/2 */
    return Float.intBitsToFloat(tmp);
}

public static float invSqrt(float x)
{
     float xhalf = 0.5f*x;
     int i = Float.floatToIntBits(x);
     i = 0x5f3759df - (i >> 1);
     x = Float.intBitsToFloat(i);
     x = x * (1.5f - xhalf * x * x);
     return 1.0f/x;
}
3d 4-space abstract aesthetic system aesthetics algorithm alien ambient ambisonics animation architecture art artificial audio audio research black&white book caskets classic clicks & cuts code color computer-vision conceptual art consoles cpp culture ddr design devices digtial fabrication documenta documentation drawing dynamics electricity electromagnetism electronics environment event exhibition experimental exploration fashion festival film flocking folk food fractal furniture gamedev generative genetic geometry glitch graphic hacks haptics hardware history hyperspace ideas illustration images inspiration installation instrument intelligence interactive interieur japan java knowledge management landscape library life light liquid live london math micro minimal modernism monochrome motion motion graphics multiples music naming nature nervous ink networked networking opensource osx painting paper particles performance personal photography physics playful politics press print processing processing.org programming quotes recipes research retro romance ruby scripts sculpture SENDUNG.net shopping snippets social software sound space space exploration craft space exploration craft orbiter supercollider swiss systems technology theory theremin toys transformed travel tricks typography universe video visual vj water web2.0 xcode