Skip to content
Forum Archive

Tips&Tricks in AVS

274 posts

dirkdeftly#
actually, that "fast" version isn't nearly correct, but it's a comparatively good approximation, and you get more proverbial bang for your buck 🙂
dirkdeftly#
a big 57f|_| to that sir.

visag, i'm going to tell you this one last time. STOP MAKING THOSE FUCKING RANDOM POSTS 😠
VisualAgnosia#
Good to hear from you Atero. I've missed your highly inteligent attempts at abuse for things that have nothing to do with you 🙂

Your attempt to inveigle me not to post "randomly" might be founded if they were actually "random". Odviously resorting to colourful language one may pick up from a seedy back alley where crack cocaine and "Hoes" may be obtained, is a fitting way of showing your dissapreciation for things you don't understand 👍.

Not to worry I have found an old dusty copy of the "Big ol' fun book of psychiatric experts, ways to help individuals not make fools of themselves .. written by Dr. Phil" which i could post you. A great read which I admit changed my life when I was an abusive, sexually frustrated, introvertedly sadistic egotist myself. There is hope ! moving along..

N E Way .. I have finnished my work now and I am a free man again. Unleashed from my bindings of the working class. I am once again umonkst the frey of self indulgence to do what ever I please.

A very interesting thread this one I have seen alot which is of good use to me.

Repra - Zent Siddhartha_1 All the Adeladians in tha house
[img]http://www.educo****b_zahran/images/en_australie/prace/adelaide_small.jpg[/img]
dirkdeftly#
no where did i put that "ban him" screenshot...

gd material belongs in gd, KEEP IT THERE. 😠
sidd#
an interlect which we will probably never uinderstand.

atero, the king off being pissed off at whatever is happening anywhere.

The cunning smarts of posting a useless message to inform someone that they have posted a useless message.

If that isnt the most intelegent thing you have ever seen, please post and tell me what is. But i wont chack on GD, so post it here!
HAHA!


sigh
sidd#
i posted this on another thread, and thought it should go here:

The color fade doesnt use HLS, as this wouldnt really effect the way it fades out at all. It is is tad more complicated, and if you read this you will see why Nullsoft didnt even try to explain it to all the n00bs who download AVS.

This is what i have worked out:

The top bar deals with the additive colors, or cyan, magentta and yellow. If it is left of half way across, is timesed by a number between 0 and 1, if more than half way across, it is timesd by a number greater than 1.
Because C,M and Y are comprised of mixes of the base colours (RGB), this method connot make solid cyans etc. Instead, as you increase the slider, the colors apear to lose their base, or their saturation, and eventually fade to white.

The middle slider deals with the base colours, or Red, Green and Blue. It works in the same way as CMY, by multiplying by 0-1, or 1>. Because it is multiplied, not added, and colours connot excede there maximum potential, the colours dont fade to white. Instead, more to the right you put it, the more the original colours will become solid red, green or blue.

The last one sort of works with brightness, luminescence, or the amount of 'white' (whichever does it for you). Works with the same multiplication method as above. This is the most 'normal' and useful: This will make the screen either fade to black or white. At a rate depending on how far to the left or right you place the bar.

A few tips:
the normal fadeout effect can be done by placing all the bars in the same position, and to the left of the center.

You can avoid the CMY bar doing the fading to white thing by makjing sure the RGB bar is always postioned slightly greater.

Remember that the sliders do not actually reprisent the colour values, they are multipliers and such.

If you dont understand the multiplication thingo, it is basically doing this:
if the slider is x units to the left: variable/x
if the slifer is x units to the right: variable*x
dirkdeftly#
which is, afaik, not true. put the top slidebar all the way to the left and you get rgb, put the second slidebar all the way to the left and you get low contrast, fast cycling pallettes. check out my post in the "Laser? WTF?" thread
Raz#
Lets try to keep this thread for tips and tricks about avs and not about how atero has pms and how visag posts random stuff. Really, who cares? And if they do, why? Is there something wrong with their brain that means they have to get pissed off at the slightest fault. Atero, it's not the end of the world if theres one random post. Sometimes random posting is funny. Theres no need to go all anal and be the hitler of the forum. Now... avs...

