Dark Bit Factory & Gravity

GENERAL => Projects => Topic started by: taj on October 03, 2006

Title: 3d chladni volumes as textures
Post by: taj on October 03, 2006
Over here Paul Bourke talks about 2d chladni fields which are those amazing patterns you get when you put sand on a metal plate and then vibrate it.
http://local.wasp.uwa.edu.au/~pbourke/modelling/chladni/

He does some work in 3d too but its not very intuitive when you see the shapes.

This afternoon I guessed it might make a cool demo to animate one in 3d texture. I wrote a GLSL shader to do a 3d chladni field and then mapped that to a sphere and animated it in the simplest way possible. I think the result, although a bit esoteric is very cool indeed. This will definitely be appearing in some form in a 4k for breakpoint. The file isnt size compressed, the whole effect might be 400 bytes or so.

So bottom line is, I believe these chladni fields could make awesome textures and geometry generators.

OOOps of course you need shaders to run this - model 2.0 unfortunately. So I'll upload an image in a minute too.

Title: Re: 3d chladni volumes as textures
Post by: taj on October 03, 2006
A couple of small images for those ont able to run the code.

Title: Re: 3d chladni volumes as textures
Post by: zparticle on October 03, 2006
That's a pretty cool idea, wish I could run the code.
Title: Re: 3d chladni volumes as textures
Post by: ninogenio on October 03, 2006
looks very cool,

im going to have to find a way of running shader model 2.0 programs.
Title: Re: 3d chladni volumes as textures
Post by: taj on October 03, 2006
Sorry guys...
Title: Re: 3d chladni volumes as textures
Post by: Shockwave on October 03, 2006
Damn nice textures, good implimentation, that's just going from the shots you posted. I bet they look even better in motion.
Title: Re: 3d chladni volumes as textures
Post by: Clyde on October 03, 2006
Can run the exe fine. Looks really cool running, reminds me of a kind of plasma-ish effect.
Title: Re: 3d chladni volumes as textures
Post by: Shockwave on October 03, 2006
It died here :(
Title: Re: 3d chladni volumes as textures
Post by: zawran on October 03, 2006
Looks rather cool in motion. Great work.
Title: Re: 3d chladni volumes as textures
Post by: taj on October 03, 2006
Thanks all fpr the comments, makes posting worth while.

Clyde, I think you are right. The equations seem to be very similar to plasma ones in many ways. In essence its just the sum of cosines (or sines) in 3d. That didnt occur to me until after I posted. The cool thing is doing it so fast in real time thanks to shaders and cutting holes in the sphere but that said, I'm convinced its just plasma!

Title: Re: 3d chladni volumes as textures
Post by: benny! on October 04, 2006
@taj:

Screenies look outstanding. Time to buy better hardware I think ! N1
Title: Re: 3d chladni volumes as textures
Post by: relsoft on October 04, 2006
Awesome dude!!!!

Too bad my card does not support shader 2.0
Title: Re: 3d chladni volumes as textures
Post by: taj on October 04, 2006
Thanks again guys! If anyone gets interested in shaders and wants the code, anyone can ask of course but my feeling is that very few people here would use the code anyway. However, you are welcome if you want it, just ask.

Shockwave, *should* you be able to run this?...can you run any of the matrix trilogy? if so I'd like to make a few changes to the windowing code and try again with you. I'm worried it doesnt work for you. Also do you have nvdia or ati? What model? Maybe there are some problems with shader compatability. Sigh, things are getting complicated in the hardware world...I'd like to get it sorted so I know if my shader framework is solid or not.
Title: Re: 3d chladni volumes as textures
Post by: benny! on October 04, 2006
[OT]
Anyone can suggest a good / modern gfx-card !? Shouldnt be too expensive
[/OT] sorry for hijacking
Title: Re: 3d chladni volumes as textures
Post by: taj on October 04, 2006
No problem benny...maybe an admin will move the subject somewhere.

When cost is an issue, Ati is, I believe,the better price/performance choice. Thats what I heard and what I saw when I went shopping recently.

The problem is AGP cards are much more expensive than PCI-E...are you AGP or PCI-E? I recently tried to buy a graphics card with PS3.0, DX 9 support and fonud I could not afford an AGP version which was 200 pounds. However that was a 3 months ago and things change. My current graphics card which, whilst not great quality and somewhat unstable, has good shader performance is an Ati 1600 PRO which comes in various types from around 65 pounds for pci-E.

http://www.overclockers.co.uk/acatalog/X1600_Series.html

Its not super fast but it does everything you need. I have found a few issues with some shaders which fall back to software rendering but they are rare. I do not play games so checking on websites about modern game performance on it might be adviseable.

http://www.extremetech.com/article2/0,1697,1945665,00.asp

This concludes that if you play doom3 use Nvidias cards but overall price performance is better with x1600...BTW this article compares 17 graphics cards from 2006, the prices are a bit "old" but conclusions should still be valid. I HATE ati cards but Im on a budget too.



Hope this helps.
Title: Re: 3d chladni volumes as textures
Post by: benny! on October 04, 2006
thanks for your anwers m8. I am definatley about to update some of my hardware compenents.
i will browse around a bit and checking out some hardware sites...

(damn ... i want to see that baby in motion  ;) )
Title: Re: 3d chladni volumes as textures
Post by: Jim on October 04, 2006
I'm stuck with AGP at home too.  I bought a Radeon X1600 AGP which is the fastest AGP card ATI make last time I looked.  It cost me around AUD160, which is UKP65 or so.  It can play any of the demos here and all the latest games easily, even though it's a country mile behind the top of the range PCIe stuff.  Watch out though - these new cards are NOISY!  I had to go and spend 15quid on a Zalman whisper quiet fan to stop it keeping me awake at night (2 rooms away!).

