xbox360
26th February 2008, 05:09
#===================================================================================
#
# A small "noise factory"
#
#===================================================================================
# *** Adjust values below: ***
grain1_strength = 10 # [ 0 - ???] strength of grain / for mid-tone areas
grain1_size = 1.15 # [0.5 - 4.0] size of grain / for mid-tone areas
grain2_strength = 5 # [ 0 - ???] strength of grain / for dark & bright areas
grain2_size = 0.8 # [0.5 - 4.0] size of grain / for dark & bright areas
grain1_sharpness = 100 # [ 0 - 100] very soft (0) to very sharp(100)
grain2_sharpness = 100 # [ 0 - 100] grain definition
grain1_texture = 100 # [ 0 - 100] strength of "material texture" appearance
grain2_texture = 50 # [ 0 - 100] (in fact: 'bump' effect)
ontop_grain = 3 # [ 0 - ???] additional grain to put on top of prev. generated grain
temp_avg = 20 # [ 0 - 100] percentage of noise's temporal averaging
brightness_bias = 0.96 # [0.5 - 2.0] bias for dark|bright --> midtone fading
#-----------------------------------------------------------------------------------
o = last
ox = o.width
oy = o.height
sx1 = m4(ox/grain1_size)
sy1 = m4(oy/grain1_size)
sx1a = m4((ox+sx1)/2.0)
sy1a = m4((oy+sy1)/2.0)
sx2 = m4(ox/grain2_size)
sy2 = m4(oy/grain2_size)
sx2a = m4((ox+sx2)/2.0)
sy2a = m4((oy+sy2)/2.0)
b1 = grain1_sharpness/(-50.0) + 1.0
b2 = grain2_sharpness/(-50.0) + 1.0
b1a = b1/2.0
b2a = b2/2.0
c1 = (1.0-b1)/2.0
c2 = (1.0-b2)/2.0
c1a = c1/2.0
c2a = c2/2.0
t1a = string(grain1_texture)
t1b = string(100-grain1_texture)
t2a = string(grain2_texture)
t2b = string(100-grain2_texture)
tmpavg = temp_avg/100.0
#-----------------------------------------------------------------------------------
ADD_DIFF = "x y - 128 +"
BUMPKERNEL1 = T1a + " 0 0 0 " + T1b + " 0 0 0 0"
BUMPKERNEL2 = T2a + " 0 0 0 " + T2b + " 0 0 0 0"
CENTER2MAX_BIAS = "x 120 - abs "+string(brightness_bias)+" ^ 2.5 *"
#-----------------------------------------------------------------------------------
grainlayer1 = blankclip(o, width=sx1, height=sy1, color=$808080) .AddGrain(grain1_strength, 0, 0)
grainlayer1 = (grain1_texture==0)
\ ? grainlayer1
\ : yv12lutxy(grainlayer1,grainlayer1.DEdgeMask(0,255,0,255, BUMPKERNEL1), ADD_DIFF)
grainlayer1 = (grain1_size == 1.0) ? grainlayer1
\ : (grain1_size < 0.75) ? grainlayer1.bicubicresize(sx1a,sy1a, b1a, c1a).bicubicresize(ox,oy, b1a,c1a)
\ : grainlayer1.bicubicresize(ox,oy, b1,c1)
#-----------------------------------------------------------------------------------
grainlayer2 = blankclip(o, width=sx2, height=sy2, color=$808080) .AddGrain(grain2_strength, 0, 0)
grainlayer2 = (grain2_texture==0)
\ ? grainlayer2
\ : yv12lutxy(grainlayer2,grainlayer2.DEdgeMask(0,255,0,255, BUMPKERNEL1), ADD_DIFF)
grainlayer2 = (grain2_size == 1.0) ? grainlayer2
\ : (grain2_size < 0.75) ? grainlayer2.bicubicresize(sx2a,sy2a, b2a, c2a).bicubicresize(ox,oy, b2a,c2a)
\ : grainlayer2.bicubicresize(ox,oy, b2,c2)
#-----------------------------------------------------------------------------------
grainlayer = MaskedMerge(grainlayer1, grainlayer2, o.yv12lut(CENTER2MAX_BIAS), U=1,V=1)
grainlayer = (temp_avg==0) ? grainlayer
\ : grainlayer.mergeluma(grainlayer.temporalsoften(1,255,255,255,2), tmpavg)
grainlayer = (ontop_grain==0) ? grainlayer
\ : grainlayer.AddGrain(ontop_grain,0,0)
#-----------------------------------------------------------------------------------
result = yv12lutxy(o, grainlayer, ADD_DIFF, U=2,V=2)
return result
#-----------------------------------------------------------------------------------
function m4(float x) {return( x<16?16:int(round(x/4.0)*4)) }
#===================================================================================
When I try to use it I get this error:
Script error: Invalid arguments to function "width"
Plugins I used is MaskTools & AddGrain
#
# A small "noise factory"
#
#===================================================================================
# *** Adjust values below: ***
grain1_strength = 10 # [ 0 - ???] strength of grain / for mid-tone areas
grain1_size = 1.15 # [0.5 - 4.0] size of grain / for mid-tone areas
grain2_strength = 5 # [ 0 - ???] strength of grain / for dark & bright areas
grain2_size = 0.8 # [0.5 - 4.0] size of grain / for dark & bright areas
grain1_sharpness = 100 # [ 0 - 100] very soft (0) to very sharp(100)
grain2_sharpness = 100 # [ 0 - 100] grain definition
grain1_texture = 100 # [ 0 - 100] strength of "material texture" appearance
grain2_texture = 50 # [ 0 - 100] (in fact: 'bump' effect)
ontop_grain = 3 # [ 0 - ???] additional grain to put on top of prev. generated grain
temp_avg = 20 # [ 0 - 100] percentage of noise's temporal averaging
brightness_bias = 0.96 # [0.5 - 2.0] bias for dark|bright --> midtone fading
#-----------------------------------------------------------------------------------
o = last
ox = o.width
oy = o.height
sx1 = m4(ox/grain1_size)
sy1 = m4(oy/grain1_size)
sx1a = m4((ox+sx1)/2.0)
sy1a = m4((oy+sy1)/2.0)
sx2 = m4(ox/grain2_size)
sy2 = m4(oy/grain2_size)
sx2a = m4((ox+sx2)/2.0)
sy2a = m4((oy+sy2)/2.0)
b1 = grain1_sharpness/(-50.0) + 1.0
b2 = grain2_sharpness/(-50.0) + 1.0
b1a = b1/2.0
b2a = b2/2.0
c1 = (1.0-b1)/2.0
c2 = (1.0-b2)/2.0
c1a = c1/2.0
c2a = c2/2.0
t1a = string(grain1_texture)
t1b = string(100-grain1_texture)
t2a = string(grain2_texture)
t2b = string(100-grain2_texture)
tmpavg = temp_avg/100.0
#-----------------------------------------------------------------------------------
ADD_DIFF = "x y - 128 +"
BUMPKERNEL1 = T1a + " 0 0 0 " + T1b + " 0 0 0 0"
BUMPKERNEL2 = T2a + " 0 0 0 " + T2b + " 0 0 0 0"
CENTER2MAX_BIAS = "x 120 - abs "+string(brightness_bias)+" ^ 2.5 *"
#-----------------------------------------------------------------------------------
grainlayer1 = blankclip(o, width=sx1, height=sy1, color=$808080) .AddGrain(grain1_strength, 0, 0)
grainlayer1 = (grain1_texture==0)
\ ? grainlayer1
\ : yv12lutxy(grainlayer1,grainlayer1.DEdgeMask(0,255,0,255, BUMPKERNEL1), ADD_DIFF)
grainlayer1 = (grain1_size == 1.0) ? grainlayer1
\ : (grain1_size < 0.75) ? grainlayer1.bicubicresize(sx1a,sy1a, b1a, c1a).bicubicresize(ox,oy, b1a,c1a)
\ : grainlayer1.bicubicresize(ox,oy, b1,c1)
#-----------------------------------------------------------------------------------
grainlayer2 = blankclip(o, width=sx2, height=sy2, color=$808080) .AddGrain(grain2_strength, 0, 0)
grainlayer2 = (grain2_texture==0)
\ ? grainlayer2
\ : yv12lutxy(grainlayer2,grainlayer2.DEdgeMask(0,255,0,255, BUMPKERNEL1), ADD_DIFF)
grainlayer2 = (grain2_size == 1.0) ? grainlayer2
\ : (grain2_size < 0.75) ? grainlayer2.bicubicresize(sx2a,sy2a, b2a, c2a).bicubicresize(ox,oy, b2a,c2a)
\ : grainlayer2.bicubicresize(ox,oy, b2,c2)
#-----------------------------------------------------------------------------------
grainlayer = MaskedMerge(grainlayer1, grainlayer2, o.yv12lut(CENTER2MAX_BIAS), U=1,V=1)
grainlayer = (temp_avg==0) ? grainlayer
\ : grainlayer.mergeluma(grainlayer.temporalsoften(1,255,255,255,2), tmpavg)
grainlayer = (ontop_grain==0) ? grainlayer
\ : grainlayer.AddGrain(ontop_grain,0,0)
#-----------------------------------------------------------------------------------
result = yv12lutxy(o, grainlayer, ADD_DIFF, U=2,V=2)
return result
#-----------------------------------------------------------------------------------
function m4(float x) {return( x<16?16:int(round(x/4.0)*4)) }
#===================================================================================
When I try to use it I get this error:
Script error: Invalid arguments to function "width"
Plugins I used is MaskTools & AddGrain