Oh yeah, nice to see you back visag, try not to provoke him too much.
shreyas_potnis#
RGB - HSL

Convert the RBG values to the range 0-1
Example: from the video colors page, colorbar red has R=83%, B=7%, G=7%, or in this scale, R=.83, B=.07, G=.07

Find min and max values of R, B, G
In the example, maxcolor = .83, mincolor=.07

If the max and min colors are the same (ie the color is some kind of grey), S is defined to be 0, and H is undefined but in programs usually written as 0

Otherwise, L = (maxcolor + mincolor)/2
For the example, L = (.83+.07)/2 = .45

Test L.
If L < 0.5, S=(maxcolor-mincolor)/(maxcolor+mincolor)
If L >=0.5, S=(maxcolor-mincolor)/(2.0-maxcolor-mincolor)
For the example, L=0.45 so S=(.83-.07)/(.83+.07) = .84

If R=maxcolor, H = (G-B)/(maxcolor-mincolor)
If G=maxcolor, H = 2.0 + (B-R)/(maxcolor-mincolor)
If B=maxcolor, H = 4.0 + (R-G)/(maxcolor-mincolor)
For the example, R=maxcolor so H = (.07-.07)/(.83-.07) = 0

To use the scaling shown in the video color page, convert L and S back to percentages, and H into an angle in degrees (ie scale it from 0-360)

HSL - RGB
If S=0, define R, G, and B all to L

Otherwise, test L.
If L < 0.5, temp2=L*(1.0+S)
If L >= 0.5, temp2=L+S - L*S
In the colorbar example for colorbar green, H=120, L=52, S=79, so converting to the range 0-1, L=.52, so
temp2=(.52+.79) - (.52*.79) = .899

temp1 = 2.0*L - temp2
In the example, temp1 = 2.0*.52 - .899 = .141

Convert H to the range 0-1
In the example, H=120/360 = .33

For each of R, G, B, compute another temporary value, temp3, as follows:
for R, temp3=H+1.0/3.0
for G, temp3=H
for B, temp3=H-1.0/3.0
if temp3 < 0, temp3 = temp3 + 1.0
In the example, Rtemp3=.33+.33 = .66, Gtemp3=.33, Btemp3=.33-.33=0

