RfM
Rif Motion Blur


return to main index



Introduction

The python script presented here illustrates how a Rif can alter the visual characteristics of motion blur. Many thanks to Ali Jafargholi of the Savannah College of Art and Design for his help in developing the Rif and the model of the aircraft.

Figure 1 shows a model of a propeller aircraft that has been rendered using "standard" motion blur - activated by the Render Settings->Features->Motion Blur checkbox.



Figure 1
Standard motion blur

Figure 2 shows the aircraft rendered after the beauty rib has been filtered by the Rif shown in listing 1.



Figure 2
Modified motion blur

The Rif has modified the blur of the propeller so that it displays rotational blur but no translational blur. For the Rif to work properly the propeller has been parented to the "body" of the aircraft - figure 3.



Figure 3


Using the Rif

If the reader has installed the mel and python scripts given the tutorials,
    RfM: Batch Rendering and
    RfM: Batch Filtering
they should save listing 1 as rif_motionblur.py in their Maya/projects/RfM_python directory. Running the rif and displaying the image in "it" is then simply a matter of executing the following command in the Maya's script window.

    batchRenderRI("rif_it;rif_motionblur.Rif('body','propeller')",1);


Listing 1 (rif_motionblur.py)


import prman
  
class Rif(prman.Rif):
    activeShapeName = ''
    motionBlockOpen = False
    motionNumSamples = 0
    motionSample = -1
    lastGroupTransform = []
    
    def __init__(self, ri, args):
        self.parent = args[0]
        self.child = args[1]
        prman.Rif.__init__(self, ri)
  
    def Attribute(self, attrname, params):
        if attrname == 'identifier':
            self.activeShapeName = params['string name'][0]
        self.m_ri.Attribute(attrname, params)
        if self.activeShapeName == 'propeller':
            self.m_ri.Identity()
            self.m_ri.ConcatTransform(self.lastGroupTransform[0])
            self.lastGroupTransform = []
            
    def MotionBegin(self, samples):
        if self.activeShapeName == self.parent:
            self.motionBlockOpen = True
            self.motionNumSamples = len(samples)
            self.motionSample = 0
        self.m_ri.MotionBegin(samples)
  
    def ConcatTransform(self,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p):
        if self.motionBlockOpen:
            self.motionSample += 1
            # store the transform for shutter close
            if self.motionSample == self.motionNumSamples:
                self.lastGroupTransform.append([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p])
                self.motionSample = 0
        self.m_ri.ConcatTransform([a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p])
  
    def MotionEnd(self):
        self.motionBlockOpen = False
        self.motionNumSamples = 0
        self.motionTransforms = []
        self.m_ri.MotionEnd()





© 2002- Malcolm Kesson. All rights reserved.