Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 


Submitted by Brian Washburn, posted on April 06, 2002




Image Description, by Brian Washburn



This IOTD demonstrates my 2d metaball engine I wrote in a couple days, rendered in OpenGL.

Rendering and calculating metaballs are very cpu extensive, 2d or 3d. My goal was to have many metaballs on the screen at once without slowdown, so I opted for 2d. To reduce the computing load and increase fps, the window itself is rendered in 320x240, and then is broken into 160x120 chunks. Even then, rendering a mere 10 metaballs would mean 192000 illiterations! (120x160x10). With certain optimizations I managed to reduce that number to around 15000.

Drawing the metaballs involves density/electrical fields. Density fields are usually used to display things such as air pressure or temperature but they can be used to display blobs also. Every point on my 160x120 graph is tested to see how far away it is from all the metaball's centers. If that value passes a certain threshhold the pixel passes, and is rendered. Surprisingly, the color of each pixel is determined almost the same way.

Enjoy!

The 'A' key adds a metaball. The 'S' key subtracts a metaball. 'Enter' singles out a a certain threshhold value, and only draws it. (torus)

The demo is available for download here: iotd-04-06-2002_metaballs.zip (41k)

Brian Washburn, 2002


[prev]
Image of the Day Gallery
www.flipcode.com

[next]

 
Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
Frikki

April 06, 2002, 03:49 PM

first !!! at last

 
postalrat

April 06, 2002, 04:00 PM

Do people use the word 'engine' just to confuse me or has someone defined where that words should be used now? Is this an application, engine, visualization, simulation, library, tool, game, ????

 
Rand

April 06, 2002, 04:12 PM

FIRST REPLY TO FIRST POST

DO I GET MY FUCKING PRIZE NOW?

 
ector

April 06, 2002, 04:13 PM

postalrat, why are you writing that in every IOTD? it's getting tiresome..

anyway.. the IOTD would have been cooler with some grid interpolation ("marching squares") :)

 
Rand

April 06, 2002, 04:14 PM

FIRST REPLY TO SECOND POST !!!


HAHHA I AM SOO FUCKIN COOL, at last!

 
Rand

April 06, 2002, 04:14 PM

FIRST REPLY TO THIRD POST!!!

THIS IS MY LUCKY DAY

 
Kurt Miller

April 06, 2002, 04:16 PM

Please stop doing that...

 
Rand

April 06, 2002, 04:16 PM

FIRST REPLY TO THIRD POST!!!

THIS IS MY LUCKY DAY

 
Rand

April 06, 2002, 04:18 PM

sorry I was so excited abouting getting first reply to first post, I guess I got carried away. FIRST@!@!!

 
Waimanu

April 06, 2002, 04:24 PM

mmh you're not too much into optimization are you? not to be rude but i did this in opengl in 1997 and it was about the same framerate as yours.. oh and it was 3d.

 
DirtySouthAfrican

April 06, 2002, 04:30 PM

The level of optimization possible in a 2D meta- er... blot algorithm is so fantastic that... if I told you, I would have to kill you! I got ~ the same framerate at 640x480 field samples rendered directly to the frame buffer in OpenPTC.

 
timm

April 06, 2002, 04:57 PM

Yeah, but how man illiterations did you use?

 
Division By Zero

April 06, 2002, 05:02 PM

WOW !!!! IT LOOOKS IMPRESSIVE !@!!!!
BALLS BALLS METABALLSSSSSS

LOOKS LIKE TAKEN FROM OLD MY GRANDMA'S BOOK
BUT IT'S NEW !!!! strange ... ;p

GOOD WOOORRRKK !!!


AND ...
the most important
thing is
that

------------------ IT'S WORTH A COMMENT !!!!! ---------------------

 
Division By Zero

April 06, 2002, 05:03 PM

I would like to add .... 2 metaballs in 2 days .... thats magic

 
Waimanu

April 06, 2002, 05:04 PM

no listen to him, he's right. this program is pretty slow. you're the one being illiterate you can't even come up with a correct sentence.

 
gumby

April 06, 2002, 05:05 PM

How does real-time 3d metaball animation work?
Seems that with octree / k-d tree you can cull
many more more voxels. How do you compute the isosurface
in realtime?

 
goltrpoat

April 06, 2002, 05:08 PM

Marching cubes, or marching tetrahedrons.. this was being done rather extensively in 96 or so, then it died down and now apparently people are reinventing the wheel..

 
DirtySouthAfrican

April 06, 2002, 05:10 PM

Iterations? Wtf?

I had 4 blobs and I found the field (1/r^2) at each point, and if it was above threshhold, I plotted it... I also did stuff like if it was within certain range of threshold, so you get borders. Also did colours.

 
Albert Sandberg

April 06, 2002, 05:11 PM

Sounds extremely complicated to make something that could be faked so easily, but I bet you have a medical purpose or simular just to make up for the precision ;-)

Albert

 
kismet

April 06, 2002, 05:13 PM

I think you guys missed the joke...

 
davepermen

April 06, 2002, 05:13 PM

how about this way:
for every metaball:
add the intensity to all the grid-points it does affect

instead of
for every point in grid:
for every metaball:
add the intensity if this ball affects this point, else add 0

would speed up much

 
DirtySouthAfrican

April 06, 2002, 05:26 PM

This guy posts in crap English all over the place :D

 
DirtySouthAfrican

April 06, 2002, 05:27 PM

Small problem with that there algo if yours :D... you can only know which cells are affected by a metaball by considering the other metaballs... otherwise you could just render circles...

 
DirtySouthAfrican

April 06, 2002, 05:28 PM

The use of metaballs IS faking it.

 
davepermen

April 06, 2002, 05:31 PM

my algo works. and is correct. why? it looks correct => it is correct.

 
Mathieu 'POĻ' HENRI

April 06, 2002, 05:36 PM

god, how did you managed to make 2d metaballs being slow on my 1.4Ghz athlon ? you're really out of optimization stuff, no ?

you should have a look at some 256 bytes intros, there's plenty of them displaying quazillion of metaballs extremely fast

the method davepermen noticed is as efficient as obvious ( no offence, obvious ideas are often the best )

 
davepermen

April 06, 2002, 05:38 PM

do you mean me with this post?

 
DirtySouthAfrican

April 06, 2002, 05:41 PM

timm

 
DirtySouthAfrican

April 06, 2002, 05:42 PM

If you like drawing circles, sure... if you want "necking" which is the technical term for what metaballs do, then your algorithm doesn't work, or, if it works, is just the general algorithm stated differently.

Of course, the use of spatial subdivision is crucial.

 
DirtySouthAfrican

April 06, 2002, 05:43 PM

The last 256 byte intro I saw displayed a scrolling line of text that said something about a 1987 demo group...

oh, and another one let you play pong.

 
This thread contains 102 messages.
First Previous ( To view more messages, select a page: 0 1 2 3 ... out of 3) Next Last
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.