For each of R, G, B, do the following test:
If 6.0*temp3 < 1, color=temp1+(temp2-temp1)*6.0*temp3
Else if 2.0*temp3 < 1, color=temp2
Else if 3.0*temp3 < 2, color=temp1+(temp2-temp1)*((2.0/3.0)-temp3)*6.0
In the example,
3.0*Rtemp3 < 2 so R=.141+(.899-.141)*((2.0/3.0-.66)*6.0=.141
2.0*Gtemp3 < 1 so G=.899
6.0*Btemp3 < 1 so B=.141+(.899-.141)*6.0*0=.141


Scale back to the range 0-100 to use the scaling shown in the video color page
For the example, R=14, G=90, B=14

Found on the net 🙂
sidd#
hang on,
what use is RGB-HSL if the only time you ever get to specify colours in code form is in the superscope, where you can only use RGB for output.

also, your HSL-RGB code is exactly the same as given above, only mine was already coded for avs.
sidd#
that was kinda the point atero... they both use the HSL-RGB algorithm... so why post it twice?
you follow?
dirkdeftly#
whereas your algorithm was compiled (sorta), and shreyas's post explained it in detail.

and...afaik there is only one hsl/rgb algorithm. excepting sat={1,0} and lum={1,0}, it's a one-to-one function
sidd#
well, thats not entirely true, there are many different ways of alligning the hue value to show as loop from 0-1.
It is not neccessarily correct to have red, green or blue in any order, (although it is normally R-G-B).
Also, most methods use sine to 'shape' the scale. The one me and shreyas used doesnt, it just uses linear 1/3's.
shreyas_potnis#
Conding the algo in AVS sort of makes it a bit more complicated, so I just posted the algo here. No need to post the link, as I have copied whatever was preset on the page 🙂
dirkdeftly#
and...look at your hsl colorpicker some time. does it look like it has a sinusoidal interpolation? no, i'm afraid it doesn't. and what do you see when h=0? red. h=240? red. that's just the way it is, i'm sorry....
shreyas_potnis#
Metaballs dm, I made it some time ago:

init:
dc=1.2;g1=1;g2=1;

Frame:
bf=(bf+.1)/1.1;mov=tx1*tx2*tx3;af=h/w;
tx1=(tx1+dx1*.1)/1.1;ty1=(ty1+dy1*.1)/1.1;
tx2=(tx2+dx2*.1)/1.1;ty2=(ty2+dy2*.1)/1.1;
tx3=(tx3+dx3*.1)/1.1;ty3=(ty3+dy3*.1)/1.1;
tx4=(tx4+dx4*.1)/1.1;ty4=(ty4+dy4*.1)/1.1;
tx5=(tx5+dx5*.1)/1.1;ty5=(ty5+dy5*.1)/1.1;

Beat:
dx1=(rand(200)/100-1)*dc;dy1=(rand(200)/100-1)*dc;
dx2=(rand(200)/100-1)*dc;dy2=(rand(200)/100-1)*dc;
dx3=(rand(200)/100-1)*dc;dy3=(rand(200)/100-1)*dc;
dx4=(rand(200)/100-1)*dc;dy4=(rand(200)/100-1)*dc;
dx5=(rand(200)/100-1)*dc;dy5=(rand(200)/100-1)*dc;
bf=2;

Pixel:
y=y*af;
x1=x+tx1;
y1=y+ty1;

x2=x+tx2;
y2=y+ty2;

x3=x+tx3;
y3=y+ty3;

x4=x+tx4;
y4=y+ty4;

x5=x+tx5;
y5=y+ty6;

d1=pow(sqrt(sqr(x1)+sqr(y1))*g1,g2);
d2=pow(sqrt(sqr(x2)+sqr(y2))*g1,g2);
d3=pow(sqrt(sqr(x3)+sqr(y3))*g1,g2);
d4=pow(sqrt(sqr(x4)+sqr(y4))*g1,g2);
d5=pow(sqrt(sqr(x5)+sqr(y5))*g1,g2);

d=d1*d2*d3*d4*d5;
x=x1+x2+x3+x4+x5;
y=y1+y2+y3+y4+y5;
r=atan2(x1,y1)+mov;

alpha=bf-min(bf,d)

I am quite happy with the end results, dunno if its done before.
Tuggummi#
shift per pixel

A simple trick for advanced avsers.

To shift a scope by pixel.

X-axis
xt=xt+(#/w)*2

Y-axis
yt=yt+(#/h)*2

#=ammount of pixels skipped. 1=none , 0=no movement

Example:

per frame
xt=xt+(2/w)*2 ;

per pixel
y=i*2-1 ;
x=if(above(xt,1),-1,xt)


This will shift your scope by skipping every other line.


|-|-|-|-

Notice that if you want to skip 2 pixels, you don't use 2 you use 3. A way of "remembering" it is to write it like this:

xt=xt+(#/w)*2+2/w

2/w adds the extra pixel, so that what ever number you use in # it will skip that ammount of pixels. Of course it's better to use straight up higher number, but it's just for convenience.

example:

xt=xt+(3/w)*2+2/w

Will move the scope like this:


|---|---|---|---|---


Notice also that shifting per pixel won't work with sin&cos, only when you apply it directly to the scope movement it will work, you can use the if functions to limit the movement of the scope or to make it warp to the otherside once it reaches the end.
shreyas_potnis#
A very neat trick to darken the colours a little bit.
use an effect list with input replace and outpuit multiply. this will squrare the colours. as rgb are 0....1 then if RGB are not 0 or 1 their squares will be less than the original numbers!
Zevensoft#
It's effectively exactly the same as a Gamma 0.5 ramp.
If you invert the colours before and after, it becomes a Gamma 2.0 ramp.
shreyas_potnis#
Bunch of dm's I wrote in spare time...I hope someone can make good use of it.
DM Collection:
1) Binaculors

Frame:
t=t+.05;t1=t1+ti*.1;ti=ti*.9;
ox1=sin(t1)*.5*sin(t);oy=cos(t1)*.5;
rx=0;ry=0;rz=rz+.01+sin(t1-sin(t))*.05;
oz=t*5+sin(t1)*.5+.5;
sx=sin(rx);sy=sin(ry);sz=sin(rz);
cx=cos(rx);cy=cos(ry);cz=cos(rz);
af=max(h,w)/min(h,w);


Beat: ti=1

Point:
y=if(above(h,w),y*af,y);x=if(above(w,h),x*af,x);
dx1=x*cz-y*sz;dy1=x*sz+y*cz;
dy2=dy1*cx-sx;dz2=dy1*sx+cx;
dx3=dx1*cy-dz2*sy;dz2=dx1*sy+dz2*cy;

ox=ox1+.5;
dx1=sqr(dx3);dy1=sqr(dy2);dz1=sqr(dz2);
mtx=dx3*ox;mty=dy2*oy;mtz=dz2*oz;

a=2*(dx1+dy1);
b=2*(mtx+mty);
c=sqr(ox)+sqr(oy)-1;
D=sqr(b)-2*a*c;
k1=(-b+sqrt(abs(D)))/a;

ox=ox1-.5;
mtx=dx3*ox;mty=dy2*oy;mtz=dz2*oz;

a=2*(dx1+dy1);
b=2*(mtx+mty);
c=sqr(ox)+sqr(oy)-1;
D=sqr(b)-2*a*c;
k2=(-b+sqrt(abs(D)))/a;

k=max(k1,k2);
ix=k*dx3+ox;
iy=k*dy2+oy;
iz=k*dz2+oz;

x=atan2(ix,iy);
y=asin(sin(iz));
d=sqr(ix-ox)+sqr(iy-oy)+sqr(iz-oz);
alpha=4/(d+1);



2) 8 sided shape
Frame:
t=t+.001+ti*.1;ti=ti*.9;
ox=cos(t)*.6*sin(t*.76+t);
oy=cos(t*.76+1)*.9;
oz=sin(t-1)*cos(t);
rx=0.1+atan2(ox,sqr(oy)+sqr(oz));
ry=atan2(ox,oz);
rz=-atan2(oz,sqr(ox)+sqr(oy));

sx=sin(rx);sy=sin(ry);sz=sin(rz);
cx=cos(rx);cy=cos(ry);cz=cos(rz);
af=max(h,w)/min(h,w);

cz1=cos(-pi/4);sz1=sin(-pi/4);

Beat:ti=.4

Point:
y=if(above(h,w),y*af,y);x=if(above(w,h),x*af,x);

dx1=x*cz-y*sz;
dy1=x*sz+y*cz;
dy2=dy1*cx-sx;
dz2=dy1*sx+cx;
dx3=dx1*cy-dz2*sy;
dz2=dx1*sy+dz2*cy;
dx1=dx3*cz1-dy2*sz1;
dy1=dx3*sz1+dy2*cz1;
dx3=dx1;dy2=dy1;

k1=(1-oy-ox)/(dy2+dx3);
k1=if(below(k1,0),(-1-oy-ox)/(dy2+dx3),k1);

k3=(1-oy)/dy2;
k3=if(below(k3,0),(-1-oy)/dy2,k3);

k4=(1-ox)/dx3;
k4=if(below(k4,0),(-1-ox)/dx3,k4);

k5=(2-oz)/dz2;
k5=if(below(k5,0),(-2-oz)/dz2,k5);

k=min(min(k1,k5),min(k4,k3));

x=k*dx3+ox;
y=k*dz2+oz;

x=if(equal(k,k4),k*dy2+oy,x);
y=if(equal(k,k5),k*dy2+oz,y);


3) 3 tunnel intersection:
Note: there is something special about this dm, what you need to do is use a 4X4 colour grid to the original texture so that the upper right part of the texture has a different colour tone than the lower left part. Now observe 🙂

Frame:
t=t+.05;

rad=1.4;
rx=(rx+rx1*.1)/1.1;
ry=(ry+ry1*.1)/1.1;
rz=(rz+rz1*.1)/1.1;

sx=sin(rx);sy=sin(ry);sz=sin(rz);
cx=cos(rx);cy=cos(ry);cz=cos(rz);

ox=(sx+cy+cz)*.33;
oy=(sy+cx+cz)*.33;
oz=(sz+cx+cy)*.33;

af=max(h,w)/min(h,w);

Beat:
cb=cb+1;
rx1=if(cb%5,rx1,if(below(abs(rx-rx1),.3),rx1+pi/2*sign(getosc(0,0,0)),rx1));
ry1=if(cb%3,ry1,if(below(abs(ry-ry1),.3),ry1+pi/2*sign(getosc(0.1,0,0)),ry1));
rz1=if(cb%2,rz1,if(below(abs(rz-rz1),.3),rz1+pi/2*sign(getosc(0.2,0,0)),rz1));
col=-col;

Point:
y=if(above(h,w),y*af,y);x=if(above(w,h),x*af,x);
dx1=x*cz-y*sz;dy1=x*sz+y*cz;
dy2=dy1*cx-sx;dz2=dy1*sx+cx;
dx3=dx1*cy-dz2*sy;dz2=dx1*sy+dz2*cy;

dx1=sqr(dx3);dy1=sqr(dy2);dz1=sqr(dz2);
mtx=dx3*ox;mty=dy2*oy;mtz=dz2*oz;

¤ center sphere;

a=dx1+dy1+dz1;
b=2*(dx3*ox+dy2*oy+dz2*oz);
c=sqr(oz)+sqr(oy)+sqr(oz)-4;
D=sqr(b)-4*a*c;
k4=(-b+sqrt(abs(d)))/(2*a);
k4=if(below(D,0),1000,k4);

c=sqr(oz)+sqr(oy)+sqr(oz)-16;
D=sqr(b)-4*a*c;
k5=(-b+sqrt(abs(d)))/(2*a);
k5=if(below(D,0),1000,k5);

¤cylinder on z-axis;
a=2*(dx1+dy1);
b=2*(mtx+mty);
c=sqr(ox)+sqr(oy)-sqr(rad);
D=sqr(b)-2*a*c;
k1=(-b+sqrt(abs(D)))/a;

k1=if(below(D,0),1000,k1);

¤cyliner along y-axis;
a=2*(dx1+dz1);
b=2*(mtx+mtz);
c=sqr(ox)+sqr(oz)-sqr(rad);
D=sqr(b)-2*a*c;
k2=(-b+sqrt(abs(D)))/a;
k2=if(below(D,0),1000,k2);

¤cyliner along x-axis;
a=2*(dy1+dz1);
b=2*(mty+mtz);
c=sqr(oy)+sqr(oz)-sqr(rad);
D=sqr(b)-2*a*c;
k3=(-b+sqrt(abs(D)))/a;

k3=if(below(D,0),1000,k3);

k=min(max(max(max(k1,k2),k3),k4),k5);

ix=k*dx3+ox;iy=k*dy2+oy;iz=k*dz2+oz;

x=if(equal(k,k1),ix,if(equal(k,k2),ix,iy));
y=if(equal(k,k1),iz,if(equal(k,k2),iy,ix));

r=if(equal(k,k4),2,4);
x=if(equal(k,k4)+equal(k,k5),atan2(ix,iz)/2,x);
y=if(equal(k,k4)+equal(k,k5),asin(iy/r)*2,y);

x=asin(sin(x*pi*.5))*2/pi;
y=asin(sin(y*pi*.5))*2/pi;

x=if(equal(k,k4)+equal(k,k5),abs(x)*col,-abs(x)*col);
y=if(equal(k,k4)+equal(k,k5),abs(y)*col,-abs(y)*col);
d=sqr(ix-ox)+sqr(iy-oy)+sqr(iz-oz);
alpha=7/(d+1)*bnot(equal(k,1000));



4) 3 tunnel intersection in a cube: same as above except insead of the intersection sphere, there is a cube
Init:
pi=acos(-1);col=1
fRAME:
t=t+.05;

