Skip to content
Forum Archive

Glass Cubes

29 posts

Raz#

Glass Cubes

Well this had the potential for greatness but that collapsed when i realised the major problem. I was originally making a glass rubix cube with 27 separate cubes out of translucent sides using the bnot function but after making 5 i realised it had a tremendouslylow FPS. This is what i stuck with eventually but the FPS is utter shite. I might just scrap it on the grounds that FPS is greatly important. What do you think?

edit: just did this at 2am, realised some wstupid things i did, will change attatchment/repost it very soon.
UnConeD#
You could calculate the 'n' value of the scopes dynamically so only the minimum points required is used... oh and why are you using all those effect lists? They are a source of slowdown too.

Oh and use the correct aspect ratio! Your scopes all look squashed in a rectangular window.
Raz#
I managed to drag up the FPS quite a bit and made it look even better. I've yet to optimise the code don't worry it will get done. It has that awful "monster" for the 3d rotation in x and y and i've yet to fix aspect ratio. The effect is there though. Fix the code tomorrow need sleep now.
anubis2003#
Yeah, the code could definitely use some optimizations. Take out the effect lists and all but one of the render modes(at the beginning). Also, I would try doing the "lighting" a bit better.
Zevensoft#
This may be of help.
dirkdeftly#
unconed...please...please...please...please...stop bitching about aspect ratios. if it's not fixed by the time the pack is released, then you can bitch. otherwise STFU N00B
shreyas_potnis#
raz..what kinda pc do you have, a SUPER COMPUTER?
i dont get even 4 fps on my pc!
please remove all those effect lists with the input/output both set to replace
UnConeD#
Atero: here's the deal... I fire up the preset, notice the squashed rotation immediately and it looks ugly to me. I didn't even look at the code.

It takes 5 seconds to fix this and it ruins a preset for me. Just like bouncy camera movement or scopes that are unnecessarily repetitive and or restricted (like using sin(t) and cos(t) for two rotation angles).

Maybe I'll do a grep 'Atero getosc rand %' and see how much comes up?
UnConeD#
Used a hexeditor to remove some inefficiencies (fixed the x/y calculation and cached the cosines/sine). Et voilà: the preset goes from 13.4 FPS to 18.4 here.

Raz is lucky all the scopes are nearly the same, so he could simply optimize one and duplicate it around the place, but still it's best to optimize a bunch of nearly-identical scopes from the beginning.

(ignore the £---;, it's there to preserve the length of the code)
Raz#
Wow, thanks man. I just finished doing near enough the exact same thing though with the sin's and cos's, jesus i've even used the same variable names for them. maybe ive been staring at your code in wonder too long. You've done the x and y thing differently though and i'm going to presume your way is better so i'll probably combine some things from my way and yours. Thanks a lot though, great optimisations.

this is what i did:
anubis2003#
I thought one of you would do this, but yyy and zzz aren't used and they can be removed. Don't know how big of a difference it will make FPS-wise, but it could help
Raz#
Now this, i love. It brings the FPS down again a little but it also turns it into a preset and not an idea. I've done a shit-ton of optimising and here it is:
mikm#
I like it, but it looks a little to chaotic and fast at times. To me, the silvery ones look better. The glassy one looks wierd at times.
dirkdeftly#
no i didn't, cos i was on my uberuberubershitty computer, and seeing as how slow everybody said it was, i wasn't even going to fuck with it.

but i'll look at it now...

as for the look: i think you should be rendering each scope w/maxblend, but adding them to the rest of the picture:
EL (ignore, additive)
.render mode: maxblend
.superscope
EL (ignore, additive)
...
haven't tested it yet, but it's worth a try. the cubes should also change color. lastly: don't use straight up getosc for syncing! use something like (getosc(...)*bignumber)%returns as a replacement for rand(returns).
UnConeD#
Hate to sound nasty, but it's still inefficient... divisions are slower than multiplications. So:

iz=(1+(5+z3)*0.3);
x=x3/iz;
y=y3/iz*(w/h);

can be changed into:

iz=0.3/(8+z3);
x=x3*iz;
y=y3*iz*(w/h);

Oh and you should store w/h into some variable onframe, so you lose that division too. Remember that this stuff is being executed for every point (a couple hundred times), so small optimizations in per-point can make a huge difference!

About your 3D scope code... I wonder why you divide z3 by 3. This has the effect of zooming in on the picture (reducing the camera angle) and makes everything looks flatter. Check out the attachment (note: I'm editing, attachment will be in next post), where I quickly modified your preset so it has a normal, 90° field-of-view. Notice how there is much more depth-perception. Anyway you might've done this on purpose, I don't know.

As for the preset, I like the looks, but you should play with it some more. How about you make every cube-surface light on/off onbeat, perhaps in a certain color? Because the cubes are glass, the incorrect depth occlusion won't matter much.
The edges are a nice touch, but the color changes are hardly noticable.
Oh and if you have really loud music, the movement goes pretty nuts: try playing with it some more so it moves at a more constant speed. You can use getspec(0,0,0) as a volume indicator, especially when averaged over time (vol=vol*.9 + getspec(0,0,0)*.1 or something)

I ridiculed Atero's nagging a bit, but it's valuable nevertheless. Using a regular getosc for responsiveness makes you preset respond to only one sample of sound. This is good if all you want is a random-ish number, but not for variables such as rotation and speed, because they'll be too chaotic.

The best way to learn this kind of stuff is to make a moving-particle-like scope. Try making a dot that moves around at constant speed towards a random point, or one that accelerates and slows down in accordance with the beat.

Sometimes, the most important dimension in a preset is time: if a preset doesn't 'flow' nicely, it won't matter how it looks.
UnConeD#
(Attachment for post above)
Pixelcraft#
Looks great. I like how the central cube that faces the screen is brighter than the cubes on the other sides. Good job Raz,UnConeD and other "remixers."👍
Raz#
Hmm, i'd forgotten about that thanks. I originally did it because i thought it would look too much like my electric cube preset because i started with the same rotations and then modified them so that the z axis was smaller. I divided it by something smaller and additive blended things. Here's what i got now

btw thanks for all your help and comments everyone. You're all great 👍
shape#
I optimize some there, get 60fps in docked...
optimized points num,
optimized rotation algorithm.
But my answer is late...
Raz#
thanks man, great optimisations. I'd already done the cos and the sin thing but i hadn't done the n optimisations. Thanks 👍
Raz#
I have the tossest of computers and it runs at 13 with all the optimisations that i've done but not posted.