Archive: Fast Square Renderer


4th August 2002 18:37 UTC

Fast Square Renderer
Hey guys. I've been playing around with stuff for my upcoming AVS pack, and I've got a question.

For a preset of mine, I've got a rotating square that changes colors. Currently, I do this with a SS that draws lots of line, but it takes a (relatively) long time to do that. Attached are two presets, one of them contains the entire preset, and the other just the square.
The question is, is there any better way to do that? I thought there was a way, by making a movement that just says

 d=0; 
and a 1x1 DM that zooms and rotates, but it doesn't work.

Any ideas?
Thanks,
~Keaton

4th August 2002 18:56 UTC

The problem with a DM is that, when wrap is turned off, it stretches the edges so that the image always fits inside the window. I suggest you add a superscope that draws a black square around the edges, and then use a DM. If your gridsize is high enough and the black edges are not too thin, then you won't see any stretching.

Or you can leave wrap on and use alpha blending, but I think the previous technique is faster.


22nd August 2002 00:28 UTC

i've looked at your superscope, it is about a million times more complex than it needs to be. attached is a completely solid square preset (no holes at all) that rotates and changes color at much higher fps than either of your attempts (it peaks out on my system at about 60-70 at 320x200). it uses really simple code so you should just be able to look at it to understand it hopefully. if not all it does is draw a load of parallel lines in the shape of a square then multiplies the result by the 2d rotation matrix. the color change code i put in was just so that is wasn't plain white.

if this isn't what your trying to do then sorry for wasting your time.
if it is then i hope that it is helpful


22nd August 2002 01:44 UTC

I made some improvements to that one as well. It turned out one of my biggest problems was the way I determined how many points to use. Instead of using more points to draw a bigger square, I did the opposite! Whoops! Well, anyway, the effect is done and now you'll just hafta wait until my pack comes out to see it...


22nd August 2002 10:45 UTC

yeah i did make it a bit quick you could have taken the sin and cos out of point and into frame for a bit more speed... anyways nice to know you figured it out


3rd September 2002 11:22 UTC

FFSQ (f****** fast square)
This one uses the excactly the number of points needed for the current resolution. Remember:
one pixel on x in SSC-coords is 2/w
one pixel on y in SSC-coords os 2/h

init:
size=1

frame:
step=2/h;n=h*size;asp=h/w;
yp=-size/2;xp=-size/2;p=0;

init:
p=bnot(p);
yp=yp+p*step;xp=(-size/2+p*size)*asp


----------------------------

asp = aspect ratio x/y to keep square in different windows.
Remove this if you rotate the thing but now you don't get a real square. if you like to rotate the "square" you have to setup n depending on the max of width and height to avoid holes.

frame:
maxlines=max(w,h);step=2/maxlines;n=maxlines*size;
yp=-size/2;xp=-size/2;p=0;


3rd September 2002 12:13 UTC

EXAMPLE
Here's an example of the above used with my 3D-SSC-Setup!


5th September 2002 10:32 UTC

COLORING THE THING
Worked a little more on the 3D-Setup using z3 and getosc and beat to color the square and doing music-reaction...