rx=(rx+rx1*.1)/1.1;
ry=(ry+ry1*.1)/1.1;
rz=(rz+rz1*.1)/1.1;

sx=sin(rx);sy=sin(ry);sz=sin(rz);
cx=cos(rx);cy=cos(ry);cz=cos(rz);

ox=(sx+cy+cz)*.33;
oy=(sy+cx+cz)*.33;
oz=(sz+cx+cy)*.33;

af=max(h,w)/min(h,w);

Beat:
cb=cb+1;
rx1=if(cb%5,rx1,if(below(abs(rx-rx1),.3),rx1+pi/2*sign(getosc(0,0,0)),rx1));
ry1=if(cb%3,ry1,if(below(abs(ry-ry1),.3),ry1+pi/2*sign(getosc(0.1,0,0)),ry1));
rz1=if(cb%2,rz1,if(below(abs(rz-rz1),.3),rz1+pi/2*sign(getosc(0.2,0,0)),rz1));
col=-col;

Point:
y=if(above(h,w),y*af,y);x=if(above(w,h),x*af,x);
dx1=x*cz-y*sz;dy1=x*sz+y*cz;
dy2=dy1*cx-sx;dz2=dy1*sx+cx;
dx3=dx1*cy-dz2*sy;dz2=dx1*sy+dz2*cy;

