jmac698
18th November 2011, 06:31
After IanB was duly impressed by some surprising code banged out by Gavino in http://forum.doom9.org/showthread.php?t=163107, I thought I'd take up the challenge of doing something unusual in Avisynth, thus, the first demo.
I am constantly amazed at what people can actually do with Avisynth scripts.
#Fractal Zoomer 1.01 by jmac698
#The first Avisynth demo-style fractal zoomer
#requires masktools
#warning: slow startup
aspect=(2.5+1)/(1+1)
w=160
h=round(w/aspect)
h=h-h%2
blankclip(width=w,height=h,pixel_type="YV12", color_yuv=$8040C0, length=320)
global zrsqr=last
global zisqr=last
global zr=last
global zi=last
global cr=last
global ci=last
global cr=ScriptClip(cr,"""
mt_lutspa(mode="relative inclusive",yexpr="x 3.5 * 2.5 - "+string(36-current_frame/10.)+" * 128 +")#-2.5 to 1 (oiii.bbbb) 88 to 144
""")
global ci=ScriptClip(ci,"""
mt_lutspa(mode="relative inclusive",yexpr="y 2 * 1 - "+string(36-current_frame/10.)+" * 128 +")#112 to 144
""")
effect="softlight"
mandeliter
overlay(mandeliter,opacity=.5,mode=effect)
overlay(mandeliter,opacity=.5,mode=effect)
overlay(mandeliter,opacity=.5,mode=effect)
overlay(mandeliter,opacity=.5,mode=effect)
overlay(mandeliter,opacity=.5,mode=effect)
overlay(mandeliter,opacity=.5,mode=effect)
bilinearresize(720,410)
ScriptClip("""
subtitle("Avisynth Fractal Zoomer by jmac",y=300+sin(current_frame/100.)*40,x=720-current_frame*3.5,size=24,text_color=$8080ff)
""")
function mandeliter{
global zi=mt_lutxyz(zr,zi,ci,yexpr=smult(smult("x","y"),"160")+" z + 128 -")
global zr=mt_lutxyz(zrsqr,zisqr,cr,yexpr=mt_polish("x-y+z"))
global zrsqr=mt_lut(zr,yexpr=smult("x","x"))
global zisqr=mt_lut(zi,yexpr=smult("x","x"))
mt_lutxy(zrsqr,zisqr,yexpr=mt_polish("x+y-128>=192?255:0"))
}
function smult(string x, string y){
#Perform 8 bit signed mult in offset $80 with mantissa bits
mantissa=4
one=pow(2,8-mantissa)
x+" 128 - "+string(one)+" / "+y+" 128 - "+string(one)+" / * "+string(one)+" * 128 +"
}
Small mistake, change 160 to 192, looks much better now....
I am constantly amazed at what people can actually do with Avisynth scripts.
#Fractal Zoomer 1.01 by jmac698
#The first Avisynth demo-style fractal zoomer
#requires masktools
#warning: slow startup
aspect=(2.5+1)/(1+1)
w=160
h=round(w/aspect)
h=h-h%2
blankclip(width=w,height=h,pixel_type="YV12", color_yuv=$8040C0, length=320)
global zrsqr=last
global zisqr=last
global zr=last
global zi=last
global cr=last
global ci=last
global cr=ScriptClip(cr,"""
mt_lutspa(mode="relative inclusive",yexpr="x 3.5 * 2.5 - "+string(36-current_frame/10.)+" * 128 +")#-2.5 to 1 (oiii.bbbb) 88 to 144
""")
global ci=ScriptClip(ci,"""
mt_lutspa(mode="relative inclusive",yexpr="y 2 * 1 - "+string(36-current_frame/10.)+" * 128 +")#112 to 144
""")
effect="softlight"
mandeliter
overlay(mandeliter,opacity=.5,mode=effect)
overlay(mandeliter,opacity=.5,mode=effect)
overlay(mandeliter,opacity=.5,mode=effect)
overlay(mandeliter,opacity=.5,mode=effect)
overlay(mandeliter,opacity=.5,mode=effect)
overlay(mandeliter,opacity=.5,mode=effect)
bilinearresize(720,410)
ScriptClip("""
subtitle("Avisynth Fractal Zoomer by jmac",y=300+sin(current_frame/100.)*40,x=720-current_frame*3.5,size=24,text_color=$8080ff)
""")
function mandeliter{
global zi=mt_lutxyz(zr,zi,ci,yexpr=smult(smult("x","y"),"160")+" z + 128 -")
global zr=mt_lutxyz(zrsqr,zisqr,cr,yexpr=mt_polish("x-y+z"))
global zrsqr=mt_lut(zr,yexpr=smult("x","x"))
global zisqr=mt_lut(zi,yexpr=smult("x","x"))
mt_lutxy(zrsqr,zisqr,yexpr=mt_polish("x+y-128>=192?255:0"))
}
function smult(string x, string y){
#Perform 8 bit signed mult in offset $80 with mantissa bits
mantissa=4
one=pow(2,8-mantissa)
x+" 128 - "+string(one)+" / "+y+" 128 - "+string(one)+" / * "+string(one)+" * 128 +"
}
Small mistake, change 160 to 192, looks much better now....