Waiting for the Core2Quad to come out next quarter to upgrade my PC I think.  I haven't had a new one for 3 years now - it just shows how the technology went stagnant for a couple of years while Intel dropped the ball.

Jim
Title: Re: 3d chladni volumes as textures
Post by: ninogenio on October 04, 2006
what do you guys make of these new physics accellerators there bolting to mobos?
Title: Re: 3d chladni volumes as textures
Post by: Rbz on October 04, 2006
@Taj: works fine here, that's a nice idea for texture/effect, looking forward to see your winner 4k, welldone!

P4 2.8 - 512MB
Geforce 6600GT - 128Mb
Title: Re: 3d chladni volumes as textures
Post by: taj on October 06, 2006
Thanks rbraz! Don't hold your breath, I'll aim for breakpoint so its 6 months yet...
Title: Re: 3d chladni volumes as textures
Post by: Blitz Amateur on October 06, 2006
As another alternative, I've got an ATI X800 PRO PCI-EX and it was about $150 (Not sure how that translates too pounds) And it's performed amazingly for me. It's got 256mb memory, and SM 2.0.

As far as games application, I can run F.E.A.R. at 1280x960 2xAA 16xAF all setting full except soft shadows, and it's a very playable speed. So, in my opinion, it's a good card :) (And if you don't know what F.E.A.R. is, google it.)
Title: Re: 3d chladni volumes as textures
Post by: taj on October 06, 2006
Yeah I agree with blitzamateur. I have x800 at work. Its slower at shaders than my x1600 PRO (a bit) but faster at *everything* else.
Title: Re: 3d chladni volumes as textures
Post by: Shockwave on October 06, 2006
None of the matrix trilogy work on this computer, or that one .
My gfx card is a radeon X300 se.
It should support shaders 2.0 some stuff doesn't run here, not juts your code either.
Title: Re: 3d chladni volumes as textures
Post by: taj on October 06, 2006
Well ok in this program I have a line:

if(...) discard;

which throws away the pixel if th condition is met. Technically this is shader model 3.0 as it is dynamic branching its just I never thought of a single line of code as being dynamic branching but of course it is. So I guess this demo really requires shader model 3.0. However that doesnt explain the matrix ones, but my best guess here is that to qualify as PS 2.0 model, you only had to be able to do 95 instructions (I assume assembler level) in the shader. PS 3.0 supports 65535. Probably my vertex shader is too big to fit into PS 2.0.

Probably.

But I dont know.



Title: Re: 3d chladni volumes as textures
Post by: Shockwave on October 06, 2006
It seems to try and set the screen up because it changes the res but then it hangs really big time. I've had some excellent crashes out of it! :)
Title: Re: 3d chladni volumes as textures
Post by: taj on October 06, 2006
ooops, sorry about that...probably Jim is right the framework itself is a bit nasty...lets blame auld ;-)
Title: Re: 3d chladni volumes as textures
Post by: Shockwave on October 06, 2006
Ok!  ;D If he'd registered here I'd give him some bad Karma!
Title: Re: 3d chladni volumes as textures
Post by: Tetra on October 22, 2006
Looks great and very nicely visiualized too  8)
Title: Re: 3d chladni volumes as textures
Post by: taj on October 23, 2006
Thanks tetra. I think a good thing to do with it would be making the spheres look like they ar built out of metal so give it a  molten metal look.
Title: Re: 3d chladni volumes as textures
Post by: benny! on October 26, 2006
Just received my new gfx card / machine and watched your code. Looks fantastic and
it runs very smooth and fast ... well done !
Title: Re: 3d chladni volumes as textures
Post by: taj on October 26, 2006
Thanks Benny, what did you chose in the end for a gfx card?
Title: Re: 3d chladni volumes as textures
Post by: benny! on October 26, 2006
Quote from: taj on October 26, 2006
Thanks Benny, what did you chose in the end for a gfx card?