dx1=sqr(dx3);dy1=sqr(dy2);dz1=sqr(dz2);
mtx=dx3*ox;mty=dy2*oy;mtz=dz2*oz;

¤cylinder on z-axis;
a=2*(dx1+dy1);
b=2*(mtx+mty);
c=sqr(ox)+sqr(oy)-sqr(rad);
D=sqr(b)-2*a*c;
k1=(-b+sqrt(abs(D)))/a;

k1=if(below(D,0),1000,k1);

¤cyliner along y-axis;
a=2*(dx1+dz1);
b=2*(mtx+mtz);
c=sqr(ox)+sqr(oz)-sqr(rad);
D=sqr(b)-2*a*c;
k2=(-b+sqrt(abs(D)))/a;
k2=if(below(D,0),1000,k2);

¤cyliner along x-axis;
a=2*(dy1+dz1);
b=2*(mty+mtz);
c=sqr(oy)+sqr(oz)-sqr(rad);
D=sqr(b)-2*a*c;
k3=(-b+sqrt(abs(D)))/a;

k3=if(below(D,0),1000,k3);

k4=(2-ox)/dx3;
k5=(2-oy)/dy2;
k6=(2-oz)/dz2;

k4=if(below(k4,0),(-ox-2)/dx3,k4);
k5=if(below(k5,0),(-oy-2)/dy2,k5);
k6=if(below(k6,0),(-oz-2)/dz2,k6);

