|
|
|||
|
||||
Lua scripting for Project
Dogwaffle: Waving
in the Breeze
(or under water) |
||||
|
||||
Here is a script which will let
you create animations of waving grass
in wind, or under water. (the rising bubbles in this example were added
with the Snowfall filter in the Timeline editor while the animation
frames were flipped upside-down). It applys a sine wave to the canvass, with the power of the wave based on the y distance, so the effect tends to fade away towards the bottom. It supports animation, and the image can be sheared as well, making your reeds look like they're bent over. If you create several different versions with different time offsets and composite them together, I think you can get what you're looking for. |
||||
The script:
|
-- -- How to create an animation waving grass (wind blown). -- -- It applys a sine wave to the canvass, with the power of the wave -- based on the y distance, so the effect tends to fade away towards -- the bottom. It supports animation, and the image can be sheared as -- well, making your reeds look like they're bent over. -- -- If you create several different versions with different time offsets -- and composite them together, I think you can get what you're looking -- for. -- filename: wave_in_breeze.lua function wave(frequency, power, phase,shear) local x, y, r, g, b,v local x2, y2 shear=(shear/100) for y = 0, height - 1 do for x = 0, width - 1 do v=math.cos((phase+((y/height))*frequency)*.01745) --multiply by y to fade the effect out v=v*(1-(y/height)) v=v*power v=v-(shear*(height-y)) x2=x+v y2=y if x2<0 then x2=0 end if x2>(width-1) then x2=(width-1) end r, g, b = get_rgb(x2, y2) set_rgb(x, y, r, g, b) end progress(y / height) end end -- the main program. Dog_SaveUndo() GUI_SetCaption("Wave") h1 = GUI_AddControl("Scroller", "Power", 40, 0, 100) h2 = GUI_AddControl("Scroller", "Frequency", 100, 0, 1000) h3 = GUI_AddControl("Scroller", "Speed", 10, 0, 50) h4 = GUI_AddControl("Scroller", "Shear", 0, 0, 100) GUI_OpenPanel() --event loop. Repeat until ok or cancel pressed (index of -1 or -2) repeat idx, retval, retstr = GUI_WaitOnEvent() power, string=GUI_GetSettings(h1) frequency, string=GUI_GetSettings(h2) speed, string= GUI_GetSettings(h3) shear, string= GUI_GetSettings(h4) if (idx>-1) then wave(frequency, power, 0,shear) Dog_Refresh() end until idx < 0 --repeat until GUI_ClosePanel() if idx == -2 then --Restore the image Dog_RestoreUndo() Dog_GetBuffer() end if idx == -1 then --apply to frames Dog_RestoreUndo() Dog_GetBuffer() frames=Dog_GetTotalFrames() currentframe=Dog_GetCurrentFrame() for n=0,frames-1 do Dog_GotoFrame(n) wave(frequency, power, n*speed,shear) Dog_Refresh() end Dog_GotoFrame(currentframe) end |
|
||
|
||||
the file: | wave_in_breeze.lua |
|||
|
||||
Samples: |
||||
WindBlown2.avi (Xvid codec, 63 kb) Dark Seaweed: (painted in Dogwaffle with Particle brushes) |
||||
Animated Brush (with Black in secondary color for transparency key) dark-seaweed-waving.7z - (183 kb compressed with 7zip, uncompresses to 20+ MB) Clips: (Indeo 4.5 codec) Multiple
instances rendered at various opacity levels, sizes and locations with
the Brush Keyframer!
|
||||
|