- AVS
- Few questions about AVS... (advanced stuffs)
Archive: Few questions about AVS... (advanced stuffs)
Nic01
5th April 2002 04:14 UTC
Few questions about AVS... (advanced stuffs)
I kinda still have a lot to learn 'bout AVS...
Here are the load of questions :p
How do you make a whole screen-grid using only 1 SSC?
Another SSC question : How can I make a line SSC, in which somewhere along the SSC, there's a line perpendicular to the first line, but still using the same SSC? (I gonna use this to make a Tetris preset I've planned to make... making a Tetris shapes lens DMs are easy, but using SSC... I can't =( )(I'll also edit line width, so just need the skeleton)
I know it won't help me, but what is the gridsize of Trans/Movement?
How to make a DM Lens that is curved nicely from edge to middle?
To explain :
Like the lens in UnConeD's Second Reality, not like in :
d=if(band(band(above(x,-.5),below(x,.5)),band(above(y,-.5),below(y,.5))),d/2,d);
Answers to the question would be very appreciated =)
Jaheckelsafar
5th April 2002 08:01 UTC
I don't think movement has a grid size, I believe it does all the pixels in the render.
As to the rest, no idea.
UnConeD
5th April 2002 14:52 UTC
One at a time :)
How do you make a whole screen-grid using only 1 SSC?
The trick here is to throw
i out the window... it's inaccurate due to round-off errors. Also remember that you can set
n in every frame. So basically we need to make a variable
xp (xposition) traverse every value from 0 to
w (width), while
yp traverses every position from 0 to [i]h[ (height).
Unfortunately, it's best to use w+1 and h+1 for width and height. If you don't, you'll get nasty round-off errors too.
So, in onframe:
ww
=w+1;hh+h+1;n=ww*hh;xp=0;yp=0;iw=1/ww;ih=1/hh;
iw and
ih are the inverted (adjusted) width and height, calculated only once every frame to speed the preset up... multiplication is several times faster than division.
In per point:
x
=xp*iw*2-1;y=yp*ih*2-1;
.....
xp=if(above(xp+1,ww),0,xp+1);
yp=if(xp,yp,yp+1);
First, we transform the variables xp,yp in the range (0..ww, 0..hh) into AVS coordinates (-1..1, -1..1), by dividing by width and height, and multiplying by 2 and subtracting 1.
Then, at the end, we increase
xp by one. When it equals the width, we set it back to zero.
yp is increased only when
xp is zero. Note that this doesn't happen the first time around (because
xp will equal 1 after the first pixel). So you have a pretty grid that fills the full screen... but it's slow as hell. Speed-up tips include skipping every uneven pixel and using lines to get a 'pixel-doubled' grid.
UnConeD
5th April 2002 16:47 UTC
If you want to make one superscope which consists of multiple disconnected line segments, you'll need to use a render-mode like Additive or Maximum, and simply set the color to black when you don't want a line to be drawn. A good example is my Plankton preset... all the swimming particles are only one SSC, and you can see this by turning off the blendmode change.
Nic01
6th April 2002 21:28 UTC
Umm, I think I need to rephrase my Tetris SSC question a bit, this time in form of a different question...
How do you make a "T" using one SSC?
An "l" With horizontally laid "T" on top of it using one SSC?
(In other words, the shpae itself... :p )
UnConeD
6th April 2002 22:23 UTC
Probably something like this:
1---------->2 -----3<----2 -----3-----
|
|
v
4
Use if's in a 4 point superscope to set the coordinates accordingly each time.
Nic01
7th April 2002 18:31 UTC
Hmm, but what Variable?
I tried using If(equal(n,#) , but doesn't work...
Hmm, possibly I'd have to use 2-3 synchronized SSCs...
So, my (probably :p ) last question :
What is the min/max value of Getosc/Getspec command?
UnConeD
8th April 2002 03:01 UTC
i'd do something like:
"u=i*n"
-> that way, u contains a number 0, 1, 2, 3... up to 'n'. Then use that in if statements.
Nic01
10th April 2002 02:34 UTC
Tried that, didn't work... :cry:
BUT...
Try this : (any variable)=n*i-i :D
That works! (All that problem, and one simple formula...)
I use p for the variable - stands for "point"...
And of course, only the coordinates of the point is the only thing needed to be done, using "i" won't work (remember, when SSC is set on lines, it will automatically draw line from n#1 to n#2 to n#3... but not last n to first n)
The Tetris shapes are rather easy to make once the formula above come into use...
Hmm, now if only I can make a smooth lens, not a lens with the edge a bit too obvious...
UnConeD
10th April 2002 03:48 UTC
For a good lens... first of all, you need a good view on mathematical functions.
Try the following superscope:
u=i*2-1;
x=u;y=-(u*u);
This will draw a parabola... because the relationship between any variable 'x' and its square 'x*x' is shaped like that. Similary, a linear relationship f(x) = a*x (where a is any real number) is a straight line passing through the origin. Try visualising math functions this way. Fill this in in the superscope: y=-(sin(u)); Now try y=-(sin(u*2)); This has the effect that the graph is 'squished' horizontally, so you see more of it.
What am I getting at? Well... the distortion you want is probably that you're changing a 'd' based on a specific formula. I also suppose that you use something like d=if(below(d, 0.5), ..., ...) to keep the lens small. So what you want now is a function that bulges/enlarges when 'd' is inside your interval, and is nicely linear (i.e. doesn't change d) outside. You also need to make sure that, when d is on the edge of the lens, there is no sudden jump in value.
Here's a good example:
y=-(if(below(abs(u),.5),abs(u)*u*2,u));
If you remove/change the *2, you'll see that the graph is no longer continuous. I also made sure that the function behaves appropriately for negative values, but for 'd' values, which are positive-only, that's not even necessary. Of course, I'm not sure if this will look like a convincing lens, but you should be able to figure out an appropriate formula yourself.
For better plotting of mathematical functions, you need a good math program... but for a quick look, a superscope will do :).