k=min(min(k4,k5),k6);
k=max(k,max(max(k1,k2),k3));

ix=k*dx3+ox;iy=k*dy2+oy;iz=k*dz2+oz;

x=if(equal(k,k1),ix,if(equal(k,k2),ix,iy));
y=if(equal(k,k1),iz,if(equal(k,k2),iy,ix));
y=if(equal(k,k4),iy,y);
y=if(bor(equal(k,k5),equal(k,k6)),iz,y);
y=if(equal(k,k6),iy,y);
x=if(equal(k,k4),iz,x);
x=if(bor(equal(k,k5),equal(k,k6)),ix,x);
dx1=if(equal(k,k1)+equal(k,k2)+equal(k,k3),1,-1);

x=abs(asin(sin(x*pi*.5))*2/pi)*col*dx1;
y=abs(asin(sin(y*pi*.5))*2/pi)*col*dx1;
d=sqr(ix-ox)+sqr(iy-oy)+sqr(iz-oz);
alpha=4/(d+1)*bnot(equal(k,1000));
jheriko#
Those DMs could use some optimisation. Remember that putting things in if statements means that both results are calculated so for instance:

x=if(equal(k,k4)+equal(k,k5),abs(x)*col,-abs(x)*col);

should be

x=if(equal(k,k4)+equal(k,k5),1,-1)*abs(x)*col;

one less abs and one less * than before.
kPlanet#
och warumn ni!?
da müsste sich mal einer ransetzen...^^
und... nein ich werd das nicht sein! löl