I bought a complete new system. A friend of mine (a hardcore gamer) wanted to sell
his machine ... so I bought his whole system. It has an nVidea GeForce 6800
installed and so far I am really pleased with it.
Title: Re: 3d chladni volumes as textures
Post by: mind on November 02, 2006
Quote from: taj on October 04, 2006
Thanks again guys! If anyone gets interested in shaders and wants the code, anyone can ask of course but my feeling is that very few people here would use the code anyway. However, you are welcome if you want it, just ask.

Shockwave, *should* you be able to run this?...can you run any of the matrix trilogy? if so I'd like to make a few changes to the windowing code and try again with you. I'm worried it doesnt work for you. Also do you have nvdia or ati? What model? Maybe there are some problems with shader compatability. Sigh, things are getting complicated in the hardware world...I'd like to get it sorted so I know if my shader framework is solid or not.


actually, i have thought of a pretty interesting use for this, so if you dont mind i'd love to take a peek on your implementation of the code.. possibilites are endless :D

//Johnny
Title: Re: 3d chladni volumes as textures
Post by: taj on November 02, 2006
@mind: sure , check your PMs...
Title: Re: 3d chladni volumes as textures
Post by: Rbz on November 02, 2006
Today I was playing with that Chladni formula, and yes, you can make very nice textures shape with this one  :)


Check out the attached file below...
Title: Re: 3d chladni volumes as textures
Post by: taj on November 02, 2006
Thats very cool to see. I think we are beginning to see that 2d/3d chladni has a lot of potential in very few bytes for some very impressive procedural texturing. Is your texturing 2d or 3d rbraz?
Title: Re: 3d chladni volumes as textures
Post by: Rbz on November 02, 2006
For now It's just a 2D texture, next time, I will try the "circular plate" and merge two shape together for plasma like effect and  I will try the 3D version too   O0

Title: Re: 3d chladni volumes as textures
Post by: rdc on November 02, 2006
Okay, let me ask a dumb question. How do you translate the equations into pixel coordinates?
Title: Re: 3d chladni volumes as textures
Post by: Rbz on November 03, 2006
For 2D draw, I did this (c code):

for(y=0; y<256; y++)
{
for(x=0; x<256; x++)
{

//chladni effect
u = 192+x+( (cos(n * PI * x / L) * cos(m * PI * y / L)) - (cos(m * PI * x / L) * cos(n * PI * y / L)) );
v = 112+y;
WritePixelFast((int)u, (int)v, (color << 16) | (color << 8 ) | color);
}
}

