Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AviSynth GrainPlate function
#1
Code:
############################################################################################
### GrainPlate 1.0: add real grains to your clip!                                        ###
###                                                                                      ###
### Usage:   GrainPlate(clip, strenght)                                                  ###
###          where strenght range goes from 0 (clip untouched) to 1 (max strenght)       ###
###                                                                                      ###
### Just add your own grain plate, there are many free to download over the web.         ###
### Hints: NEVER upscale/downscale a grain plate; choose one with the same size of your  ###
### clip, or bigger; choose only REAL film grain, and not recreated.                     ###
###                                                                                      ###
### AviSynth script made by spoRv (http://blog.sporv.com) - Created: 2014-06-18          ###
###                                                         Updated: 2016-12-29          ###
###                                                                                      ###
### Creative Commons 4,0 - Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)       ###
### Link to the licence page: https://creativecommons.org/licenses/by-sa/4.0/            ###
############################################################################################

function grainplate (clip clip, "strength") {
strength = default( strength, 0.25)
grain=avisource("putyourowngrainplatefilehere.avi")\
.crop(0,0,clip.width,clip.height).loop.trim(0,clip.framecount-1)
return overlay(clip.tweak(bright=1),grain,mode="softlight",opacity=strength) }

Warning: check the brightness settings with the grain plate you decide to use; it must be raised to be the same of the source without grain plate applied!
Fundamental collection thread | Vimeo channel | My personal blog
Reply
Thanks given by:
#2
Thx! 

For those who only have monochrome grain plates like myself, I modified it a bit:
Code:
function grainplate (clip clip, "strength") {
strength = default( strength, 0.25)
g=AVISource("04-MED_CLEAN.avi")
g=MergeRGB(g,UnalignedSplice(g.trim(g.framecount/2-1,g.framecount-1),g.trim(0,(g.framecount/2)-1)),UnalignedSplice(g.trim(g.framecount/3-1,g.framecount-1),g.trim(0,(g.framecount/3)-1)))
grain=g.crop(0,0,clip.width,clip.height).loop.trim(0,clip.framecount-1)
return overlay(clip.tweak(bright=1),grain,mode="softlight",opacity=strength) }

Basically, this applies a delay to the grain plate, once by -50% and once by -33%. Then it merges the RGB from the normal grainplate, the -50% delayed one and the -33% delayed one. 

This is helpful because a monochrome grainplate doesn't really do much to help with chroma blocking. Also, a monochrome grainplate gives an unrealistic result for anything but black-and-white film, as we all know film consists of color layers.

This isn't 100% realistic, as film doesn't consist of RGB layers, but it's good enough for me.

Edit: Just make sure the duration of your grainplate is divisible by both 2 and 3, else some weird results may occur.
Reply
Thanks given by:


Possibly Related Threads...
Thread Author Replies Views Last Post
  AviSynth DeFade function spoRv 4 1,075 2017-01-23, 06:02 PM
Last Post: jerryshadoe

Forum Jump:


Users browsing this thread: 1 Guest(s)