Hi folks. Recently I posted a tutorial on how to render fast 2D blobby objects in BlitzMax in realtime, in this thread:
http://www.blitzbasic.com/Community/posts.php?topic=45716
I decided to release a more complex version of my blob routines that uses lots of direct OpenGL and almost no Max2D commands. This version loads and needs four pre-rendered blob-field images (examples included below) which are 512x512 grayscale RGB images in PNG format. It also loads a `filler` image texture which is a 256x256 color RGB image in PNG format (example also included below).
This version can actually load 4 different blob-field images at once so you can experiment with using the same one four times or more than one kind. These blob images are based on a standard blob field as generated by the included `DrawSquare512` and `DrawBall512` programs. Using those programs you can generate the basic blob field - I use a screengrab to save them to disk as PNG's. They have been loaded into image processing graphics software and manipulated, for example applying a simple `twist/twirl/spin` effect. There are many effects you could apply, for example a wave or ripple effect. Effects that move the pixels around, preserving the basic content, are the best and still produce a blob effect.
This version doesn't include animation but I have since implemented an animated version that loads 20 frames of a cyclic animation, produced with image processing software applied to the standard blob field image with a rippling wave effect.
You can move the mouse around to move all of the blobs. Positioning the mouse near the lower right at about 3/4 of the width and height of the screen produces a fairly stationary shape.
I haven't tidied up the code too much and there is some old/optional bits that are commented out. There's also some extraneous OpenGL calls near the start that may not be needed - but I found that the `default` state of the OpenGL machine was different on different platforms, so I'm just making sure things are set up right.
For me this runs okay on an iMac 1GHz G4 with an nVidea GeForce 4MX at around 30fps with vblank synching. You may need a comparable gfx card performance (750 million texels/second or so at least, I would guess - the GeForce 4MX is 1 billion texels/second).
Feel free to use this for whatever purpose you like, no strings attached. I hope it will work on your system with no problems.
These are four different blob field images that you will need. Currently the code will load all four but you could change it to load only one repeatedly. The reason I applied a `twist` effect to the blob field is that it produces much smaller blobs and is still smooth. It took a lot of experimentation to come up with this effect.




You also will need this filler texture image (or something similar). Any 256x256 PNG will do but it should be RGB not RGBA (no alpha). This image is just faded out at the edges so as to smoothly blend together. Other images that I found interesting were based on clouds or fractals.

This is the main program and is freeware. I apologize for any untidyness or `procedural coding` technique, it's not very object-oriented. The blob images are uploaded as GL_ALPHA textures, which are just one 8-bit color component per pixel. This saves on storage space, and allows use of particular blend modes later on. The filler image is regular color texture. The rendering code within the main loop - you can comment out whole sections if you'd like to see the effect that each part has. There are also some flags at the top of the code to turn certain things on and off. You can also modify the rotation angle increments and the kind of colors that are produced at other points in the code.
This is the program you use to generate a basic blob field image, freeware also. This one generates circular blob fields (standard blobby objects). This produces blobs that form nicely curved outlines as standard. The commented-out code at the end adds various extra little effects to it (just experiments).
And this one generates a blob field image based on squares - this produces a very interesting bubbling blob effect of many different shapes and sizes (of course freeware too). I have never seen this done before so maybe I can lay claim to actually inventing this! Since it is based on squares you might think it couldn't produce a blob shape, but it actually does, and goes further to add a lot of variety.
The effect should end up looking something like this:

All these files are free for your use in whatever manner. :-)
|