Title: Re: 3d chladni volumes as textures
Post by: mind on November 03, 2006
Quote from: rdc on November 02, 2006
Okay, let me ask a dumb question. How do you translate the equations into pixel coordinates?

well, since you have x and y coordinates inside the equation, simply put the equation inside your x/y loop, something like this:


for x = 0 to 255
for y = 0 to 255
  {
     x2 = ( cos( n*pi*x/L ) * cos( m*pi*y/L ) )*128;
     y2 = ( cos( m*pi*x/L ) * cos( n*pi*y/L ) )*128;
     color = x2-y2;
     if color<000 { color = 000};
     if color>255 { color = 255};
     pBuffer[x][y] = color;
  }


notice that i multiply the x2 and y2 by 128 to normalize from -1  1 to 0  255 for a more pleasant visual effect.. also, i split the equation up for simplicity and to make it easier to read.

problem i have for now is that i havent found a nice way to make it tile yet, as in the examples seen over at paul bourkeÃ,´s..

hope that helped :)

//Johnny
Title: Re: 3d chladni volumes as textures
Post by: rdc on November 03, 2006
Thanks guys, both examples are a big help. I'll have to play around with this some.
Title: Re: 3d chladni volumes as textures
Post by: mind on November 03, 2006
here's a lil something i whipped up in an hour that somewhat lets you experiment with the chladni volume in 2d.. you adjust the M and N with mouse X and mouse Y, and scroll around it with the up/down/left/right keys.. it's an experiment made to test the possibilites of using it as a procedural pattern generator.. basically, you can save each texture in less than 20 bytes.. however i didnt implement loading/saving yet.. nor did i optimize the software.. anyways, go crazy :) let me know what you think of it..

TODO: let the user change size of the plate(the L variable) in the "UI", aswell as a few of my own parameters i added, like multiplication of pi to make it seamless at powers of 2, the option to use the absolute value of x-y instead of x-y aswell as the option to use a full color range instead of just b/w etc..

i'll update the software when i have the time but until then, i hope you enjoy what it is so far :)

it's a quick pascal hack(im at my gf's place so i have no access to any useful compilers, but i will compile a decent xp version with a nice UI asap) and you can grab it right here: http://web.bitnet.net/johnny/chladni.exe

//Johnny
Title: Re: 3d chladni volumes as textures
Post by: taj on November 03, 2006
Fantastic stuff mind. Im going to look much closer at this tomorrow. 20 bytes is a lot for each texture and at 4k would be almost unacceptable for me *unless* the texture code is 100 bytes or something . You should examine that closely and see if you really need that much. I bet you can get it to ten easily if you try.

In the mean time, some karma.
Title: Re: 3d chladni volumes as textures
Post by: mind on November 03, 2006
well, i dont NEED 20 bytes per texture.. i could save it in 4-6 bytes with standard parameters.. but since i like my stuff to be a lil more flexible im willing to waste another 10 bytes or so per texture.. keep in mind that it's 20 bytes before compression..

as of now, i can make it in:
l=1 byte(if i want a 256x256 texture)

m=1 byte(can be extended to an int)
n=1 byte(same as above)

xpos=1 byte(can be extended to an int)
ypos=1 byte(same as above)

thats 5 bytes per texture(or 11-17 with the 2-4 ints).. i havent really done the exact math for the extended textures though, with all my partameters and such.. but i approximated to around 20 bytes uncompressed.. meaning you can have around 20 unique textures(monochrome or linear) in 400 bytes... uncompressed..

thanks for the praise though.. now my next project is to get your shader code running, and to make something useful out of it :) speaking of which, how do i give karma? you deserve some for hooking me up with the code..

//Johnny
Title: Re: 3d chladni volumes as textures
Post by: rdc on November 03, 2006
Very cool mind. I am finding this Chlandi stuff very interesting.
Title: Re: 3d chladni volumes as textures
Post by: Rbz on November 03, 2006
Quote from: mind on November 03, 2006speaking of which, how do i give karma? you deserve some for hooking me up with the code..

You will need at least 25 posts to change people Karma, read this (http://dbfinteractive.com/index.php?topic=201.0) , anyway I'll give Taj some good karma in your name  ;)