Log in

View Full Version : How do I use this noise factory script ?


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

Boulder
26th February 2008, 08:10
What is your script?

xbox360
27th February 2008, 04:12
More Info is available here:

http://www.neuron2.net/board/viewtopic.php?t=720

Boulder
27th February 2008, 04:34
Yes, I know the function originates from there, but what is your complete script?

xbox360
27th February 2008, 10:21
LoadPlugin("DGDecode.dll")
Loadlugin("MaskTools.dll")
Loadlugin("AddGrain.dll")
Import("noisefactory.avs)

Mpeg2Source("xxx.d2v")

Boulder
27th February 2008, 10:24
You need to place the Import line after the MPEG2Source line. That way the contents of the imported script will be applied to the source (since the script is not wrapped inside a function in the avs file).

xbox360
2nd March 2008, 06:30
Still not working, same eror !!!:devil:

Boulder
2nd March 2008, 09:14
Post the complete script once again ;)

xbox360
2nd March 2008, 09:48
Boulder YOU SUCK !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :mad::mad::mad::mad::mad::mad::mad::mad::mad::mad:

Boulder
2nd March 2008, 09:58
If I ask you to post the complete script that you tried to use, that is not the way to respond.

sh0dan
2nd March 2008, 10:11
@xbox360: Please reconsider you attitude toward people who are trying to help you.

Thread closed.