gordmoo
16th October 2005 01:27 UTC
gravity fun times!
hey there :)
i made a gravity engine for a preset a while back but was never happy with it, not to mention it having a colour bug in it when i releaced it >_<. so i made a better one that i like to think resembles something more like a sun being swallowed by a black hole thats a little, irratic :)
seing as i don't have much time to avs stuff anymore i thought id just put this out there instead of it just wasting away on my hard drive :)
not that im asking, but if anyone could do anything funky with it, id love it :) oh and there are 10000 particles or so in this so it might run a lil slow on slower computers.. and i left out dynamic texter resizing code because resizing 10000 images is not my idea of quick, so i wouldn't recomend anything more than 512x384 ;)
oh, and whist i of course did all this windows, i changed the names to fit posting guidelines in linux and thus couldn't test it, i got a friend on a windows box to change the second texterII to the right bitmap name, but just incase the second texterII should point to 'gord - blackhole.bmp' :)
PAK-9
16th October 2005 17:34 UTC
Nice idea, looks quite funky
Some points:
- Use smaller texer2's where possible, blending is an expensive operation especially when you do it 10,000 times.
- You have a load of pointless buffer saves and an effect list, you dont need them (see optimised preset)
- You can do a lot of programmatic optimisation to speed it up, for example where you have:
red=(1/255)*6;
green=(1/255)*4;
blue=(1/255)*2;
Those are just constant values. At present you are doing 30,000 divides and 30,000 multiplications every frame to calculate the colour values, when you really need 0.
I've attached an optimised version. As well as the above I also set the bounding box (outbox) to 1 (why would you want it any bigger?) and reduced the particle count. This gives me about 22fps instead of 14fps (57% faster :P )
gordmoo
17th October 2005 08:52 UTC
yea i know about that stuff, it was just when i was making it kinda came out that way, lots of fine tuning when you have 10000 particles, too high a value and you have white _everywhere_, too low and black. n seing as its blended as regular 1 byte channels, makes sence. but yes i should of done that :)
i think the biggest problem is the megabuffers, iv done tests before where you can get huge speedups.. hard to do without them though.
all the rest of the weirdness in the code come from the fact that its based on an earlyer thing i did where the mouse was used to move the gravity well, which is a _lot_ of fun to play about with, seriously -_-
the problem with using smaller bitmaps for texterII is that you end up having to use more particles to achive the same effect, catch 22 thing i guess.
i'll see if i have time to take a look at the optimised one later and remove all the filler, so to speak :)
PAK-9
17th October 2005 09:46 UTC
You can use a bit of a trick when using smaller texer's by setting the outbox to a value < 1, tweak the speed settings and use a movement to resize it to the whole window (with bilinear filtering). I originally had that in the optimised version with a scale of 0.5 but i took it because it was a bit noticable, I think 0.75 or so would be hard to notice tho.
gordmoo
18th October 2005 12:22 UTC
i had some spare time last night so i optimised it as much as i could whist keeping the same effect and fluidity. went with that resizing trick as there arn't really any sharp edges so it suits interpolated resizing nicely :) it runs at around 32fps on my 1.8ghz amd processor, around 200% speedup from the first version :).
also _finally_ corrected some gravity code i did, before two objects with diffirent masses would fall at seperate speeds.. which.. isn't quite, right... really. now the only mass that counts is the gravity well :), makes me wish i still had my notes from college really.
the gravity well movement isn't really what i want stil though, iv tryed to create some code many times that would produce the smooth effect that id like, but this will have to do.
thank you mr pak-9 :)
eheiney
18th October 2005 17:27 UTC
Pretty damn nice. :up:
I really like it when the 'thing' passes over the center and the 'stuff' explodes. ;)
PAK-9
18th October 2005 20:26 UTC
:up: